A Buffer for bit-level and byte-level manipulation.
public func bitSize() : NatReturns the number of bits in the buffer
public func bitCapacity() : NatReturns the max number of bits the buffer can hold without resizing
public func byteSize() : NatReturns the number of bytes in the buffer
public func byteCapacity() : NatReturns the max number of bytes the buffer can hold without resizing
public func bitcount(bit : Bool) : NatReturns the number of bits that match the given bit
public func addBit(bit : Bool)Adds a single bit to the bitbuffer
public func addBits(n : Nat, bits : Nat)Adds the given bits to the bitbuffer
public func getBit(i : Nat) : BoolReturns the bit at the given index as a Bool
public func getBits(i : Nat, n : Nat) : NatReturns the bits at the given index as a Nat
public func dropBit()Drops the first bit from the buffer.
public func dropBits(n : Nat)Drops the first n bits from the bitbuffer.
Trap if n is greater than the number of bits in the bitbuffer.
public func invert()Flips all the bits in the buffer
public func clear()public func bits() : Iter<Bool>Returns an iterator over the bits in the buffer
public func bytes() : Iter<Nat8>Returns an iterator over the bytes in the buffer
public func byteAlign()Aligns the buffer to the next byte boundary
public func new() : BitBufferInitializes an empty bitbuffer
public func withByteCapacity(byte_capacity : Nat) : BitBufferInitializes a bitbuffer with the given byte capacity
public func init(bit_capacity : Nat, ones : Bool) : BitBufferInitializes a bitbuffer with bit_capacity bits and fills it with ones if true or zeros if false.
public func tabulate(bit_capacity : Nat, f : (Nat) -> Bool) : BitBufferInitializes a bitbuffer with bit_capacity bits and fills it with the bits returned by the function f.
public func isByteAligned(bitbuffer : BitBuffer) : BoolChecks if the bits in the buffer are byte aligned
public func bitcountNonZero(bitbuffer : BitBuffer) : NatReturns the number of bits that are set to true or 1 in the buffer
public func addByte(bitbuffer : BitBuffer, byte : Nat8)public func getByte(bitbuffer : BitBuffer, bit_index : Nat) : Nat8public func dropByte(bitbuffer : BitBuffer)public func fromBytes(bytes : [Nat8]) : BitBufferpublic func addBytes(bitbuffer : BitBuffer, bytes : [Nat8])public func getBytes(
bitbuffer : BitBuffer,
bit_index : Nat,
n : Nat
) : [Nat8]public func dropBytes(bitbuffer : BitBuffer, n : Nat)public func addNat8(bitbuffer : BitBuffer, nat8 : Nat8)public func getNat8(bitbuffer : BitBuffer, bit_index : Nat) : Nat8public func dropNat8(bitbuffer : BitBuffer)public func addNat16(bitbuffer : BitBuffer, nat16 : Nat16)public func getNat16(bitbuffer : BitBuffer, bit_index : Nat) : Nat16public func dropNat16(bitbuffer : BitBuffer)public func addNat32(bitbuffer : BitBuffer, nat32 : Nat32)public func getNat32(bitbuffer : BitBuffer, bit_index : Nat) : Nat32public func dropNat32(bitbuffer : BitBuffer)public func addNat64(bitbuffer : BitBuffer, nat64 : Nat64)public func getNat64(bitbuffer : BitBuffer, bit_index : Nat) : Nat64public func dropNat64(bitbuffer : BitBuffer)public func addInt8(bitbuffer : BitBuffer, int8 : Int8)public func addInt16(bitbuffer : BitBuffer, int16 : Int16)public func addInt32(bitbuffer : BitBuffer, int32 : Int32)public func addInt64(bitbuffer : BitBuffer, int64 : Int64)