|
Reduct
v1.0.4-3-gdaf0d70
A functional and immutable language.
|
List management. More...
#include "defs.h"Go to the source code of this file.
Data Structures | |
| struct | reduct_list_node_t |
| List node structure. More... | |
| struct | reduct_list_t |
| List structure. More... | |
| struct | reduct_list_iter_t |
| List iterator structure. More... | |
Macros | |
| #define | REDUCT_LIST_BITS 2 |
| Number of bits per level in the trie. | |
| #define | REDUCT_LIST_WIDTH (1 << REDUCT_LIST_BITS) |
| The number of children per node. | |
| #define | REDUCT_LIST_MASK (REDUCT_LIST_WIDTH - 1) |
| Mask for the index at each level. | |
| #define | REDUCT_LIST_TAIL_OFFSET(_list) (((_list)->length > 0) ? (((_list)->length - 1) & ~REDUCT_LIST_MASK) : 0) |
| Calculate the offset of the tail node. | |
| #define | REDUCT_LIST_ITER(_list) {(_list), 0, REDUCT_NULL, REDUCT_LIST_TAIL_OFFSET(_list)} |
| Create a initializer for a list iterator. | |
| #define | REDUCT_LIST_ITER_AT(_list, _start) {(_list), (_start), REDUCT_NULL, REDUCT_LIST_TAIL_OFFSET(_list)} |
| Create a initializer for a list iterator start at a specific index. | |
| #define | REDUCT_LIST_FOR_EACH(_handle, _list) for (reduct_list_iter_t _iter = REDUCT_LIST_ITER(_list); reduct_list_iter_next(&_iter, (_handle));) |
| Macro for iterating over all elements in a list. | |
| #define | REDUCT_LIST_FOR_EACH_AT(_handle, _list, _start) for (reduct_list_iter_t _iter = REDUCT_LIST_ITER_AT(_list, _start); reduct_list_iter_next(&_iter, (_handle));) |
| Macro for iterating over elements in a list starting from a specific index. | |
Functions | |
| REDUCT_API reduct_list_t * | reduct_list_new (struct reduct *reduct) |
| Create a new editable list. | |
| 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_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_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 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 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_API void | reduct_list_append (struct reduct *reduct, reduct_list_t *list, reduct_handle_t val) |
| Append an element to the list. | |
| 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_bool_t | reduct_list_iter_next (reduct_list_iter_t *iter, reduct_handle_t *out) |
| Get the next element from the iterator. | |
List management.
Definition in file list.h.
| #define REDUCT_LIST_BITS 2 |
| #define REDUCT_LIST_WIDTH (1 << REDUCT_LIST_BITS) |
| #define REDUCT_LIST_MASK (REDUCT_LIST_WIDTH - 1) |
| #define REDUCT_LIST_TAIL_OFFSET | ( | _list | ) | (((_list)->length > 0) ? (((_list)->length - 1) & ~REDUCT_LIST_MASK) : 0) |
| #define REDUCT_LIST_ITER | ( | _list | ) | {(_list), 0, REDUCT_NULL, REDUCT_LIST_TAIL_OFFSET(_list)} |
| #define REDUCT_LIST_ITER_AT | ( | _list, | |
| _start | |||
| ) | {(_list), (_start), REDUCT_NULL, REDUCT_LIST_TAIL_OFFSET(_list)} |
| #define REDUCT_LIST_FOR_EACH | ( | _handle, | |
| _list | |||
| ) | for (reduct_list_iter_t _iter = REDUCT_LIST_ITER(_list); reduct_list_iter_next(&_iter, (_handle));) |
Macro for iterating over all elements in a list.
| _handle | The reduct_handle_t variable to store each element. |
| _list | Pointer to the reduct_list_t to iterate. |
| #define REDUCT_LIST_FOR_EACH_AT | ( | _handle, | |
| _list, | |||
| _start | |||
| ) | for (reduct_list_iter_t _iter = REDUCT_LIST_ITER_AT(_list, _start); reduct_list_iter_next(&_iter, (_handle));) |
Macro for iterating over elements in a list starting from a specific index.
| _handle | The reduct_handle_t variable to store each element. |
| _list | Pointer to the reduct_list_t to iterate. |
| _start | The starting index. |
| REDUCT_API reduct_list_t * reduct_list_new | ( | struct reduct * | reduct | ) |
Create a new editable list.
| reduct | Pointer to the Reduct structure. |
| 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 | Pointer to the Reduct structure. |
| list | Pointer to the source list. |
| index | The index to update. |
| val | The new value to set. |
Definition at line 74 of file list_impl.h.
| 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 | Pointer to the Reduct structure. |
| list | Pointer to the source list. |
| index | The index of the element to remove. |
Definition at line 106 of file list_impl.h.
| 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 | Pointer to the Reduct structure. |
| list | Pointer to the source list. |
| start | The starting index (inclusive). |
| end | The ending index (exclusive). |
Definition at line 131 of file list_impl.h.
| 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 | Pointer to the Reduct structure. |
| list | Pointer to the list. |
| index | The index of the element to retrieve. |
Definition at line 157 of file list_impl.h.
| 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 | Pointer to the Reduct structure. |
| list | Pointer to the list. |
| index | The index of the element to retrieve. |
Definition at line 172 of file list_impl.h.
| REDUCT_API void reduct_list_append | ( | struct reduct * | reduct, |
| reduct_list_t * | list, | ||
| reduct_handle_t | val | ||
| ) |
Append an element to the list.
| reduct | Pointer to the Reduct structure. |
| list | The target list (must be editable). |
| val | Handle to the value to append. |
| 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 | Pointer to the Reduct structure. |
| list | The target list (must be editable). |
| other | The source list to copy from. |
| 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.
| iter | Pointer to the iterator. |
| out | Pointer to store the retrieved handle. |
Definition at line 255 of file list_impl.h.