Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(714)

Side by Side Diff: runtime/lib/growable_array.dart

Issue 9431015: Wrote functions to convert collections and maps to strings and invoked (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/lib/collections.dart ('k') | runtime/lib/immutable_map.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « runtime/lib/collections.dart ('k') | runtime/lib/immutable_map.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698