| 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 [List] that delegates all methods to another [List]. | |
| 19 * For instance you can create a FruitList like this : | |
| 20 * | |
| 21 * class FruitList extends DelegatingList<Fruit> { | |
| 22 * final List<Fruit> _fruits = []; | |
| 23 * | |
| 24 * List<Fruit> get delegate => _fruits; | |
| 25 * | |
| 26 * // custom methods | |
| 27 * } | |
| 28 */ | |
| 29 abstract class DelegatingList<E> extends DelegatingIterable<E> | |
| 30 implements List<E> { | |
| 31 List<E> get delegate; | |
| 32 | |
| 33 E operator [](int index) => delegate[index]; | |
| 34 | |
| 35 void operator []=(int index, E value) { | |
| 36 delegate[index] = value; | |
| 37 } | |
| 38 | |
| 39 void add(E value) => delegate.add(value); | |
| 40 | |
| 41 void addAll(Iterable<E> iterable) => delegate.addAll(iterable); | |
| 42 | |
| 43 Map<int, E> asMap() => delegate.asMap(); | |
| 44 | |
| 45 void clear() => delegate.clear(); | |
| 46 | |
| 47 void fillRange(int start, int end, [E fillValue]) => | |
| 48 delegate.fillRange(start, end, fillValue); | |
| 49 | |
| 50 Iterable<E> getRange(int start, int end) => delegate.getRange(start, end); | |
| 51 | |
| 52 int indexOf(E element, [int start = 0]) => delegate.indexOf(element, start); | |
| 53 | |
| 54 void insert(int index, E element) => delegate.insert(index, element); | |
| 55 | |
| 56 void insertAll(int index, Iterable<E> iterable) => | |
| 57 delegate.insertAll(index, iterable); | |
| 58 | |
| 59 int lastIndexOf(E element, [int start]) => | |
| 60 delegate.lastIndexOf(element, start); | |
| 61 | |
| 62 void set length(int newLength) { | |
| 63 delegate.length = newLength; | |
| 64 } | |
| 65 | |
| 66 bool remove(Object value) => delegate.remove(value); | |
| 67 | |
| 68 E removeAt(int index) => delegate.removeAt(index); | |
| 69 | |
| 70 E removeLast() => delegate.removeLast(); | |
| 71 | |
| 72 void removeRange(int start, int end) => delegate.removeRange(start, end); | |
| 73 | |
| 74 void removeWhere(bool test(E element)) => delegate.removeWhere(test); | |
| 75 | |
| 76 void replaceRange(int start, int end, Iterable<E> iterable) => | |
| 77 delegate.replaceRange(start, end, iterable); | |
| 78 | |
| 79 void retainWhere(bool test(E element)) => delegate.retainWhere(test); | |
| 80 | |
| 81 Iterable<E> get reversed => delegate.reversed; | |
| 82 | |
| 83 void setAll(int index, Iterable<E> iterable) => | |
| 84 delegate.setAll(index, iterable); | |
| 85 | |
| 86 void setRange(int start, int end, Iterable<E> iterable, | |
| 87 [int skipCount = 0]) => | |
| 88 delegate.setRange(start, end, iterable, skipCount); | |
| 89 | |
| 90 void shuffle([Random random]) => delegate.shuffle(random); | |
| 91 | |
| 92 void sort([int compare(E a, E b)]) => delegate.sort(compare); | |
| 93 | |
| 94 List<E> sublist(int start, [int end]) => delegate.sublist(start, end); | |
| 95 } | |
| OLD | NEW |