implement optimizations

This commit is contained in:
2026-01-30 13:41:43 +01:00
parent 7144c21074
commit 0f890c923c
10 changed files with 99 additions and 168 deletions

View File

@@ -0,0 +1,16 @@
package com.infendro.random
import kotlin.random.Random
abstract class PRNG : Random() {
abstract fun seed(seed: ByteArray)
protected abstract fun generate(): Int
override fun nextBits(bitCount: Int): Int {
require(bitCount in 0..32)
if (bitCount == 0) return 0
return generate() ushr (32 - bitCount)
}
}