| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef VM_HASH_MAP_H_ | 5 #ifndef VM_HASH_MAP_H_ |
| 6 #define VM_HASH_MAP_H_ | 6 #define VM_HASH_MAP_H_ |
| 7 | 7 |
| 8 namespace dart { | 8 namespace dart { |
| 9 | 9 |
| 10 template <typename KeyValueTrait> | 10 template <typename KeyValueTrait> |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 void ResizeLists(intptr_t new_size); | 43 void ResizeLists(intptr_t new_size); |
| 44 uword Bound(uword value) const { return value & (array_size_ - 1); } | 44 uword Bound(uword value) const { return value & (array_size_ - 1); } |
| 45 | 45 |
| 46 intptr_t array_size_; | 46 intptr_t array_size_; |
| 47 intptr_t lists_size_; | 47 intptr_t lists_size_; |
| 48 intptr_t count_; // The number of values stored in the HashMap. | 48 intptr_t count_; // The number of values stored in the HashMap. |
| 49 HashMapListElement* array_; // Primary store - contains the first value | 49 HashMapListElement* array_; // Primary store - contains the first value |
| 50 // with a given hash. Colliding elements are stored in linked lists. | 50 // with a given hash. Colliding elements are stored in linked lists. |
| 51 HashMapListElement* lists_; // The linked lists containing hash collisions. | 51 HashMapListElement* lists_; // The linked lists containing hash collisions. |
| 52 intptr_t free_list_head_; // Unused elements in lists_ are on the free list. | 52 intptr_t free_list_head_; // Unused elements in lists_ are on the free list. |
| 53 |
| 54 // Disallow operator=. Use public copy constructor to copy instead. |
| 55 DirectChainedHashMap<KeyValueTrait>& operator=( |
| 56 const DirectChainedHashMap& other); |
| 53 }; | 57 }; |
| 54 | 58 |
| 55 | 59 |
| 56 template <typename KeyValueTrait> | 60 template <typename KeyValueTrait> |
| 57 typename KeyValueTrait::Value | 61 typename KeyValueTrait::Value |
| 58 DirectChainedHashMap<KeyValueTrait>:: | 62 DirectChainedHashMap<KeyValueTrait>:: |
| 59 Lookup(typename KeyValueTrait::Key key) const { | 63 Lookup(typename KeyValueTrait::Key key) const { |
| 60 uword hash = static_cast<uword>(KeyValueTrait::Hashcode(key)); | 64 uword hash = static_cast<uword>(KeyValueTrait::Hashcode(key)); |
| 61 uword pos = Bound(hash); | 65 uword pos = Bound(hash); |
| 62 if (KeyValueTrait::ValueOf(array_[pos].kv) != NULL) { | 66 if (KeyValueTrait::ValueOf(array_[pos].kv) != NULL) { |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 } | 216 } |
| 213 | 217 |
| 214 static inline bool IsKeyEqual(Pair kv, Key key) { | 218 static inline bool IsKeyEqual(Pair kv, Key key) { |
| 215 return kv->Equals(key); | 219 return kv->Equals(key); |
| 216 } | 220 } |
| 217 }; | 221 }; |
| 218 | 222 |
| 219 } // namespace dart | 223 } // namespace dart |
| 220 | 224 |
| 221 #endif // VM_HASH_MAP_H_ | 225 #endif // VM_HASH_MAP_H_ |
| OLD | NEW |