(@NotNull List<T> list)
| 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(); |