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 * Delegating wrappers for [Iterable], [List], [Set], [Queue] and [Map]. | 6 * Delegating wrappers for [Iterable], [List], [Set], [Queue] and [Map]. |
7 * | 7 * |
8 * Also adds unmodifiable views for `Set` and `Map`, and a fixed length | 8 * Also adds unmodifiable views for `Set` and `Map`, and a fixed length |
9 * view for `List`. The unmodifable list view from `dart:collection` is exported | 9 * view for `List`. The unmodifable list view from `dart:collection` is exported |
10 * as well, just for completeness. | 10 * as well, just for completeness. |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
117 const DelegatingList(List<E> base) : super(base); | 117 const DelegatingList(List<E> base) : super(base); |
118 | 118 |
119 List<E> get _listBase => _base; | 119 List<E> get _listBase => _base; |
120 | 120 |
121 E operator [](int index) => _listBase[index]; | 121 E operator [](int index) => _listBase[index]; |
122 | 122 |
123 void operator []=(int index, E value) { | 123 void operator []=(int index, E value) { |
124 _listBase[index] = value; | 124 _listBase[index] = value; |
125 } | 125 } |
126 | 126 |
127 void set last(E value) { | |
128 _listBase.last = value; | |
nweiz
2014/06/12 23:03:58
This will cause an analyzer warning on versions of
| |
129 } | |
130 | |
127 void add(E value) { | 131 void add(E value) { |
128 _listBase.add(value); | 132 _listBase.add(value); |
129 } | 133 } |
130 | 134 |
131 void addAll(Iterable<E> iterable) { | 135 void addAll(Iterable<E> iterable) { |
132 _listBase.addAll(iterable); | 136 _listBase.addAll(iterable); |
133 } | 137 } |
134 | 138 |
135 Map<int, E> asMap() => _listBase.asMap(); | 139 Map<int, E> asMap() => _listBase.asMap(); |
136 | 140 |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
420 * the elements of [other]. | 424 * the elements of [other]. |
421 * | 425 * |
422 * Note that the returned set will use the default equality operation, which | 426 * Note that the returned set will use the default equality operation, which |
423 * may be different than the equality operation [this] uses. | 427 * may be different than the equality operation [this] uses. |
424 */ | 428 */ |
425 Set<E> union(Set<E> other) => toSet()..addAll(other); | 429 Set<E> union(Set<E> other) => toSet()..addAll(other); |
426 } | 430 } |
427 | 431 |
428 /** | 432 /** |
429 * Creates a modifiable [Set] view of the values of a [Map]. | 433 * Creates a modifiable [Set] view of the values of a [Map]. |
430 * | 434 * |
431 * The `Set` view assumes that the keys of the `Map` can be uniquely determined | 435 * The `Set` view assumes that the keys of the `Map` can be uniquely determined |
432 * from the values. The `keyForValue` function passed to the constructor finds | 436 * from the values. The `keyForValue` function passed to the constructor finds |
433 * the key for a single value. The `keyForValue` function should be consistent | 437 * the key for a single value. The `keyForValue` function should be consistent |
434 * with equality. If `value1 == value2` then `keyForValue(value1)` and | 438 * with equality. If `value1 == value2` then `keyForValue(value1)` and |
435 * `keyForValue(value2)` should be considered equal keys by the underlying map, | 439 * `keyForValue(value2)` should be considered equal keys by the underlying map, |
436 * and vice versa. | 440 * and vice versa. |
437 * | 441 * |
438 * Modifying the set will modify the underlying map based on the key returned by | 442 * Modifying the set will modify the underlying map based on the key returned by |
439 * `keyForValue`. | 443 * `keyForValue`. |
440 * | 444 * |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
560 * Returns a new set which contains all the elements of [this] and [other]. | 564 * Returns a new set which contains all the elements of [this] and [other]. |
561 * | 565 * |
562 * That is, the returned set contains all the elements of this [Set] and all | 566 * That is, the returned set contains all the elements of this [Set] and all |
563 * the elements of [other]. | 567 * the elements of [other]. |
564 * | 568 * |
565 * Note that the returned set will use the default equality operation, which | 569 * Note that the returned set will use the default equality operation, which |
566 * may be different than the equality operation [this] uses. | 570 * may be different than the equality operation [this] uses. |
567 */ | 571 */ |
568 Set<V> union(Set<V> other) => toSet()..addAll(other); | 572 Set<V> union(Set<V> other) => toSet()..addAll(other); |
569 } | 573 } |
OLD | NEW |