fix hash map (-> 0.19)
This commit is contained in:
@@ -12,7 +12,7 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation("me.alex_s168:blitz:0.17")
|
implementation("me.alex_s168:blitz:0.19")
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@@ -5,7 +5,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group = "me.alex_s168"
|
group = "me.alex_s168"
|
||||||
version = "0.18"
|
version = "0.19"
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
@@ -1,5 +1,7 @@
|
|||||||
package blitz.collections
|
package blitz.collections
|
||||||
|
|
||||||
|
import kotlin.math.abs
|
||||||
|
|
||||||
class BlitzHashMap<K, V>(
|
class BlitzHashMap<K, V>(
|
||||||
private val bucketCount: Int = 16,
|
private val bucketCount: Int = 16,
|
||||||
private val bucketSrc: DynBuckets<K, V>,
|
private val bucketSrc: DynBuckets<K, V>,
|
||||||
@@ -8,7 +10,7 @@ class BlitzHashMap<K, V>(
|
|||||||
private val buckets = Array(bucketCount) { bucketSrc.new() }
|
private val buckets = Array(bucketCount) { bucketSrc.new() }
|
||||||
|
|
||||||
override fun index(key: K): Index<K,V> =
|
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>) =
|
private inline fun index(idx: Index<K,V>) =
|
||||||
idx as IndexImpl
|
idx as IndexImpl
|
||||||
|
Reference in New Issue
Block a user