OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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.collection; | 5 part of dart.collection; |
6 | 6 |
7 /** | 7 /** |
8 * Abstract implementation of a list. | 8 * Abstract implementation of a list. |
9 * | 9 * |
10 * All operations are defined in terms of `length`, `operator[]`, | 10 * All operations are defined in terms of `length`, `operator[]`, |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 int moveLength = oldLength - start; | 335 int moveLength = oldLength - start; |
336 this.length += length; | 336 this.length += length; |
337 if (moveLength > 0) { | 337 if (moveLength > 0) { |
338 this.setRange(start + length, oldLength, this, start); | 338 this.setRange(start + length, oldLength, this, start); |
339 } | 339 } |
340 for (int i = 0; i < length; i++) { | 340 for (int i = 0; i < length; i++) { |
341 this[start + i] = initialValue; | 341 this[start + i] = initialValue; |
342 } | 342 } |
343 } | 343 } |
344 | 344 |
345 void removeRange(int start, int length) { | 345 void removeRange(int start, int end) { |
346 if (start < 0 || start > this.length) { | 346 if (start < 0 || start > this.length) { |
347 throw new RangeError.range(start, 0, this.length); | 347 throw new RangeError.range(start, 0, this.length); |
348 } | 348 } |
349 if (length < 0 || start + length > this.length) { | 349 if (end < start || end > this.length) { |
350 throw new RangeError.range(length, 0, this.length - start); | 350 throw new RangeError.range(end, start, this.length); |
351 } | 351 } |
352 int end = start + length; | 352 int length = end - start; |
353 setRange(start, this.length - length, this, end); | 353 setRange(start, this.length - length, this, end); |
354 this.length -= length; | 354 this.length -= length; |
355 } | 355 } |
356 | 356 |
357 void clearRange(int start, int length, [E fill]) { | 357 void clearRange(int start, int length, [E fill]) { |
358 for (int i = 0; i < length; i++) { | 358 for (int i = 0; i < length; i++) { |
359 this[start + i] = fill; | 359 this[start + i] = fill; |
360 } | 360 } |
361 } | 361 } |
362 | 362 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 E result = this[index]; | 457 E result = this[index]; |
458 setRange(index, this.length - 1, this, index + 1); | 458 setRange(index, this.length - 1, this, index + 1); |
459 length--; | 459 length--; |
460 return result; | 460 return result; |
461 } | 461 } |
462 | 462 |
463 Iterable<E> get reversed => new ReversedListIterable(this); | 463 Iterable<E> get reversed => new ReversedListIterable(this); |
464 | 464 |
465 String toString() => ToString.iterableToString(this); | 465 String toString() => ToString.iterableToString(this); |
466 } | 466 } |
OLD | NEW |