| 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 /** Common parts of [HashSet] and [LinkedHashSet] implementations. */ | 7 /** Common parts of [HashSet] and [LinkedHashSet] implementations. */ |
| 8 abstract class _HashSetBase<E> extends SetBase<E> { | 8 abstract class _HashSetBase<E> extends SetBase<E> { |
| 9 | 9 |
| 10 // The following two methods override the ones in SetBase. | 10 // The following two methods override the ones in SetBase. |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 * All the [elements] should be assignable to [E]. | 114 * All the [elements] should be assignable to [E]. |
| 115 * The `elements` iterable itself may have any element type, so this | 115 * The `elements` iterable itself may have any element type, so this |
| 116 * constructor can be used to down-cast a `Set`, for example as: | 116 * constructor can be used to down-cast a `Set`, for example as: |
| 117 * | 117 * |
| 118 * Set<SuperType> superSet = ...; | 118 * Set<SuperType> superSet = ...; |
| 119 * Set<SubType> subSet = | 119 * Set<SubType> subSet = |
| 120 * new HashSet<SubType>.from(superSet.where((e) => e is SubType)); | 120 * new HashSet<SubType>.from(superSet.where((e) => e is SubType)); |
| 121 */ | 121 */ |
| 122 factory HashSet.from(Iterable elements) { | 122 factory HashSet.from(Iterable elements) { |
| 123 HashSet<E> result = new HashSet<E>(); | 123 HashSet<E> result = new HashSet<E>(); |
| 124 for (E e in elements) result.add(e); | 124 for (final e in elements) { |
| 125 E element = e as Object/*=E*/; |
| 126 result.add(element); |
| 127 } |
| 125 return result; | 128 return result; |
| 126 } | 129 } |
| 127 | 130 |
| 128 /** | 131 /** |
| 129 * Provides an iterator that iterates over the elements of this set. | 132 * Provides an iterator that iterates over the elements of this set. |
| 130 * | 133 * |
| 131 * The order of iteration is unspecified, | 134 * The order of iteration is unspecified, |
| 132 * but consistent between changes to the set. | 135 * but consistent between changes to the set. |
| 133 */ | 136 */ |
| 134 Iterator<E> get iterator; | 137 Iterator<E> get iterator; |
| 135 } | 138 } |
| OLD | NEW |