OLD | NEW |
1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 uint32_t occupancy() const { | 73 uint32_t occupancy() const { |
74 uint32_t count = 0; | 74 uint32_t count = 0; |
75 for (HashMap::Entry* p = map_.Start(); p != NULL; p = map_.Next(p)) { | 75 for (HashMap::Entry* p = map_.Start(); p != NULL; p = map_.Next(p)) { |
76 count++; | 76 count++; |
77 } | 77 } |
78 CHECK_EQ(map_.occupancy(), static_cast<double>(count)); | 78 CHECK_EQ(map_.occupancy(), static_cast<double>(count)); |
79 return count; | 79 return count; |
80 } | 80 } |
81 | 81 |
82 private: | 82 private: |
| 83 IntKeyHash hash_; |
83 HashMap map_; | 84 HashMap map_; |
84 IntKeyHash hash_; | |
85 }; | 85 }; |
86 | 86 |
87 | 87 |
88 static uint32_t Hash(uint32_t key) { return 23; } | 88 static uint32_t Hash(uint32_t key) { return 23; } |
89 static uint32_t CollisionHash(uint32_t key) { return key & 0x3; } | 89 static uint32_t CollisionHash(uint32_t key) { return key & 0x3; } |
90 | 90 |
91 | 91 |
92 void TestSet(IntKeyHash hash, int size) { | 92 void TestSet(IntKeyHash hash, int size) { |
93 IntSet set(hash); | 93 IntSet set(hash); |
94 CHECK_EQ(0, set.occupancy()); | 94 CHECK_EQ(0, set.occupancy()); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 | 167 |
168 } | 168 } |
169 CHECK_EQ(0, set.occupancy()); | 169 CHECK_EQ(0, set.occupancy()); |
170 } | 170 } |
171 | 171 |
172 | 172 |
173 TEST(Set) { | 173 TEST(Set) { |
174 TestSet(Hash, 1000); | 174 TestSet(Hash, 1000); |
175 TestSet(CollisionHash, 100); | 175 TestSet(CollisionHash, 100); |
176 } | 176 } |
OLD | NEW |