|
Serene Runtime 1.0.0-dev
C runtime for the Serene programming language
|
#include "serene/rt/impl/array_list.h"#include <stdint.h>#include <stdio.h>#include "serene/rt/context.h"#include "serene/utils.h"Go to the source code of this file.
Macros | |
| #define | AL_LOG(FMT, ...) |
Functions | |
| static uint16_t | array_list_depth_index (const uint8_t depth, const uint64_t index) |
| Find the array index of the given index, considering the given depth. | |
| static array_list_elem_t * | array_list_create_page (const srn_context_t *ctx) |
| Create a PAGE (just slots for the data). | |
| static array_list_node_t * | array_list_new_node (const srn_context_t *ctx) |
| static array_list_node_t * | array_list_new_path (const srn_context_t *ctx, uint8_t depth, array_list_node_t *leaf) |
| Walk from the root to a possible leaf node and create all the inner and leaf nodes if necessary. | |
| static void | array_list_push_leaf (const srn_context_t *ctx, array_list_node_t *node, uint8_t depth, uint64_t index, array_list_node_t *leaf) |
| Insert leaf below node at the position of logical index index, mutating node and its descendants in place. | |
| 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. | |
| static srn_error_t * | array_list_slot (const array_list_t *al, array_list_index_t n, array_list_elem_t **out_slot) |
| Resolve the address of the slot backing logical index n into *out_slot. | |
| array_list_maybe_element_t | array_list_get (const array_list_t *al, array_list_index_t n) |
| Negative index is not supported. | |
| 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. | |
| static void | array_list_pull_last_leaf (array_list_t *al) |
| Detach the rightmost leaf from the trie and hand its buffer back as the tail, the inverse of the promotion that array_list_push does. | |
| static void | array_list_drop_last (array_list_t *al) |
| Drop the final element, keeping the tail as the physical end of the sequence. | |
| 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 to keep the sequence contiguous. | |
| #define AL_LOG | ( | FMT, | |
| ... ) |
Definition at line 30 of file array_list.c.
|
inlinestatic |
Create a PAGE (just slots for the data).
Definition at line 42 of file array_list.c.
|
inlinestatic |
Find the array index of the given index, considering the given depth.
depth can be thought of, as which 5 bits of the index are we looking at (AL_SHIFT is 5).
Definition at line 37 of file array_list.c.
|
static |
Drop the final element, keeping the tail as the physical end of the sequence.
Definition at line 288 of file array_list.c.
|
nodiscard |
Create an empty array list in the given context ctx.
Definition at line 101 of file array_list.c.
|
nodiscard |
Negative index is not supported.
Look up the element at the given index n in the given array list al.
Definition at line 235 of file array_list.c.
|
inlinestatic |
Definition at line 52 of file array_list.c.
|
static |
Walk from the root to a possible leaf node and create all the inner and leaf nodes if necessary.
We use this only when we insert new data
Definition at line 64 of file array_list.c.
|
static |
Detach the rightmost leaf from the trie and hand its buffer back as the tail, the inverse of the promotion that array_list_push does.
Only called when the tail has drained to empty while the trie still holds elements, so the trie holds whole leaves only and len is a multiple of AL_BR. The trie depth is left as is, an over-tall trie stays correct for reads, updates, and pushes.
Definition at line 264 of file array_list.c.
|
nodiscard |
Push the given element x to the end of array_list al.
Definition at line 114 of file array_list.c.
|
static |
Insert leaf below node at the position of logical index index, mutating node and its descendants in place.
Missing inner nodes along the path are created on the way down.
Definition at line 78 of file array_list.c.
|
nodiscard |
Remove the element at the given index n from the array list al, shifting every later element down one to keep the sequence contiguous.
Returns null on success, or an error when n is out of bounds.
Definition at line 301 of file array_list.c.
|
static |
Resolve the address of the slot backing logical index n into *out_slot.
Returns null on success and an error otherwise, leaving *out_slot null when it fails.
Definition at line 198 of file array_list.c.
|
nodiscard |
Update the given index n of the array list al with the new element x.
Returns null on success, or an error when n is out of bounds.
Definition at line 246 of file array_list.c.