|
Serene Runtime 1.0.0
C runtime for the Serene programming language
|
This is an implementation of bit - partitioned, persistent, immutable sequence For more information, have a look at Ideal hash trees paper.
More...
Go to the source code of this file.
Data Structures | |
| struct | seq_lookup_result_t |
| struct | seq_node_t |
| We have two type of node that both are implemented using the same data structure. More... | |
| struct | seq_t |
Macros | |
| #define | SEQ_BR 32u |
| branching factor (power of two) | |
| #define | SEQ_SHIFT 5u |
| log2(SEQ_BR) | |
| #define | SEQ_MASK (SEQ_BR - 1u) |
| #define | SEQ_MAX_DEPTH 11 |
| logical length. | |
Typedefs | |
| typedef void * | seq_elem_t |
| We use generic pointers to refer to internal nodes, leaf nodes and even elements. | |
| typedef struct seq_lookup_result_t | seq_lookup_result_t |
| typedef struct seq_node_t | seq_node_t |
| We have two type of node that both are implemented using the same data structure. | |
| typedef struct seq_t | seq_t |
Functions | |
| seq_t | seq_empty (const srn_context_t *ctx) |
| seq_t | seq_push (const srn_context_t *ctx, const seq_t *seq, seq_elem_t x) |
| seq_lookup_result_t | seq_get (const srn_context_t *ctx, const seq_t *seq, size_t n) |
| Negative index is not supported. | |
This is an implementation of bit - partitioned, persistent, immutable sequence For more information, have a look at Ideal hash trees paper.
TL;DR:
TODO:
Definition in file seq.h.
| #define SEQ_MAX_DEPTH 11 |
logical length.
While techically this implementation will support up to 2^85 elements in each seq, but we will limit it down to (2^64-1)(UINT64_MAX)(on 64bit machines) in order to keep the seq_t as small as possible. 12 is the magic number that we use to limit the depth to. 32^11 = 1,152,921,504,606,846,976 elements
| typedef void* seq_elem_t |
We use generic pointers to refer to internal nodes, leaf nodes and even elements.
It makes the calculation cruical to determining what type of data we are looking at, in each node. seq_elem_t will be pointing to actual user data when the node is a leaf node (depth == 0) and it will be pointing to the next node in the trie if the node is an inner node (depth != 0).
| typedef struct seq_lookup_result_t seq_lookup_result_t |
| typedef struct seq_node_t seq_node_t |
We have two type of node that both are implemented using the same data structure.
Inner nodes that point to other inner nodes or leaf nodes, and leaf nodes which points to actual elements of the sequence.
The main factor in determining the nature of the node is the depth of the trie. Depth zero, means a leaf node and an inner node otherwise.
| typedef struct seq_t seq_t |
|
nodiscard |
Definition at line 76 of file seq.c.
|
nodiscard |
Negative index is not supported.
Definition at line 173 of file seq.c.
|
nodiscard |
Definition at line 87 of file seq.c.