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<T> { | 5 class ListFactory<T> { |
6 | 6 |
7 factory List.from(Iterable<T> other) { | 7 factory List.from(Iterable<T> other) { |
8 GrowableObjectArray<T> list = new GrowableObjectArray<T>(); | 8 GrowableObjectArray<T> list = new GrowableObjectArray<T>(); |
9 for (final e in other) { | 9 for (final e in other) { |
10 list.add(e); | 10 list.add(e); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 void _copyFromObjectArray(ObjectArray src, | 59 void _copyFromObjectArray(ObjectArray src, |
60 int srcStart, | 60 int srcStart, |
61 int dstStart, | 61 int dstStart, |
62 int count) | 62 int count) |
63 native "ObjectArray_copyFromObjectArray"; | 63 native "ObjectArray_copyFromObjectArray"; |
64 | 64 |
65 void setRange(int start, int length, List<T> from, [int startFrom = 0]) { | 65 void setRange(int start, int length, List<T> from, [int startFrom = 0]) { |
66 if (length < 0) { | 66 if (length < 0) { |
67 throw new IllegalArgumentException("negative length $length"); | 67 throw new IllegalArgumentException("negative length $length"); |
68 } | 68 } |
69 copyFrom(from, start, startFrom, count); | 69 copyFrom(from, startFrom, start, length); |
70 } | 70 } |
71 | 71 |
72 void removeRange(int start, int length) { | 72 void removeRange(int start, int length) { |
73 throw const UnsupportedOperationException( | 73 throw const UnsupportedOperationException( |
74 "Cannot remove range of a non-extendable array"); | 74 "Cannot remove range of a non-extendable array"); |
75 } | 75 } |
76 | 76 |
77 void insertRange(int start, int length, [T initialValue = null]) { | 77 void insertRange(int start, int length, [T initialValue = null]) { |
78 throw const UnsupportedOperationException( | 78 throw const UnsupportedOperationException( |
79 "Cannot insert range in a non-extendable array"); | 79 "Cannot insert range in a non-extendable array"); |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 if (!hasNext()) { | 307 if (!hasNext()) { |
308 throw const NoMoreElementsException(); | 308 throw const NoMoreElementsException(); |
309 } | 309 } |
310 return _array[_pos++]; | 310 return _array[_pos++]; |
311 } | 311 } |
312 | 312 |
313 final List<T> _array; | 313 final List<T> _array; |
314 final int _length; // Cache array length for faster access. | 314 final int _length; // Cache array length for faster access. |
315 int _pos; | 315 int _pos; |
316 } | 316 } |
OLD | NEW |