OLD | NEW |
1 // Copyright (c) 2011, 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 class Arrays { | 5 class Arrays { |
6 | 6 |
7 static void copy(List<Object> src, int srcStart, | 7 static void copy(List<Object> src, int srcStart, |
8 List<Object> dst, int dstStart, int count) { | 8 List<Object> dst, int dstStart, int count) { |
9 if (srcStart === null) srcStart = 0; | 9 if (srcStart === null) srcStart = 0; |
10 if (dstStart === null) dstStart = 0; | 10 if (dstStart === null) dstStart = 0; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 if (startIndex >= a.length) { | 56 if (startIndex >= a.length) { |
57 startIndex = a.length - 1; | 57 startIndex = a.length - 1; |
58 } | 58 } |
59 for (int i = startIndex; i >= 0; i--) { | 59 for (int i = startIndex; i >= 0; i--) { |
60 if (a[i] == element) { | 60 if (a[i] == element) { |
61 return i; | 61 return i; |
62 } | 62 } |
63 } | 63 } |
64 return -1; | 64 return -1; |
65 } | 65 } |
| 66 |
| 67 static void rangeCheck(Array a, int start, int length) { |
| 68 if (length < 0) { |
| 69 throw new IllegalArgumentException("negative length $length"); |
| 70 } |
| 71 if (start < 0 || start > a.length) { |
| 72 throw new IndexOutOfRangeException(start); |
| 73 } |
| 74 if (start + length > a.length) { |
| 75 throw new IndexOutOfRangeException(start + length); |
| 76 } |
| 77 } |
66 } | 78 } |
OLD | NEW |