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 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 // doubling its size. | 171 // doubling its size. |
172 void add(T value) { | 172 void add(T value) { |
173 var len = length; | 173 var len = length; |
174 if (len == _capacity) { | 174 if (len == _capacity) { |
175 _grow(len * 2); | 175 _grow(len * 2); |
176 } | 176 } |
177 _setLength(len + 1); | 177 _setLength(len + 1); |
178 this[len] = value; | 178 this[len] = value; |
179 } | 179 } |
180 | 180 |
181 void addLast(T element) { | |
182 add(element); | |
183 } | |
184 | |
185 void addAll(Iterable<T> iterable) { | 181 void addAll(Iterable<T> iterable) { |
186 for (T elem in iterable) { | 182 for (T elem in iterable) { |
187 add(elem); | 183 add(elem); |
188 } | 184 } |
189 } | 185 } |
190 | 186 |
191 T removeLast() { | 187 T removeLast() { |
192 var len = length - 1; | 188 var len = length - 1; |
193 var elem = this[len]; | 189 var elem = this[len]; |
194 this[len] = null; | 190 this[len] = null; |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 } | 343 } |
348 | 344 |
349 Set<T> toSet() { | 345 Set<T> toSet() { |
350 return new Set<T>.from(this); | 346 return new Set<T>.from(this); |
351 } | 347 } |
352 | 348 |
353 Map<int, T> asMap() { | 349 Map<int, T> asMap() { |
354 return IterableMixinWorkaround.asMapList(this); | 350 return IterableMixinWorkaround.asMapList(this); |
355 } | 351 } |
356 } | 352 } |
OLD | NEW |