| 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 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"); |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 add(element); | 156 add(element); |
| 157 } | 157 } |
| 158 | 158 |
| 159 void addAll(Collection<T> collection) { | 159 void addAll(Collection<T> collection) { |
| 160 for (T elem in collection) { | 160 for (T elem in collection) { |
| 161 add(elem); | 161 add(elem); |
| 162 } | 162 } |
| 163 } | 163 } |
| 164 | 164 |
| 165 T removeLast() { | 165 T removeLast() { |
| 166 if (_length == 0) { |
| 167 throw new IndexOutOfRangeException(-1); |
| 168 } |
| 166 _length--; | 169 _length--; |
| 167 return backingArray[_length]; | 170 return backingArray[_length]; |
| 168 } | 171 } |
| 169 | 172 |
| 170 T last() { | 173 T last() { |
| 171 if (_length === 0) { | 174 if (_length === 0) { |
| 172 throw new IndexOutOfRangeException(-1); | 175 throw new IndexOutOfRangeException(-1); |
| 173 } | 176 } |
| 174 return backingArray[_length - 1]; | 177 return backingArray[_length - 1]; |
| 175 } | 178 } |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 if (!hasNext()) { | 242 if (!hasNext()) { |
| 240 throw const NoMoreElementsException(); | 243 throw const NoMoreElementsException(); |
| 241 } | 244 } |
| 242 return _array[_pos++]; | 245 return _array[_pos++]; |
| 243 } | 246 } |
| 244 | 247 |
| 245 final GrowableObjectArray<T> _array; | 248 final GrowableObjectArray<T> _array; |
| 246 int _pos; | 249 int _pos; |
| 247 } | 250 } |
| 248 | 251 |
| OLD | NEW |