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

Side by Side Diff: sdk/lib/core/list.dart

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 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 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 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.core; 5 part of dart.core;
6 6
7 /** 7 /**
8 * A [List] is an indexable collection with a length. 8 * A [List] is an indexable collection with a length.
9 * 9 *
10 * A `List` implementation can choose not to support all methods 10 * A `List` implementation can choose not to support all methods
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 * 182 *
183 * This increases the length of the list by one and shifts all later elements 183 * This increases the length of the list by one and shifts all later elements
184 * towards the end of the list. 184 * towards the end of the list.
185 * 185 *
186 * It is an error if the [index] does not point inside the list or at the 186 * It is an error if the [index] does not point inside the list or at the
187 * position after the last element. 187 * position after the last element.
188 */ 188 */
189 void insert(int index, E element); 189 void insert(int index, E element);
190 190
191 /** 191 /**
192 * Inserts all elements of [iterable] at position [index] in the list.
193 *
194 * This increases the length of the list by the length of [iterable] and
195 * shifts all later elements towards the end of the list.
196 *
197 * It is an error if the [index] does not point inside the list or at the
198 * position after the last element.
199 */
200 void insertAll(int index, Iterable<E> iterable);
201
202 /**
203 * Overwrites elements of `this` with the elemenst of [iterable] starting
204 * at position [index] in the list.
205 *
206 * This operation does not increase the length of the list.
207 *
208 * It is an error if the [index] does not point inside the list or at the
209 * position after the last element.
210 *
211 * It is an error if the [iterable] is longer than [length] - [index].
Lasse Reichstein Nielsen 2013/04/15 12:03:08 How about not making it an error if the iterable i
floitsch 2013/04/15 16:22:48 Both are reasonable. I prefer the error since that
212 */
213 void setAll(int index, Iterable<E> iterable);
214
215 /**
192 * Removes [value] from the list. Returns true if [value] was 216 * Removes [value] from the list. Returns true if [value] was
193 * in the list. Returns false otherwise. The method has no effect 217 * in the list. Returns false otherwise. The method has no effect
194 * if [value] value was not in the list. 218 * if [value] value was not in the list.
195 */ 219 */
196 bool remove(Object value); 220 bool remove(Object value);
197 221
198 /** 222 /**
199 * Removes the element at position [index] from the list. 223 * Removes the element at position [index] from the list.
200 * 224 *
201 * This reduces the length of the list by one and moves all later elements 225 * This reduces the length of the list by one and moves all later elements
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 303
280 /** 304 /**
281 * Removes the elements in the range [start]..[end] (excluding). 305 * Removes the elements in the range [start]..[end] (excluding).
282 * 306 *
283 * It is an error if [start]..[end] is not a valid range pointing into the 307 * It is an error if [start]..[end] is not a valid range pointing into the
284 * `this`. 308 * `this`.
285 */ 309 */
286 void removeRange(int start, int end); 310 void removeRange(int start, int end);
287 311
288 /** 312 /**
313 * Sets the elements in the range [start]..[end] (excluding) to the given
314 * [fillValue].
315 *
316 * It is an error if [start]..[end] is not a valid range pointing into the
317 * `this`.
318 */
319 void fillRange(int start, int end, [E fillValue]);
320
321 /**
322 * Removes the elements in the range [start]..[end] (excluding) and replaces
323 * them with the contents of the [iterable].
324 *
325 * It is an error if [start]..[end] is not a valid range pointing into the
326 * `this`.
327 *
328 * Example:
329 *
330 * var list = [1, 2, 3, 4, 5];
331 * list.replaceRange(1, 3, [6, 7, 8, 9]);
332 * print(list); // [1, 6, 7, 8, 9, 4, 5]
333 */
334 void replaceRange(int start, int end, Iterable<E> iterable);
335
336 /**
289 * Returns an unmodifiable [Map] view of `this`. 337 * Returns an unmodifiable [Map] view of `this`.
290 * 338 *
291 * It has the indices of this list as keys, and the corresponding elements 339 * It has the indices of this list as keys, and the corresponding elements
292 * as values. 340 * as values.
293 */ 341 */
294 Map<int, E> asMap(); 342 Map<int, E> asMap();
295 } 343 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698