OLD | NEW |
| (Empty) |
1 part of dart._internal; | |
2 abstract class FixedLengthListMixin<E> {void set length(int newLength) { | |
3 throw new UnsupportedError("Cannot change the length of a fixed-length list"); | |
4 } | |
5 void add(E value) { | |
6 throw new UnsupportedError("Cannot add to a fixed-length list"); | |
7 } | |
8 void insert(int index, E value) { | |
9 throw new UnsupportedError("Cannot add to a fixed-length list"); | |
10 } | |
11 void insertAll(int at, Iterable<E> iterable) { | |
12 throw new UnsupportedError("Cannot add to a fixed-length list"); | |
13 } | |
14 void addAll(Iterable<E> iterable) { | |
15 throw new UnsupportedError("Cannot add to a fixed-length list"); | |
16 } | |
17 bool remove(Object element) { | |
18 throw new UnsupportedError("Cannot remove from a fixed-length list"); | |
19 } | |
20 void removeWhere(bool test(E element)) { | |
21 throw new UnsupportedError("Cannot remove from a fixed-length list"); | |
22 } | |
23 void retainWhere(bool test(E element)) { | |
24 throw new UnsupportedError("Cannot remove from a fixed-length list"); | |
25 } | |
26 void clear() { | |
27 throw new UnsupportedError("Cannot clear a fixed-length list"); | |
28 } | |
29 E removeAt(int index) { | |
30 throw new UnsupportedError("Cannot remove from a fixed-length list"); | |
31 } | |
32 E removeLast() { | |
33 throw new UnsupportedError("Cannot remove from a fixed-length list"); | |
34 } | |
35 void removeRange(int start, int end) { | |
36 throw new UnsupportedError("Cannot remove from a fixed-length list"); | |
37 } | |
38 void replaceRange(int start, int end, Iterable<E> iterable) { | |
39 throw new UnsupportedError("Cannot remove from a fixed-length list"); | |
40 } | |
41 } | |
42 abstract class UnmodifiableListMixin<E> implements List<E> {void operator []=(i
nt index, E value) { | |
43 throw new UnsupportedError("Cannot modify an unmodifiable list"); | |
44 } | |
45 void set length(int newLength) { | |
46 throw new UnsupportedError("Cannot change the length of an unmodifiable list"); | |
47 } | |
48 void setAll(int at, Iterable<E> iterable) { | |
49 throw new UnsupportedError("Cannot modify an unmodifiable list"); | |
50 } | |
51 void add(E value) { | |
52 throw new UnsupportedError("Cannot add to an unmodifiable list"); | |
53 } | |
54 E insert(int index, E value) { | |
55 throw new UnsupportedError("Cannot add to an unmodifiable list"); | |
56 } | |
57 void insertAll(int at, Iterable<E> iterable) { | |
58 throw new UnsupportedError("Cannot add to an unmodifiable list"); | |
59 } | |
60 void addAll(Iterable<E> iterable) { | |
61 throw new UnsupportedError("Cannot add to an unmodifiable list"); | |
62 } | |
63 bool remove(Object element) { | |
64 throw new UnsupportedError("Cannot remove from an unmodifiable list"); | |
65 } | |
66 void removeWhere(bool test(E element)) { | |
67 throw new UnsupportedError("Cannot remove from an unmodifiable list"); | |
68 } | |
69 void retainWhere(bool test(E element)) { | |
70 throw new UnsupportedError("Cannot remove from an unmodifiable list"); | |
71 } | |
72 void sort([Comparator<E> compare]) { | |
73 throw new UnsupportedError("Cannot modify an unmodifiable list"); | |
74 } | |
75 void shuffle([Random random]) { | |
76 throw new UnsupportedError("Cannot modify an unmodifiable list"); | |
77 } | |
78 void clear() { | |
79 throw new UnsupportedError("Cannot clear an unmodifiable list"); | |
80 } | |
81 E removeAt(int index) { | |
82 throw new UnsupportedError("Cannot remove from an unmodifiable list"); | |
83 } | |
84 E removeLast() { | |
85 throw new UnsupportedError("Cannot remove from an unmodifiable list"); | |
86 } | |
87 void setRange(int start, int end, Iterable<E> iterable, [int skipCount = 0]) { | |
88 throw new UnsupportedError("Cannot modify an unmodifiable list"); | |
89 } | |
90 void removeRange(int start, int end) { | |
91 throw new UnsupportedError("Cannot remove from an unmodifiable list"); | |
92 } | |
93 void replaceRange(int start, int end, Iterable<E> iterable) { | |
94 throw new UnsupportedError("Cannot remove from an unmodifiable list"); | |
95 } | |
96 void fillRange(int start, int end, [E fillValue]) { | |
97 throw new UnsupportedError("Cannot modify an unmodifiable list"); | |
98 } | |
99 } | |
100 abstract class FixedLengthListBase<E> = ListBase<E> with FixedLengthListMixin<E
>; | |
101 abstract class UnmodifiableListBase<E> = ListBase<E> with UnmodifiableListMixin
<E>; | |
102 class _ListIndicesIterable extends ListIterable<int> {List _backedList; | |
103 _ListIndicesIterable(this._backedList); | |
104 int get length => _backedList.length; | |
105 int elementAt(int index) { | |
106 RangeError.checkValidIndex(index, this); | |
107 return index; | |
108 } | |
109 } | |
110 class ListMapView<E> implements Map<int, E> {List<E> _values; | |
111 ListMapView(this._values); | |
112 E operator [](Object key) => containsKey(key) ? _values[DEVC$RT.cast(key, Objec
t, int, "ImplicitCast", """line 251, column 59 of dart:_internal/list.dart: """,
key is int, true)] : null; | |
113 int get length => _values.length; | |
114 Iterable<E> get values => new SubListIterable<E>(_values, 0, null); | |
115 Iterable<int> get keys => new _ListIndicesIterable(_values); | |
116 bool get isEmpty => _values.isEmpty; | |
117 bool get isNotEmpty => _values.isNotEmpty; | |
118 bool containsValue(Object value) => _values.contains(value); | |
119 bool containsKey(Object key) => key is int && key >= 0 && key < length; | |
120 void forEach(void f(int key, E value)) { | |
121 int length = _values.length; | |
122 for (int i = 0; i < length; i++) { | |
123 f(i, _values[i]); | |
124 if (length != _values.length) { | |
125 throw new ConcurrentModificationError(_values); | |
126 } | |
127 } | |
128 } | |
129 void operator []=(int key, E value) { | |
130 throw new UnsupportedError("Cannot modify an unmodifiable map"); | |
131 } | |
132 E putIfAbsent(int key, E ifAbsent()) { | |
133 throw new UnsupportedError("Cannot modify an unmodifiable map"); | |
134 } | |
135 E remove(Object key) { | |
136 throw new UnsupportedError("Cannot modify an unmodifiable map"); | |
137 } | |
138 void clear() { | |
139 throw new UnsupportedError("Cannot modify an unmodifiable map"); | |
140 } | |
141 void addAll(Map<int, E> other) { | |
142 throw new UnsupportedError("Cannot modify an unmodifiable map"); | |
143 } | |
144 String toString() => Maps.mapToString(this); | |
145 } | |
146 class ReversedListIterable<E> extends ListIterable<E> {Iterable<E> _source; | |
147 ReversedListIterable(this._source); | |
148 int get length => _source.length; | |
149 E elementAt(int index) => _source.elementAt(_source.length - 1 - index); | |
150 } | |
151 abstract class UnmodifiableListError {static UnsupportedError add() => new Unsu
pportedError("Cannot add to unmodifiable List"); | |
152 static UnsupportedError change() => new UnsupportedError("Cannot change the con
tent of an unmodifiable List"); | |
153 static UnsupportedError length() => new UnsupportedError("Cannot change length
of unmodifiable List"); | |
154 static UnsupportedError remove() => new UnsupportedError("Cannot remove from un
modifiable List"); | |
155 } | |
156 abstract class NonGrowableListError {static UnsupportedError add() => new Unsup
portedError("Cannot add to non-growable List"); | |
157 static UnsupportedError length() => new UnsupportedError("Cannot change length
of non-growable List"); | |
158 static UnsupportedError remove() => new UnsupportedError("Cannot remove from no
n-growable List"); | |
159 } | |
160 external List makeListFixedLength(List growableList) ; | |
OLD | NEW |