1#ifndef REDUCT_LIST_IMPL_H
2#define REDUCT_LIST_IMPL_H 1
91 if (index >= tailOffset)
122 if (_iter.index - 1 != index)
146 while (iter.
index < end)
210 list->
root = fullTail;
220 list->
root = newRoot;
Core definitions and structures.
#define REDUCT_LIKELY(_x)
#define REDUCT_UNLIKELY(_x)
reduct_bool_t
Boolean type.
#define REDUCT_MEMCPY(_dest, _src, _size)
reduct_uint64_t reduct_handle_t
Handle type.
#define REDUCT_ASSERT(_cond)
#define REDUCT_ERROR_RUNTIME(_reduct,...)
Throw a runtime error using the jump buffer in the error structure.
#define REDUCT_HANDLE_TO_ITEM(_handle)
Get the item pointer of a handle.
REDUCT_API void reduct_handle_ensure_item(struct reduct *reduct, reduct_handle_t *handle)
Ensure that a handle is an item handle.
#define REDUCT_ITEM_TYPE_LIST
A list.
REDUCT_API reduct_item_t * reduct_item_new(struct reduct *reduct)
Allocate a new Reduct item.
#define REDUCT_ITEM_TYPE_LIST_NODE
A list node.
#define REDUCT_LIST_ITER_AT(_list, _start)
Create a initializer for a list iterator start at a specific index.
#define REDUCT_LIST_BITS
Number of bits per level in the trie.
#define REDUCT_LIST_WIDTH
The number of children per node.
#define REDUCT_LIST_TAIL_OFFSET(_list)
Calculate the offset of the tail node.
#define REDUCT_LIST_FOR_EACH(_handle, _list)
Macro for iterating over all elements in a list.
#define REDUCT_LIST_MASK
Mask for the index at each level.
static reduct_list_node_t * reduct_push_tail(reduct_t *reduct, reduct_uint32_t shift, reduct_size_t index, reduct_list_node_t *parent, reduct_list_node_t *tailNode)
static reduct_list_node_t * reduct_list_assoc_internal(reduct_t *reduct, reduct_uint32_t shift, reduct_list_node_t *node, reduct_size_t index, reduct_handle_t val)
static reduct_list_node_t * reduct_list_node_new(struct reduct *reduct)
REDUCT_API reduct_handle_t reduct_list_nth(struct reduct *reduct, reduct_list_t *list, reduct_size_t index)
Get the nth element of the list.
REDUCT_API reduct_list_t * reduct_list_dissoc(struct reduct *reduct, reduct_list_t *list, reduct_size_t index)
Create a new list with the element at the specified index removed.
REDUCT_API void reduct_list_append_list(reduct_t *reduct, reduct_list_t *list, reduct_list_t *other)
REDUCT_API reduct_list_t * reduct_list_assoc(struct reduct *reduct, reduct_list_t *list, reduct_size_t index, reduct_handle_t val)
Create a new list with an updated value at the specified index.
REDUCT_API void reduct_list_append(reduct_t *reduct, reduct_list_t *list, reduct_handle_t val)
static reduct_list_node_t * reduct_list_find_leaf(reduct_list_t *list, reduct_size_t index, reduct_size_t tailOffset)
REDUCT_API reduct_list_t * reduct_list_slice(struct reduct *reduct, reduct_list_t *list, reduct_size_t start, reduct_size_t end)
Create a new list by slicing an existing list.
static reduct_list_node_t * reduct_list_node_copy(reduct_t *reduct, reduct_list_node_t *node)
REDUCT_API reduct_bool_t reduct_list_iter_next(reduct_list_iter_t *iter, reduct_handle_t *out)
Get the next element from the iterator.
REDUCT_API reduct_list_t * reduct_list_new(reduct_t *reduct)
REDUCT_API struct reduct_item * reduct_list_nth_item(struct reduct *reduct, reduct_list_t *list, reduct_size_t index)
Get the nth element of the list as an item.
reduct_list_t list
A list.
reduct_list_node_t node
A list node.
reduct_item_type_t type
The type of the item.
reduct_list_node_t * leaf
reduct_handle_t handles[REDUCT_LIST_WIDTH]
struct reduct_list_node * children[REDUCT_LIST_WIDTH]
reduct_list_node_t * tail
Pointer to the tail node.
reduct_list_node_t * root
Pointer to the trie root node.
reduct_uint32_t shift
The amount to shift the index to compute access paths.
reduct_uint32_t length
Total number of elements.