| 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._internal; | 5 part of dart._internal; |
| 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 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 651 return _iterator.moveNext(); | 651 return _iterator.moveNext(); |
| 652 } | 652 } |
| 653 | 653 |
| 654 E get current => _iterator.current; | 654 E get current => _iterator.current; |
| 655 } | 655 } |
| 656 | 656 |
| 657 /** | 657 /** |
| 658 * The always empty [Iterable]. | 658 * The always empty [Iterable]. |
| 659 */ | 659 */ |
| 660 class EmptyIterable<E> extends Iterable<E> | 660 class EmptyIterable<E> extends Iterable<E> |
| 661 implements EfficientLengthIterable<E> { | 661 implements EfficientLengthIterable<E> { |
| 662 const EmptyIterable(); | 662 const EmptyIterable(); |
| 663 | 663 |
| 664 Iterator<E> get iterator => const EmptyIterator(); | 664 Iterator<E> get iterator => const EmptyIterator(); |
| 665 | 665 |
| 666 void forEach(void action(E element)) {} | 666 void forEach(void action(E element)) {} |
| 667 | 667 |
| 668 bool get isEmpty => true; | 668 bool get isEmpty => true; |
| 669 | 669 |
| 670 int get length => 0; | 670 int get length => 0; |
| 671 | 671 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 748 * Creates errors throw by [Iterable] when the element count is wrong. | 748 * Creates errors throw by [Iterable] when the element count is wrong. |
| 749 */ | 749 */ |
| 750 abstract class IterableElementError { | 750 abstract class IterableElementError { |
| 751 /** Error thrown thrown by, e.g., [Iterable.first] when there is no result. */ | 751 /** Error thrown thrown by, e.g., [Iterable.first] when there is no result. */ |
| 752 static StateError noElement() => new StateError("No element"); | 752 static StateError noElement() => new StateError("No element"); |
| 753 /** Error thrown by, e.g., [Iterable.single] if there are too many results. */ | 753 /** Error thrown by, e.g., [Iterable.single] if there are too many results. */ |
| 754 static StateError tooMany() => new StateError("Too many elements"); | 754 static StateError tooMany() => new StateError("Too many elements"); |
| 755 /** Error thrown by, e.g., [List.setRange] if there are too few elements. */ | 755 /** Error thrown by, e.g., [List.setRange] if there are too few elements. */ |
| 756 static StateError tooFew() => new StateError("Too few elements"); | 756 static StateError tooFew() => new StateError("Too few elements"); |
| 757 } | 757 } |
| OLD | NEW |