| OLD | NEW |
| (Empty) |
| 1 // Copyright 2013 Google Inc. All Rights Reserved. | |
| 2 // | |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); | |
| 4 // you may not use this file except in compliance with the License. | |
| 5 // You may obtain a copy of the License at | |
| 6 // | |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 | |
| 8 // | |
| 9 // Unless required by applicable law or agreed to in writing, software | |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, | |
| 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 12 // See the License for the specific language governing permissions and | |
| 13 // limitations under the License. | |
| 14 | |
| 15 part of quiver.collection; | |
| 16 | |
| 17 /** | |
| 18 * An implementation of [Iterable] that delegates all methods to another | |
| 19 * [Iterable]. | |
| 20 * For instance you can create a FruitIterable like this : | |
| 21 * | |
| 22 * class FruitIterable extends DelegatingIterable<Fruit> { | |
| 23 * final Iterable<Fruit> _fruits = []; | |
| 24 * | |
| 25 * Iterable<Fruit> get delegate => _fruits; | |
| 26 * | |
| 27 * // custom methods | |
| 28 * } | |
| 29 */ | |
| 30 abstract class DelegatingIterable<E> implements Iterable<E> { | |
| 31 Iterable<E> get delegate; | |
| 32 | |
| 33 bool any(bool test(E element)) => delegate.any(test); | |
| 34 | |
| 35 bool contains(Object element) => delegate.contains(element); | |
| 36 | |
| 37 E elementAt(int index) => delegate.elementAt(index); | |
| 38 | |
| 39 bool every(bool test(E element)) => delegate.every(test); | |
| 40 | |
| 41 Iterable expand(Iterable f(E element)) => delegate.expand(f); | |
| 42 | |
| 43 E get first => delegate.first; | |
| 44 | |
| 45 E firstWhere(bool test(E element), {E orElse()}) => | |
| 46 delegate.firstWhere(test, orElse: orElse); | |
| 47 | |
| 48 fold(initialValue, combine(previousValue, E element)) => | |
| 49 delegate.fold(initialValue, combine); | |
| 50 | |
| 51 void forEach(void f(E element)) => delegate.forEach(f); | |
| 52 | |
| 53 bool get isEmpty => delegate.isEmpty; | |
| 54 | |
| 55 bool get isNotEmpty => delegate.isNotEmpty; | |
| 56 | |
| 57 Iterator<E> get iterator => delegate.iterator; | |
| 58 | |
| 59 String join([String separator = ""]) => delegate.join(separator); | |
| 60 | |
| 61 E get last => delegate.last; | |
| 62 | |
| 63 E lastWhere(bool test(E element), {E orElse()}) => | |
| 64 delegate.lastWhere(test, orElse: orElse); | |
| 65 | |
| 66 int get length => delegate.length; | |
| 67 | |
| 68 Iterable map(f(E element)) => delegate.map(f); | |
| 69 | |
| 70 E reduce(E combine(E value, E element)) => delegate.reduce(combine); | |
| 71 | |
| 72 E get single => delegate.single; | |
| 73 | |
| 74 E singleWhere(bool test(E element)) => delegate.singleWhere(test); | |
| 75 | |
| 76 Iterable<E> skip(int n) => delegate.skip(n); | |
| 77 | |
| 78 Iterable<E> skipWhile(bool test(E value)) => delegate.skipWhile(test); | |
| 79 | |
| 80 Iterable<E> take(int n) => delegate.take(n); | |
| 81 | |
| 82 Iterable<E> takeWhile(bool test(E value)) => delegate.takeWhile(test); | |
| 83 | |
| 84 List<E> toList({bool growable: true}) => delegate.toList(growable: growable); | |
| 85 | |
| 86 Set<E> toSet() => delegate.toSet(); | |
| 87 | |
| 88 Iterable<E> where(bool test(E element)) => delegate.where(test); | |
| 89 } | |
| OLD | NEW |