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