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 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
385 * Returns a lazy iterable of the [count] first elements of this iterable. | 385 * Returns a lazy iterable of the [count] first elements of this iterable. |
386 * | 386 * |
387 * The returned `Iterable` may contain fewer than `count` elements, if `this` | 387 * The returned `Iterable` may contain fewer than `count` elements, if `this` |
388 * contains fewer than `count` elements. | 388 * contains fewer than `count` elements. |
389 * | 389 * |
390 * The elements can be computed by stepping through [iterator] until [count] | 390 * The elements can be computed by stepping through [iterator] until [count] |
391 * elements have been seen. | 391 * elements have been seen. |
392 * | 392 * |
393 * The `count` must not be negative. | 393 * The `count` must not be negative. |
394 */ | 394 */ |
395 Iterable<E> take(int n) { | 395 Iterable<E> take(int count) { |
396 return new TakeIterable<E>(this, n); | 396 return new TakeIterable<E>(this, count); |
397 } | 397 } |
398 | 398 |
399 /** | 399 /** |
400 * Returns a lazy iterable of the leading elements satisfying [test]. | 400 * Returns a lazy iterable of the leading elements satisfying [test]. |
401 * | 401 * |
402 * The filtering happens lazily. Every new iterator of the returned | 402 * The filtering happens lazily. Every new iterator of the returned |
403 * iterable starts iterating over the elements of `this`. | 403 * iterable starts iterating over the elements of `this`. |
404 * | 404 * |
405 * The elements can be computed by stepping through [iterator] until an | 405 * The elements can be computed by stepping through [iterator] until an |
406 * element is found where `test(element)` is false. At that point, | 406 * element is found where `test(element)` is false. At that point, |
407 * the returned iterable stops (its `moveNext()` returns false). | 407 * the returned iterable stops (its `moveNext()` returns false). |
408 */ | 408 */ |
409 Iterable<E> takeWhile(bool test(E value)) { | 409 Iterable<E> takeWhile(bool test(E value)) { |
410 return new TakeWhileIterable<E>(this, test); | 410 return new TakeWhileIterable<E>(this, test); |
411 } | 411 } |
412 | 412 |
413 /** | 413 /** |
414 * Returns an Iterable that provides all but the first [count] elements. | 414 * Returns an Iterable that provides all but the first [count] elements. |
415 * | 415 * |
416 * When the returned iterable is iterated, it starts iterating over `this`, | 416 * When the returned iterable is iterated, it starts iterating over `this`, |
417 * first skipping past the initial [count] elements. | 417 * first skipping past the initial [count] elements. |
418 * If `this` has fewer than `count` elements, then the resulting Iterable is | 418 * If `this` has fewer than `count` elements, then the resulting Iterable is |
419 * empty. | 419 * empty. |
420 * After that, the remaining elements are iterated in the same order as | 420 * After that, the remaining elements are iterated in the same order as |
421 * in this iterable. | 421 * in this iterable. |
422 * | 422 * |
423 * The `count` must not be negative. | 423 * The `count` must not be negative. |
424 */ | 424 */ |
425 Iterable<E> skip(int n) { | 425 Iterable<E> skip(int n) { |
Lasse Reichstein Nielsen
2015/08/11 06:07:00
This one too.
sethladd
2015/08/11 14:48:12
Done.
| |
426 return new SkipIterable<E>(this, n); | 426 return new SkipIterable<E>(this, n); |
427 } | 427 } |
428 | 428 |
429 /** | 429 /** |
430 * Returns an Iterable that skips leading elements while [test] is satisfied. | 430 * Returns an Iterable that skips leading elements while [test] is satisfied. |
431 * | 431 * |
432 * The filtering happens lazily. Every new Iterator of the returned | 432 * The filtering happens lazily. Every new Iterator of the returned |
433 * Iterable iterates over all elements of `this`. | 433 * Iterable iterates over all elements of `this`. |
434 * | 434 * |
435 * The returned iterable provides elements by iterating this iterable, | 435 * The returned iterable provides elements by iterating this iterable, |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
665 */ | 665 */ |
666 abstract class BidirectionalIterator<E> implements Iterator<E> { | 666 abstract class BidirectionalIterator<E> implements Iterator<E> { |
667 /** | 667 /** |
668 * Move back to the previous element. | 668 * Move back to the previous element. |
669 * | 669 * |
670 * Returns true and updates [current] if successful. Returns false | 670 * Returns true and updates [current] if successful. Returns false |
671 * and sets [current] to null if there is no previous element. | 671 * and sets [current] to null if there is no previous element. |
672 */ | 672 */ |
673 bool movePrevious(); | 673 bool movePrevious(); |
674 } | 674 } |
OLD | NEW |