Test: complete send chat message without signature
This commit is contained in:
6 files changed
+118
-7
No files matched your search
@@ -33,3 +33,32 @@ public fun BitSet.getBit(bitIndex: Int): Boolean {
|
||||
val bitOffset = bitIndex and 63
|
||||
return (this[longIndex] and (1L shl bitOffset)) != 0L
|
||||
}
|
||||
|
||||
public class FixedBitSet20(initialBits: Int = 0) {
|
||||
private var bits: Int = initialBits and 0xFFFFF
|
||||
|
||||
public operator fun get(index: Int): Boolean {
|
||||
require(index in 0..19) { "Index out of range [0, 19]" }
|
||||
return (bits and (1 shl index)) != 0
|
||||
}
|
||||
|
||||
public operator fun set(index: Int, value: Boolean) {
|
||||
require(index in 0..19) { "Index out of range [0, 19]" }
|
||||
bits = if (value) {
|
||||
bits or (1 shl index)
|
||||
} else {
|
||||
bits and (1 shl index).inv()
|
||||
}
|
||||
}
|
||||
|
||||
public fun toByteArray(): ByteArray {
|
||||
val result = ByteArray(3)
|
||||
result[0] = (bits and 0xFF).toByte()
|
||||
result[1] = ((bits shr 8) and 0xFF).toByte()
|
||||
result[2] = ((bits shr 16) and 0x0F).toByte()
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
public fun createFixedBitSet20(initialBits: Int = 0): FixedBitSet20 =
|
||||
FixedBitSet20(initialBits)
|
||||
Reference in New Issue
Block a user