| 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._collection.dev; | 5 part of dart._collection.dev; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * An [Iterable] for classes that have efficient [length] and [elementAt]. | 8 * An [Iterable] for classes that have efficient [length] and [elementAt]. |
| 9 * | 9 * |
| 10 * All other methods are implemented in terms of [length] and [elementAt], | 10 * All other methods are implemented in terms of [length] and [elementAt], |
| 11 * including [iterator]. | 11 * including [iterator]. |
| 12 */ | 12 */ |
| 13 abstract class ListIterable<E> extends Iterable<E> { | 13 abstract class ListIterable<E> extends Iterable<E> { |
| 14 int get length; | 14 int get length; |
| 15 E elementAt(int i); | 15 E elementAt(int i); |
| 16 | 16 |
| 17 const ListIterable(); |
| 18 |
| 17 Iterator<E> get iterator => new ListIterator<E>(this); | 19 Iterator<E> get iterator => new ListIterator<E>(this); |
| 18 | 20 |
| 19 void forEach(void action(E element)) { | 21 void forEach(void action(E element)) { |
| 20 int length = this.length; | 22 int length = this.length; |
| 21 for (int i = 0; i < length; i++) { | 23 for (int i = 0; i < length; i++) { |
| 22 action(elementAt(i)); | 24 action(elementAt(i)); |
| 23 if (length != this.length) { | 25 if (length != this.length) { |
| 24 throw new ConcurrentModificationError(this); | 26 throw new ConcurrentModificationError(this); |
| 25 } | 27 } |
| 26 } | 28 } |
| (...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 683 class EmptyIterator<E> implements Iterator<E> { | 685 class EmptyIterator<E> implements Iterator<E> { |
| 684 const EmptyIterator(); | 686 const EmptyIterator(); |
| 685 bool moveNext() => false; | 687 bool moveNext() => false; |
| 686 E get current => null; | 688 E get current => null; |
| 687 } | 689 } |
| 688 | 690 |
| 689 /** An [Iterator] that can move in both directions. */ | 691 /** An [Iterator] that can move in both directions. */ |
| 690 abstract class BiDirectionalIterator<T> implements Iterator<T> { | 692 abstract class BiDirectionalIterator<T> implements Iterator<T> { |
| 691 bool movePrevious(); | 693 bool movePrevious(); |
| 692 } | 694 } |
| OLD | NEW |