| 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 * All the [elements] should be assignable to [E]. | 97 * All the [elements] should be assignable to [E]. |
| 98 * The `elements` iterable itself may have any element type, | 98 * The `elements` iterable itself may have any element type, |
| 99 * so this constructor can be used to down-cast a `Set`, for example as: | 99 * so this constructor can be used to down-cast a `Set`, for example as: |
| 100 * | 100 * |
| 101 * Set<SuperType> superSet = ...; | 101 * Set<SuperType> superSet = ...; |
| 102 * Iterable<SuperType> tmp = superSet.where((e) => e is SubType); | 102 * Iterable<SuperType> tmp = superSet.where((e) => e is SubType); |
| 103 * Set<SubType> subSet = new LinkedHashSet<SubType>.from(tmp); | 103 * Set<SubType> subSet = new LinkedHashSet<SubType>.from(tmp); |
| 104 */ | 104 */ |
| 105 factory LinkedHashSet.from(Iterable elements) { | 105 factory LinkedHashSet.from(Iterable elements) { |
| 106 LinkedHashSet<E> result = new LinkedHashSet<E>(); | 106 LinkedHashSet<E> result = new LinkedHashSet<E>(); |
| 107 for (final E element in elements) { | 107 for (final element in elements) { |
| 108 result.add(element); | 108 E e = element as Object/*=E*/; |
| 109 result.add(e); |
| 109 } | 110 } |
| 110 return result; | 111 return result; |
| 111 } | 112 } |
| 112 | 113 |
| 113 /** | 114 /** |
| 114 * Executes a function on each element of the set. | 115 * Executes a function on each element of the set. |
| 115 * | 116 * |
| 116 * The elements are iterated in insertion order. | 117 * The elements are iterated in insertion order. |
| 117 */ | 118 */ |
| 118 void forEach(void action(E element)); | 119 void forEach(void action(E element)); |
| 119 | 120 |
| 120 /** | 121 /** |
| 121 * Provides an iterator that iterates over the elements in insertion order. | 122 * Provides an iterator that iterates over the elements in insertion order. |
| 122 */ | 123 */ |
| 123 Iterator<E> get iterator; | 124 Iterator<E> get iterator; |
| 124 } | 125 } |
| OLD | NEW |