| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 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. |
| 4 |
| 5 part of dart.dom.html; |
| 6 |
| 7 abstract class ImmutableListMixin<E> implements List<E> { |
| 8 // From Iterable<$E>: |
| 9 Iterator<E> get iterator { |
| 10 // Note: NodeLists are not fixed size. And most probably length shouldn't |
| 11 // be cached in both iterator _and_ forEach method. For now caching it |
| 12 // for consistency. |
| 13 return new FixedSizeListIterator<E>(this); |
| 14 } |
| 15 |
| 16 // From Collection<E>: |
| 17 void add(E value) { |
| 18 throw new UnsupportedError("Cannot add to immutable List."); |
| 19 } |
| 20 |
| 21 void addAll(Iterable<E> iterable) { |
| 22 throw new UnsupportedError("Cannot add to immutable List."); |
| 23 } |
| 24 |
| 25 // From List<E>: |
| 26 void sort([int compare(E a, E b)]) { |
| 27 throw new UnsupportedError("Cannot sort immutable List."); |
| 28 } |
| 29 |
| 30 void insert(int index, E element) { |
| 31 throw new UnsupportedError("Cannot add to immutable List."); |
| 32 } |
| 33 |
| 34 void insertAll(int index, Iterable<E> iterable) { |
| 35 throw new UnsupportedError("Cannot add to immutable List."); |
| 36 } |
| 37 |
| 38 void setAll(int index, Iterable<E> iterable) { |
| 39 throw new UnsupportedError("Cannot modify an immutable List."); |
| 40 } |
| 41 |
| 42 E removeAt(int pos) { |
| 43 throw new UnsupportedError("Cannot remove from immutable List."); |
| 44 } |
| 45 |
| 46 E removeLast() { |
| 47 throw new UnsupportedError("Cannot remove from immutable List."); |
| 48 } |
| 49 |
| 50 void remove(Object object) { |
| 51 throw new UnsupportedError("Cannot remove from immutable List."); |
| 52 } |
| 53 |
| 54 void removeWhere(bool test(E element)) { |
| 55 throw new UnsupportedError("Cannot remove from immutable List."); |
| 56 } |
| 57 |
| 58 void retainWhere(bool test(E element)) { |
| 59 throw new UnsupportedError("Cannot remove from immutable List."); |
| 60 } |
| 61 |
| 62 void setRange(int start, int end, Iterable<E> iterable, [int skipCount]) { |
| 63 throw new UnsupportedError("Cannot setRange on immutable List."); |
| 64 } |
| 65 |
| 66 void removeRange(int start, int end) { |
| 67 throw new UnsupportedError("Cannot removeRange on immutable List."); |
| 68 } |
| 69 |
| 70 void replaceRange(int start, int end, Iterable<E> iterable) { |
| 71 throw new UnsupportedError("Cannot modify an immutable List."); |
| 72 } |
| 73 |
| 74 void fillRange(int start, int end, [E fillValue]) { |
| 75 throw new UnsupportedError("Cannot modify an immutable List."); |
| 76 } |
| 77 } |
| OLD | NEW |