OLD | NEW |
1 // Copyright 2013 Google Inc. All Rights Reserved. | 1 // Copyright 2013 Google Inc. All Rights Reserved. |
2 // | 2 // |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
4 // you may not use this file except in compliance with 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 | 5 // You may obtain a copy of the License at |
6 // | 6 // |
7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
8 // | 8 // |
9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 // See the License for the specific language governing permissions and | 12 // See the License for the specific language governing permissions and |
13 // limitations under the License. | 13 // limitations under the License. |
14 | 14 |
15 part of quiver.collection; | 15 part of quiver.collection; |
16 | 16 |
17 /** | 17 /// An implementation of [List] that delegates all methods to another [List]. |
18 * An implementation of [List] that delegates all methods to another [List]. | 18 /// For instance you can create a FruitList like this : |
19 * For instance you can create a FruitList like this : | 19 /// |
20 * | 20 /// class FruitList extends DelegatingList<Fruit> { |
21 * class FruitList extends DelegatingList<Fruit> { | 21 /// final List<Fruit> _fruits = []; |
22 * final List<Fruit> _fruits = []; | 22 /// |
23 * | 23 /// List<Fruit> get delegate => _fruits; |
24 * List<Fruit> get delegate => _fruits; | 24 /// |
25 * | 25 /// // custom methods |
26 * // custom methods | 26 /// } |
27 * } | |
28 */ | |
29 abstract class DelegatingList<E> extends DelegatingIterable<E> | 27 abstract class DelegatingList<E> extends DelegatingIterable<E> |
30 implements List<E> { | 28 implements List<E> { |
31 List<E> get delegate; | 29 List<E> get delegate; |
32 | 30 |
33 E operator [](int index) => delegate[index]; | 31 E operator [](int index) => delegate[index]; |
34 | 32 |
35 void operator []=(int index, E value) { | 33 void operator []=(int index, E value) { |
36 delegate[index] = value; | 34 delegate[index] = value; |
37 } | 35 } |
38 | 36 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 void setRange(int start, int end, Iterable<E> iterable, | 84 void setRange(int start, int end, Iterable<E> iterable, |
87 [int skipCount = 0]) => | 85 [int skipCount = 0]) => |
88 delegate.setRange(start, end, iterable, skipCount); | 86 delegate.setRange(start, end, iterable, skipCount); |
89 | 87 |
90 void shuffle([Random random]) => delegate.shuffle(random); | 88 void shuffle([Random random]) => delegate.shuffle(random); |
91 | 89 |
92 void sort([int compare(E a, E b)]) => delegate.sort(compare); | 90 void sort([int compare(E a, E b)]) => delegate.sort(compare); |
93 | 91 |
94 List<E> sublist(int start, [int end]) => delegate.sublist(start, end); | 92 List<E> sublist(int start, [int end]) => delegate.sublist(start, end); |
95 } | 93 } |
OLD | NEW |