| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 class ListFactory<E> { | 5 class ListFactory<E> { |
| 6 | 6 |
| 7 factory List.from(Iterable<E> other) { | 7 factory List.from(Iterable<E> other) { |
| 8 GrowableObjectArray<E> list = new GrowableObjectArray<E>(); | 8 GrowableObjectArray<E> list = new GrowableObjectArray<E>(); |
| 9 for (final e in other) { | 9 for (final e in other) { |
| 10 list.add(e); | 10 list.add(e); |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 bool isEmpty() { | 227 bool isEmpty() { |
| 228 return this.length === 0; | 228 return this.length === 0; |
| 229 } | 229 } |
| 230 | 230 |
| 231 void sort(int compare(E a, E b)) { | 231 void sort(int compare(E a, E b)) { |
| 232 throw const UnsupportedOperationException( | 232 throw const UnsupportedOperationException( |
| 233 "Cannot modify an immutable array"); | 233 "Cannot modify an immutable array"); |
| 234 } | 234 } |
| 235 | 235 |
| 236 String toString() { | 236 String toString() { |
| 237 return "ImmutableArray"; | 237 return Arrays.asString(this); |
| 238 } | 238 } |
| 239 | 239 |
| 240 int indexOf(E element, [int start = 0]) { | 240 int indexOf(E element, [int start = 0]) { |
| 241 return Arrays.indexOf(this, element, start, this.length); | 241 return Arrays.indexOf(this, element, start, this.length); |
| 242 } | 242 } |
| 243 | 243 |
| 244 int lastIndexOf(E element, [int start = null]) { | 244 int lastIndexOf(E element, [int start = null]) { |
| 245 if (start === null) start = length - 1; | 245 if (start === null) start = length - 1; |
| 246 return Arrays.lastIndexOf(this, element, start); | 246 return Arrays.lastIndexOf(this, element, start); |
| 247 } | 247 } |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 if (!hasNext()) { | 300 if (!hasNext()) { |
| 301 throw const NoMoreElementsException(); | 301 throw const NoMoreElementsException(); |
| 302 } | 302 } |
| 303 return _array[_pos++]; | 303 return _array[_pos++]; |
| 304 } | 304 } |
| 305 | 305 |
| 306 final List<E> _array; | 306 final List<E> _array; |
| 307 final int _length; // Cache array length for faster access. | 307 final int _length; // Cache array length for faster access. |
| 308 int _pos; | 308 int _pos; |
| 309 } | 309 } |
| OLD | NEW |