Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(365)

Side by Side Diff: sdk/lib/_collection_dev/iterable.dart

Issue 107333003: Fix an old TODO. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sdk/lib/_collection_dev/collection_dev_sources.gypi ('k') | sdk/lib/_collection_dev/lists.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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._collection.dev; 5 part of dart._collection.dev;
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 998 matching lines...) Expand 10 before | Expand all | Expand 10 after
1009 while (length > 1) { 1009 while (length > 1) {
1010 int pos = random.nextInt(length); 1010 int pos = random.nextInt(length);
1011 length -= 1; 1011 length -= 1;
1012 var tmp = list[length]; 1012 var tmp = list[length];
1013 list[length] = list[pos]; 1013 list[length] = list[pos];
1014 list[pos] = tmp; 1014 list[pos] = tmp;
1015 } 1015 }
1016 } 1016 }
1017 1017
1018 static int indexOfList(List list, var element, int start) { 1018 static int indexOfList(List list, var element, int start) {
1019 return Arrays.indexOf(list, element, start, list.length); 1019 return Lists.indexOf(list, element, start, list.length);
1020 } 1020 }
1021 1021
1022 static int lastIndexOfList(List list, var element, int start) { 1022 static int lastIndexOfList(List list, var element, int start) {
1023 if (start == null) start = list.length - 1; 1023 if (start == null) start = list.length - 1;
1024 return Arrays.lastIndexOf(list, element, start); 1024 return Lists.lastIndexOf(list, element, start);
1025 } 1025 }
1026 1026
1027 static void _rangeCheck(List list, int start, int end) { 1027 static void _rangeCheck(List list, int start, int end) {
1028 if (start < 0 || start > list.length) { 1028 if (start < 0 || start > list.length) {
1029 throw new RangeError.range(start, 0, list.length); 1029 throw new RangeError.range(start, 0, list.length);
1030 } 1030 }
1031 if (end < start || end > list.length) { 1031 if (end < start || end > list.length) {
1032 throw new RangeError.range(end, start, list.length); 1032 throw new RangeError.range(end, start, list.length);
1033 } 1033 }
1034 } 1034 }
(...skipping 18 matching lines...) Expand all
1053 if (from is List) { 1053 if (from is List) {
1054 otherList = from; 1054 otherList = from;
1055 otherStart = skipCount; 1055 otherStart = skipCount;
1056 } else { 1056 } else {
1057 otherList = from.skip(skipCount).toList(growable: false); 1057 otherList = from.skip(skipCount).toList(growable: false);
1058 otherStart = 0; 1058 otherStart = 0;
1059 } 1059 }
1060 if (otherStart + length > otherList.length) { 1060 if (otherStart + length > otherList.length) {
1061 throw new StateError("Not enough elements"); 1061 throw new StateError("Not enough elements");
1062 } 1062 }
1063 Arrays.copy(otherList, otherStart, list, start, length); 1063 Lists.copy(otherList, otherStart, list, start, length);
1064 } 1064 }
1065 1065
1066 static void replaceRangeList(List list, int start, int end, 1066 static void replaceRangeList(List list, int start, int end,
1067 Iterable iterable) { 1067 Iterable iterable) {
1068 _rangeCheck(list, start, end); 1068 _rangeCheck(list, start, end);
1069 if (iterable is! EfficientLength) { 1069 if (iterable is! EfficientLength) {
1070 iterable = iterable.toList(); 1070 iterable = iterable.toList();
1071 } 1071 }
1072 int removeLength = end - start; 1072 int removeLength = end - start;
1073 int insertLength = iterable.length; 1073 int insertLength = iterable.length;
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
1158 1158
1159 static Set setDifference(Set set, Set other, Set result) { 1159 static Set setDifference(Set set, Set other, Set result) {
1160 for (var element in set) { 1160 for (var element in set) {
1161 if (!other.contains(element)) { 1161 if (!other.contains(element)) {
1162 result.add(element); 1162 result.add(element);
1163 } 1163 }
1164 } 1164 }
1165 return result; 1165 return result;
1166 } 1166 }
1167 } 1167 }
OLDNEW
« no previous file with comments | « sdk/lib/_collection_dev/collection_dev_sources.gypi ('k') | sdk/lib/_collection_dev/lists.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698