pub struct HamtMut<K, V, H> { /* private fields */ }
Expand description
Mutable HAMT data structure
This is created after a thaw of an immutable HAMT, and right after the creation, all the node are still shared with the immutable HAMT.
Once modification happens, then each nodes from root to leaf will be modified and kept in an efficient mutable format until freezing.
Implementations§
Source§impl<H: Hasher + Default, K: Clone + Eq + Hash, V: Clone> HamtMut<K, V, H>
impl<H: Hasher + Default, K: Clone + Eq + Hash, V: Clone> HamtMut<K, V, H>
Sourcepub fn insert(&mut self, k: K, v: V) -> Result<(), InsertError>
pub fn insert(&mut self, k: K, v: V) -> Result<(), InsertError>
Insert a new key into the HAMT
If the key already exists, then an InsertError is returned.
To simulaneously manipulate a key, either to insert or update, use ‘insert_or_update’
Source§impl<H: Hasher + Default, K: Eq + Hash + Clone, V: PartialEq + Clone> HamtMut<K, V, H>
impl<H: Hasher + Default, K: Eq + Hash + Clone, V: PartialEq + Clone> HamtMut<K, V, H>
Sourcepub fn remove_match(&mut self, k: &K, v: &V) -> Result<(), RemoveError>
pub fn remove_match(&mut self, k: &K, v: &V) -> Result<(), RemoveError>
Remove a key from the HAMT, if it also matching the value V
If the key doesn’t exist, then RemoveError::KeyNotFound will be returned and otherwise if the key exists but the value doesn’t match, RemoveError::ValueNotMatching will be returned.
Source§impl<H: Hasher + Default, K: Eq + Hash + Clone, V: Clone> HamtMut<K, V, H>
impl<H: Hasher + Default, K: Eq + Hash + Clone, V: Clone> HamtMut<K, V, H>
Sourcepub fn replace(&mut self, k: &K, v: V) -> Result<V, ReplaceError>
pub fn replace(&mut self, k: &K, v: V) -> Result<V, ReplaceError>
Replace the element at the key by the v and return the new tree and the old value.
Sourcepub fn replace_with<F>(&mut self, k: &K, f: F) -> Result<(), ReplaceError>
pub fn replace_with<F>(&mut self, k: &K, f: F) -> Result<(), ReplaceError>
Replace the element at the key by the v and return the new tree and the old value.
Source§impl<H: Hasher + Default, K: Eq + Hash + Clone, V: Clone> HamtMut<K, V, H>
impl<H: Hasher + Default, K: Eq + Hash + Clone, V: Clone> HamtMut<K, V, H>
Sourcepub fn update<F, U>(&mut self, k: &K, f: F) -> Result<(), UpdateError<U>>
pub fn update<F, U>(&mut self, k: &K, f: F) -> Result<(), UpdateError<U>>
Update the element at the key K.
If the closure F in parameter returns None, then the key is deleted.
If the key is not present then UpdateError::KeyNotFound is returned
Sourcepub fn insert_or_update<F, E>(&mut self, k: K, v: V, f: F) -> Result<(), E>
pub fn insert_or_update<F, E>(&mut self, k: K, v: V, f: F) -> Result<(), E>
Update or insert the element at the key K
If the element is not present, then V is added, otherwise the closure F is apply to the found element. If the closure returns None, then the key is deleted
Sourcepub fn insert_or_update_simple<F>(&mut self, k: K, v: V, f: F)
pub fn insert_or_update_simple<F>(&mut self, k: K, v: V, f: F)
Update or insert the element at the key K
If the element is not present, then V is added, otherwise the closure F is apply to the found element. If the closure returns None, then the key is deleted.
This is similar to ‘insert_or_update’ except the closure shouldn’t be failing