| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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; | 5 part of dart.collection; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * This [Iterable] mixin implements all [Iterable] members except `iterator`. | 8 * This [Iterable] mixin implements all [Iterable] members except `iterator`. |
| 9 * | 9 * |
| 10 * All other methods are implemented in terms of `iterator`. | 10 * All other methods are implemented in terms of `iterator`. |
| 11 */ | 11 */ |
| 12 abstract class IterableMixin<E> implements Iterable<E> { | 12 abstract class IterableMixin<E> implements Iterable<E> { |
| 13 // This class has methods copied verbatim into: | 13 // This class has methods copied verbatim into: |
| 14 // - IterableBase | 14 // - IterableBase |
| 15 // - SetMixin | 15 // - SetMixin |
| 16 // If changing a method here, also change the other copies. | 16 // If changing a method here, also change the other copies. |
| 17 | 17 |
| 18 Iterable<T> map<T>(T f(E element)) => new MappedIterable<E, T>(this, f); | 18 Iterable<T> map<T>(T f(E element)) => new MappedIterable<E, T>(this, f); |
| 19 | 19 |
| 20 Iterable<E> where(bool f(E element)) => new WhereIterable<E>(this, f); | 20 Iterable<E> where(bool f(E element)) => new WhereIterable<E>(this, f); |
| 21 | 21 |
| 22 Iterable<T> | 22 Iterable<T> expand<T>(Iterable<T> f(E element)) => |
| 23 expand<T>(Iterable<T> f(E element)) => new ExpandIterable<E, T>(this, f); | 23 new ExpandIterable<E, T>(this, f); |
| 24 | 24 |
| 25 bool contains(Object element) { | 25 bool contains(Object element) { |
| 26 for (E e in this) { | 26 for (E e in this) { |
| 27 if (e == element) return true; | 27 if (e == element) return true; |
| 28 } | 28 } |
| 29 return false; | 29 return false; |
| 30 } | 30 } |
| 31 | 31 |
| 32 void forEach(void f(E element)) { | 32 void forEach(void f(E element)) { |
| 33 for (E element in this) f(element); | 33 for (E element in this) f(element); |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 elision = "..."; | 389 elision = "..."; |
| 390 length += ELLIPSIS_SIZE + OVERHEAD; | 390 length += ELLIPSIS_SIZE + OVERHEAD; |
| 391 } | 391 } |
| 392 } | 392 } |
| 393 if (elision != null) { | 393 if (elision != null) { |
| 394 parts.add(elision); | 394 parts.add(elision); |
| 395 } | 395 } |
| 396 parts.add(penultimateString); | 396 parts.add(penultimateString); |
| 397 parts.add(ultimateString); | 397 parts.add(ultimateString); |
| 398 } | 398 } |
| OLD | NEW |