| 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 if (length == 0) throw new StateError("No elements"); | 54 if (length == 0) throw new StateError("No elements"); |
| 55 return this[length - 1]; | 55 return this[length - 1]; |
| 56 } | 56 } |
| 57 | 57 |
| 58 E get single { | 58 E get single { |
| 59 if (length == 0) throw new StateError("No elements"); | 59 if (length == 0) throw new StateError("No elements"); |
| 60 if (length > 1) throw new StateError("Too many elements"); | 60 if (length > 1) throw new StateError("Too many elements"); |
| 61 return this[0]; | 61 return this[0]; |
| 62 } | 62 } |
| 63 | 63 |
| 64 bool contains(E element) { | 64 bool contains(Object element) { |
| 65 int length = this.length; | 65 int length = this.length; |
| 66 for (int i = 0; i < length; i++) { | 66 for (int i = 0; i < length; i++) { |
| 67 if (this[i] == element) return true; | 67 if (this[i] == element) return true; |
| 68 if (length != this.length) { | 68 if (length != this.length) { |
| 69 throw new ConcurrentModificationError(this); | 69 throw new ConcurrentModificationError(this); |
| 70 } | 70 } |
| 71 } | 71 } |
| 72 return false; | 72 return false; |
| 73 } | 73 } |
| 74 | 74 |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 for (E element in iterable) { | 465 for (E element in iterable) { |
| 466 this[index++] = element; | 466 this[index++] = element; |
| 467 } | 467 } |
| 468 } | 468 } |
| 469 } | 469 } |
| 470 | 470 |
| 471 Iterable<E> get reversed => new ReversedListIterable(this); | 471 Iterable<E> get reversed => new ReversedListIterable(this); |
| 472 | 472 |
| 473 String toString() => ToString.iterableToString(this); | 473 String toString() => ToString.iterableToString(this); |
| 474 } | 474 } |
| OLD | NEW |