OLD | NEW |
1 // -- start List<$E> mixins. | 1 // -- start List<$E> mixins. |
2 // $E is the element type. | 2 // $E is the element type. |
3 | 3 |
4 // From Iterable<$E>: | 4 // From Iterable<$E>: |
5 | 5 |
6 Iterator<$E> get iterator { | 6 Iterator<$E> get iterator { |
7 // Note: NodeLists are not fixed size. And most probably length shouldn't | 7 // Note: NodeLists are not fixed size. And most probably length shouldn't |
8 // be cached in both iterator _and_ forEach method. For now caching it | 8 // be cached in both iterator _and_ forEach method. For now caching it |
9 // for consistency. | 9 // for consistency. |
10 return new FixedSizeListIterator<$E>(this); | 10 return new FixedSizeListIterator<$E>(this); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 void set length(int value) { | 88 void set length(int value) { |
89 throw new UnsupportedError("Cannot resize immutable List."); | 89 throw new UnsupportedError("Cannot resize immutable List."); |
90 } | 90 } |
91 $endif | 91 $endif |
92 | 92 |
93 $if DEFINE_CLEAR | 93 $if DEFINE_CLEAR |
94 void clear() { | 94 void clear() { |
95 throw new UnsupportedError("Cannot clear immutable List."); | 95 throw new UnsupportedError("Cannot clear immutable List."); |
96 } | 96 } |
97 $else | 97 $else |
98 // contains() defined by IDL. | 98 // clear() defined by IDL. |
99 $endif | 99 $endif |
100 | 100 |
101 void sort([int compare($E a, $E b)]) { | 101 void sort([int compare($E a, $E b)]) { |
102 throw new UnsupportedError("Cannot sort immutable List."); | 102 throw new UnsupportedError("Cannot sort immutable List."); |
103 } | 103 } |
104 | 104 |
105 int indexOf($E element, [int start = 0]) => | 105 int indexOf($E element, [int start = 0]) => |
106 Lists.indexOf(this, element, start, this.length); | 106 Lists.indexOf(this, element, start, this.length); |
107 | 107 |
108 int lastIndexOf($E element, [int start]) { | 108 int lastIndexOf($E element, [int start]) { |
(...skipping 15 matching lines...) Expand all Loading... |
124 if (length == 1) return this[0]; | 124 if (length == 1) return this[0]; |
125 if (length == 0) throw new StateError("No elements"); | 125 if (length == 0) throw new StateError("No elements"); |
126 throw new StateError("More than one element"); | 126 throw new StateError("More than one element"); |
127 } | 127 } |
128 | 128 |
129 $E min([int compare($E a, $E b)]) => IterableMixinWorkaround.min(this, compare
); | 129 $E min([int compare($E a, $E b)]) => IterableMixinWorkaround.min(this, compare
); |
130 | 130 |
131 $E max([int compare($E a, $E b)]) => IterableMixinWorkaround.max(this, compare
); | 131 $E max([int compare($E a, $E b)]) => IterableMixinWorkaround.max(this, compare
); |
132 | 132 |
133 $E removeAt(int pos) { | 133 $E removeAt(int pos) { |
134 throw new UnsupportedError("Cannot removeAt on immutable List."); | 134 throw new UnsupportedError("Cannot remove from immutable List."); |
135 } | 135 } |
136 | 136 |
137 $E removeLast() { | 137 $E removeLast() { |
138 throw new UnsupportedError("Cannot removeLast on immutable List."); | 138 throw new UnsupportedError("Cannot remove from immutable List."); |
| 139 } |
| 140 |
| 141 void remove(Object object) { |
| 142 throw new UnsupportedError("Cannot remove from immutable List."); |
| 143 } |
| 144 |
| 145 void removeAll(Iterable elements) { |
| 146 throw new UnsupportedError("Cannot remove from immutable List."); |
| 147 } |
| 148 |
| 149 void retainAll(Iterable elements) { |
| 150 throw new UnsupportedError("Cannot remove from immutable List."); |
| 151 } |
| 152 |
| 153 void removeMatching(bool test($E element)) { |
| 154 throw new UnsupportedError("Cannot remove from immutable List."); |
| 155 } |
| 156 |
| 157 void retainMatching(bool test($E element)) { |
| 158 throw new UnsupportedError("Cannot remove from immutable List."); |
139 } | 159 } |
140 | 160 |
141 void setRange(int start, int rangeLength, List<$E> from, [int startFrom]) { | 161 void setRange(int start, int rangeLength, List<$E> from, [int startFrom]) { |
142 throw new UnsupportedError("Cannot setRange on immutable List."); | 162 throw new UnsupportedError("Cannot setRange on immutable List."); |
143 } | 163 } |
144 | 164 |
145 void removeRange(int start, int rangeLength) { | 165 void removeRange(int start, int rangeLength) { |
146 throw new UnsupportedError("Cannot removeRange on immutable List."); | 166 throw new UnsupportedError("Cannot removeRange on immutable List."); |
147 } | 167 } |
148 | 168 |
149 void insertRange(int start, int rangeLength, [$E initialValue]) { | 169 void insertRange(int start, int rangeLength, [$E initialValue]) { |
150 throw new UnsupportedError("Cannot insertRange on immutable List."); | 170 throw new UnsupportedError("Cannot insertRange on immutable List."); |
151 } | 171 } |
152 | 172 |
153 List<$E> getRange(int start, int rangeLength) => | 173 List<$E> getRange(int start, int rangeLength) => |
154 Lists.getRange(this, start, rangeLength, <$E>[]); | 174 Lists.getRange(this, start, rangeLength, <$E>[]); |
155 | 175 |
156 // -- end List<$E> mixins. | 176 // -- end List<$E> mixins. |
OLD | NEW |