BitPacker
struct BitPackerPacks values of a fixed bit width, least-significant bit first.
Bits go into a 64-bit accumulator and leave it eight at a time, so a value costs a shift, an or and at most a few byte stores — not a loop over its bits with a bounds-checked list grow inside it.
Implements Copyable, Defaultable, Movable
- Fields
out: List[UInt8]acc: UInt64bits: Int
__init__
def __init__(out self) reserve
def reserve(mut self, count: Int, width: Int) put
def put(mut self, value: UInt64, width: Int) align
def align(mut self)