MCPcopy Create free account
hub / github.com/ReadyTalk/avian / shuffle

Method shuffle

classpath/java/util/Collections.java:19–32  ·  view source on GitHub ↗
(List list, Random random)

Source from the content-addressed store, hash-verified

17 private Collections() { }
18
19 public static void shuffle(List list, Random random) {
20 Object[] array = Data.toArray(list, new Object[list.size()]);
21 for (int i = 0; i < array.length; ++i) {
22 int j = random.nextInt(array.length);
23 Object tmp = array[i];
24 array[i] = array[j];
25 array[j] = tmp;
26 }
27
28 list.clear();
29 for (int i = 0; i < array.length; ++i) {
30 list.add(array[i]);
31 }
32 }
33
34 public static void shuffle(List list) {
35 shuffle(list, new Random());

Callers

nothing calls this directly

Calls 5

toArrayMethod · 0.95
nextIntMethod · 0.80
sizeMethod · 0.65
clearMethod · 0.65
addMethod · 0.65

Tested by

no test coverage detected