Chromium Code Reviews| 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 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 174 Iterable<E> where(bool test(E element)) => new WhereIterable<E>(this, test); | 174 Iterable<E> where(bool test(E element)) => new WhereIterable<E>(this, test); |
| 175 | 175 |
| 176 /** | 176 /** |
| 177 * Expands each element of this [Iterable] into zero or more elements. | 177 * Expands each element of this [Iterable] into zero or more elements. |
| 178 * | 178 * |
| 179 * The resulting Iterable runs through the elements returned | 179 * The resulting Iterable runs through the elements returned |
| 180 * by [f] for each element of this, in iteration order. | 180 * by [f] for each element of this, in iteration order. |
| 181 * | 181 * |
| 182 * The returned [Iterable] is lazy, and calls [f] for each element | 182 * The returned [Iterable] is lazy, and calls [f] for each element |
| 183 * of this every time it's iterated. | 183 * of this every time it's iterated. |
| 184 * | |
| 185 * Example: | |
| 186 * | |
| 187 * var lists = [<int>[1, 2, 3], <int>[3, 4, 5]]; | |
| 188 * Set<int> ints = lists.expand((list) => list).toSet(); | |
| 189 * print(ints); | |
|
floitsch
2016/08/05 09:38:40
I prefer not to write the type arguments and sets:
stanm
2016/08/05 16:48:31
Done.
| |
| 190 * | |
| 191 * > {1, 2, 3, 4, 5} | |
| 192 * | |
| 184 */ | 193 */ |
| 185 Iterable/*<T>*/ expand/*<T>*/(Iterable/*<T>*/ f(E element)) => | 194 Iterable/*<T>*/ expand/*<T>*/(Iterable/*<T>*/ f(E element)) => |
| 186 new ExpandIterable<E, dynamic/*=T*/>(this, f); | 195 new ExpandIterable<E, dynamic/*=T*/>(this, f); |
| 187 | 196 |
| 188 /** | 197 /** |
| 189 * Returns true if the collection contains an element equal to [element]. | 198 * Returns true if the collection contains an element equal to [element]. |
| 190 * | 199 * |
| 191 * This operation will check each element in order for being equal to | 200 * This operation will check each element in order for being equal to |
| 192 * [element], unless it has a more efficient way to find an element | 201 * [element], unless it has a more efficient way to find an element |
| 193 * equal to [element]. | 202 * equal to [element]. |
| (...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 638 */ | 647 */ |
| 639 abstract class BidirectionalIterator<E> implements Iterator<E> { | 648 abstract class BidirectionalIterator<E> implements Iterator<E> { |
| 640 /** | 649 /** |
| 641 * Move back to the previous element. | 650 * Move back to the previous element. |
| 642 * | 651 * |
| 643 * Returns true and updates [current] if successful. Returns false | 652 * Returns true and updates [current] if successful. Returns false |
| 644 * and sets [current] to null if there is no previous element. | 653 * and sets [current] to null if there is no previous element. |
| 645 */ | 654 */ |
| 646 bool movePrevious(); | 655 bool movePrevious(); |
| 647 } | 656 } |
| OLD | NEW |