OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 /** | 5 /** |
6 * Wrappers that prevent List, Set, or Map objects from being modified. | 6 * Wrappers that prevent List, Set, or Map objects from being modified. |
7 * | 7 * |
8 * The [Set] and [Map] wrappers allow reading from the wrapped collection, | 8 * The [Set] and [Map] wrappers allow reading from the wrapped collection, |
9 * but prohibit writing. | 9 * but prohibit writing. |
10 * | 10 * |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 => _source.lastIndexOf(element, start); | 47 => _source.lastIndexOf(element, start); |
48 | 48 |
49 Iterable<E> getRange(int start, int end) => _source.getRange(start, end); | 49 Iterable<E> getRange(int start, int end) => _source.getRange(start, end); |
50 | 50 |
51 List<E> sublist(int start, [int end]) => _source.sublist(start, end); | 51 List<E> sublist(int start, [int end]) => _source.sublist(start, end); |
52 | 52 |
53 Iterable<E> get reversed => _source.reversed; | 53 Iterable<E> get reversed => _source.reversed; |
54 | 54 |
55 Map<int, E> asMap() => _source.asMap(); | 55 Map<int, E> asMap() => _source.asMap(); |
56 | 56 |
57 | |
58 void operator []=(int index, E value) { _source[index] = value; } | 57 void operator []=(int index, E value) { _source[index] = value; } |
59 | 58 |
60 void sort([int compare(E a, E b)]) { _source.sort(compare); } | 59 void sort([int compare(E a, E b)]) { _source.sort(compare); } |
61 | 60 |
| 61 void shuffle() { _source.shuffle(); } |
| 62 |
62 void setRange(int start, int end, Iterable<E> iterable, [int skipCount = 0]) { | 63 void setRange(int start, int end, Iterable<E> iterable, [int skipCount = 0]) { |
63 _source.setRange(start, end, iterable, skipCount); | 64 _source.setRange(start, end, iterable, skipCount); |
64 } | 65 } |
65 | 66 |
66 void fillRange(int start, int end, [E fillValue]) { | 67 void fillRange(int start, int end, [E fillValue]) { |
67 _source.fillRange(start, end, fillValue); | 68 _source.fillRange(start, end, fillValue); |
68 } | 69 } |
69 | 70 |
70 void setAll(int index, Iterable<E> iterable) { | 71 void setAll(int index, Iterable<E> iterable) { |
71 _source.setAll(index, iterable); | 72 _source.setAll(index, iterable); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 /** | 148 /** |
148 * Throws an [UnsupportedError]; | 149 * Throws an [UnsupportedError]; |
149 * operations that change the length of the list are disallowed. | 150 * operations that change the length of the list are disallowed. |
150 */ | 151 */ |
151 void clear() => _throw(); | 152 void clear() => _throw(); |
152 } | 153 } |
153 | 154 |
154 /** | 155 /** |
155 * An unmodifiable set. | 156 * An unmodifiable set. |
156 * | 157 * |
157 * An UnmodifiableSetView contains a [Set] object and ensures | 158 * An UnmodifiableSetView contains a [Set] object and ensures |
158 * that it does not change. | 159 * that it does not change. |
159 * Methods that would change the set, | 160 * Methods that would change the set, |
160 * such as [add] and [remove], throw an [UnsupportedError]. | 161 * such as [add] and [remove], throw an [UnsupportedError]. |
161 * Permitted operations defer to the wrapped set. | 162 * Permitted operations defer to the wrapped set. |
162 */ | 163 */ |
163 class UnmodifiableSetView<E> extends _IterableView<E> | 164 class UnmodifiableSetView<E> extends _IterableView<E> |
164 implements Set<E> { | 165 implements Set<E> { |
165 Set<E> _source; | 166 Set<E> _source; |
166 UnmodifiableSetView(Set<E> source) : _source = source; | 167 UnmodifiableSetView(Set<E> source) : _source = source; |
167 | 168 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 /** | 224 /** |
224 * Throws an [UnsupportedError]; | 225 * Throws an [UnsupportedError]; |
225 * operations that change the set are disallowed. | 226 * operations that change the set are disallowed. |
226 */ | 227 */ |
227 void clear() => _throw(); | 228 void clear() => _throw(); |
228 } | 229 } |
229 | 230 |
230 /** | 231 /** |
231 * An unmodifiable map. | 232 * An unmodifiable map. |
232 * | 233 * |
233 * An UnmodifiableMapView contains a [Map] object and ensures | 234 * An UnmodifiableMapView contains a [Map] object and ensures |
234 * that it does not change. | 235 * that it does not change. |
235 * Methods that would change the map, | 236 * Methods that would change the map, |
236 * such as [addAll] and [remove], throw an [UnsupportedError]. | 237 * such as [addAll] and [remove], throw an [UnsupportedError]. |
237 * Permitted operations defer to the wrapped map. | 238 * Permitted operations defer to the wrapped map. |
238 */ | 239 */ |
239 class UnmodifiableMapView<K, V> implements Map<K, V> { | 240 class UnmodifiableMapView<K, V> implements Map<K, V> { |
240 Map<K, V> _source; | 241 Map<K, V> _source; |
241 UnmodifiableMapView(Map<K, V> source) : _source = source; | 242 UnmodifiableMapView(Map<K, V> source) : _source = source; |
242 | 243 |
243 static void _throw() { | 244 static void _throw() { |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 Iterable<E> take(int n) => _source.take(n); | 349 Iterable<E> take(int n) => _source.take(n); |
349 | 350 |
350 Iterable<E> takeWhile(bool test(E value)) => _source.takeWhile(test); | 351 Iterable<E> takeWhile(bool test(E value)) => _source.takeWhile(test); |
351 | 352 |
352 List<E> toList({ bool growable: true }) => _source.toList(growable: growable); | 353 List<E> toList({ bool growable: true }) => _source.toList(growable: growable); |
353 | 354 |
354 Set<E> toSet() => _source.toSet(); | 355 Set<E> toSet() => _source.toSet(); |
355 | 356 |
356 Iterable<E> where(bool test(E element)) => _source.where(test); | 357 Iterable<E> where(bool test(E element)) => _source.where(test); |
357 } | 358 } |
OLD | NEW |