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 vs. the global index (for iterating over the bytes contained in the list) run in opposing directions!
The toBitStringView 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 memDumpView.
Implements Iterable over bits. Use bytes to iterate over bytes
Constructors
Properties
Functions
Iterates over each bit in the BitSet and invokes the provided action for every index and corresponding bit value.
Returns a binary representation of this bit set's memory layout, when packed into a byte array Bytes are separated by a single space. An empty byte array results in an empty string.
Returns the first bit set to true from fromIndex (= inclusive).
Returns the first bit set to true after index (= exclusive).
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