| OLD | NEW |
| 1 // Copyright (c) 2011, 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 // TODO(ngeoffray): Rename to Lists. | 5 // TODO(ngeoffray): Rename to Lists. |
| 6 class Arrays { | 6 class Arrays { |
| 7 | |
| 8 static String asString(List list) { | |
| 9 String result = "["; | |
| 10 int len = list.length; | |
| 11 for (int i = 0; i < len; i++) { | |
| 12 // TODO(4466785): Deal with recursion and formatting. | |
| 13 result += list[i].toString() + ", "; | |
| 14 } | |
| 15 result += "]"; | |
| 16 return result; | |
| 17 } | |
| 18 | |
| 19 static void copy(List src, int srcStart, | 7 static void copy(List src, int srcStart, |
| 20 List dst, int dstStart, int count) { | 8 List dst, int dstStart, int count) { |
| 21 if (srcStart === null) srcStart = 0; | 9 if (srcStart === null) srcStart = 0; |
| 22 if (dstStart === null) dstStart = 0; | 10 if (dstStart === null) dstStart = 0; |
| 23 | 11 |
| 24 if (srcStart < dstStart) { | 12 if (srcStart < dstStart) { |
| 25 for (int i = srcStart + count - 1, j = dstStart + count - 1; | 13 for (int i = srcStart + count - 1, j = dstStart + count - 1; |
| 26 i >= srcStart; i--, j--) { | 14 i >= srcStart; i--, j--) { |
| 27 dst[j] = src[i]; | 15 dst[j] = src[i]; |
| 28 } | 16 } |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 } | 82 } |
| 95 if (start < 0 || start >= a.length) { | 83 if (start < 0 || start >= a.length) { |
| 96 throw new IndexOutOfRangeException(start); | 84 throw new IndexOutOfRangeException(start); |
| 97 } | 85 } |
| 98 if (start + length > a.length) { | 86 if (start + length > a.length) { |
| 99 throw new IndexOutOfRangeException(start + length); | 87 throw new IndexOutOfRangeException(start + length); |
| 100 } | 88 } |
| 101 } | 89 } |
| 102 } | 90 } |
| 103 | 91 |
| OLD | NEW |