| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 virtual void Delete(void* p) { Malloced::Delete(p); } | 43 virtual void Delete(void* p) { Malloced::Delete(p); } |
| 44 }; | 44 }; |
| 45 | 45 |
| 46 | 46 |
| 47 class HashMap { | 47 class HashMap { |
| 48 public: | 48 public: |
| 49 static Allocator DefaultAllocator; | 49 static Allocator DefaultAllocator; |
| 50 | 50 |
| 51 typedef bool (*MatchFun) (void* key1, void* key2); | 51 typedef bool (*MatchFun) (void* key1, void* key2); |
| 52 | 52 |
| 53 // Dummy constructor. This constructor doesn't set up the hash | |
| 54 // map properly so don't use it unless you have good reason (e.g., | |
| 55 // you know that the HashMap will never be used). | |
| 56 HashMap(); | |
| 57 | |
| 58 // initial_capacity is the size of the initial hash map; | 53 // initial_capacity is the size of the initial hash map; |
| 59 // it must be a power of 2 (and thus must not be 0). | 54 // it must be a power of 2 (and thus must not be 0). |
| 60 explicit HashMap(MatchFun match, | 55 explicit HashMap(MatchFun match, |
| 61 Allocator* allocator = &DefaultAllocator, | 56 Allocator* allocator = &DefaultAllocator, |
| 62 uint32_t initial_capacity = 8); | 57 uint32_t initial_capacity = 8); |
| 63 | 58 |
| 64 ~HashMap(); | 59 ~HashMap(); |
| 65 | 60 |
| 66 // HashMap entries are (key, value, hash) triplets. | 61 // HashMap entries are (key, value, hash) triplets. |
| 67 // Some clients may not need to use the value slot | 62 // Some clients may not need to use the value slot |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 Entry* map_end() const { return map_ + capacity_; } | 109 Entry* map_end() const { return map_ + capacity_; } |
| 115 Entry* Probe(void* key, uint32_t hash); | 110 Entry* Probe(void* key, uint32_t hash); |
| 116 void Initialize(uint32_t capacity); | 111 void Initialize(uint32_t capacity); |
| 117 void Resize(); | 112 void Resize(); |
| 118 }; | 113 }; |
| 119 | 114 |
| 120 | 115 |
| 121 } } // namespace v8::internal | 116 } } // namespace v8::internal |
| 122 | 117 |
| 123 #endif // V8_HASHMAP_H_ | 118 #endif // V8_HASHMAP_H_ |
| OLD | NEW |