Fixes the pseudo code

This commit is contained in:
Vitor Pamplona 2024-09-13 15:10:28 -04:00
parent 3c7429b665
commit 36f9a2e58f

6
76.md
View File

@ -61,11 +61,13 @@ class BloomFilter(size: Int, rounds: Int, buffer: ByteArray) {
return true return true
} }
fun encode() = size + ":" + rounds + ":" + base64Enc(bits.toByteArray()) // base64 might include extra 0 bits to fill the last byte fun encode() {
return size + ":" + rounds + ":" + base64Encode(bits.toByteArray())
}
fun decode(str: String): BloomFilter { fun decode(str: String): BloomFilter {
val parts = str.split(":") val parts = str.split(":")
return BloomFilter(parts[0].toInt(), parts[1].toInt(), base64Decode(bits.toByteArray())) return BloomFilter(parts[0].toInt(), parts[1].toInt(), base64Decode(parts[2]))
} }
} }
``` ```