| 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 part of dart._internal; | 5 part of dart._internal; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * Marker interface for [Iterable] subclasses that have an efficient | 8 * Marker interface for [Iterable] subclasses that have an efficient |
| 9 * [length] implementation. | 9 * [length] implementation. |
| 10 */ | 10 */ |
| (...skipping 908 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 919 } | 919 } |
| 920 } | 920 } |
| 921 if (foundMatching) return result; | 921 if (foundMatching) return result; |
| 922 throw IterableElementError.noElement(); | 922 throw IterableElementError.noElement(); |
| 923 } | 923 } |
| 924 | 924 |
| 925 static elementAt(Iterable iterable, int index) { | 925 static elementAt(Iterable iterable, int index) { |
| 926 if (index is! int) throw new ArgumentError.notNull("index"); | 926 if (index is! int) throw new ArgumentError.notNull("index"); |
| 927 RangeError.checkNotNegative(index, "index"); | 927 RangeError.checkNotNegative(index, "index"); |
| 928 int elementIndex = 0; | 928 int elementIndex = 0; |
| 929 for (E element in iterable) { | 929 for (var element in iterable) { |
| 930 if (index == elementIndex) return element; | 930 if (index == elementIndex) return element; |
| 931 elementIndex++; | 931 elementIndex++; |
| 932 } | 932 } |
| 933 throw new RangeError.index(index, iterable, "index", null, elementIndex); | 933 throw new RangeError.index(index, iterable, "index", null, elementIndex); |
| 934 } | 934 } |
| 935 | 935 |
| 936 static String join(Iterable iterable, [String separator]) { | 936 static String join(Iterable iterable, [String separator]) { |
| 937 StringBuffer buffer = new StringBuffer(); | 937 StringBuffer buffer = new StringBuffer(); |
| 938 buffer.writeAll(iterable, separator); | 938 buffer.writeAll(iterable, separator); |
| 939 return buffer.toString(); | 939 return buffer.toString(); |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1160 * Creates errors throw by [Iterable] when the element count is wrong. | 1160 * Creates errors throw by [Iterable] when the element count is wrong. |
| 1161 */ | 1161 */ |
| 1162 abstract class IterableElementError { | 1162 abstract class IterableElementError { |
| 1163 /** Error thrown thrown by, e.g., [Iterable.first] when there is no result. */ | 1163 /** Error thrown thrown by, e.g., [Iterable.first] when there is no result. */ |
| 1164 static StateError noElement() => new StateError("No element"); | 1164 static StateError noElement() => new StateError("No element"); |
| 1165 /** Error thrown by, e.g., [Iterable.single] if there are too many results. */ | 1165 /** Error thrown by, e.g., [Iterable.single] if there are too many results. */ |
| 1166 static StateError tooMany() => new StateError("Too many elements"); | 1166 static StateError tooMany() => new StateError("Too many elements"); |
| 1167 /** Error thrown by, e.g., [List.setRange] if there are too few elements. */ | 1167 /** Error thrown by, e.g., [List.setRange] if there are too few elements. */ |
| 1168 static StateError tooFew() => new StateError("Too few elements"); | 1168 static StateError tooFew() => new StateError("Too few elements"); |
| 1169 } | 1169 } |
| OLD | NEW |