| 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_SET_H_ | 5 #ifndef VM_HASH_SET_H_ |
| 6 #define VM_HASH_SET_H_ | 6 #define VM_HASH_SET_H_ |
| 7 | 7 |
| 8 #include "vm/allocation.h" | 8 #include "vm/allocation.h" |
| 9 #include "platform/utils.h" | 9 #include "platform/utils.h" |
| 10 | 10 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 } | 28 } |
| 29 | 29 |
| 30 intptr_t Size() const { | 30 intptr_t Size() const { |
| 31 return size_mask_ + 1; | 31 return size_mask_ + 1; |
| 32 } | 32 } |
| 33 | 33 |
| 34 intptr_t Count() const { | 34 intptr_t Count() const { |
| 35 return count_; | 35 return count_; |
| 36 } | 36 } |
| 37 | 37 |
| 38 uword At(intptr_t i) const { |
| 39 ASSERT(i >= 0); |
| 40 ASSERT(i < Size()); |
| 41 return keys_[i]; |
| 42 } |
| 43 |
| 38 // Returns false if the caller should stop adding entries to this HashSet. | 44 // Returns false if the caller should stop adding entries to this HashSet. |
| 39 bool Add(uword value) { | 45 bool Add(uword value) { |
| 40 ASSERT(value != 0); | 46 ASSERT(value != 0); |
| 41 ASSERT(count_ < growth_limit_); | 47 ASSERT(count_ < growth_limit_); |
| 42 intptr_t hash = Hash(value); | 48 intptr_t hash = Hash(value); |
| 43 while (true) { | 49 while (true) { |
| 44 if (keys_[hash] == value) { | 50 if (keys_[hash] == value) { |
| 45 return true; | 51 return true; |
| 46 } else if (SlotIsEmpty(hash)) { | 52 } else if (SlotIsEmpty(hash)) { |
| 47 keys_[hash] = value; | 53 keys_[hash] = value; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 intptr_t growth_limit_; | 94 intptr_t growth_limit_; |
| 89 intptr_t count_; | 95 intptr_t count_; |
| 90 intptr_t fill_ratio_; | 96 intptr_t fill_ratio_; |
| 91 | 97 |
| 92 DISALLOW_IMPLICIT_CONSTRUCTORS(HashSet); | 98 DISALLOW_IMPLICIT_CONSTRUCTORS(HashSet); |
| 93 }; | 99 }; |
| 94 | 100 |
| 95 } // namespace dart | 101 } // namespace dart |
| 96 | 102 |
| 97 #endif // VM_HASH_SET_H_ | 103 #endif // VM_HASH_SET_H_ |
| OLD | NEW |