|
Reduct
v4.0.5-1-g4851deb
A functional and immutable language.
|
List management. More...
#include <reduct/arena.h>#include <reduct/defs.h>#include <stdatomic.h>#include <stdbool.h>#include <stddef.h>Go to the source code of this file.
Data Structures | |
| struct | reduct_list_t |
| List structure. More... | |
| struct | reduct_list_entry_t |
| A key-value pair for creating association lists. More... | |
Macros | |
| #define | REDUCT_LIST_SMALL_MAX 4 |
| The maximum number of elements in a small list. | |
| #define | REDUCT_LIST_LARGE_MIN 16 |
| The minimum number of elements in a large list. | |
| #define | REDUCT_LIST_EXTRA_ROOM_FACTOR 2 |
| The factor of extra capacity to allocate around large lists. | |
| #define | REDUCT_LIST_FLAG_NONE 0 |
| No flags. | |
| #define | REDUCT_LIST_FLAG_LARGE (1 << 0) |
| List has an allocated buffer within an arena. | |
| #define | REDUCT_LIST_FLAG_USED_HEAD (1 << 1) |
| Reserved headroom has been used by a derivative list. | |
| #define | REDUCT_LIST_FLAG_USED_TAIL (1 << 2) |
| Reserved tailroom has been used by a derivative list. | |
Typedefs | |
| typedef uint8_t | reduct_list_flags_t |
Functions | |
| REDUCT_API reduct_list_t * | reduct_list_new (struct reduct *reduct, size_t length) |
| Create a new editable list. | |
| REDUCT_API reduct_list_t * | reduct_list_new_handles (struct reduct *reduct, size_t count, reduct_handle_t *handles) |
| Create a new list from an array of handles. | |
| REDUCT_API reduct_list_t * | reduct_list_new_alist (struct reduct *reduct, size_t count,...) |
| Create a new association list (list storing key-value pairs) from a variable number of pairs. | |
| REDUCT_API reduct_list_t * | reduct_list_new_alist_entries (struct reduct *reduct, size_t count, const reduct_list_entry_t *entries) |
| Create a new association list from an array of entries. | |
| REDUCT_API reduct_list_t * | reduct_list_slice (struct reduct *reduct, reduct_list_t *list, size_t start, size_t end) |
| Create a new list by slicing an existing list. | |
| REDUCT_API reduct_list_t * | reduct_list_append (struct reduct *reduct, reduct_list_t *list, reduct_handle_t val) |
| Create a new list by appending an element to an existing list. | |
| REDUCT_API reduct_list_t * | reduct_list_prepend (struct reduct *reduct, reduct_list_t *list, reduct_handle_t val) |
| Create a new list by prepending an element to an existing list. | |
| REDUCT_API reduct_list_t * | reduct_list_concat (struct reduct *reduct, reduct_list_t *a, reduct_list_t *b) |
| Create a new list by concatenating two existing lists. | |
| REDUCT_API void | reduct_list_retain (struct reduct *reduct, reduct_list_t *list) |
| Retain a list, preventing it from being collected by the garbage collector. | |
| REDUCT_API void | reduct_list_release (struct reduct *reduct, reduct_list_t *list) |
| Release a list, potentially allowing the garbage collector to collect it. | |
List management.
Definition in file list.h.
| #define REDUCT_LIST_SMALL_MAX 4 |
| #define REDUCT_LIST_LARGE_MIN 16 |
| #define REDUCT_LIST_EXTRA_ROOM_FACTOR 2 |
| #define REDUCT_LIST_FLAG_LARGE (1 << 0) |
| #define REDUCT_LIST_FLAG_USED_HEAD (1 << 1) |
| #define REDUCT_LIST_FLAG_USED_TAIL (1 << 2) |
| typedef uint8_t reduct_list_flags_t |
| REDUCT_API reduct_list_t * reduct_list_new | ( | struct reduct * | reduct, |
| size_t | length | ||
| ) |
Create a new editable list.
| reduct | Pointer to the Reduct structure. |
| length | The predetermined length of the list. |
| REDUCT_API reduct_list_t * reduct_list_new_handles | ( | struct reduct * | reduct, |
| size_t | count, | ||
| reduct_handle_t * | handles | ||
| ) |
Create a new list from an array of handles.
| reduct | Pointer to the Reduct structure. |
| count | The number of handles. |
| handles | The array of handles. |
| REDUCT_API reduct_list_t * reduct_list_new_alist | ( | struct reduct * | reduct, |
| size_t | count, | ||
| ... | |||
| ) |
Create a new association list (list storing key-value pairs) from a variable number of pairs.
| reduct | Pointer to the Reduct structure. |
| count | The number of pairs. |
| ... | Each pair should be provided as a (const char*, reduct_handle_t). |
| REDUCT_API reduct_list_t * reduct_list_new_alist_entries | ( | struct reduct * | reduct, |
| size_t | count, | ||
| const reduct_list_entry_t * | entries | ||
| ) |
Create a new association list from an array of entries.
| reduct | Pointer to the Reduct structure. |
| count | Number of entries. |
| entries | Array of key-value pairs. |
| REDUCT_API reduct_list_t * reduct_list_slice | ( | struct reduct * | reduct, |
| reduct_list_t * | list, | ||
| size_t | start, | ||
| 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). |
| REDUCT_API reduct_list_t * reduct_list_append | ( | struct reduct * | reduct, |
| reduct_list_t * | list, | ||
| reduct_handle_t | val | ||
| ) |
Create a new list by appending an element to an existing list.
| reduct | Pointer to the Reduct structure. |
| list | Pointer to the source list. |
| val | The value to append. |
| REDUCT_API reduct_list_t * reduct_list_prepend | ( | struct reduct * | reduct, |
| reduct_list_t * | list, | ||
| reduct_handle_t | val | ||
| ) |
Create a new list by prepending an element to an existing list.
| reduct | Pointer to the Reduct structure. |
| list | Pointer to the source list. |
| val | The value to prepend. |
| REDUCT_API reduct_list_t * reduct_list_concat | ( | struct reduct * | reduct, |
| reduct_list_t * | a, | ||
| reduct_list_t * | b | ||
| ) |
Create a new list by concatenating two existing lists.
| reduct | Pointer to the Reduct structure. |
| a | Pointer to the first list. |
| b | Pointer to the second list. |
| REDUCT_API void reduct_list_retain | ( | struct reduct * | reduct, |
| reduct_list_t * | list | ||
| ) |
Retain a list, preventing it from being collected by the garbage collector.
| reduct | Pointer to the Reduct structure. |
| list | Pointer to the list. |
| REDUCT_API void reduct_list_release | ( | struct reduct * | reduct, |
| reduct_list_t * | list | ||
| ) |
Release a list, potentially allowing the garbage collector to collect it.
| reduct | Pointer to the Reduct structure. |
| list | Pointer to the list. |