| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 /** | 5 /** |
| 6 * This class is the public interface of a set. A set is a collection | 6 * This class is the public interface of a set. A set is a collection |
| 7 * without duplicates. | 7 * without duplicates. |
| 8 */ | 8 */ |
| 9 abstract class Set<E> extends Collection<E> { | 9 abstract class Set<E> extends Collection<E> { |
| 10 factory Set() => new _HashSetImpl<E>(); | 10 factory Set() => new _HashSetImpl<E>(); |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 | 202 |
| 203 // TODO(4504458): Replace set_ with set. | 203 // TODO(4504458): Replace set_ with set. |
| 204 _HashSetIterator(_HashSetImpl<E> set_) | 204 _HashSetIterator(_HashSetImpl<E> set_) |
| 205 : _nextValidIndex = -1, | 205 : _nextValidIndex = -1, |
| 206 _entries = set_._backingMap._keys { | 206 _entries = set_._backingMap._keys { |
| 207 _advance(); | 207 _advance(); |
| 208 } | 208 } |
| 209 | 209 |
| 210 bool get hasNext { | 210 bool get hasNext { |
| 211 if (_nextValidIndex >= _entries.length) return false; | 211 if (_nextValidIndex >= _entries.length) return false; |
| 212 if (_entries[_nextValidIndex] == _HashMapImpl._DELETED_KEY) { | 212 if (identical(_entries[_nextValidIndex], _HashMapImpl._DELETED_KEY)) { |
| 213 // This happens in case the set was modified in the meantime. | 213 // This happens in case the set was modified in the meantime. |
| 214 // A modification on the set may make this iterator misbehave, | 214 // A modification on the set may make this iterator misbehave, |
| 215 // but we should never return the sentinel. | 215 // but we should never return the sentinel. |
| 216 _advance(); | 216 _advance(); |
| 217 } | 217 } |
| 218 return _nextValidIndex < _entries.length; | 218 return _nextValidIndex < _entries.length; |
| 219 } | 219 } |
| 220 | 220 |
| 221 E next() { | 221 E next() { |
| 222 if (!hasNext) { | 222 if (!hasNext) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 238 } | 238 } |
| 239 | 239 |
| 240 // The entries in the set. May contain null or the sentinel value. | 240 // The entries in the set. May contain null or the sentinel value. |
| 241 List<E> _entries; | 241 List<E> _entries; |
| 242 | 242 |
| 243 // The next valid index in [_entries] or the length of [entries_]. | 243 // The next valid index in [_entries] or the length of [entries_]. |
| 244 // If it is the length of [_entries], calling [hasNext] on the | 244 // If it is the length of [_entries], calling [hasNext] on the |
| 245 // iterator will return false. | 245 // iterator will return false. |
| 246 int _nextValidIndex; | 246 int _nextValidIndex; |
| 247 } | 247 } |
| OLD | NEW |