| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 part of dart.collection; | 5 part of dart.collection; |
| 6 | 6 |
| 7 class LinkedHashSet<E> extends Collection<E> implements Set<E> { | 7 class LinkedHashSet<E> extends Collection<E> implements Set<E> { |
| 8 static const int _INITIAL_CAPACITY = 8; | 8 static const int _INITIAL_CAPACITY = 8; |
| 9 _LinkedHashTable<E> _table; | 9 _LinkedHashTable<E> _table; |
| 10 | 10 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 int offset = _table._next(_LinkedHashTable._HEAD_OFFSET); | 23 int offset = _table._next(_LinkedHashTable._HEAD_OFFSET); |
| 24 int modificationCount = _table._modificationCount; | 24 int modificationCount = _table._modificationCount; |
| 25 while (offset != _LinkedHashTable._HEAD_OFFSET) { | 25 while (offset != _LinkedHashTable._HEAD_OFFSET) { |
| 26 E key = _table._key(offset); | 26 E key = _table._key(offset); |
| 27 action(key); | 27 action(key); |
| 28 _table._checkModification(modificationCount); | 28 _table._checkModification(modificationCount); |
| 29 offset = _table._next(offset); | 29 offset = _table._next(offset); |
| 30 } | 30 } |
| 31 } | 31 } |
| 32 | 32 |
| 33 int get length => _table._elementCount; |
| 34 |
| 33 bool get isEmpty => _table._elementCount == 0; | 35 bool get isEmpty => _table._elementCount == 0; |
| 34 | 36 |
| 35 bool contains(Object object) => _table._get(object) >= 0; | 37 bool contains(Object object) => _table._get(object) >= 0; |
| 36 | 38 |
| 37 E get first { | 39 E get first { |
| 38 int firstOffset = _table._next(_LinkedHashTable._HEAD_OFFSET); | 40 int firstOffset = _table._next(_LinkedHashTable._HEAD_OFFSET); |
| 39 if (firstOffset == _LinkedHashTable._HEAD_OFFSET) { | 41 if (firstOffset == _LinkedHashTable._HEAD_OFFSET) { |
| 40 throw new StateError("No elements"); | 42 throw new StateError("No elements"); |
| 41 } | 43 } |
| 42 return _table._key(firstOffset); | 44 return _table._key(firstOffset); |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 for (E element in other) { | 150 for (E element in other) { |
| 149 if (this.contains(element)) { | 151 if (this.contains(element)) { |
| 150 result.add(element); | 152 result.add(element); |
| 151 } | 153 } |
| 152 } | 154 } |
| 153 return result; | 155 return result; |
| 154 } | 156 } |
| 155 | 157 |
| 156 String toString() => Collections.collectionToString(this); | 158 String toString() => Collections.collectionToString(this); |
| 157 } | 159 } |
| OLD | NEW |