Crater Container Library 0.2.0
|
|
Function table for bit vector. More...
Data Fields | |
cr8r_base_ft | base |
Base function table values (data and size). More... | |
uint64_t(* | new_size )(cr8r_base_ft *, uint64_t cap) |
determines the capacity to grow to if the bit vector is full but needs to have additional elements added. More... | |
void *(* | resize )(cr8r_base_ft *, void *p, uint64_t cap) |
resize the backing array to a new size, possibly copying it to a new buffer. More... | |
Function table for bit vector.
Imagine this struct as the class of the bit vector. This struct specifies how to perform necessary operations (allocation, etc). Remember that function tables must be initialized manually.
cr8r_base_ft cr8r_bvec_ft::base |
Base function table values (data and size).
Note that the bit vector will always use uint64_t's regardless of what base.size is set to, so base.size can only potentially affect new_size and resize. If using general purpose functions like cr8r_default_resize, base.size should be set to sizeof(uint64_t).
uint64_t(* cr8r_bvec_ft::new_size) (cr8r_base_ft *, uint64_t cap) |
determines the capacity to grow to if the bit vector is full but needs to have additional elements added.
Both "cap" and the return value are counted in terms of number of uint64_t's, not number of bytes or bits. cr8r_default_new_size is a good choice generally.
void*(* cr8r_bvec_ft::resize) (cr8r_base_ft *, void *p, uint64_t cap) |
resize the backing array to a new size, possibly copying it to a new buffer.
"cap" is counted in terms of number of uint64_t's, not number of bytes or bits. Must return NULL and "free" buf if the new cap is 0, must "free" NULL (by doing nothing), and must be able to allocate a new buffer if the current buffer is NULL. cr8r_default_resize wraps realloc and free to do this. If it is not possible to safely move elements, then this function should probably not be allowed to move the allocated buffer (in the manner realloc does) and should fail instead so that external logic can manage copying to a new vector.