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 GrowableObjectArray<T> implements Array<T> { | 5 class GrowableObjectArray<T> implements Array<T> { |
6 Array<T> backingArray; | 6 Array<T> backingArray; |
7 | 7 |
8 void copyFrom(Array<Object> src, int srcStart, int dstStart, int count) { | 8 void copyFrom(Array<Object> src, int srcStart, int dstStart, int count) { |
9 Arrays.copy(src, srcStart, this, dstStart, count); | 9 Arrays.copy(src, srcStart, this, dstStart, count); |
10 } | 10 } |
(...skipping 24 matching lines...) Expand all Loading... |
35 start, | 35 start, |
36 this.length - length - start); | 36 this.length - length - start); |
37 this.length = this.length - length; | 37 this.length = this.length - length; |
38 } | 38 } |
39 | 39 |
40 void insertRange(int start, int length, [T initialValue = null]) { | 40 void insertRange(int start, int length, [T initialValue = null]) { |
41 throw const NotImplementedException(); | 41 throw const NotImplementedException(); |
42 } | 42 } |
43 | 43 |
44 List<T> getRange(int start, int length) { | 44 List<T> getRange(int start, int length) { |
45 throw const NotImplementedException(); | 45 if (length == 0) return []; |
| 46 Arrays.rangeCheck(this, start, length); |
| 47 return new List<T>.fromList(this, start, start + length); |
46 } | 48 } |
47 | 49 |
48 // The length of this growable array. It is always less than the | 50 // The length of this growable array. It is always less than the |
49 // length of the backing array. | 51 // length of the backing array. |
50 int _length; | 52 int _length; |
51 // Constant used by indexOf and lastIndexOf when the element given | 53 // Constant used by indexOf and lastIndexOf when the element given |
52 // is not in the array. | 54 // is not in the array. |
53 static final int ABSENT = -1; | 55 static final int ABSENT = -1; |
54 | 56 |
55 GrowableObjectArray() | 57 GrowableObjectArray() |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 if (!hasNext()) { | 211 if (!hasNext()) { |
210 throw const NoMoreElementsException(); | 212 throw const NoMoreElementsException(); |
211 } | 213 } |
212 return _array[_pos++]; | 214 return _array[_pos++]; |
213 } | 215 } |
214 | 216 |
215 final GrowableObjectArray<T> _array; | 217 final GrowableObjectArray<T> _array; |
216 int _pos; | 218 int _pos; |
217 } | 219 } |
218 | 220 |
OLD | NEW |