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

Unified Diff: sdk/lib/internal/iterable.dart

Issue 515183002: Make String.fromCharCodes take start/end. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Merge to tip of tree. Created 6 years, 3 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: sdk/lib/internal/iterable.dart
diff --git a/sdk/lib/internal/iterable.dart b/sdk/lib/internal/iterable.dart
index 006b31acb6fef4ee6860799d8135c2c10c6b1cfe..78cebced560803c219dfc51a76f37b55fde7eab8 100644
--- a/sdk/lib/internal/iterable.dart
+++ b/sdk/lib/internal/iterable.dart
@@ -226,7 +226,7 @@ abstract class ListIterable<E> extends IterableBase<E>
}
class SubListIterable<E> extends ListIterable<E> {
- final Iterable<E> _iterable;
+ final Iterable<E> _iterable; // Has efficient length and elementAt.
final int _start;
/** If null, represents the length of the iterable. */
final int _endOrLength;
@@ -293,6 +293,21 @@ class SubListIterable<E> extends ListIterable<E> {
return new SubListIterable<E>(_iterable, _start, newEnd);
}
}
+
+ List<E> toList({bool growable: false}) {
+ int start = _start;
+ int end = _iterable.length;
+ if (_endOrLength != null && _endOrLength < end) end = _endOrLength;
+ int length = end - start;
+ if (length < 0) length = 0;
+ List result = growable ? (new List<E>()..length = length)
+ : new List<E>(length);
+ for (int i = 0; i < length; i++) {
+ result[i] = _iterable.elementAt(start + i);
+ if (_iterable.length < end) throw new ConcurrentModificationError(this);
+ }
+ return result;
+ }
}
/**

Powered by Google App Engine
This is Rietveld 408576698