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