| 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 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 if (start < 0 || start > this.length) { | 42 if (start < 0 || start > this.length) { |
| 43 throw new IndexOutOfRangeException(start); | 43 throw new IndexOutOfRangeException(start); |
| 44 } | 44 } |
| 45 var old_length = this.length; | 45 var old_length = this.length; |
| 46 this.length = old_length + length; // Will expand if needed. | 46 this.length = old_length + length; // Will expand if needed. |
| 47 Arrays.copy(this, | 47 Arrays.copy(this, |
| 48 start, | 48 start, |
| 49 this, | 49 this, |
| 50 start + length, | 50 start + length, |
| 51 old_length - start); | 51 old_length - start); |
| 52 if (initialValue !== null) { | 52 for (int i = start; i < start + length; i++) { |
| 53 for (int i = start; i < start + length; i++) { | 53 this[i] = initialValue; |
| 54 this[i] = initialValue; | |
| 55 } | |
| 56 } | 54 } |
| 57 } | 55 } |
| 58 | 56 |
| 59 List<T> getRange(int start, int length) { | 57 List<T> getRange(int start, int length) { |
| 60 if (length == 0) return []; | 58 if (length == 0) return []; |
| 61 Arrays.rangeCheck(this, start, length); | 59 Arrays.rangeCheck(this, start, length); |
| 62 List list = new List<T>(); | 60 List list = new List<T>(); |
| 63 list.length = length; | 61 list.length = length; |
| 64 Arrays.copy(this, start, list, 0, length); | 62 Arrays.copy(this, start, list, 0, length); |
| 65 return list; | 63 return list; |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 T next() { | 227 T next() { |
| 230 if (!hasNext()) { | 228 if (!hasNext()) { |
| 231 throw const NoMoreElementsException(); | 229 throw const NoMoreElementsException(); |
| 232 } | 230 } |
| 233 return _array[_pos++]; | 231 return _array[_pos++]; |
| 234 } | 232 } |
| 235 | 233 |
| 236 final GrowableObjectArray<T> _array; | 234 final GrowableObjectArray<T> _array; |
| 237 int _pos; | 235 int _pos; |
| 238 } | 236 } |
| OLD | NEW |