OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 part of dart._collection.dev; | 5 part of dart._collection.dev; |
6 | 6 |
7 // TODO(ngeoffray): Rename to Lists. | 7 // TODO(ngeoffray): Rename to Lists. |
8 class Arrays { | 8 class Arrays { |
9 static void copy(List src, int srcStart, | 9 static void copy(List src, int srcStart, |
10 List dst, int dstStart, int count) { | 10 List dst, int dstStart, int count) { |
11 if (srcStart < dstStart) { | 11 if (srcStart < dstStart) { |
12 for (int i = srcStart + count - 1, j = dstStart + count - 1; | 12 for (int i = srcStart + count - 1, j = dstStart + count - 1; |
13 i >= srcStart; i--, j--) { | 13 i >= srcStart; i--, j--) { |
14 dst[j] = src[i]; | 14 dst[j] = src[i]; |
15 } | 15 } |
16 } else { | 16 } else { |
17 for (int i = srcStart, j = dstStart; i < srcStart + count; i++, j++) { | 17 for (int i = srcStart, j = dstStart; i < srcStart + count; i++, j++) { |
18 dst[j] = src[i]; | 18 dst[j] = src[i]; |
19 } | 19 } |
20 } | 20 } |
21 } | 21 } |
22 | 22 |
23 static bool areEqual(List a, Object b) { | 23 static bool areEqual(List a, var b) { |
24 if (identical(a, b)) return true; | 24 if (identical(a, b)) return true; |
25 if (!(b is List)) return false; | 25 if (!(b is List)) return false; |
26 int length = a.length; | 26 int length = a.length; |
27 if (length != b.length) return false; | 27 if (length != b.length) return false; |
28 | 28 |
29 for (int i = 0; i < length; i++) { | 29 for (int i = 0; i < length; i++) { |
30 if (!identical(a[i], b[i])) return false; | 30 if (!identical(a[i], b[i])) return false; |
31 } | 31 } |
32 return true; | 32 return true; |
33 } | 33 } |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 if (start < 0 ) { | 91 if (start < 0 ) { |
92 String message = "$start must be greater than or equal to 0"; | 92 String message = "$start must be greater than or equal to 0"; |
93 throw new RangeError(message); | 93 throw new RangeError(message); |
94 } | 94 } |
95 if (start + length > a.length) { | 95 if (start + length > a.length) { |
96 String message = "$start + $length must be in the range [0..${a.length})"; | 96 String message = "$start + $length must be in the range [0..${a.length})"; |
97 throw new RangeError(message); | 97 throw new RangeError(message); |
98 } | 98 } |
99 } | 99 } |
100 } | 100 } |
OLD | NEW |