Skip to main content

Module adaptive_radix

Module adaptive_radix 

Source
Expand description

Adaptive Radix Tree (ART) for prefix search (bd-1cgh9).

A radix tree with adaptive node sizes (Node4/Node16/Node48/Node256) that provides O(k) lookup and O(k + m) prefix scan, where k = key length and m = number of matches.

§Node Types

TypeKeysChildrenSizeUse Case
Node444~48 BVery sparse
Node161616~192 BModerate density
Node484848+256~656 BDense
Node256256256~2056 BVery dense (full)

§Example

use ftui_widgets::adaptive_radix::AdaptiveRadixTree;

let mut art = AdaptiveRadixTree::new();
art.insert("file:open", 1);
art.insert("file:save", 2);
art.insert("file:close", 3);
art.insert("edit:undo", 4);

// Prefix scan
let matches = art.prefix_scan("file:");
assert_eq!(matches.len(), 3);

// Exact lookup
assert_eq!(art.get("edit:undo"), Some(&4));

Structs§

AdaptiveRadixTree
An adaptive radix tree for string-keyed data.
NodeDistribution
Distribution of node types in the tree.