![]() |
NDEVR
API Documentation
|
A buffer that stores elements using a configurable number of bits per element. More...
Public Member Functions | |
| BitAlignedBuffer (uint04 bits_per_element) | |
| Constructs a BitAlignedBuffer with the specified number of bits per element. | |
| void | add (uint08 value) |
| Appends a value to the end of the buffer. | |
| uint04 | bitSize () const |
| Returns the number of bits used per element. | |
| void | clear () |
| Removes all elements and frees storage. | |
| void | ensureCapacity (uint04 newSize) |
| Ensures the internal storage can hold at least the specified number of elements. | |
| uint08 | getValueAtBitOffset (uint04 bit_pos) const |
| Retrieves the value stored at a specific bit offset within the buffer. | |
| void | loadFromBytes (const uint8_t *data, uint04 byteCount) |
| Loads raw byte data into the buffer, replacing existing contents. | |
| uint08 | operator[] (uint04 index) const |
| Accesses the element at the given index (read-only). | |
| void | set (uint04 index, uint08 value) |
| Sets the value of the element at the given index. | |
| void | setSize (uint04 size) |
| Sets the number of elements in the buffer, allocating storage as needed. | |
| uint04 | size () const |
| Returns the number of elements currently stored in the buffer. | |
A buffer that stores elements using a configurable number of bits per element.
Provides a compact storage mechanism where each element occupies a fixed number of bits (less than 64), packed tightly into 64-bit words. Handles bit alignment and word boundary spillover automatically.
Definition at line 13 of file BitAlignedBuffer.h.
|
inline |
Constructs a BitAlignedBuffer with the specified number of bits per element.
| [in] | bits_per_element | The number of bits used to store each element. Must be > 0 and < 64. |
Definition at line 20 of file BitAlignedBuffer.h.
|
inline |
Appends a value to the end of the buffer.
| [in] | value | The value to append. Must fit within the configured bits per element. |
Definition at line 63 of file BitAlignedBuffer.h.
References ensureCapacity().
|
inline |
Returns the number of bits used per element.
Definition at line 158 of file BitAlignedBuffer.h.
|
inline |
Ensures the internal storage can hold at least the specified number of elements.
| [in] | newSize | The minimum number of elements the buffer should be able to hold. |
Definition at line 174 of file BitAlignedBuffer.h.
Retrieves the value stored at a specific bit offset within the buffer.
| [in] | bit_pos | The bit position from which to read the value. |
Definition at line 91 of file BitAlignedBuffer.h.
Referenced by operator[]().
|
inline |
Loads raw byte data into the buffer, replacing existing contents.
| [in] | data | Pointer to the source byte array. |
| [in] | byteCount | The number of bytes to load from the source array. |
Definition at line 39 of file BitAlignedBuffer.h.
Accesses the element at the given index (read-only).
| [in] | index | The zero-based element index. |
Definition at line 122 of file BitAlignedBuffer.h.
References getValueAtBitOffset().
Sets the value of the element at the given index.
| [in] | index | The zero-based element index. |
| [in] | value | The value to store. Must fit within the configured bits per element. |
Definition at line 133 of file BitAlignedBuffer.h.
|
inline |
Sets the number of elements in the buffer, allocating storage as needed.
| [in] | size | The desired number of elements. |
Definition at line 29 of file BitAlignedBuffer.h.
References ensureCapacity(), and size().
|
inline |
Returns the number of elements currently stored in the buffer.
Definition at line 166 of file BitAlignedBuffer.h.
Referenced by setSize().