From b83c9edf137cb173e61de5c98f0e418fe97f95e0 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 3 Mar 2025 22:22:04 +0700 Subject: [PATCH] Delegate List.shuffle extension impl to Minecraft util --- .../kotlin/ru/dbotthepony/mc/otm/core/Ext.kt | 25 +------------------ 1 file changed, 1 insertion(+), 24 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt index 04120682f..718e617b1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt @@ -188,24 +188,6 @@ fun > T.prev(values: Array): T { return values[next] } -fun IntArray.shuffle(random: RandomGenerator) { - for (i in lastIndex downTo 1) { - val j = random.nextInt(i + 1) - val copy = this[i] - this[i] = this[j] - this[j] = copy - } -} - -fun MutableList.shuffle(random: RandomGenerator) { - for (i in lastIndex downTo 1) { - val j = random.nextInt(i + 1) - val copy = this[i] - this[i] = this[j] - this[j] = copy - } -} - fun IntArray.shuffle(random: RandomSource) { for (i in lastIndex downTo 1) { val j = random.nextInt(i + 1) @@ -216,12 +198,7 @@ fun IntArray.shuffle(random: RandomSource) { } fun MutableList.shuffle(random: RandomSource) { - for (i in lastIndex downTo 1) { - val j = random.nextInt(i + 1) - val copy = this[i] - this[i] = this[j] - this[j] = copy - } + return Util.shuffle(this, random) } fun List.random(random: RandomGenerator): T {