27#define REDUCT_LIST_BITS 2
28#define REDUCT_LIST_WIDTH (1 << REDUCT_LIST_BITS)
29#define REDUCT_LIST_MASK (REDUCT_LIST_WIDTH - 1)
35typedef struct reduct_list_node
47typedef struct reduct_list
138typedef struct reduct_list_iter
149#define REDUCT_LIST_TAIL_OFFSET(_list) (((_list)->length > 0) ? (((_list)->length - 1) & ~REDUCT_LIST_MASK) : 0)
156#define REDUCT_LIST_ITER(_list) {(_list), 0, REDUCT_NULL, REDUCT_LIST_TAIL_OFFSET(_list)}
164#define REDUCT_LIST_ITER_AT(_list, _start) {(_list), (_start), REDUCT_NULL, REDUCT_LIST_TAIL_OFFSET(_list)}
181#define REDUCT_LIST_FOR_EACH(_handle, _list) \
182 for (reduct_list_iter_t _iter = REDUCT_LIST_ITER(_list); reduct_list_iter_next(&_iter, (_handle));)
191#define REDUCT_LIST_FOR_EACH_AT(_handle, _list, _start) \
192 for (reduct_list_iter_t _iter = REDUCT_LIST_ITER_AT(_list, _start); reduct_list_iter_next(&_iter, (_handle));)
reduct_bool_t
Boolean type.
reduct_uint64_t reduct_handle_t
Handle type.
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 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 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.
REDUCT_API void reduct_list_append(struct reduct *reduct, reduct_list_t *list, reduct_handle_t val)
Append an element to the list.
#define REDUCT_LIST_WIDTH
The number of children per 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 void reduct_list_append_list(struct reduct *reduct, reduct_list_t *list, reduct_list_t *other)
Append all elements from one list to another.
REDUCT_API reduct_list_t * reduct_list_new(struct reduct *reduct)
Create a new editable list.
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_node_t * leaf
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.