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
TreeNode
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> = @TreeNode<K, V>
TreeNode
Empty
Node(@K, @V, @TreeNode<K, V>, @TreeNode<K, V>)
find
fn find<K: Eq Ord, 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 Eq Ord, 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.