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 part of dart._collection.dev; | 5 part of dart._collection.dev; |
6 | 6 |
7 /** | 7 /** |
8 * Mixin that throws on the length changing operations of [List]. | 8 * Mixin that throws on the length changing operations of [List]. |
9 * | 9 * |
10 * Intended to mix-in on top of [ListMixin] for fixed-length lists. | 10 * Intended to mix-in on top of [ListMixin] for fixed-length lists. |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 E removeAt(int index) { | 63 E removeAt(int index) { |
64 throw new UnsupportedError( | 64 throw new UnsupportedError( |
65 "Cannot remove from a fixed-length list"); | 65 "Cannot remove from a fixed-length list"); |
66 } | 66 } |
67 | 67 |
68 E removeLast() { | 68 E removeLast() { |
69 throw new UnsupportedError( | 69 throw new UnsupportedError( |
70 "Cannot remove from a fixed-length list"); | 70 "Cannot remove from a fixed-length list"); |
71 } | 71 } |
72 | 72 |
73 void removeRange(int start, int length) { | 73 void removeRange(int start, int end) { |
74 throw new UnsupportedError( | 74 throw new UnsupportedError( |
75 "Cannot remove from a fixed-length list"); | 75 "Cannot remove from a fixed-length list"); |
76 } | 76 } |
77 | |
78 void insertRange(int start, int length, [E initialValue]) { | |
79 throw new UnsupportedError( | |
80 "Cannot insert range in a fixed-length list"); | |
81 } | |
82 } | 77 } |
83 | 78 |
84 /** | 79 /** |
85 * Mixin for an unmodifiable [List] class. | 80 * Mixin for an unmodifiable [List] class. |
86 * | 81 * |
87 * This overrides all mutating methods with methods that throw. | 82 * This overrides all mutating methods with methods that throw. |
88 * This mixin is intended to be mixed in on top of [ListMixin] on | 83 * This mixin is intended to be mixed in on top of [ListMixin] on |
89 * unmodifiable lists. | 84 * unmodifiable lists. |
90 */ | 85 */ |
91 abstract class UnmodifiableListMixin<E> { | 86 abstract class UnmodifiableListMixin<E> { |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 E removeLast() { | 153 E removeLast() { |
159 throw new UnsupportedError( | 154 throw new UnsupportedError( |
160 "Cannot remove from an unmodifiable list"); | 155 "Cannot remove from an unmodifiable list"); |
161 } | 156 } |
162 | 157 |
163 void setRange(int start, int end, Iterable<E> iterable, [int skipCount = 0]) { | 158 void setRange(int start, int end, Iterable<E> iterable, [int skipCount = 0]) { |
164 throw new UnsupportedError( | 159 throw new UnsupportedError( |
165 "Cannot modify an unmodifiable list"); | 160 "Cannot modify an unmodifiable list"); |
166 } | 161 } |
167 | 162 |
168 void removeRange(int start, int length) { | 163 void removeRange(int start, int end) { |
169 throw new UnsupportedError( | 164 throw new UnsupportedError( |
170 "Cannot remove from an unmodifiable list"); | 165 "Cannot remove from an unmodifiable list"); |
171 } | 166 } |
172 | |
173 void insertRange(int start, int length, [E initialValue]) { | |
174 throw new UnsupportedError( | |
175 "Cannot insert range in an unmodifiable list"); | |
176 } | |
177 } | 167 } |
178 | 168 |
179 /** | 169 /** |
180 * Abstract implementation of a fixed-length list. | 170 * Abstract implementation of a fixed-length list. |
181 * | 171 * |
182 * All operations are defined in terms of `length`, `operator[]` and | 172 * All operations are defined in terms of `length`, `operator[]` and |
183 * `operator[]=`, which need to be implemented. | 173 * `operator[]=`, which need to be implemented. |
184 */ | 174 */ |
185 typedef FixedLengthListBase<E> = ListBase<E> with FixedLengthListMixin<E>; | 175 typedef FixedLengthListBase<E> = ListBase<E> with FixedLengthListMixin<E>; |
186 | 176 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 } | 239 } |
250 | 240 |
251 class ReversedListIterable<E> extends ListIterable<E> { | 241 class ReversedListIterable<E> extends ListIterable<E> { |
252 Iterable<E> _source; | 242 Iterable<E> _source; |
253 ReversedListIterable(this._source); | 243 ReversedListIterable(this._source); |
254 | 244 |
255 int get length => _source.length; | 245 int get length => _source.length; |
256 | 246 |
257 E elementAt(int index) => _source.elementAt(_source.length - 1 - index); | 247 E elementAt(int index) => _source.elementAt(_source.length - 1 - index); |
258 } | 248 } |
OLD | NEW |