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

Unified Diff: runtime/lib/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 side-by-side diff with in-line comments
Download patch
Index: runtime/lib/array.dart
diff --git a/runtime/lib/array.dart b/runtime/lib/array.dart
index 165ba64812fe23e8c34f4db3210345b0c9ec585f..7dd70bc712533cf183f7c1cb6408486e67002a9b 100644
--- a/runtime/lib/array.dart
+++ b/runtime/lib/array.dart
@@ -154,6 +154,8 @@ class _ObjectArray<E> implements List<E> {
return this.length == 0;
}
+ List<E> get reversed => new ReversedList<E>(this, 0, length);
+
void sort([int compare(E a, E b)]) {
if (compare == null) compare = Comparable.compare;
_Sort.sort(this, compare);
@@ -383,6 +385,8 @@ class _ImmutableArray<E> implements List<E> {
return this.length == 0;
}
+ List<E> get reversed => new ReversedList<E>(this, 0, length);
+
void sort([int compare(E a, E b)]) {
throw new UnsupportedError(
"Cannot modify an immutable array");

Powered by Google App Engine
This is Rietveld 408576698