fix hash map (-> 0.19)

This commit is contained in:
alex_s168
2024-07-30 20:02:48 +00:00
parent 8439df8ae5
commit aca62fd413
3 changed files with 5 additions and 3 deletions

View File

@@ -1,5 +1,7 @@
package blitz.collections
import kotlin.math.abs
class BlitzHashMap<K, V>(
private val bucketCount: Int = 16,
private val bucketSrc: DynBuckets<K, V>,
@@ -8,7 +10,7 @@ class BlitzHashMap<K, V>(
private val buckets = Array(bucketCount) { bucketSrc.new() }
override fun index(key: K): Index<K,V> =
IndexImpl(buckets[hash(key) % bucketCount], key)
IndexImpl(buckets[abs(hash(key)) % bucketCount], key)
private inline fun index(idx: Index<K,V>) =
idx as IndexImpl