| 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 /** | 7 /** |
| 8 * A [LinkedHashSet] is a hash-table based [Set] implementation. | 8 * A [LinkedHashSet] is a hash-table based [Set] implementation. |
| 9 * | 9 * |
| 10 * The `LinkedHashSet` also keep track of the order that elements were inserted | 10 * The `LinkedHashSet` also keep track of the order that elements were inserted |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 * If [isValidKey] is omitted, it defaults to testing if the object is an | 47 * If [isValidKey] is omitted, it defaults to testing if the object is an |
| 48 * [E] instance. | 48 * [E] instance. |
| 49 * | 49 * |
| 50 * If you supply one of [equals] and [hashCode], | 50 * If you supply one of [equals] and [hashCode], |
| 51 * you should generally also to supply the other. | 51 * you should generally also to supply the other. |
| 52 * An example would be using [identical] and [identityHashCode], | 52 * An example would be using [identical] and [identityHashCode], |
| 53 * which is equivalent to using the shorthand [LinkedSet.identity]). | 53 * which is equivalent to using the shorthand [LinkedSet.identity]). |
| 54 */ | 54 */ |
| 55 factory LinkedHashSet({ bool equals(E e1, E e2), | 55 factory LinkedHashSet({ bool equals(E e1, E e2), |
| 56 int hashCode(E e), | 56 int hashCode(E e), |
| 57 bool isValidKey(potentialKey) }) { | 57 bool isValidKey(Object potentialKey) }) { |
| 58 if (isValidKey == null) { | 58 if (isValidKey == null) { |
| 59 if (hashCode == null) { | 59 if (hashCode == null) { |
| 60 if (equals == null) { | 60 if (equals == null) { |
| 61 return new _LinkedHashSet<E>(); | 61 return new _LinkedHashSet<E>(); |
| 62 } | 62 } |
| 63 hashCode = _defaultHashCode; | 63 hashCode = _defaultHashCode; |
| 64 } else { | 64 } else { |
| 65 if (identical(identityHashCode, hashCode) && | 65 if (identical(identityHashCode, hashCode) && |
| 66 identical(identical, equals)) { | 66 identical(identical, equals)) { |
| 67 return new _LinkedIdentityHashSet<E>(); | 67 return new _LinkedIdentityHashSet<E>(); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 * | 117 * |
| 118 * The elements are iterated in insertion order. | 118 * The elements are iterated in insertion order. |
| 119 */ | 119 */ |
| 120 void forEach(void action(E element)); | 120 void forEach(void action(E element)); |
| 121 | 121 |
| 122 /** | 122 /** |
| 123 * Provides an iterator that iterates over the elements in insertion order. | 123 * Provides an iterator that iterates over the elements in insertion order. |
| 124 */ | 124 */ |
| 125 Iterator<E> get iterator; | 125 Iterator<E> get iterator; |
| 126 } | 126 } |
| OLD | NEW |