TreeMap
I am a binary tree-based map/dict ADT. Keys and values are arbitrary 64-bit values with pass-by-value semantics. TreeMap__new_owned can help with cleanup if the keys and/or values are pointers to owned objects. Using null as a key works if comparator and drop_key are null-safe. Using null as a value works if drop_value is null-safe.
Currently, the tree structure is not balanced, so time complexity is nominally O(n), including size! This will change.
TreeMap
pub struct TreeMap
Type of TreeMaps.
TreeMap__new
pub fn TreeMap__new(void* comparator)
I create a new TreeMap, using the provided comparator function pointer to provide total order over its keys.
TreeMap__new_owned
pub fn TreeMap__new_owned(void* comparator, void* drop_key, void* drop_value)
TreeMap_contains
pub fn TreeMap_contains(TreeMap* self, void key)
I indicate whether the map has a mapping for key.
TreeMap_delete
pub fn TreeMap_delete(TreeMap* self, void key)
I ensure the map does not contain an entry with the provided key, whether one previously existed or not.
TreeMap_drop
pub fn TreeMap_drop(TreeMap* self)
I drop the map, free-ing all internal structure, along with its keys and values (if they are owned).
TreeMap_get
pub fn TreeMap_get(TreeMap* self, void key)
I return the value mapped to the provided key, or null if one doesn't exit in the map.
TreeMap_is_empty
pub fn TreeMap_is_empty(TreeMap* self)
I return whether the map is empty.
TreeMap_max_key
pub fn TreeMap_max_key(TreeMap* self)
TreeMap_min_key
pub fn TreeMap_min_key(TreeMap* self)
TreeMap_put
pub fn TreeMap_put(TreeMap* self, void key, void value)
I ensure the map contains an entry with the provided key, mapped to the provided value. If a mapping already existed, its value is replaced, but its key is not.
TreeMap_size
pub fn TreeMap_size(TreeMap* self)
I return the number of entries in the map.