Daniel Cheng | 3d1108de | 2022-09-07 23:42:04 | [diff] [blame] | 1 | // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
license.bot | bf09a50 | 2008-08-24 00:55:55 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
initial.commit | d7cae12 | 2008-07-26 21:49:38 | [diff] [blame] | 4 | |
Brett Wilson | f976d3f | 2017-08-18 17:23:39 | [diff] [blame] | 5 | #ifndef BASE_CONTAINERS_ID_MAP_H_ |
| 6 | #define BASE_CONTAINERS_ID_MAP_H_ |
initial.commit | d7cae12 | 2008-07-26 21:49:38 | [diff] [blame] | 7 | |
avi | 9b6f4293 | 2015-12-26 22:15:14 | [diff] [blame] | 8 | #include <stddef.h> |
jkarlin | 7bc034c | 2015-09-25 20:45:47 | [diff] [blame] | 9 | #include <stdint.h> |
brettw | 1ce49f6 | 2017-04-27 19:42:32 | [diff] [blame] | 10 | |
David Sanders | 61357c8 | 2022-01-19 19:38:43 | [diff] [blame] | 11 | #include <iterator> |
| 12 | #include <ostream> |
aelias | aed214d0 | 2016-09-24 01:26:42 | [diff] [blame] | 13 | #include <type_traits> |
brettw | 1ce49f6 | 2017-04-27 19:42:32 | [diff] [blame] | 14 | #include <unordered_map> |
aelias | aed214d0 | 2016-09-24 01:26:42 | [diff] [blame] | 15 | #include <utility> |
[email protected] | 9de09f8 | 2009-08-17 20:13:53 | [diff] [blame] | 16 | |
David Sanders | 61357c8 | 2022-01-19 19:38:43 | [diff] [blame] | 17 | #include "base/check.h" |
Hans Wennborg | 7b53371 | 2020-06-22 20:52:27 | [diff] [blame] | 18 | #include "base/check_op.h" |
brettw | 1ce49f6 | 2017-04-27 19:42:32 | [diff] [blame] | 19 | #include "base/containers/flat_set.h" |
Keishi Hattori | 0e45c02 | 2021-11-27 09:25:52 | [diff] [blame] | 20 | #include "base/memory/raw_ptr.h" |
Hans Wennborg | 7b53371 | 2020-06-22 20:52:27 | [diff] [blame] | 21 | #include "base/notreached.h" |
jsbell | 41359ee | 2015-11-16 19:43:34 | [diff] [blame] | 22 | #include "base/sequence_checker.h" |
initial.commit | d7cae12 | 2008-07-26 21:49:38 | [diff] [blame] | 23 | |
Brett Wilson | f976d3f | 2017-08-18 17:23:39 | [diff] [blame] | 24 | namespace base { |
| 25 | |
initial.commit | d7cae12 | 2008-07-26 21:49:38 | [diff] [blame] | 26 | // This object maintains a list of IDs that can be quickly converted to |
| 27 | // pointers to objects. It is implemented as a hash table, optimized for |
| 28 | // relatively small data sets (in the common case, there will be exactly one |
| 29 | // item in the list). |
| 30 | // |
| 31 | // Items can be inserted into the container with arbitrary ID, but the caller |
| 32 | // must ensure they are unique. Inserting IDs and relying on automatically |
| 33 | // generated ones is not allowed because they can collide. |
rlanday | de24c6d | 2016-12-01 03:05:40 | [diff] [blame] | 34 | |
| 35 | // The map's value type (the V param) can be any dereferenceable type, such as a |
| 36 | // raw pointer or smart pointer |
| 37 | template <typename V, typename K = int32_t> |
| 38 | class IDMap final { |
[email protected] | b8b67081 | 2014-05-27 18:10:06 | [diff] [blame] | 39 | public: |
jkarlin | 7bc034c | 2015-09-25 20:45:47 | [diff] [blame] | 40 | using KeyType = K; |
[email protected] | b8b67081 | 2014-05-27 18:10:06 | [diff] [blame] | 41 | |
| 42 | private: |
rlanday | de24c6d | 2016-12-01 03:05:40 | [diff] [blame] | 43 | using T = typename std::remove_reference<decltype(*V())>::type; |
brettw | 1ce49f6 | 2017-04-27 19:42:32 | [diff] [blame] | 44 | |
| 45 | using HashTable = std::unordered_map<KeyType, V>; |
initial.commit | d7cae12 | 2008-07-26 21:49:38 | [diff] [blame] | 46 | |
| 47 | public: |
[email protected] | 9de09f8 | 2009-08-17 20:13:53 | [diff] [blame] | 48 | IDMap() : iteration_depth_(0), next_id_(1), check_on_null_data_(false) { |
jsbell | 41359ee | 2015-11-16 19:43:34 | [diff] [blame] | 49 | // A number of consumers of IDMap create it on one thread but always |
| 50 | // access it from a different, but consistent, thread (or sequence) |
fdoray | e2b19a1 | 2016-07-29 02:30:16 | [diff] [blame] | 51 | // post-construction. The first call to CalledOnValidSequence() will re-bind |
| 52 | // it. |
tzik | fd754ee | 2018-03-28 15:49:28 | [diff] [blame] | 53 | DETACH_FROM_SEQUENCE(sequence_checker_); |
initial.commit | d7cae12 | 2008-07-26 21:49:38 | [diff] [blame] | 54 | } |
| 55 | |
Lei Zhang | 6825df46 | 2020-06-23 16:17:43 | [diff] [blame] | 56 | IDMap(const IDMap&) = delete; |
| 57 | IDMap& operator=(const IDMap&) = delete; |
| 58 | |
[email protected] | 9e7e0e0 | 2010-01-25 23:25:16 | [diff] [blame] | 59 | ~IDMap() { |
jsbell | 41359ee | 2015-11-16 19:43:34 | [diff] [blame] | 60 | // Many IDMap's are static, and hence will be destroyed on the main |
| 61 | // thread. However, all the accesses may take place on another thread (or |
| 62 | // sequence), such as the IO thread. Detaching again to clean this up. |
tzik | fd754ee | 2018-03-28 15:49:28 | [diff] [blame] | 63 | DETACH_FROM_SEQUENCE(sequence_checker_); |
[email protected] | 9e7e0e0 | 2010-01-25 23:25:16 | [diff] [blame] | 64 | } |
| 65 | |
michaeln | bfea6ec | 2014-12-09 23:16:13 | [diff] [blame] | 66 | // Sets whether Add and Replace should DCHECK if passed in NULL data. |
| 67 | // Default is false. |
[email protected] | a6ed943 | 2009-07-01 22:35:26 | [diff] [blame] | 68 | void set_check_on_null_data(bool value) { check_on_null_data_ = value; } |
| 69 | |
initial.commit | d7cae12 | 2008-07-26 21:49:38 | [diff] [blame] | 70 | // Adds a view with an automatically generated unique ID. See AddWithID. |
rlanday | 6eada032 | 2016-11-30 18:59:30 | [diff] [blame] | 71 | KeyType Add(V data) { return AddInternal(std::move(data)); } |
initial.commit | d7cae12 | 2008-07-26 21:49:38 | [diff] [blame] | 72 | |
| 73 | // Adds a new data member with the specified ID. The ID must not be in |
| 74 | // the list. The caller either must generate all unique IDs itself and use |
| 75 | // this function, or allow this object to generate IDs and call Add. These |
aelias | aed214d0 | 2016-09-24 01:26:42 | [diff] [blame] | 76 | // two methods may not be mixed, or duplicate IDs may be generated. |
rlanday | 6eada032 | 2016-11-30 18:59:30 | [diff] [blame] | 77 | void AddWithID(V data, KeyType id) { AddWithIDInternal(std::move(data), id); } |
initial.commit | d7cae12 | 2008-07-26 21:49:38 | [diff] [blame] | 78 | |
[email protected] | 9e7e0e0 | 2010-01-25 23:25:16 | [diff] [blame] | 79 | void Remove(KeyType id) { |
tzik | fd754ee | 2018-03-28 15:49:28 | [diff] [blame] | 80 | DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
[email protected] | 9de09f8 | 2009-08-17 20:13:53 | [diff] [blame] | 81 | typename HashTable::iterator i = data_.find(id); |
tzik | d164667 | 2018-03-28 20:41:13 | [diff] [blame] | 82 | if (i == data_.end() || IsRemoved(id)) { |
initial.commit | d7cae12 | 2008-07-26 21:49:38 | [diff] [blame] | 83 | NOTREACHED() << "Attempting to remove an item not in the list"; |
| 84 | return; |
| 85 | } |
[email protected] | 9de09f8 | 2009-08-17 20:13:53 | [diff] [blame] | 86 | |
[email protected] | 9e7e0e0 | 2010-01-25 23:25:16 | [diff] [blame] | 87 | if (iteration_depth_ == 0) { |
[email protected] | 9de09f8 | 2009-08-17 20:13:53 | [diff] [blame] | 88 | data_.erase(i); |
[email protected] | 9e7e0e0 | 2010-01-25 23:25:16 | [diff] [blame] | 89 | } else { |
[email protected] | 9de09f8 | 2009-08-17 20:13:53 | [diff] [blame] | 90 | removed_ids_.insert(id); |
[email protected] | 9e7e0e0 | 2010-01-25 23:25:16 | [diff] [blame] | 91 | } |
initial.commit | d7cae12 | 2008-07-26 21:49:38 | [diff] [blame] | 92 | } |
| 93 | |
sungmann.cho | 82e601f9 | 2017-02-17 04:43:13 | [diff] [blame] | 94 | // Replaces the value for |id| with |new_data| and returns the existing value. |
| 95 | // Should only be called with an already added id. |
aelias | aed214d0 | 2016-09-24 01:26:42 | [diff] [blame] | 96 | V Replace(KeyType id, V new_data) { |
tzik | fd754ee | 2018-03-28 15:49:28 | [diff] [blame] | 97 | DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
michaeln | bfea6ec | 2014-12-09 23:16:13 | [diff] [blame] | 98 | DCHECK(!check_on_null_data_ || new_data); |
| 99 | typename HashTable::iterator i = data_.find(id); |
aelias | aed214d0 | 2016-09-24 01:26:42 | [diff] [blame] | 100 | DCHECK(i != data_.end()); |
tzik | d164667 | 2018-03-28 20:41:13 | [diff] [blame] | 101 | DCHECK(!IsRemoved(id)); |
michaeln | bfea6ec | 2014-12-09 23:16:13 | [diff] [blame] | 102 | |
tzik | d164667 | 2018-03-28 20:41:13 | [diff] [blame] | 103 | using std::swap; |
| 104 | swap(i->second, new_data); |
aelias | aed214d0 | 2016-09-24 01:26:42 | [diff] [blame] | 105 | return new_data; |
michaeln | bfea6ec | 2014-12-09 23:16:13 | [diff] [blame] | 106 | } |
| 107 | |
[email protected] | fea0b961 | 2012-10-29 21:36:22 | [diff] [blame] | 108 | void Clear() { |
tzik | fd754ee | 2018-03-28 15:49:28 | [diff] [blame] | 109 | DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
[email protected] | fea0b961 | 2012-10-29 21:36:22 | [diff] [blame] | 110 | if (iteration_depth_ == 0) { |
aelias | aed214d0 | 2016-09-24 01:26:42 | [diff] [blame] | 111 | data_.clear(); |
[email protected] | fea0b961 | 2012-10-29 21:36:22 | [diff] [blame] | 112 | } else { |
tzik | c5837e2 | 2018-03-29 05:31:15 | [diff] [blame] | 113 | removed_ids_.reserve(data_.size()); |
| 114 | removed_ids_.insert(KeyIterator(data_.begin()), KeyIterator(data_.end())); |
[email protected] | fea0b961 | 2012-10-29 21:36:22 | [diff] [blame] | 115 | } |
| 116 | } |
| 117 | |
initial.commit | d7cae12 | 2008-07-26 21:49:38 | [diff] [blame] | 118 | bool IsEmpty() const { |
tzik | fd754ee | 2018-03-28 15:49:28 | [diff] [blame] | 119 | DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
[email protected] | 2de069e | 2010-02-16 09:15:38 | [diff] [blame] | 120 | return size() == 0u; |
initial.commit | d7cae12 | 2008-07-26 21:49:38 | [diff] [blame] | 121 | } |
| 122 | |
[email protected] | 9e7e0e0 | 2010-01-25 23:25:16 | [diff] [blame] | 123 | T* Lookup(KeyType id) const { |
tzik | fd754ee | 2018-03-28 15:49:28 | [diff] [blame] | 124 | DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
[email protected] | 9de09f8 | 2009-08-17 20:13:53 | [diff] [blame] | 125 | typename HashTable::const_iterator i = data_.find(id); |
tzik | d164667 | 2018-03-28 20:41:13 | [diff] [blame] | 126 | if (i == data_.end() || !i->second || IsRemoved(id)) |
aelias | aed214d0 | 2016-09-24 01:26:42 | [diff] [blame] | 127 | return nullptr; |
| 128 | return &*i->second; |
initial.commit | d7cae12 | 2008-07-26 21:49:38 | [diff] [blame] | 129 | } |
| 130 | |
| 131 | size_t size() const { |
tzik | fd754ee | 2018-03-28 15:49:28 | [diff] [blame] | 132 | DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
[email protected] | 2de069e | 2010-02-16 09:15:38 | [diff] [blame] | 133 | return data_.size() - removed_ids_.size(); |
initial.commit | d7cae12 | 2008-07-26 21:49:38 | [diff] [blame] | 134 | } |
| 135 | |
[email protected] | 0c8b894 | 2012-10-27 01:03:01 | [diff] [blame] | 136 | #if defined(UNIT_TEST) |
| 137 | int iteration_depth() const { |
| 138 | return iteration_depth_; |
| 139 | } |
| 140 | #endif // defined(UNIT_TEST) |
| 141 | |
[email protected] | 9de09f8 | 2009-08-17 20:13:53 | [diff] [blame] | 142 | // It is safe to remove elements from the map during iteration. All iterators |
| 143 | // will remain valid. |
| 144 | template<class ReturnType> |
| 145 | class Iterator { |
| 146 | public: |
rlanday | de24c6d | 2016-12-01 03:05:40 | [diff] [blame] | 147 | Iterator(IDMap<V, K>* map) : map_(map), iter_(map_->data_.begin()) { |
[email protected] | 0c8b894 | 2012-10-27 01:03:01 | [diff] [blame] | 148 | Init(); |
| 149 | } |
| 150 | |
| 151 | Iterator(const Iterator& iter) |
| 152 | : map_(iter.map_), |
| 153 | iter_(iter.iter_) { |
| 154 | Init(); |
| 155 | } |
| 156 | |
| 157 | const Iterator& operator=(const Iterator& iter) { |
| 158 | map_ = iter.map; |
| 159 | iter_ = iter.iter; |
| 160 | Init(); |
| 161 | return *this; |
[email protected] | 9de09f8 | 2009-08-17 20:13:53 | [diff] [blame] | 162 | } |
| 163 | |
| 164 | ~Iterator() { |
tzik | fd754ee | 2018-03-28 15:49:28 | [diff] [blame] | 165 | DCHECK_CALLED_ON_VALID_SEQUENCE(map_->sequence_checker_); |
[email protected] | 0c8b894 | 2012-10-27 01:03:01 | [diff] [blame] | 166 | |
| 167 | // We're going to decrement iteration depth. Make sure it's greater than |
| 168 | // zero so that it doesn't become negative. |
| 169 | DCHECK_LT(0, map_->iteration_depth_); |
| 170 | |
[email protected] | 9de09f8 | 2009-08-17 20:13:53 | [diff] [blame] | 171 | if (--map_->iteration_depth_ == 0) |
| 172 | map_->Compact(); |
| 173 | } |
| 174 | |
| 175 | bool IsAtEnd() const { |
tzik | fd754ee | 2018-03-28 15:49:28 | [diff] [blame] | 176 | DCHECK_CALLED_ON_VALID_SEQUENCE(map_->sequence_checker_); |
[email protected] | 9de09f8 | 2009-08-17 20:13:53 | [diff] [blame] | 177 | return iter_ == map_->data_.end(); |
| 178 | } |
| 179 | |
[email protected] | 9e7e0e0 | 2010-01-25 23:25:16 | [diff] [blame] | 180 | KeyType GetCurrentKey() const { |
tzik | fd754ee | 2018-03-28 15:49:28 | [diff] [blame] | 181 | DCHECK_CALLED_ON_VALID_SEQUENCE(map_->sequence_checker_); |
[email protected] | 9de09f8 | 2009-08-17 20:13:53 | [diff] [blame] | 182 | return iter_->first; |
| 183 | } |
| 184 | |
| 185 | ReturnType* GetCurrentValue() const { |
tzik | fd754ee | 2018-03-28 15:49:28 | [diff] [blame] | 186 | DCHECK_CALLED_ON_VALID_SEQUENCE(map_->sequence_checker_); |
tzik | d164667 | 2018-03-28 20:41:13 | [diff] [blame] | 187 | if (!iter_->second || map_->IsRemoved(iter_->first)) |
| 188 | return nullptr; |
aelias | aed214d0 | 2016-09-24 01:26:42 | [diff] [blame] | 189 | return &*iter_->second; |
[email protected] | 9de09f8 | 2009-08-17 20:13:53 | [diff] [blame] | 190 | } |
| 191 | |
| 192 | void Advance() { |
tzik | fd754ee | 2018-03-28 15:49:28 | [diff] [blame] | 193 | DCHECK_CALLED_ON_VALID_SEQUENCE(map_->sequence_checker_); |
[email protected] | 9de09f8 | 2009-08-17 20:13:53 | [diff] [blame] | 194 | ++iter_; |
| 195 | SkipRemovedEntries(); |
| 196 | } |
| 197 | |
| 198 | private: |
[email protected] | 0c8b894 | 2012-10-27 01:03:01 | [diff] [blame] | 199 | void Init() { |
tzik | fd754ee | 2018-03-28 15:49:28 | [diff] [blame] | 200 | DCHECK_CALLED_ON_VALID_SEQUENCE(map_->sequence_checker_); |
[email protected] | 0c8b894 | 2012-10-27 01:03:01 | [diff] [blame] | 201 | ++map_->iteration_depth_; |
| 202 | SkipRemovedEntries(); |
| 203 | } |
| 204 | |
[email protected] | 9de09f8 | 2009-08-17 20:13:53 | [diff] [blame] | 205 | void SkipRemovedEntries() { |
tzik | d164667 | 2018-03-28 20:41:13 | [diff] [blame] | 206 | while (iter_ != map_->data_.end() && map_->IsRemoved(iter_->first)) |
[email protected] | 9de09f8 | 2009-08-17 20:13:53 | [diff] [blame] | 207 | ++iter_; |
[email protected] | 9de09f8 | 2009-08-17 20:13:53 | [diff] [blame] | 208 | } |
| 209 | |
Keishi Hattori | 0e45c02 | 2021-11-27 09:25:52 | [diff] [blame] | 210 | raw_ptr<IDMap<V, K>> map_; |
[email protected] | 9de09f8 | 2009-08-17 20:13:53 | [diff] [blame] | 211 | typename HashTable::const_iterator iter_; |
| 212 | }; |
| 213 | |
| 214 | typedef Iterator<T> iterator; |
| 215 | typedef Iterator<const T> const_iterator; |
| 216 | |
| 217 | private: |
tzik | c5837e2 | 2018-03-29 05:31:15 | [diff] [blame] | 218 | // Transforms a map iterator to an iterator on the keys of the map. |
| 219 | // Used by Clear() to populate |removed_ids_| in bulk. |
Peter Kasting | 0acb7f5ef | 2022-05-05 23:57:27 | [diff] [blame] | 220 | struct KeyIterator { |
| 221 | using iterator_category = std::forward_iterator_tag; |
| 222 | using value_type = KeyType; |
| 223 | using difference_type = std::ptrdiff_t; |
| 224 | using pointer = KeyType*; |
| 225 | using reference = KeyType&; |
| 226 | |
tzik | c5837e2 | 2018-03-29 05:31:15 | [diff] [blame] | 227 | using inner_iterator = typename HashTable::iterator; |
| 228 | inner_iterator iter_; |
| 229 | |
| 230 | KeyIterator(inner_iterator iter) : iter_(iter) {} |
| 231 | KeyType operator*() const { return iter_->first; } |
| 232 | KeyIterator& operator++() { |
| 233 | ++iter_; |
| 234 | return *this; |
| 235 | } |
| 236 | KeyIterator operator++(int) { return KeyIterator(iter_++); } |
| 237 | bool operator==(const KeyIterator& other) const { |
| 238 | return iter_ == other.iter_; |
| 239 | } |
| 240 | bool operator!=(const KeyIterator& other) const { |
| 241 | return iter_ != other.iter_; |
| 242 | } |
| 243 | }; |
| 244 | |
aelias | aed214d0 | 2016-09-24 01:26:42 | [diff] [blame] | 245 | KeyType AddInternal(V data) { |
tzik | fd754ee | 2018-03-28 15:49:28 | [diff] [blame] | 246 | DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
aelias | aed214d0 | 2016-09-24 01:26:42 | [diff] [blame] | 247 | DCHECK(!check_on_null_data_ || data); |
| 248 | KeyType this_id = next_id_; |
| 249 | DCHECK(data_.find(this_id) == data_.end()) << "Inserting duplicate item"; |
| 250 | data_[this_id] = std::move(data); |
| 251 | next_id_++; |
| 252 | return this_id; |
| 253 | } |
[email protected] | 9e7e0e0 | 2010-01-25 23:25:16 | [diff] [blame] | 254 | |
aelias | aed214d0 | 2016-09-24 01:26:42 | [diff] [blame] | 255 | void AddWithIDInternal(V data, KeyType id) { |
tzik | fd754ee | 2018-03-28 15:49:28 | [diff] [blame] | 256 | DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
aelias | aed214d0 | 2016-09-24 01:26:42 | [diff] [blame] | 257 | DCHECK(!check_on_null_data_ || data); |
tzik | d164667 | 2018-03-28 20:41:13 | [diff] [blame] | 258 | if (IsRemoved(id)) { |
| 259 | removed_ids_.erase(id); |
| 260 | } else { |
| 261 | DCHECK(data_.find(id) == data_.end()) << "Inserting duplicate item"; |
| 262 | } |
aelias | aed214d0 | 2016-09-24 01:26:42 | [diff] [blame] | 263 | data_[id] = std::move(data); |
| 264 | } |
[email protected] | 9e7e0e0 | 2010-01-25 23:25:16 | [diff] [blame] | 265 | |
tzik | d164667 | 2018-03-28 20:41:13 | [diff] [blame] | 266 | bool IsRemoved(KeyType key) const { |
| 267 | return removed_ids_.find(key) != removed_ids_.end(); |
| 268 | } |
| 269 | |
[email protected] | 9de09f8 | 2009-08-17 20:13:53 | [diff] [blame] | 270 | void Compact() { |
| 271 | DCHECK_EQ(0, iteration_depth_); |
jkarlin | 7bc034c | 2015-09-25 20:45:47 | [diff] [blame] | 272 | for (const auto& i : removed_ids_) |
tzik | d164667 | 2018-03-28 20:41:13 | [diff] [blame] | 273 | data_.erase(i); |
[email protected] | 9de09f8 | 2009-08-17 20:13:53 | [diff] [blame] | 274 | removed_ids_.clear(); |
| 275 | } |
| 276 | |
| 277 | // Keep track of how many iterators are currently iterating on us to safely |
| 278 | // handle removing items during iteration. |
| 279 | int iteration_depth_; |
| 280 | |
| 281 | // Keep set of IDs that should be removed after the outermost iteration has |
| 282 | // finished. This way we manage to not invalidate the iterator when an element |
| 283 | // is removed. |
brettw | 1ce49f6 | 2017-04-27 19:42:32 | [diff] [blame] | 284 | base::flat_set<KeyType> removed_ids_; |
[email protected] | 9de09f8 | 2009-08-17 20:13:53 | [diff] [blame] | 285 | |
initial.commit | d7cae12 | 2008-07-26 21:49:38 | [diff] [blame] | 286 | // The next ID that we will return from Add() |
[email protected] | 9e7e0e0 | 2010-01-25 23:25:16 | [diff] [blame] | 287 | KeyType next_id_; |
initial.commit | d7cae12 | 2008-07-26 21:49:38 | [diff] [blame] | 288 | |
| 289 | HashTable data_; |
[email protected] | a6ed943 | 2009-07-01 22:35:26 | [diff] [blame] | 290 | |
[email protected] | a6ed943 | 2009-07-01 22:35:26 | [diff] [blame] | 291 | // See description above setter. |
| 292 | bool check_on_null_data_; |
[email protected] | 9de09f8 | 2009-08-17 20:13:53 | [diff] [blame] | 293 | |
tzik | fd754ee | 2018-03-28 15:49:28 | [diff] [blame] | 294 | SEQUENCE_CHECKER(sequence_checker_); |
initial.commit | d7cae12 | 2008-07-26 21:49:38 | [diff] [blame] | 295 | }; |
| 296 | |
Brett Wilson | f976d3f | 2017-08-18 17:23:39 | [diff] [blame] | 297 | } // namespace base |
| 298 | |
| 299 | #endif // BASE_CONTAINERS_ID_MAP_H_ |