| 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 } |
| 11 | 11 |
| 12 void setRange(int start, int length, List<T> from, [int startFrom = 0]) { | 12 void setRange(int start, int length, List<T> from, [int startFrom = 0]) { |
| 13 if (length < 0) throw new IllegalArgumentException(length); |
| 13 Arrays.copy(from, startFrom, this, start, length); | 14 Arrays.copy(from, startFrom, this, start, length); |
| 14 } | 15 } |
| 15 | 16 |
| 16 void removeRange(int start, int length) { | 17 void removeRange(int start, int length) { |
| 17 throw const NotImplementedException(); | 18 if (length == 0) { |
| 19 return; |
| 20 } |
| 21 if (length < 0) { |
| 22 throw const IllegalArgumentException(); |
| 23 } |
| 24 if (start < 0 || start >= this.length) { |
| 25 throw new IndexOutOfRangeException(start); |
| 26 } |
| 27 if (start + length > this.length) { |
| 28 throw new IndexOutOfRangeException(start + length); |
| 29 } |
| 30 Arrays.copy(backingArray, |
| 31 start + length, |
| 32 backingArray, |
| 33 start, |
| 34 this.length - length - start); |
| 35 this.length = this.length - length; |
| 18 } | 36 } |
| 19 | 37 |
| 20 void insertRange(int start, int length, [T initialValue = null]) { | 38 void insertRange(int start, int length, [T initialValue = null]) { |
| 21 throw const NotImplementedException(); | 39 throw const NotImplementedException(); |
| 22 } | 40 } |
| 23 | 41 |
| 24 List<T> getRange(int start, int length) { | 42 List<T> getRange(int start, int length) { |
| 25 throw const NotImplementedException(); | 43 throw const NotImplementedException(); |
| 26 } | 44 } |
| 27 | 45 |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 if (!hasNext()) { | 207 if (!hasNext()) { |
| 190 throw const NoMoreElementsException(); | 208 throw const NoMoreElementsException(); |
| 191 } | 209 } |
| 192 return _array[_pos++]; | 210 return _array[_pos++]; |
| 193 } | 211 } |
| 194 | 212 |
| 195 final GrowableObjectArray<T> _array; | 213 final GrowableObjectArray<T> _array; |
| 196 int _pos; | 214 int _pos; |
| 197 } | 215 } |
| 198 | 216 |
| OLD | NEW |