Skip to content

Commit

Permalink
(Quillraven#159) fixed hashcode function in bitArray
Browse files Browse the repository at this point in the history
  • Loading branch information
AnderWoche committed Oct 26, 2024
1 parent 9b584e1 commit 3ade433
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ class BitArray(

val word = length() ushr 6
var hash = 0
for (i in 0..word) {
for (i in 0..< word) {
hash = 127 * hash + (bits[i] xor (bits[i] ushr 32)).toInt()
}
return hash
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
package com.github.quillraven.fleks.collection

import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertFalse
import kotlin.test.assertTrue
import kotlin.test.*

internal class BitArrayTest {

@Test
fun testBitAt63HashcodeFunction() {
val bits = BitArray(1)
bits.set(63)
bits.hashCode()
}


@Test
fun createEmptyBitArray() {
val bits = BitArray(0)
Expand Down

0 comments on commit 3ade433

Please sign in to comment.