| 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], |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 void forEach(void action(E element)) { | 21 void forEach(void action(E element)) { |
| 22 int length = this.length; | 22 int length = this.length; |
| 23 for (int i = 0; i < length; i++) { | 23 for (int i = 0; i < length; i++) { |
| 24 action(elementAt(i)); | 24 action(elementAt(i)); |
| 25 if (length != this.length) { | 25 if (length != this.length) { |
| 26 throw new ConcurrentModificationError(this); | 26 throw new ConcurrentModificationError(this); |
| 27 } | 27 } |
| 28 } | 28 } |
| 29 } | 29 } |
| 30 | 30 |
| 31 bool get isEmpty => length != 0; | 31 bool get isEmpty => length == 0; |
| 32 | 32 |
| 33 E get first { | 33 E get first { |
| 34 if (length == 0) throw new StateError("No elements"); | 34 if (length == 0) throw new StateError("No elements"); |
| 35 return elementAt(0); | 35 return elementAt(0); |
| 36 } | 36 } |
| 37 | 37 |
| 38 E get last { | 38 E get last { |
| 39 if (length == 0) throw new StateError("No elements"); | 39 if (length == 0) throw new StateError("No elements"); |
| 40 return elementAt(length - 1); | 40 return elementAt(length - 1); |
| 41 } | 41 } |
| (...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 690 class EmptyIterator<E> implements Iterator<E> { | 690 class EmptyIterator<E> implements Iterator<E> { |
| 691 const EmptyIterator(); | 691 const EmptyIterator(); |
| 692 bool moveNext() => false; | 692 bool moveNext() => false; |
| 693 E get current => null; | 693 E get current => null; |
| 694 } | 694 } |
| 695 | 695 |
| 696 /** An [Iterator] that can move in both directions. */ | 696 /** An [Iterator] that can move in both directions. */ |
| 697 abstract class BidirectionalIterator<T> implements Iterator<T> { | 697 abstract class BidirectionalIterator<T> implements Iterator<T> { |
| 698 bool movePrevious(); | 698 bool movePrevious(); |
| 699 } | 699 } |
| OLD | NEW |