Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(201)

Side by Side Diff: tools/dom/templates/immutable_list_mixin.darttemplate

Issue 14175013: Add setAll, insertAll, replaceRange and fillRange. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 $E get single { 136 $E get single {
137 if (length == 1) return this[0]; 137 if (length == 1) return this[0];
138 if (length == 0) throw new StateError("No elements"); 138 if (length == 0) throw new StateError("No elements");
139 throw new StateError("More than one element"); 139 throw new StateError("More than one element");
140 } 140 }
141 141
142 void insert(int index, $E element) { 142 void insert(int index, $E element) {
143 throw new UnsupportedError("Cannot add to immutable List."); 143 throw new UnsupportedError("Cannot add to immutable List.");
144 } 144 }
145 145
146 void insertAll(int index, Iterable<$E> iterable) {
147 throw new UnsupportedError("Cannot add to immutable List.");
148 }
149
150 void setAll(int index, Iterable<$E> iterable) {
151 throw new UnsupportedError("Cannot modify an immutable List.");
152 }
153
146 $E removeAt(int pos) { 154 $E removeAt(int pos) {
147 throw new UnsupportedError("Cannot remove from immutable List."); 155 throw new UnsupportedError("Cannot remove from immutable List.");
148 } 156 }
149 157
150 $E removeLast() { 158 $E removeLast() {
151 throw new UnsupportedError("Cannot remove from immutable List."); 159 throw new UnsupportedError("Cannot remove from immutable List.");
152 } 160 }
153 161
154 void remove(Object object) { 162 void remove(Object object) {
155 throw new UnsupportedError("Cannot remove from immutable List."); 163 throw new UnsupportedError("Cannot remove from immutable List.");
156 } 164 }
157 165
158 void removeWhere(bool test($E element)) { 166 void removeWhere(bool test($E element)) {
159 throw new UnsupportedError("Cannot remove from immutable List."); 167 throw new UnsupportedError("Cannot remove from immutable List.");
160 } 168 }
161 169
162 void retainWhere(bool test($E element)) { 170 void retainWhere(bool test($E element)) {
163 throw new UnsupportedError("Cannot remove from immutable List."); 171 throw new UnsupportedError("Cannot remove from immutable List.");
164 } 172 }
165 173
166 void setRange(int start, int end, Iterable<$E> iterable, [int skipCount]) { 174 void setRange(int start, int end, Iterable<$E> iterable, [int skipCount]) {
167 throw new UnsupportedError("Cannot setRange on immutable List."); 175 throw new UnsupportedError("Cannot setRange on immutable List.");
168 } 176 }
169 177
170 void removeRange(int start, int end) { 178 void removeRange(int start, int end) {
171 throw new UnsupportedError("Cannot removeRange on immutable List."); 179 throw new UnsupportedError("Cannot removeRange on immutable List.");
172 } 180 }
173 181
182 void replaceRange(int start, int end, Iterable<$E> iterable) {
183 throw new UnsupportedError("Cannot modify an immutable List.");
184 }
185
186 void fillRange(int start, int end, [$E fillValue]) {
187 throw new UnsupportedError("Cannot modify an immutable List.");
188 }
189
174 Iterable<$E> getRange(int start, int end) => 190 Iterable<$E> getRange(int start, int end) =>
175 IterableMixinWorkaround.getRangeList(this, start, end); 191 IterableMixinWorkaround.getRangeList(this, start, end);
176 192
177 List<$E> sublist(int start, [int end]) { 193 List<$E> sublist(int start, [int end]) {
178 if (end == null) end = length; 194 if (end == null) end = length;
179 return Lists.getRange(this, start, end, <$E>[]); 195 return Lists.getRange(this, start, end, <$E>[]);
180 } 196 }
181 197
182 Map<int, $E> asMap() => 198 Map<int, $E> asMap() =>
183 IterableMixinWorkaround.asMapList(this); 199 IterableMixinWorkaround.asMapList(this);
184 200
185 String toString() { 201 String toString() {
186 StringBuffer buffer = new StringBuffer('['); 202 StringBuffer buffer = new StringBuffer('[');
187 buffer.writeAll(this, ', '); 203 buffer.writeAll(this, ', ');
188 buffer.write(']'); 204 buffer.write(']');
189 return buffer.toString(); 205 return buffer.toString();
190 } 206 }
191 207
192 // -- end List<$E> mixins. 208 // -- end List<$E> mixins.
OLDNEW
« sdk/lib/core/list.dart ('K') | « tools/dom/templates/html/impl/impl_Node.darttemplate ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698