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

Unified Diff: client/dom/src/_Lists.dart

Issue 9271036: Implement List<T> operations on dom types via manual mixins. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: remove debug comment Created 8 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: client/dom/src/_Lists.dart
diff --git a/client/dom/src/_Lists.dart b/client/dom/src/_Lists.dart
index e75b06a0bdc55be01e25720ba13968d798be99d3..002c1fc671ac02ecf348b2d03ad252a8e911931a 100644
--- a/client/dom/src/_Lists.dart
+++ b/client/dom/src/_Lists.dart
@@ -46,4 +46,23 @@ class _Lists {
}
return -1;
}
+
+ /**
+ * Returns a sub list copy of this list, from [start] to
+ * [:start + length:].
+ * Returns an empty list if [length] is 0.
+ * Throws an [IllegalArgumentException] if [length] is negative.
+ * Throws an [IndexOutOfRangeException] if [start] or
+ * [:start + length:] are out of range.
+ */
+ static List getRange(List a, int start, int length, List accumulator) {
+ if (length < 0) throw new IllegalArgumentException('length');
+ if (start < 0) throw new IndexOutOfRangeException(start);
+ int end = start + length;
+ if (end > a.length) throw new IndexOutOfRangeException(end);
+ for (int i = start; i < end; i++) {
+ accumulator.add(a[i]);
+ }
+ return accumulator;
+ }
}
« no previous file with comments | « client/dom/scripts/dartgenerator.py ('k') | client/dom/templates/dom/frog/immutable_list_mixin.darttemplate » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698