| 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 | 48 |
| 49 typedef bool (*MatchFun) (void* key1, void* key2); | 49 typedef bool (*MatchFun) (void* key1, void* key2); |
| 50 | 50 |
| 51 // Dummy constructor. This constructor doesn't set up the hash | 51 // Dummy constructor. This constructor doesn't set up the hash |
| 52 // map properly so don't use it unless you have good reason (e.g., | 52 // map properly so don't use it unless you have good reason (e.g., |
| 53 // you know that the HashMap will never be used). | 53 // you know that the HashMap will never be used). |
| 54 HashMap(); | 54 HashMap(); |
| 55 | 55 |
| 56 // initial_capacity is the size of the initial hash map; | 56 // initial_capacity is the size of the initial hash map; |
| 57 // it must be a power of 2 (and thus must not be 0). | 57 // it must be a power of 2 (and thus must not be 0). |
| 58 HashMap(MatchFun match, | 58 explicit HashMap(MatchFun match, |
| 59 Allocator* allocator = &DefaultAllocator, | 59 Allocator* allocator = &DefaultAllocator, |
| 60 uint32_t initial_capacity = 8); | 60 uint32_t initial_capacity = 8); |
| 61 | 61 |
| 62 ~HashMap(); | 62 ~HashMap(); |
| 63 | 63 |
| 64 // HashMap entries are (key, value, hash) triplets. | 64 // HashMap entries are (key, value, hash) triplets. |
| 65 // Some clients may not need to use the value slot | 65 // Some clients may not need to use the value slot |
| 66 // (e.g. implementers of sets, where the key is the value). | 66 // (e.g. implementers of sets, where the key is the value). |
| 67 struct Entry { | 67 struct Entry { |
| 68 void* key; | 68 void* key; |
| 69 void* value; | 69 void* value; |
| 70 uint32_t hash; // the full hash value for key | 70 uint32_t hash; // the full hash value for key |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 Entry* map_end() const { return map_ + capacity_; } | 112 Entry* map_end() const { return map_ + capacity_; } |
| 113 Entry* Probe(void* key, uint32_t hash); | 113 Entry* Probe(void* key, uint32_t hash); |
| 114 void Initialize(uint32_t capacity); | 114 void Initialize(uint32_t capacity); |
| 115 void Resize(); | 115 void Resize(); |
| 116 }; | 116 }; |
| 117 | 117 |
| 118 | 118 |
| 119 } } // namespace v8::internal | 119 } } // namespace v8::internal |
| 120 | 120 |
| 121 #endif // V8_HASHMAP_H_ | 121 #endif // V8_HASHMAP_H_ |
| OLD | NEW |