MCPcopy Create free account
hub / github.com/e2wugui/zeze / shuffle

Method shuffle

ZezeJava/ZezeJava/src/main/java/Zeze/Util/Random.java:23–32  ·  view source on GitHub ↗
(@NotNull List<T> list)

Source from the content-addressed store, hash-verified

21 }
22
23 public static <T> @NotNull List<T> shuffle(@NotNull List<T> list) {
24 var random = getInstance();
25 for (int i = 1, n = list.size(); i < n; i++) {
26 int pos = random.nextInt(i + 1);
27 var x = list.get(i);
28 list.set(i, list.get(pos));
29 list.set(pos, x);
30 }
31 return list;
32 }
33
34 public static <T> T @NotNull [] shuffle(T @NotNull [] list) {
35 var random = getInstance();

Callers 4

ShuffleGlobalRaftMethod · 0.95
testMethod · 0.95
shuffleRaftsMethod · 0.95
notifyOfflineMethod · 0.95

Calls 5

getInstanceMethod · 0.95
sizeMethod · 0.65
getMethod · 0.65
nextIntMethod · 0.45
setMethod · 0.45

Tested by 3

ShuffleGlobalRaftMethod · 0.76
testMethod · 0.76
shuffleRaftsMethod · 0.76