| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 List<T> { | 5 class GrowableObjectArray<T> implements List<T> { |
| 6 factory GrowableObjectArray._uninstantiable() { | 6 factory GrowableObjectArray._uninstantiable() { |
| 7 throw const UnsupportedOperationException( | 7 throw const UnsupportedOperationException( |
| 8 "GrowableObjectArray can only be allocated by the VM"); | 8 "GrowableObjectArray can only be allocated by the VM"); |
| 9 } | 9 } |
| 10 | 10 |
| 11 void copyFrom(List src, int srcStart, int dstStart, int count) { | 11 void copyFrom(List src, int srcStart, int dstStart, int count) { |
| 12 Arrays.copy(src, srcStart, this, dstStart, count); | 12 Arrays.copy(src, srcStart, this, dstStart, count); |
| 13 } | 13 } |
| 14 | 14 |
| 15 void setRange(int start, int length, List<T> from, [int startFrom = 0]) { | 15 void setRange(int start, int length, List<T> from, [int startFrom = 0]) { |
| 16 if (length < 0) { | 16 if (length < 0) { |
| 17 throw new IllegalArgumentException("negative length $length"); | 17 throw new IllegalArgumentException("negative length $length"); |
| 18 } | 18 } |
| 19 Arrays.copy(from, startFrom, this, start, length); | 19 Arrays.copy(from, startFrom, this, start, length); |
| 20 } | 20 } |
| 21 | 21 |
| 22 void removeRange(int start, int length) { | 22 void removeRange(int start, int length) { |
| 23 if (length == 0) { | 23 if (length == 0) { |
| 24 return; | 24 return; |
| 25 } | 25 } |
| 26 if (length < 0) { | 26 Arrays.rangeCheck(this, start, length); |
| 27 throw new IllegalArgumentException("negative length $length"); | |
| 28 } | |
| 29 if (start < 0 || start >= this.length) { | |
| 30 throw new IndexOutOfRangeException(start); | |
| 31 } | |
| 32 if (start + length > this.length) { | |
| 33 throw new IndexOutOfRangeException(start + length); | |
| 34 } | |
| 35 Arrays.copy(this, | 27 Arrays.copy(this, |
| 36 start + length, | 28 start + length, |
| 37 this, | 29 this, |
| 38 start, | 30 start, |
| 39 this.length - length - start); | 31 this.length - length - start); |
| 40 this.length = this.length - length; | 32 this.length = this.length - length; |
| 41 } | 33 } |
| 42 | 34 |
| 43 void insertRange(int start, int length, [T initialValue = null]) { | 35 void insertRange(int start, int length, [T initialValue = null]) { |
| 44 if (length == 0) { | 36 if (length == 0) { |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 T next() { | 229 T next() { |
| 238 if (!hasNext()) { | 230 if (!hasNext()) { |
| 239 throw const NoMoreElementsException(); | 231 throw const NoMoreElementsException(); |
| 240 } | 232 } |
| 241 return _array[_pos++]; | 233 return _array[_pos++]; |
| 242 } | 234 } |
| 243 | 235 |
| 244 final GrowableObjectArray<T> _array; | 236 final GrowableObjectArray<T> _array; |
| 245 int _pos; | 237 int _pos; |
| 246 } | 238 } |
| OLD | NEW |