| 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 new UnsupportedError( | 7 throw new UnsupportedError( |
| 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 } | 42 } |
| 43 | 43 |
| 44 void insertRange(int start, int length, [T initialValue = null]) { | 44 void insertRange(int start, int length, [T initialValue = null]) { |
| 45 if (length == 0) { | 45 if (length == 0) { |
| 46 return; | 46 return; |
| 47 } | 47 } |
| 48 if ((length < 0) || (length is! int)) { | 48 if ((length < 0) || (length is! int)) { |
| 49 throw new ArgumentError("invalid length specified $length"); | 49 throw new ArgumentError("invalid length specified $length"); |
| 50 } | 50 } |
| 51 if (start < 0 || start > this.length) { | 51 if (start < 0 || start > this.length) { |
| 52 throw new IndexOutOfRangeException(start); | 52 throw new RangeError.value(start); |
| 53 } | 53 } |
| 54 var old_length = this.length; | 54 var old_length = this.length; |
| 55 this.length = old_length + length; // Will expand if needed. | 55 this.length = old_length + length; // Will expand if needed. |
| 56 Arrays.copy(this, | 56 Arrays.copy(this, |
| 57 start, | 57 start, |
| 58 this, | 58 this, |
| 59 start + length, | 59 start + length, |
| 60 old_length - start); | 60 old_length - start); |
| 61 for (int i = start; i < start + length; i++) { | 61 for (int i = start; i < start + length; i++) { |
| 62 this[i] = initialValue; | 62 this[i] = initialValue; |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 } | 212 } |
| 213 | 213 |
| 214 String toString() { | 214 String toString() { |
| 215 return Collections.collectionToString(this); | 215 return Collections.collectionToString(this); |
| 216 } | 216 } |
| 217 | 217 |
| 218 Iterator<T> iterator() { | 218 Iterator<T> iterator() { |
| 219 return new SequenceIterator<T>(this); | 219 return new SequenceIterator<T>(this); |
| 220 } | 220 } |
| 221 } | 221 } |
| OLD | NEW |