107#define AL_MASK (AL_BR - 1u)
116#define AL_MAX_DEPTH 11
121#define AL_MAX_ELEMENTS (((size_t)1 << (AL_SHIFT * (AL_MAX_DEPTH + 1))) + AL_BR)
128 "AL_MAX_DEPTH exceeds what size_t can address on this platform"
193[[nodiscard]] [[gnu::nonnull(1)]]
199[[nodiscard]] [[gnu::nonnull(1)]]
206[[nodiscard]] [[gnu::nonnull(1)]]
212[[nodiscard]] [[gnu::nonnull(1)]]
220[[nodiscard]] [[gnu::nonnull(1)]]
array_list_maybe_element_t array_list_get(const array_list_t *al, array_list_index_t n)
Look up the element at the given index n in the given array list al.
srn_error_t * array_list_update(array_list_t *al, array_list_index_t n, array_list_elem_t x)
Update the given index n of the array list al with the new element x.
#define AL_SHIFT
log2(AL_BR)
void * array_list_elem_t
We use generic pointers to refer to internal nodes, leaf nodes and even elements.
srn_error_t * array_list_remove(array_list_t *al, array_list_index_t n)
Remove the element at the given index n from the array list al, shifting every later element down one...
#define AL_MAX_DEPTH
Maximum trie depth, meaning the level of the root.
array_list_t array_list_empty(const srn_context_t *ctx)
Create an empty array list in the given context ctx.
srn_error_t * array_list_push(array_list_t *al, array_list_elem_t x)
Push the given element x to the end of array_list al.
size_t array_list_index_t
Error handling for the runtime.
We have two type of node that both are implemented using the same data structure.
array_list_elem_t * children
We allocate children to be a buffer of AL_BR number of pointers.
array_list_node_t * root
NULL means βall data is in tailβ
uint8_t depth
tree depth in levels (0 == leaf level)
array_list_elem_t * tail
small tail array for fast push/pop.
size_t len
logical length.
uint16_t tail_len
0..AL_BR
const srn_context_t * ctx
The context that owns every allocation the array list retains.
A runtime error, a tag classifying the failure and a human-readable message.