| 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._collection.dev; | 5 part of dart._collection.dev; |
| 6 | 6 |
| 7 | 7 |
| 8 // This is a hack to make @deprecated work in dart:io. Don't remove or use this, | 8 // This is a hack to make @deprecated work in dart:io. Don't remove or use this, |
| 9 // unless coordinated with either me or the core library team. Thanks! | 9 // unless coordinated with either me or the core library team. Thanks! |
| 10 // TODO(ajohnsen): Remove at the 11th of August 2013. | 10 // TODO(ajohnsen): Remove at the 11th of August 2013. |
| (...skipping 940 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 951 | 951 |
| 952 static Iterable reversedList(List list) { | 952 static Iterable reversedList(List list) { |
| 953 return new ReversedListIterable(list); | 953 return new ReversedListIterable(list); |
| 954 } | 954 } |
| 955 | 955 |
| 956 static void sortList(List list, int compare(a, b)) { | 956 static void sortList(List list, int compare(a, b)) { |
| 957 if (compare == null) compare = Comparable.compare; | 957 if (compare == null) compare = Comparable.compare; |
| 958 Sort.sort(list, compare); | 958 Sort.sort(list, compare); |
| 959 } | 959 } |
| 960 | 960 |
| 961 static void shuffleList(List list) { | 961 static void shuffleList(List list, Random random) { |
| 962 Random random = new Random(); | 962 if (random == null) random = new Random(); |
| 963 int length = list.length; | 963 int length = list.length; |
| 964 while (length > 1) { | 964 while (length > 1) { |
| 965 int pos = random.nextInt(length); | 965 int pos = random.nextInt(length); |
| 966 length -= 1; | 966 length -= 1; |
| 967 var tmp = list[length]; | 967 var tmp = list[length]; |
| 968 list[length] = list[pos]; | 968 list[length] = list[pos]; |
| 969 list[pos] = tmp; | 969 list[pos] = tmp; |
| 970 } | 970 } |
| 971 } | 971 } |
| 972 | 972 |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1094 | 1094 |
| 1095 static Set setDifference(Set set, Set other, Set result) { | 1095 static Set setDifference(Set set, Set other, Set result) { |
| 1096 for (var element in set) { | 1096 for (var element in set) { |
| 1097 if (!other.contains(element)) { | 1097 if (!other.contains(element)) { |
| 1098 result.add(element); | 1098 result.add(element); |
| 1099 } | 1099 } |
| 1100 } | 1100 } |
| 1101 return result; | 1101 return result; |
| 1102 } | 1102 } |
| 1103 } | 1103 } |
| OLD | NEW |