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 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 int moveLength = oldLength - start; | 382 int moveLength = oldLength - start; |
383 this.length += length; | 383 this.length += length; |
384 if (moveLength > 0) { | 384 if (moveLength > 0) { |
385 this.setRange(start + length, oldLength, this, start); | 385 this.setRange(start + length, oldLength, this, start); |
386 } | 386 } |
387 for (int i = 0; i < length; i++) { | 387 for (int i = 0; i < length; i++) { |
388 this[start + i] = initialValue; | 388 this[start + i] = initialValue; |
389 } | 389 } |
390 } | 390 } |
391 | 391 |
392 void removeRange(int start, int length) { | 392 void removeRange(int start, int end) { |
393 if (start < 0 || start > this.length) { | 393 if (start < 0 || start > this.length) { |
394 throw new RangeError.range(start, 0, this.length); | 394 throw new RangeError.range(start, 0, this.length); |
395 } | 395 } |
396 if (length < 0 || start + length > this.length) { | 396 if (end < start || end > this.length) { |
397 throw new RangeError.range(length, 0, this.length - start); | 397 throw new RangeError.range(end, start, this.length); |
398 } | 398 } |
399 int end = start + length; | 399 int length = end - start; |
400 setRange(start, this.length - length, this, end); | 400 setRange(start, this.length - length, this, end); |
401 this.length -= length; | 401 this.length -= length; |
402 } | 402 } |
403 | 403 |
404 void clearRange(int start, int length, [E fill]) { | 404 void clearRange(int start, int length, [E fill]) { |
405 for (int i = 0; i < length; i++) { | 405 for (int i = 0; i < length; i++) { |
406 this[start + i] = fill; | 406 this[start + i] = fill; |
407 } | 407 } |
408 } | 408 } |
409 | 409 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 for (int i = startIndex; i >= 0; i--) { | 467 for (int i = startIndex; i >= 0; i--) { |
468 if (this[i] == element) { | 468 if (this[i] == element) { |
469 return i; | 469 return i; |
470 } | 470 } |
471 } | 471 } |
472 return -1; | 472 return -1; |
473 } | 473 } |
474 | 474 |
475 Iterable<E> get reversed => new ReversedListIterable(this); | 475 Iterable<E> get reversed => new ReversedListIterable(this); |
476 } | 476 } |
OLD | NEW |