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; |
+ } |
} |