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