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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 HashMap(); | 52 HashMap(); |
53 | 53 |
54 // initial_capacity is the size of the initial hash map; | 54 // initial_capacity is the size of the initial hash map; |
55 // it must be a power of 2 (and thus must not be 0). | 55 // it must be a power of 2 (and thus must not be 0). |
56 HashMap(MatchFun match, | 56 HashMap(MatchFun match, |
57 Allocator* allocator = &DefaultAllocator, | 57 Allocator* allocator = &DefaultAllocator, |
58 uint32_t initial_capacity = 8); | 58 uint32_t initial_capacity = 8); |
59 | 59 |
60 ~HashMap(); | 60 ~HashMap(); |
61 | 61 |
62 // HashMap entries are (key, value, hash) tripplets. | 62 // HashMap entries are (key, value, hash) triplets. |
63 // Some clients may not need to use the value slot | 63 // Some clients may not need to use the value slot |
64 // (e.g. implementers of sets, where the key is the value). | 64 // (e.g. implementers of sets, where the key is the value). |
65 struct Entry { | 65 struct Entry { |
66 void* key; | 66 void* key; |
67 void* value; | 67 void* value; |
68 uint32_t hash; // the full hash value for key | 68 uint32_t hash; // the full hash value for key |
69 }; | 69 }; |
70 | 70 |
71 // If an entry with matching key is found, Lookup() | 71 // If an entry with matching key is found, Lookup() |
72 // returns that entry. If no matching entry is found, | 72 // returns that entry. If no matching entry is found, |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 Entry* map_end() const { return map_ + capacity_; } | 107 Entry* map_end() const { return map_ + capacity_; } |
108 Entry* Probe(void* key, uint32_t hash); | 108 Entry* Probe(void* key, uint32_t hash); |
109 void Initialize(uint32_t capacity); | 109 void Initialize(uint32_t capacity); |
110 void Resize(); | 110 void Resize(); |
111 }; | 111 }; |
112 | 112 |
113 | 113 |
114 } } // namespace v8::internal | 114 } } // namespace v8::internal |
115 | 115 |
116 #endif // V8_HASHMAP_H_ | 116 #endif // V8_HASHMAP_H_ |
OLD | NEW |