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

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

Issue 11896013: Add List.reversed to give a reverse fixed-length view of a list. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 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
OLDNEW
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 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 } 284 }
285 285
286 bool get isEmpty { 286 bool get isEmpty {
287 return this.length == 0; 287 return this.length == 0;
288 } 288 }
289 289
290 void clear() { 290 void clear() {
291 this.length = 0; 291 this.length = 0;
292 } 292 }
293 293
294 List<T> get reversed => new ReversedList<T>(this, 0, length);
295
294 void sort([int compare(T a, T b)]) { 296 void sort([int compare(T a, T b)]) {
295 if (compare == null) compare = Comparable.compare; 297 if (compare == null) compare = Comparable.compare;
296 _Sort.sort(this, compare); 298 _Sort.sort(this, compare);
297 } 299 }
298 300
299 String toString() { 301 String toString() {
300 return Collections.collectionToString(this); 302 return Collections.collectionToString(this);
301 } 303 }
302 304
303 Iterator<T> get iterator { 305 Iterator<T> get iterator {
304 return new ListIterator<T>(this); 306 return new ListIterator<T>(this);
305 } 307 }
306 308
307 List<T> toList() { 309 List<T> toList() {
308 return new List<T>.from(this); 310 return new List<T>.from(this);
309 } 311 }
310 312
311 Set<T> toSet() { 313 Set<T> toSet() {
312 return new Set<T>.from(this); 314 return new Set<T>.from(this);
313 } 315 }
314 } 316 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698