A functional 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.
This is copied and modified from treemap right now. It's missing a lot of features.
treemap
find
- Find a value based on the keyinit
- Create a treemapinsert
- Insert a value into the maptraverse
- Visit all pairs in the map in order.treemap
type treemap<K, V> = @tree_node<K, V>
find
fn find<K, V: copy>(m: treemap<K, V>, k: K) -> option<V>
Find a value based on the key
init
fn init<K, V>() -> treemap<K, V>
Create a treemap
insert
fn insert<K: copy, V: copy>(m: treemap<K, V>, k: K, v: V) -> treemap<K, V>
Insert a value into the map
traverse
fn traverse<K, V: copy>(m: treemap<K, V>, f: fn(K, V))
Visit all pairs in the map in order.