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 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 } | 190 } |
191 } | 191 } |
192 return buffer.toString(); | 192 return buffer.toString(); |
193 } | 193 } |
194 } | 194 } |
195 | 195 |
196 Iterable<E> where(bool test(E element)) => super.where(test); | 196 Iterable<E> where(bool test(E element)) => super.where(test); |
197 | 197 |
198 Iterable map(f(E element)) => new MappedIterable(this, f); | 198 Iterable map(f(E element)) => new MappedIterable(this, f); |
199 | 199 |
200 Iterable mappedBy(f(E element)) => super.mappedBy(f); | |
201 | |
202 reduce(var initialValue, combine(var previousValue, E element)) { | 200 reduce(var initialValue, combine(var previousValue, E element)) { |
203 var value = initialValue; | 201 var value = initialValue; |
204 int length = this.length; | 202 int length = this.length; |
205 for (int i = 0; i < length; i++) { | 203 for (int i = 0; i < length; i++) { |
206 value = combine(value, elementAt(i)); | 204 value = combine(value, elementAt(i)); |
207 if (length != this.length) { | 205 if (length != this.length) { |
208 throw new ConcurrentModificationError(this); | 206 throw new ConcurrentModificationError(this); |
209 } | 207 } |
210 } | 208 } |
211 return value; | 209 return value; |
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
656 E min([int compare(E a, E b)]) => null; | 654 E min([int compare(E a, E b)]) => null; |
657 | 655 |
658 E max([int compare(E a, E b)]) => null; | 656 E max([int compare(E a, E b)]) => null; |
659 | 657 |
660 String join([String separator]) => ""; | 658 String join([String separator]) => ""; |
661 | 659 |
662 Iterable<E> where(bool test(E element)) => this; | 660 Iterable<E> where(bool test(E element)) => this; |
663 | 661 |
664 Iterable map(f(E element)) => const EmptyIterable(); | 662 Iterable map(f(E element)) => const EmptyIterable(); |
665 | 663 |
666 Iterable mappedBy(f(E element)) => const EmptyIterable(); | |
667 | |
668 reduce(var initialValue, combine(var previousValue, E element)) { | 664 reduce(var initialValue, combine(var previousValue, E element)) { |
669 return initialValue; | 665 return initialValue; |
670 } | 666 } |
671 | 667 |
672 Iterable<E> skip(int count) => this; | 668 Iterable<E> skip(int count) => this; |
673 | 669 |
674 Iterable<E> skipWhile(bool test(E element)) => this; | 670 Iterable<E> skipWhile(bool test(E element)) => this; |
675 | 671 |
676 Iterable<E> take(int count) => this; | 672 Iterable<E> take(int count) => this; |
677 | 673 |
678 Iterable<E> takeWhile(bool test(E element)) => this; | 674 Iterable<E> takeWhile(bool test(E element)) => this; |
679 | 675 |
680 List toList() => <E>[]; | 676 List toList() => <E>[]; |
681 | 677 |
682 Set toSet() => new Set<E>(); | 678 Set toSet() => new Set<E>(); |
683 } | 679 } |
684 | 680 |
685 /** The always empty iterator. */ | 681 /** The always empty iterator. */ |
686 class EmptyIterator<E> implements Iterator<E> { | 682 class EmptyIterator<E> implements Iterator<E> { |
687 const EmptyIterator(); | 683 const EmptyIterator(); |
688 bool moveNext() => false; | 684 bool moveNext() => false; |
689 E get current => null; | 685 E get current => null; |
690 } | 686 } |
691 | 687 |
692 /** An [Iterator] that can move in both directions. */ | 688 /** An [Iterator] that can move in both directions. */ |
693 abstract class BiDirectionalIterator<T> implements Iterator<T> { | 689 abstract class BiDirectionalIterator<T> implements Iterator<T> { |
694 bool movePrevious(); | 690 bool movePrevious(); |
695 } | 691 } |
OLD | NEW |