std1.0.0-beta-7 SafeC docs

std :: collections::btree

Struct std::BTree

#include <std/collections/btree.h> source

generic<V> struct BTree {
    struct BTreeNode<V> pool[BTREE_POOL_SIZE];
    int pool_used;
    unsigned long free_head;
    unsigned long root;
    unsigned long count;
}

Fields

§int pool_usedsource

high-water mark

§unsigned long free_headsource

freed nodes, chained through children[0]

§unsigned long rootsource

pool index + 1 (0 = empty tree)

§unsigned long countsource

key-value pairs

Methods

§void init()source · definition

Initialise (or reset) an empty tree in place. Only the scalar fields are touched — pool nodes are claimed lazily, so a ~pool-sized memset (or a by-value constructor copying the whole pool) would be pure waste.

§int insert(unsigned long key, V val)source · definition

insert or overwrite; 0 if the pool is full

§?&V get(unsigned long key) constsource · definition

null if missing

§int contains(unsigned long key) constsource · definition
§?V remove(unsigned long key)source · definition

the removed value, or null

§unsigned long length() constsource · definition
§int is_empty() constsource · definition
§void foreach(fn void(unsigned long, &V) cb)source · definition

ascending key order

§void clear()source · definition

drop every value; the tree is empty afterwards