nextRange for floats

This commit is contained in:
DBotThePony 2024-08-10 19:07:45 +07:00
parent 900ce863ae
commit f77cf29567
Signed by: DBot
GPG Key ID: DCC23B5715498507

View File

@ -5,6 +5,7 @@ import com.google.gson.JsonElement
import it.unimi.dsi.fastutil.bytes.ByteConsumer
import org.classdump.luna.ByteString
import ru.dbotthepony.kommons.util.IStruct2d
import ru.dbotthepony.kommons.util.IStruct2f
import ru.dbotthepony.kommons.util.IStruct2i
import ru.dbotthepony.kommons.util.XXHash32
import ru.dbotthepony.kommons.util.XXHash64
@ -263,6 +264,10 @@ fun RandomGenerator.nextRange(range: IStruct2d): Double {
return if (range.component1() == range.component2()) return range.component1() else nextDouble(range.component1(), range.component2())
}
fun RandomGenerator.nextRange(range: IStruct2f): Float {
return if (range.component1() == range.component2()) return range.component1() else nextFloat(range.component1(), range.component2())
}
fun <T> MutableList<T>.shuffle(random: RandomGenerator) {
for (i in 0 until size) {
val rand = random.nextInt(size)