| 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 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 Set<E> toSet() => new Set<E>.from(this); | 351 Set<E> toSet() => new Set<E>.from(this); |
| 352 | 352 |
| 353 /** | 353 /** |
| 354 * Returns the number of elements in [this]. | 354 * Returns the number of elements in [this]. |
| 355 * | 355 * |
| 356 * Counting all elements may involve iterating through all elements and can | 356 * Counting all elements may involve iterating through all elements and can |
| 357 * therefore be slow. | 357 * therefore be slow. |
| 358 * Some iterables have a more efficient way to find the number of elements. | 358 * Some iterables have a more efficient way to find the number of elements. |
| 359 */ | 359 */ |
| 360 int get length { | 360 int get length { |
| 361 assert(this is! EfficientLengthIterable); | 361 assert(this is! EfficientLength); |
| 362 int count = 0; | 362 int count = 0; |
| 363 Iterator it = iterator; | 363 Iterator it = iterator; |
| 364 while (it.moveNext()) { | 364 while (it.moveNext()) { |
| 365 count++; | 365 count++; |
| 366 } | 366 } |
| 367 return count; | 367 return count; |
| 368 } | 368 } |
| 369 | 369 |
| 370 /** | 370 /** |
| 371 * Returns `true` if there are no elements in this collection. | 371 * Returns `true` if there are no elements in this collection. |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 598 * The conversion may omit calling `toString` on some elements if they | 598 * The conversion may omit calling `toString` on some elements if they |
| 599 * are known to not occur in the output, and it may stop iterating after | 599 * are known to not occur in the output, and it may stop iterating after |
| 600 * a hundred elements. | 600 * a hundred elements. |
| 601 */ | 601 */ |
| 602 String toString() => IterableBase.iterableToShortString(this, '(', ')'); | 602 String toString() => IterableBase.iterableToShortString(this, '(', ')'); |
| 603 } | 603 } |
| 604 | 604 |
| 605 typedef E _Generator<E>(int index); | 605 typedef E _Generator<E>(int index); |
| 606 | 606 |
| 607 class _GeneratorIterable<E> extends Iterable<E> | 607 class _GeneratorIterable<E> extends Iterable<E> |
| 608 implements EfficientLengthIterable<E> { | 608 implements EfficientLength { |
| 609 final int _start; | 609 final int _start; |
| 610 final int _end; | 610 final int _end; |
| 611 final _Generator<E> _generator; | 611 final _Generator<E> _generator; |
| 612 _GeneratorIterable(this._end, E generator(int n)) | 612 _GeneratorIterable(this._end, E generator(int n)) |
| 613 : _start = 0, | 613 : _start = 0, |
| 614 _generator = (generator != null) ? generator : _id; | 614 _generator = (generator != null) ? generator : _id; |
| 615 | 615 |
| 616 _GeneratorIterable.slice(this._start, this._end, this._generator); | 616 _GeneratorIterable.slice(this._start, this._end, this._generator); |
| 617 | 617 |
| 618 Iterator<E> get iterator => | 618 Iterator<E> get iterator => |
| (...skipping 46 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 |