| OLD | NEW |
| 1 // Copyright (c) 2011, 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 ObjectArray<T> backingArray; | 6 ObjectArray<T> backingArray; |
| 7 | 7 |
| 8 factory GrowableObjectArray._uninstantiable() { | 8 factory GrowableObjectArray._uninstantiable() { |
| 9 throw const UnsupportedOperationException( | 9 throw const UnsupportedOperationException( |
| 10 "GrowableObjectArray can only be allocated by the VM"); | 10 "GrowableObjectArray can only be allocated by the VM"); |
| 11 } | 11 } |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 | 220 |
| 221 void clear() { | 221 void clear() { |
| 222 this.length = 0; | 222 this.length = 0; |
| 223 } | 223 } |
| 224 | 224 |
| 225 void sort(int compare(T a, T b)) { | 225 void sort(int compare(T a, T b)) { |
| 226 DualPivotQuicksort.sort(this, compare); | 226 DualPivotQuicksort.sort(this, compare); |
| 227 } | 227 } |
| 228 | 228 |
| 229 String toString() { | 229 String toString() { |
| 230 return Arrays.asString(this); | 230 return Collections.collectionToString(this); |
| 231 } | 231 } |
| 232 | 232 |
| 233 Iterator<T> iterator() { | 233 Iterator<T> iterator() { |
| 234 return new VariableSizeArrayIterator<T>(this); | 234 return new VariableSizeArrayIterator<T>(this); |
| 235 } | 235 } |
| 236 } | 236 } |
| 237 | 237 |
| 238 | 238 |
| 239 // Iterator for arrays with variable size. | 239 // Iterator for arrays with variable size. |
| 240 class VariableSizeArrayIterator<T> implements Iterator<T> { | 240 class VariableSizeArrayIterator<T> implements Iterator<T> { |
| 241 VariableSizeArrayIterator(GrowableObjectArray<T> array) | 241 VariableSizeArrayIterator(GrowableObjectArray<T> array) |
| 242 : _array = array, _pos = 0 { | 242 : _array = array, _pos = 0 { |
| 243 } | 243 } |
| 244 | 244 |
| 245 bool hasNext() { | 245 bool hasNext() { |
| 246 return _array._length > _pos; | 246 return _array._length > _pos; |
| 247 } | 247 } |
| 248 | 248 |
| 249 T next() { | 249 T next() { |
| 250 if (!hasNext()) { | 250 if (!hasNext()) { |
| 251 throw const NoMoreElementsException(); | 251 throw const NoMoreElementsException(); |
| 252 } | 252 } |
| 253 return _array[_pos++]; | 253 return _array[_pos++]; |
| 254 } | 254 } |
| 255 | 255 |
| 256 final GrowableObjectArray<T> _array; | 256 final GrowableObjectArray<T> _array; |
| 257 int _pos; | 257 int _pos; |
| 258 } | 258 } |
| 259 | 259 |
| OLD | NEW |