#include <Array.hh>
Inheritance diagram for bit::Array:
Public Member Functions | |
Array () | |
Construct an empty array with zero bit-width. | |
Array (u64 num_elems, unsigned int bits_per_elem) | |
Create an array with initial size. | |
u64 | num_elems () const |
Return the number of elements in the array. | |
unsigned int | bits_per_elem () const |
Return the width of the array, i.e. | |
u64 | capacity () const |
Return the number of elements allocated for the underlying buffer. | |
void | resize (u64 num_elems) |
Change the number of elements in the array. | |
void | reserve (u64 capacity) |
Change the capacity (number of allocated elements) of the array. | |
void | set_width (unsigned int bits_per_elem) |
Change the width of the elements to given width. | |
void | set (u64 elem, u32 value) |
Set the value of an element. | |
void | set_grow (u64 elem, u32 value) |
Set the value of an element growing the buffer if necessary. | |
void | set_grow_widen (u64 elem, u32 value) |
Set the value of an element growing and widening the buffer if necessary. | |
u32 | get (u64 elem) const |
Return value of an element. | |
const unsigned char * | data () const |
Const access the internal data buffer. | |
unsigned char * | data () |
Access the internal data buffer. | |
u64 | data_len () const |
Return the safe access length of the internal data buffer obtained with data() (i.e. | |
void | write (FILE *file) const |
Write the array in file. | |
void | read (FILE *file) |
Read the array from file. | |
Static Public Attributes | |
static const u64 | index_limit = (u64)-1 |
A limit index value used for return values. | |
Private Attributes | |
unsigned int | m_bits_per_elem |
Bits reserved for each element in the array. | |
u64 | m_num_elems |
Number of elements in the array. | |
u64 | m_capacity |
Number of elements allocated for the underlying buffer. | |
Buffer | m_buffer |
Buffer containing the array elements. |
|
Construct an empty array with zero bit-width.
|
|
Create an array with initial size. The initial elements are guaranteed to be zero.
|
|
Return the width of the array, i.e. the number of bits allocated for each element. |
|
Return the number of elements allocated for the underlying buffer.
|
|
Access the internal data buffer. It is safe to write and read the first data_len() bytes of the pointer. Note that set_grow(), set_grow_widen(), set_width(), resize() and reserve() may invalidate the pointer. |
|
Const access the internal data buffer. It is safe to write and read the first data_len() bytes of the pointer. Note that set_grow(), set_grow_widen(), set_width(), resize() and reserve() may invalidate the pointer. |
|
Return the safe access length of the internal data buffer obtained with data() (i.e. minimum number of bytes needed to store the elements of the array. |
|
Return value of an element.
Reimplemented in bit::FloatArray. |
|
Return the number of elements in the array.
|
|
Read the array from file. Note that capacity is not stored in the file. The capacity is set to number of elements stored in the file.
Reimplemented in bit::FloatArray. |
|
Change the capacity (number of allocated elements) of the array. Making the capacity smaller does nothing.
|
|
Change the number of elements in the array. The values of the possible new elements are guaranteed to be zero ONLY if the array has never been resized smaller.
|
|
Set the value of an element.
|
|
Set the value of an element growing the buffer if necessary. If the current capacity is not enough, the capacity is doubled (set to one from zero), and if that is not enough, the capacity is set to (elem+1).
|
|
Set the value of an element growing and widening the buffer if necessary. See set_grow() for info how capacity is handled and warnings about exceptions.
|
|
Change the width of the elements to given width. All elements must fit in the given width or bit::invalid_argument will be thrown and the array is guaranteed to be left in the original state.
|
|
Write the array in file. Note that capacity is not written into the file. When the array is read, the capacity is set to number of elements.
Reimplemented in bit::FloatArray. |
|
A limit index value used for return values. All real indices must be less than this value. |
|
Bits reserved for each element in the array.
|
|
Buffer containing the array elements.
|
|
Number of elements allocated for the underlying buffer. When values are written outside the buffer with set_grow() method, the size of the underlying buffer is doubled. |
|
Number of elements in the array.
|