| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 |
| 7 static void copy(List src, int srcStart, | 19 static void copy(List src, int srcStart, |
| 8 List dst, int dstStart, int count) { | 20 List dst, int dstStart, int count) { |
| 9 if (srcStart === null) srcStart = 0; | 21 if (srcStart === null) srcStart = 0; |
| 10 if (dstStart === null) dstStart = 0; | 22 if (dstStart === null) dstStart = 0; |
| 11 | 23 |
| 12 if (srcStart < dstStart) { | 24 if (srcStart < dstStart) { |
| 13 for (int i = srcStart + count - 1, j = dstStart + count - 1; | 25 for (int i = srcStart + count - 1, j = dstStart + count - 1; |
| 14 i >= srcStart; i--, j--) { | 26 i >= srcStart; i--, j--) { |
| 15 dst[j] = src[i]; | 27 dst[j] = src[i]; |
| 16 } | 28 } |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 } | 94 } |
| 83 if (start < 0 || start >= a.length) { | 95 if (start < 0 || start >= a.length) { |
| 84 throw new IndexOutOfRangeException(start); | 96 throw new IndexOutOfRangeException(start); |
| 85 } | 97 } |
| 86 if (start + length > a.length) { | 98 if (start + length > a.length) { |
| 87 throw new IndexOutOfRangeException(start + length); | 99 throw new IndexOutOfRangeException(start + length); |
| 88 } | 100 } |
| 89 } | 101 } |
| 90 } | 102 } |
| 91 | 103 |
| OLD | NEW |