| 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 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 Iterable<E> getRange(int start, int end) { | 317 Iterable<E> getRange(int start, int end) { |
| 318 if (start < 0 || start > this.length) { | 318 if (start < 0 || start > this.length) { |
| 319 throw new RangeError.range(start, 0, this.length); | 319 throw new RangeError.range(start, 0, this.length); |
| 320 } | 320 } |
| 321 if (end < start || end > this.length) { | 321 if (end < start || end > this.length) { |
| 322 throw new RangeError.range(end, start, this.length); | 322 throw new RangeError.range(end, start, this.length); |
| 323 } | 323 } |
| 324 return new SubListIterable(this, start, end); | 324 return new SubListIterable(this, start, end); |
| 325 } | 325 } |
| 326 | 326 |
| 327 void insertRange(int start, int length, [E initialValue]) { | |
| 328 if (start < 0 || start > this.length) { | |
| 329 throw new RangeError.range(start, 0, this.length); | |
| 330 } | |
| 331 int oldLength = this.length; | |
| 332 int moveLength = oldLength - start; | |
| 333 this.length += length; | |
| 334 if (moveLength > 0) { | |
| 335 this.setRange(start + length, oldLength, this, start); | |
| 336 } | |
| 337 for (int i = 0; i < length; i++) { | |
| 338 this[start + i] = initialValue; | |
| 339 } | |
| 340 } | |
| 341 | |
| 342 void removeRange(int start, int end) { | 327 void removeRange(int start, int end) { |
| 343 if (start < 0 || start > this.length) { | 328 if (start < 0 || start > this.length) { |
| 344 throw new RangeError.range(start, 0, this.length); | 329 throw new RangeError.range(start, 0, this.length); |
| 345 } | 330 } |
| 346 if (end < start || end > this.length) { | 331 if (end < start || end > this.length) { |
| 347 throw new RangeError.range(end, start, this.length); | 332 throw new RangeError.range(end, start, this.length); |
| 348 } | 333 } |
| 349 int length = end - start; | 334 int length = end - start; |
| 350 setRange(start, this.length - length, this, end); | 335 setRange(start, this.length - length, this, end); |
| 351 this.length -= length; | 336 this.length -= length; |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 for (int i = startIndex; i >= 0; i--) { | 413 for (int i = startIndex; i >= 0; i--) { |
| 429 if (this[i] == element) { | 414 if (this[i] == element) { |
| 430 return i; | 415 return i; |
| 431 } | 416 } |
| 432 } | 417 } |
| 433 return -1; | 418 return -1; |
| 434 } | 419 } |
| 435 | 420 |
| 436 Iterable<E> get reversed => new ReversedListIterable(this); | 421 Iterable<E> get reversed => new ReversedListIterable(this); |
| 437 } | 422 } |
| OLD | NEW |