BitStream

data class BitStream(bytes: List<Byte>, offstart: Int, offend: Int)

Bit stream that can be written to and read at both ends (i.e. you can read from the end or the beginning of the stream)

TODO: either merge this with Bitfield or find a way to use Bech32 methods instead

Parameters

bytes

bits packed as bytes, the last byte is padded with 0s

offstart

offset at which the first bit is in the first byte

offend

offset at which the last bit is in the last byte

Constructors

BitStream
Link copied to clipboard
common
fun BitStream()
BitStream
Link copied to clipboard
common
fun BitStream(bytes: List<Byte>, offstart: Int, offend: Int)

Functions

bitCount
Link copied to clipboard
common
fun bitCount(): Int
clone
Link copied to clipboard
common
fun clone(): BitStream
firstBit
Link copied to clipboard
common
fun firstBit(): Boolean
getBytes
Link copied to clipboard
common
fun getBytes(): ByteArray
isEmpty
Link copied to clipboard
common
fun isEmpty(): Boolean
isSet
Link copied to clipboard
common
fun isSet(pos: Int): Boolean
lastBit
Link copied to clipboard
common
fun lastBit(): Boolean
popBit
Link copied to clipboard
common
fun popBit(): Boolean

read the last bit from a bitstream

popByte
Link copied to clipboard
common
fun popByte(): Byte

read the last byte from a bitstream

popBytes
Link copied to clipboard
common
fun popBytes(n: Int): List<Byte>
readBit
Link copied to clipboard
common
fun readBit(): Boolean

read the first bit from a bitstream

readBits
Link copied to clipboard
common
fun readBits(count: Int): List<Boolean>
readByte
Link copied to clipboard
common
fun readByte(): Byte

read the first byte from a bitstream

writeBit
Link copied to clipboard
common
fun writeBit(bit: Boolean)

append a bit to a bistream

writeBits
Link copied to clipboard
common
fun writeBits(input: List<Boolean>)

append bits to a bistream

writeByte
Link copied to clipboard
common
fun writeByte(input: Byte)

append a byte to a bitstream

writeBytes
Link copied to clipboard
common
fun writeBytes(input: List<Byte>)

append bytes to a bitstream