OLD | NEW |
| (Empty) |
1 part of dart._internal; | |
2 class Lists {static void copy(List src, int srcStart, List dst, int dstStart, i
nt count) { | |
3 if (srcStart < dstStart) { | |
4 for (int i = srcStart + count - 1, j = dstStart + count - 1; i >= srcStart;
i--, j--) { | |
5 dst[j] = src[i]; | |
6 } | |
7 } | |
8 else { | |
9 for (int i = srcStart, j = dstStart; i < srcStart + count; i++, j++) { | |
10 dst[j] = src[i]; | |
11 } | |
12 } | |
13 } | |
14 static bool areEqual(List a, var b) { | |
15 if (identical(a, b)) return true; | |
16 if (!(b is List)) return false; | |
17 int length = a.length; | |
18 if (length != b.length) return false; | |
19 for (int i = 0; i < length; i++) { | |
20 if (!identical(a[i], b[i])) return false; | |
21 } | |
22 return true; | |
23 } | |
24 static int indexOf(List a, Object element, int startIndex, int endIndex) { | |
25 if (startIndex >= a.length) { | |
26 return -1; | |
27 } | |
28 if (startIndex < 0) { | |
29 startIndex = 0; | |
30 } | |
31 for (int i = startIndex; i < endIndex; i++) { | |
32 if (a[i] == element) { | |
33 return i; | |
34 } | |
35 } | |
36 return -1; | |
37 } | |
38 static int lastIndexOf(List a, Object element, int startIndex) { | |
39 if (startIndex < 0) { | |
40 return -1; | |
41 } | |
42 if (startIndex >= a.length) { | |
43 startIndex = a.length - 1; | |
44 } | |
45 for (int i = startIndex; i >= 0; i--) { | |
46 if (a[i] == element) { | |
47 return i; | |
48 } | |
49 } | |
50 return -1; | |
51 } | |
52 static void indicesCheck(List a, int start, int end) { | |
53 RangeError.checkValidRange(start, end, a.length); | |
54 } | |
55 static void rangeCheck(List a, int start, int length) { | |
56 RangeError.checkNotNegative(length); | |
57 RangeError.checkNotNegative(start); | |
58 if (start + length > a.length) { | |
59 String message = "$start + $length must be in the range [0..${a.length}]"; | |
60 throw new RangeError.range(length, 0, a.length - start, "length", message); | |
61 } | |
62 } | |
63 } | |
OLD | NEW |