| 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._internal; | 5 part of dart._internal; |
| 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. |
| 11 */ | 11 */ |
| 12 abstract class FixedLengthListMixin<E> { | 12 abstract class FixedLengthListMixin<E> { |
| 13 /** This operation is not supported by a fixed length list. */ | 13 /** This operation is not supported by a fixed length list. */ |
| 14 set length(int newLength) { | 14 set length(int newLength) { |
| 15 throw new UnsupportedError( | 15 throw new UnsupportedError( |
| 16 "Cannot change the length of a fixed-length list"); | 16 "Cannot change the length of a fixed-length list"); |
| 17 } | 17 } |
| 18 | 18 |
| 19 /** This operation is not supported by a fixed length list. */ | 19 /** This operation is not supported by a fixed length list. */ |
| 20 void add(E value) { | 20 void add(E value) { |
| 21 throw new UnsupportedError( | 21 throw new UnsupportedError("Cannot add to a fixed-length list"); |
| 22 "Cannot add to a fixed-length list"); | |
| 23 } | 22 } |
| 24 | 23 |
| 25 /** This operation is not supported by a fixed length list. */ | 24 /** This operation is not supported by a fixed length list. */ |
| 26 void insert(int index, E value) { | 25 void insert(int index, E value) { |
| 27 throw new UnsupportedError( | 26 throw new UnsupportedError("Cannot add to a fixed-length list"); |
| 28 "Cannot add to a fixed-length list"); | |
| 29 } | 27 } |
| 30 | 28 |
| 31 /** This operation is not supported by a fixed length list. */ | 29 /** This operation is not supported by a fixed length list. */ |
| 32 void insertAll(int at, Iterable<E> iterable) { | 30 void insertAll(int at, Iterable<E> iterable) { |
| 33 throw new UnsupportedError( | 31 throw new UnsupportedError("Cannot add to a fixed-length list"); |
| 34 "Cannot add to a fixed-length list"); | |
| 35 } | 32 } |
| 36 | 33 |
| 37 /** This operation is not supported by a fixed length list. */ | 34 /** This operation is not supported by a fixed length list. */ |
| 38 void addAll(Iterable<E> iterable) { | 35 void addAll(Iterable<E> iterable) { |
| 39 throw new UnsupportedError( | 36 throw new UnsupportedError("Cannot add to a fixed-length list"); |
| 40 "Cannot add to a fixed-length list"); | |
| 41 } | 37 } |
| 42 | 38 |
| 43 /** This operation is not supported by a fixed length list. */ | 39 /** This operation is not supported by a fixed length list. */ |
| 44 bool remove(Object element) { | 40 bool remove(Object element) { |
| 45 throw new UnsupportedError( | 41 throw new UnsupportedError("Cannot remove from a fixed-length list"); |
| 46 "Cannot remove from a fixed-length list"); | |
| 47 } | 42 } |
| 48 | 43 |
| 49 /** This operation is not supported by a fixed length list. */ | 44 /** This operation is not supported by a fixed length list. */ |
| 50 void removeWhere(bool test(E element)) { | 45 void removeWhere(bool test(E element)) { |
| 51 throw new UnsupportedError( | 46 throw new UnsupportedError("Cannot remove from a fixed-length list"); |
| 52 "Cannot remove from a fixed-length list"); | |
| 53 } | 47 } |
| 54 | 48 |
| 55 /** This operation is not supported by a fixed length list. */ | 49 /** This operation is not supported by a fixed length list. */ |
| 56 void retainWhere(bool test(E element)) { | 50 void retainWhere(bool test(E element)) { |
| 57 throw new UnsupportedError( | 51 throw new UnsupportedError("Cannot remove from a fixed-length list"); |
| 58 "Cannot remove from a fixed-length list"); | |
| 59 } | 52 } |
| 60 | 53 |
| 61 /** This operation is not supported by a fixed length list. */ | 54 /** This operation is not supported by a fixed length list. */ |
| 62 void clear() { | 55 void clear() { |
| 63 throw new UnsupportedError( | 56 throw new UnsupportedError("Cannot clear a fixed-length list"); |
| 64 "Cannot clear a fixed-length list"); | |
| 65 } | 57 } |
| 66 | 58 |
| 67 /** This operation is not supported by a fixed length list. */ | 59 /** This operation is not supported by a fixed length list. */ |
| 68 E removeAt(int index) { | 60 E removeAt(int index) { |
| 69 throw new UnsupportedError( | 61 throw new UnsupportedError("Cannot remove from a fixed-length list"); |
| 70 "Cannot remove from a fixed-length list"); | |
| 71 } | 62 } |
| 72 | 63 |
| 73 /** This operation is not supported by a fixed length list. */ | 64 /** This operation is not supported by a fixed length list. */ |
| 74 E removeLast() { | 65 E removeLast() { |
| 75 throw new UnsupportedError( | 66 throw new UnsupportedError("Cannot remove from a fixed-length list"); |
| 76 "Cannot remove from a fixed-length list"); | |
| 77 } | 67 } |
| 78 | 68 |
| 79 /** This operation is not supported by a fixed length list. */ | 69 /** This operation is not supported by a fixed length list. */ |
| 80 void removeRange(int start, int end) { | 70 void removeRange(int start, int end) { |
| 81 throw new UnsupportedError( | 71 throw new UnsupportedError("Cannot remove from a fixed-length list"); |
| 82 "Cannot remove from a fixed-length list"); | |
| 83 } | 72 } |
| 84 | 73 |
| 85 /** This operation is not supported by a fixed length list. */ | 74 /** This operation is not supported by a fixed length list. */ |
| 86 void replaceRange(int start, int end, Iterable<E> iterable) { | 75 void replaceRange(int start, int end, Iterable<E> iterable) { |
| 87 throw new UnsupportedError( | 76 throw new UnsupportedError("Cannot remove from a fixed-length list"); |
| 88 "Cannot remove from a fixed-length list"); | |
| 89 } | 77 } |
| 90 } | 78 } |
| 91 | 79 |
| 92 /** | 80 /** |
| 93 * Mixin for an unmodifiable [List] class. | 81 * Mixin for an unmodifiable [List] class. |
| 94 * | 82 * |
| 95 * This overrides all mutating methods with methods that throw. | 83 * This overrides all mutating methods with methods that throw. |
| 96 * This mixin is intended to be mixed in on top of [ListMixin] on | 84 * This mixin is intended to be mixed in on top of [ListMixin] on |
| 97 * unmodifiable lists. | 85 * unmodifiable lists. |
| 98 */ | 86 */ |
| 99 abstract class UnmodifiableListMixin<E> implements List<E> { | 87 abstract class UnmodifiableListMixin<E> implements List<E> { |
| 100 | |
| 101 /** This operation is not supported by an unmodifiable list. */ | 88 /** This operation is not supported by an unmodifiable list. */ |
| 102 void operator []=(int index, E value) { | 89 void operator []=(int index, E value) { |
| 103 throw new UnsupportedError( | 90 throw new UnsupportedError("Cannot modify an unmodifiable list"); |
| 104 "Cannot modify an unmodifiable list"); | |
| 105 } | 91 } |
| 106 | 92 |
| 107 /** This operation is not supported by an unmodifiable list. */ | 93 /** This operation is not supported by an unmodifiable list. */ |
| 108 set length(int newLength) { | 94 set length(int newLength) { |
| 109 throw new UnsupportedError( | 95 throw new UnsupportedError( |
| 110 "Cannot change the length of an unmodifiable list"); | 96 "Cannot change the length of an unmodifiable list"); |
| 111 } | 97 } |
| 112 | 98 |
| 113 /** This operation is not supported by an unmodifiable list. */ | 99 /** This operation is not supported by an unmodifiable list. */ |
| 114 void setAll(int at, Iterable<E> iterable) { | 100 void setAll(int at, Iterable<E> iterable) { |
| 115 throw new UnsupportedError( | 101 throw new UnsupportedError("Cannot modify an unmodifiable list"); |
| 116 "Cannot modify an unmodifiable list"); | |
| 117 } | 102 } |
| 118 | 103 |
| 119 /** This operation is not supported by an unmodifiable list. */ | 104 /** This operation is not supported by an unmodifiable list. */ |
| 120 void add(E value) { | 105 void add(E value) { |
| 121 throw new UnsupportedError( | 106 throw new UnsupportedError("Cannot add to an unmodifiable list"); |
| 122 "Cannot add to an unmodifiable list"); | |
| 123 } | 107 } |
| 124 | 108 |
| 125 /** This operation is not supported by an unmodifiable list. */ | 109 /** This operation is not supported by an unmodifiable list. */ |
| 126 void insert(int index, E element) { | 110 void insert(int index, E element) { |
| 127 throw new UnsupportedError( | 111 throw new UnsupportedError("Cannot add to an unmodifiable list"); |
| 128 "Cannot add to an unmodifiable list"); | |
| 129 } | 112 } |
| 130 | 113 |
| 131 /** This operation is not supported by an unmodifiable list. */ | 114 /** This operation is not supported by an unmodifiable list. */ |
| 132 void insertAll(int at, Iterable<E> iterable) { | 115 void insertAll(int at, Iterable<E> iterable) { |
| 133 throw new UnsupportedError( | 116 throw new UnsupportedError("Cannot add to an unmodifiable list"); |
| 134 "Cannot add to an unmodifiable list"); | |
| 135 } | 117 } |
| 136 | 118 |
| 137 /** This operation is not supported by an unmodifiable list. */ | 119 /** This operation is not supported by an unmodifiable list. */ |
| 138 void addAll(Iterable<E> iterable) { | 120 void addAll(Iterable<E> iterable) { |
| 139 throw new UnsupportedError( | 121 throw new UnsupportedError("Cannot add to an unmodifiable list"); |
| 140 "Cannot add to an unmodifiable list"); | |
| 141 } | 122 } |
| 142 | 123 |
| 143 /** This operation is not supported by an unmodifiable list. */ | 124 /** This operation is not supported by an unmodifiable list. */ |
| 144 bool remove(Object element) { | 125 bool remove(Object element) { |
| 145 throw new UnsupportedError( | 126 throw new UnsupportedError("Cannot remove from an unmodifiable list"); |
| 146 "Cannot remove from an unmodifiable list"); | |
| 147 } | 127 } |
| 148 | 128 |
| 149 /** This operation is not supported by an unmodifiable list. */ | 129 /** This operation is not supported by an unmodifiable list. */ |
| 150 void removeWhere(bool test(E element)) { | 130 void removeWhere(bool test(E element)) { |
| 151 throw new UnsupportedError( | 131 throw new UnsupportedError("Cannot remove from an unmodifiable list"); |
| 152 "Cannot remove from an unmodifiable list"); | |
| 153 } | 132 } |
| 154 | 133 |
| 155 /** This operation is not supported by an unmodifiable list. */ | 134 /** This operation is not supported by an unmodifiable list. */ |
| 156 void retainWhere(bool test(E element)) { | 135 void retainWhere(bool test(E element)) { |
| 157 throw new UnsupportedError( | 136 throw new UnsupportedError("Cannot remove from an unmodifiable list"); |
| 158 "Cannot remove from an unmodifiable list"); | |
| 159 } | 137 } |
| 160 | 138 |
| 161 /** This operation is not supported by an unmodifiable list. */ | 139 /** This operation is not supported by an unmodifiable list. */ |
| 162 void sort([Comparator<E> compare]) { | 140 void sort([Comparator<E> compare]) { |
| 163 throw new UnsupportedError( | 141 throw new UnsupportedError("Cannot modify an unmodifiable list"); |
| 164 "Cannot modify an unmodifiable list"); | |
| 165 } | 142 } |
| 166 | 143 |
| 167 /** This operation is not supported by an unmodifiable list. */ | 144 /** This operation is not supported by an unmodifiable list. */ |
| 168 void shuffle([Random random]) { | 145 void shuffle([Random random]) { |
| 169 throw new UnsupportedError( | 146 throw new UnsupportedError("Cannot modify an unmodifiable list"); |
| 170 "Cannot modify an unmodifiable list"); | |
| 171 } | 147 } |
| 172 | 148 |
| 173 /** This operation is not supported by an unmodifiable list. */ | 149 /** This operation is not supported by an unmodifiable list. */ |
| 174 void clear() { | 150 void clear() { |
| 175 throw new UnsupportedError( | 151 throw new UnsupportedError("Cannot clear an unmodifiable list"); |
| 176 "Cannot clear an unmodifiable list"); | |
| 177 } | 152 } |
| 178 | 153 |
| 179 /** This operation is not supported by an unmodifiable list. */ | 154 /** This operation is not supported by an unmodifiable list. */ |
| 180 E removeAt(int index) { | 155 E removeAt(int index) { |
| 181 throw new UnsupportedError( | 156 throw new UnsupportedError("Cannot remove from an unmodifiable list"); |
| 182 "Cannot remove from an unmodifiable list"); | |
| 183 } | 157 } |
| 184 | 158 |
| 185 /** This operation is not supported by an unmodifiable list. */ | 159 /** This operation is not supported by an unmodifiable list. */ |
| 186 E removeLast() { | 160 E removeLast() { |
| 187 throw new UnsupportedError( | 161 throw new UnsupportedError("Cannot remove from an unmodifiable list"); |
| 188 "Cannot remove from an unmodifiable list"); | |
| 189 } | 162 } |
| 190 | 163 |
| 191 /** This operation is not supported by an unmodifiable list. */ | 164 /** This operation is not supported by an unmodifiable list. */ |
| 192 void setRange(int start, int end, Iterable<E> iterable, [int skipCount = 0]) { | 165 void setRange(int start, int end, Iterable<E> iterable, [int skipCount = 0]) { |
| 193 throw new UnsupportedError( | 166 throw new UnsupportedError("Cannot modify an unmodifiable list"); |
| 194 "Cannot modify an unmodifiable list"); | |
| 195 } | 167 } |
| 196 | 168 |
| 197 /** This operation is not supported by an unmodifiable list. */ | 169 /** This operation is not supported by an unmodifiable list. */ |
| 198 void removeRange(int start, int end) { | 170 void removeRange(int start, int end) { |
| 199 throw new UnsupportedError( | 171 throw new UnsupportedError("Cannot remove from an unmodifiable list"); |
| 200 "Cannot remove from an unmodifiable list"); | |
| 201 } | 172 } |
| 202 | 173 |
| 203 /** This operation is not supported by an unmodifiable list. */ | 174 /** This operation is not supported by an unmodifiable list. */ |
| 204 void replaceRange(int start, int end, Iterable<E> iterable) { | 175 void replaceRange(int start, int end, Iterable<E> iterable) { |
| 205 throw new UnsupportedError( | 176 throw new UnsupportedError("Cannot remove from an unmodifiable list"); |
| 206 "Cannot remove from an unmodifiable list"); | |
| 207 } | 177 } |
| 208 | 178 |
| 209 /** This operation is not supported by an unmodifiable list. */ | 179 /** This operation is not supported by an unmodifiable list. */ |
| 210 void fillRange(int start, int end, [E fillValue]) { | 180 void fillRange(int start, int end, [E fillValue]) { |
| 211 throw new UnsupportedError( | 181 throw new UnsupportedError("Cannot modify an unmodifiable list"); |
| 212 "Cannot modify an unmodifiable list"); | |
| 213 } | 182 } |
| 214 } | 183 } |
| 215 | 184 |
| 216 /** | 185 /** |
| 217 * Abstract implementation of a fixed-length list. | 186 * Abstract implementation of a fixed-length list. |
| 218 * | 187 * |
| 219 * All operations are defined in terms of `length`, `operator[]` and | 188 * All operations are defined in terms of `length`, `operator[]` and |
| 220 * `operator[]=`, which need to be implemented. | 189 * `operator[]=`, which need to be implemented. |
| 221 */ | 190 */ |
| 222 abstract class FixedLengthListBase<E> = | 191 abstract class FixedLengthListBase<E> = ListBase<E> |
| 223 ListBase<E> with FixedLengthListMixin<E>; | 192 with FixedLengthListMixin<E>; |
| 224 | 193 |
| 225 /** | 194 /** |
| 226 * Abstract implementation of an unmodifiable list. | 195 * Abstract implementation of an unmodifiable list. |
| 227 * | 196 * |
| 228 * All operations are defined in terms of `length` and `operator[]`, | 197 * All operations are defined in terms of `length` and `operator[]`, |
| 229 * which need to be implemented. | 198 * which need to be implemented. |
| 230 */ | 199 */ |
| 231 abstract class UnmodifiableListBase<E> = | 200 abstract class UnmodifiableListBase<E> = ListBase<E> |
| 232 ListBase<E> with UnmodifiableListMixin<E>; | 201 with UnmodifiableListMixin<E>; |
| 233 | 202 |
| 234 class _ListIndicesIterable extends ListIterable<int> { | 203 class _ListIndicesIterable extends ListIterable<int> { |
| 235 List _backedList; | 204 List _backedList; |
| 236 | 205 |
| 237 _ListIndicesIterable(this._backedList); | 206 _ListIndicesIterable(this._backedList); |
| 238 | 207 |
| 239 int get length => _backedList.length; | 208 int get length => _backedList.length; |
| 240 int elementAt(int index) { | 209 int elementAt(int index) { |
| 241 RangeError.checkValidIndex(index, this); | 210 RangeError.checkValidIndex(index, this); |
| 242 return index; | 211 return index; |
| 243 } | 212 } |
| 244 } | 213 } |
| 245 | 214 |
| 246 class ListMapView<E> implements Map<int, E> { | 215 class ListMapView<E> implements Map<int, E> { |
| 247 List<E> _values; | 216 List<E> _values; |
| 248 | 217 |
| 249 ListMapView(this._values); | 218 ListMapView(this._values); |
| 250 | 219 |
| 251 E operator[] (Object key) => containsKey(key) ? _values[key] : null; | 220 E operator [](Object key) => containsKey(key) ? _values[key] : null; |
| 252 int get length => _values.length; | 221 int get length => _values.length; |
| 253 | 222 |
| 254 Iterable<E> get values => new SubListIterable<E>(_values, 0, null); | 223 Iterable<E> get values => new SubListIterable<E>(_values, 0, null); |
| 255 Iterable<int> get keys => new _ListIndicesIterable(_values); | 224 Iterable<int> get keys => new _ListIndicesIterable(_values); |
| 256 | 225 |
| 257 bool get isEmpty => _values.isEmpty; | 226 bool get isEmpty => _values.isEmpty; |
| 258 bool get isNotEmpty => _values.isNotEmpty; | 227 bool get isNotEmpty => _values.isNotEmpty; |
| 259 bool containsValue(Object value) => _values.contains(value); | 228 bool containsValue(Object value) => _values.contains(value); |
| 260 bool containsKey(Object key) => key is int && key >= 0 && key < length; | 229 bool containsKey(Object key) => key is int && key >= 0 && key < length; |
| 261 | 230 |
| 262 void forEach(void f(int key, E value)) { | 231 void forEach(void f(int key, E value)) { |
| 263 int length = _values.length; | 232 int length = _values.length; |
| 264 for (int i = 0; i < length; i++) { | 233 for (int i = 0; i < length; i++) { |
| 265 f(i, _values[i]); | 234 f(i, _values[i]); |
| 266 if (length != _values.length) { | 235 if (length != _values.length) { |
| 267 throw new ConcurrentModificationError(_values); | 236 throw new ConcurrentModificationError(_values); |
| 268 } | 237 } |
| 269 } | 238 } |
| 270 } | 239 } |
| 271 | 240 |
| 272 /** This operation is not supported by an unmodifiable map. */ | 241 /** This operation is not supported by an unmodifiable map. */ |
| 273 void operator[]= (int key, E value) { | 242 void operator []=(int key, E value) { |
| 274 throw new UnsupportedError("Cannot modify an unmodifiable map"); | 243 throw new UnsupportedError("Cannot modify an unmodifiable map"); |
| 275 } | 244 } |
| 276 | 245 |
| 277 /** This operation is not supported by an unmodifiable map. */ | 246 /** This operation is not supported by an unmodifiable map. */ |
| 278 E putIfAbsent(int key, E ifAbsent()) { | 247 E putIfAbsent(int key, E ifAbsent()) { |
| 279 throw new UnsupportedError("Cannot modify an unmodifiable map"); | 248 throw new UnsupportedError("Cannot modify an unmodifiable map"); |
| 280 } | 249 } |
| 281 | 250 |
| 282 /** This operation is not supported by an unmodifiable map. */ | 251 /** This operation is not supported by an unmodifiable map. */ |
| 283 E remove(Object key) { | 252 E remove(Object key) { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 306 E elementAt(int index) => _source.elementAt(_source.length - 1 - index); | 275 E elementAt(int index) => _source.elementAt(_source.length - 1 - index); |
| 307 } | 276 } |
| 308 | 277 |
| 309 /** | 278 /** |
| 310 * Creates errors thrown by unmodifiable lists when they are attempted modified. | 279 * Creates errors thrown by unmodifiable lists when they are attempted modified. |
| 311 * | 280 * |
| 312 * This class creates [UnsupportedError]s with specialized messages. | 281 * This class creates [UnsupportedError]s with specialized messages. |
| 313 */ | 282 */ |
| 314 abstract class UnmodifiableListError { | 283 abstract class UnmodifiableListError { |
| 315 /** Error thrown when trying to add elements to an unmodifiable list. */ | 284 /** Error thrown when trying to add elements to an unmodifiable list. */ |
| 316 static UnsupportedError add() | 285 static UnsupportedError add() => |
| 317 => new UnsupportedError("Cannot add to unmodifiable List"); | 286 new UnsupportedError("Cannot add to unmodifiable List"); |
| 318 | 287 |
| 319 /** Error thrown when trying to add elements to an unmodifiable list. */ | 288 /** Error thrown when trying to add elements to an unmodifiable list. */ |
| 320 static UnsupportedError change() | 289 static UnsupportedError change() => |
| 321 => new UnsupportedError( | 290 new UnsupportedError("Cannot change the content of an unmodifiable List"); |
| 322 "Cannot change the content of an unmodifiable List"); | |
| 323 | 291 |
| 324 /** Error thrown when trying to change the length of an unmodifiable list. */ | 292 /** Error thrown when trying to change the length of an unmodifiable list. */ |
| 325 static UnsupportedError length() | 293 static UnsupportedError length() => |
| 326 => new UnsupportedError("Cannot change length of unmodifiable List"); | 294 new UnsupportedError("Cannot change length of unmodifiable List"); |
| 327 | 295 |
| 328 /** Error thrown when trying to remove elements from an unmodifiable list. */ | 296 /** Error thrown when trying to remove elements from an unmodifiable list. */ |
| 329 static UnsupportedError remove() | 297 static UnsupportedError remove() => |
| 330 => new UnsupportedError("Cannot remove from unmodifiable List"); | 298 new UnsupportedError("Cannot remove from unmodifiable List"); |
| 331 } | 299 } |
| 332 | 300 |
| 333 /** | 301 /** |
| 334 * Creates errors thrown by non-growable lists when they are attempted modified. | 302 * Creates errors thrown by non-growable lists when they are attempted modified. |
| 335 * | 303 * |
| 336 * This class creates [UnsupportedError]s with specialized messages. | 304 * This class creates [UnsupportedError]s with specialized messages. |
| 337 */ | 305 */ |
| 338 abstract class NonGrowableListError { | 306 abstract class NonGrowableListError { |
| 339 /** Error thrown when trying to add elements to an non-growable list. */ | 307 /** Error thrown when trying to add elements to an non-growable list. */ |
| 340 static UnsupportedError add() | 308 static UnsupportedError add() => |
| 341 => new UnsupportedError("Cannot add to non-growable List"); | 309 new UnsupportedError("Cannot add to non-growable List"); |
| 342 | 310 |
| 343 /** Error thrown when trying to change the length of an non-growable list. */ | 311 /** Error thrown when trying to change the length of an non-growable list. */ |
| 344 static UnsupportedError length() | 312 static UnsupportedError length() => |
| 345 => new UnsupportedError("Cannot change length of non-growable List"); | 313 new UnsupportedError("Cannot change length of non-growable List"); |
| 346 | 314 |
| 347 /** Error thrown when trying to remove elements from an non-growable list. */ | 315 /** Error thrown when trying to remove elements from an non-growable list. */ |
| 348 static UnsupportedError remove() | 316 static UnsupportedError remove() => |
| 349 => new UnsupportedError("Cannot remove from non-growable List"); | 317 new UnsupportedError("Cannot remove from non-growable List"); |
| 350 } | 318 } |
| 351 | 319 |
| 352 /** | 320 /** |
| 353 * Converts a growable list to a fixed length list with the same elements. | 321 * Converts a growable list to a fixed length list with the same elements. |
| 354 * | 322 * |
| 355 * For internal use only. | 323 * For internal use only. |
| 356 * Only works on growable lists as created by `[]` or `new List()`. | 324 * Only works on growable lists as created by `[]` or `new List()`. |
| 357 * May throw on any other list. | 325 * May throw on any other list. |
| 358 * | 326 * |
| 359 * The operation is efficient. It doesn't copy the elements, but converts | 327 * The operation is efficient. It doesn't copy the elements, but converts |
| (...skipping 23 matching lines...) Expand all Loading... |
| 383 * or as returned by [makeListFixedLength]. | 351 * or as returned by [makeListFixedLength]. |
| 384 * | 352 * |
| 385 * The operation is efficient. It doesn't copy the elements, but converts | 353 * The operation is efficient. It doesn't copy the elements, but converts |
| 386 * the existing list directly to a fixed length list. | 354 * the existing list directly to a fixed length list. |
| 387 * That means that it is a destructive conversion. | 355 * That means that it is a destructive conversion. |
| 388 * The original list should not be used afterwards. | 356 * The original list should not be used afterwards. |
| 389 * | 357 * |
| 390 * The unmodifiable list type is similar to the one used by const lists. | 358 * The unmodifiable list type is similar to the one used by const lists. |
| 391 */ | 359 */ |
| 392 external List makeFixedListUnmodifiable(List fixedLengthList); | 360 external List makeFixedListUnmodifiable(List fixedLengthList); |
| OLD | NEW |