BitSet
Pure Kotlin Bit Set created by throwing a bunch of extension functions at a MutableList<Byte>
. As a mental model: this BitSet grows from left to right, just like writing a text.
Note: The in-byte bit index and the global index (for iterating over the bytes contained in the list) run in opposing directions!
The toBitString function print our the bits as they are accessible, disregarding byte-alignment and memory layout:
val bitSet = BitSet()
bitSet[0] = true //1 (ByteArray representation: [1])
bitSet[2] = true //101 (ByteArray representation: [5])
bitSet[8] = true //10100000 1 (ByteArray representation: [5,1])
To inspect the actual memory layout of the underlying bytes (i.e. the result of calling toByteArray), use memDump.
Implements Iterable over bits. Use bytes to iterate over bytes
Constructors
Properties
Functions
This is the real deal, as it has Long indices
return the next bit set to true following fromIndex
Returns all bits as they are accessible by the global bit index
Allocates a fresh byte array and writes the values of this bitset's underlying bytes to it