A key,value store that works on anything.
This works using a binary search tree. In the first version, it's a very naive algorithm, but it will probably be updated to be a red-black tree or something else.
TreeEdge
TreeMap
TreeNode
TreeMap
- Create a treemapfind
- Find a value based on the keyinsert
- Insert a value into the maptraverse
- Visit all pairs in the map in order.TreeEdge
type TreeEdge<K, V> = Option<@TreeNode<K, V>>
TreeMap
type TreeMap<K, V> = @mut TreeEdge<K, V>
TreeNode
pub TreeNode({key: K, mut value: V, mut left: TreeEdge<K, V>, mut right: TreeEdge<K, V>,})
TreeMap
fn TreeMap<K, V>() -> TreeMap<K, V>
Create a treemap
find
fn find<K: Copy Eq Ord, V: Copy>(m: & const TreeEdge<K, V>, k: K) -> Option<V>
Find a value based on the key
insert
fn insert<K: Copy Eq Ord, V: Copy>(m: & mut TreeEdge<K, V>, k: K, v: V)
Insert a value into the map
traverse
fn traverse<K, V: Copy>(m: & const TreeEdge<K, V>, f: fn&(& K, & V))
Visit all pairs in the map in order.