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 1074 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1085 } | 1085 } |
1086 | 1086 |
1087 static void fillRangeList(List list, int start, int end, fillValue) { | 1087 static void fillRangeList(List list, int start, int end, fillValue) { |
1088 _rangeCheck(list, start, end); | 1088 _rangeCheck(list, start, end); |
1089 for (int i = start; i < end; i++) { | 1089 for (int i = start; i < end; i++) { |
1090 list[i] = fillValue; | 1090 list[i] = fillValue; |
1091 } | 1091 } |
1092 } | 1092 } |
1093 | 1093 |
1094 static void insertAllList(List list, int index, Iterable iterable) { | 1094 static void insertAllList(List list, int index, Iterable iterable) { |
1095 RangeError.checkValidIndex(index, list); | 1095 RangeError.checkValueInInterval(index, 0, list.length, "index"); |
1096 if (iterable is! EfficientLength) { | 1096 if (iterable is! EfficientLength) { |
1097 iterable = iterable.toList(growable: false); | 1097 iterable = iterable.toList(growable: false); |
1098 } | 1098 } |
1099 int insertionLength = iterable.length; | 1099 int insertionLength = iterable.length; |
1100 list.length += insertionLength; | 1100 list.length += insertionLength; |
1101 list.setRange(index + insertionLength, list.length, list, index); | 1101 list.setRange(index + insertionLength, list.length, list, index); |
1102 for (var element in iterable) { | 1102 for (var element in iterable) { |
1103 list[index++] = element; | 1103 list[index++] = element; |
1104 } | 1104 } |
1105 } | 1105 } |
(...skipping 54 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 |