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 part of dart.core; | 5 part of dart.core; |
6 | 6 |
7 /** | 7 /** |
8 * A collection of values, or "elements", that can be accessed sequentially. | 8 * A collection of values, or "elements", that can be accessed sequentially. |
9 * | 9 * |
10 * The elements of the iterable are accessed by getting an [Iterator] | 10 * The elements of the iterable are accessed by getting an [Iterator] |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 * | 185 * |
186 * var pairs = [[1, 2], [3, 4]]; | 186 * var pairs = [[1, 2], [3, 4]]; |
187 * var flattened = pairs.expand((pair) => pair).toList(); | 187 * var flattened = pairs.expand((pair) => pair).toList(); |
188 * print(flattened); // => [1, 2, 3, 4]; | 188 * print(flattened); // => [1, 2, 3, 4]; |
189 * | 189 * |
190 * var input = [1, 2, 3]; | 190 * var input = [1, 2, 3]; |
191 * var duplicated = input.expand((i) => [i, i]).toList(); | 191 * var duplicated = input.expand((i) => [i, i]).toList(); |
192 * print(duplicated); // => [1, 1, 2, 2, 3, 3] | 192 * print(duplicated); // => [1, 1, 2, 2, 3, 3] |
193 * | 193 * |
194 */ | 194 */ |
195 Iterable<T> expand<T>(Iterable<T> f(E element)) => | 195 Iterable<T> |
196 new ExpandIterable<E, T>(this, f); | 196 expand<T>(Iterable<T> f(E element)) => new ExpandIterable<E, T>(this, f); |
197 | 197 |
198 /** | 198 /** |
199 * Returns true if the collection contains an element equal to [element]. | 199 * Returns true if the collection contains an element equal to [element]. |
200 * | 200 * |
201 * This operation will check each element in order for being equal to | 201 * This operation will check each element in order for being equal to |
202 * [element], unless it has a more efficient way to find an element | 202 * [element], unless it has a more efficient way to find an element |
203 * equal to [element]. | 203 * equal to [element]. |
204 * | 204 * |
205 * The equality used to determine whether [element] is equal to an element of | 205 * The equality used to determine whether [element] is equal to an element of |
206 * the iterable defaults to the [Object.==] of the element. | 206 * the iterable defaults to the [Object.==] of the element. |
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
645 */ | 645 */ |
646 abstract class BidirectionalIterator<E> implements Iterator<E> { | 646 abstract class BidirectionalIterator<E> implements Iterator<E> { |
647 /** | 647 /** |
648 * Move back to the previous element. | 648 * Move back to the previous element. |
649 * | 649 * |
650 * Returns true and updates [current] if successful. Returns false | 650 * Returns true and updates [current] if successful. Returns false |
651 * and sets [current] to null if there is no previous element. | 651 * and sets [current] to null if there is no previous element. |
652 */ | 652 */ |
653 bool movePrevious(); | 653 bool movePrevious(); |
654 } | 654 } |
OLD | NEW |