| 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) { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 startIndex = a.length - 1; | 68 startIndex = a.length - 1; |
| 69 } | 69 } |
| 70 for (int i = startIndex; i >= 0; i--) { | 70 for (int i = startIndex; i >= 0; i--) { |
| 71 if (a[i] == element) { | 71 if (a[i] == element) { |
| 72 return i; | 72 return i; |
| 73 } | 73 } |
| 74 } | 74 } |
| 75 return -1; | 75 return -1; |
| 76 } | 76 } |
| 77 | 77 |
| 78 static void indicesCheck(List a, int start, int end) { |
| 79 if (start < 0 || start > a.length) { |
| 80 throw new RangeError.range(start, 0, a.length); |
| 81 } |
| 82 if (end != null && (end < start || end > a.length)) { |
| 83 throw new RangeError.range(end, start, a.length); |
| 84 } |
| 85 } |
| 86 |
| 78 static void rangeCheck(List a, int start, int length) { | 87 static void rangeCheck(List a, int start, int length) { |
| 79 if (length < 0) { | 88 if (length < 0) { |
| 80 throw new ArgumentError("negative length $length"); | 89 throw new ArgumentError("negative length $length"); |
| 81 } | 90 } |
| 82 if (start < 0 ) { | 91 if (start < 0 ) { |
| 83 String message = "$start must be greater than or equal to 0"; | 92 String message = "$start must be greater than or equal to 0"; |
| 84 throw new RangeError(message); | 93 throw new RangeError(message); |
| 85 } | 94 } |
| 86 if (start + length > a.length) { | 95 if (start + length > a.length) { |
| 87 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})"; |
| 88 throw new RangeError(message); | 97 throw new RangeError(message); |
| 89 } | 98 } |
| 90 } | 99 } |
| 91 } | 100 } |
| OLD | NEW |