cr8r_bvec_ft Struct Reference

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...
 

Detailed Description

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.

Definition at line 36 of file bitvec.h.

Field Documentation

◆ base

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).

Definition at line 41 of file bitvec.h.

◆ new_size

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.

Definition at line 45 of file bitvec.h.

◆ resize

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.

Definition at line 52 of file bitvec.h.


The documentation for this struct was generated from the following file: