Enum hamt::Hamt
[−]
[src]
pub enum Hamt<K, V, HamtRef> { Empty, Leaf(HashBits, K, V), Bitmap(Size, Bitmap, Vec<HamtRef>), Collision(HashBits, Vec<(K, V)>), }
Variants
Empty | |
Leaf | |
Bitmap | |
Collision |
Methods
impl<K, V, HamtRef> Hamt<K, V, HamtRef> where K: Hash + Eq + Clone, V: Clone, HamtRef: Clone + Deref<Target=Hamt<K, V, HamtRef>> + From<Hamt<K, V, HamtRef>>
fn new() -> Self
fn len(&self) -> usize
fn is_empty(&self) -> bool
fn iter(&self) -> Iter<K, V, HamtRef>
Returns a key value iterator.
fn keys(&self) -> Keys<K, V, HamtRef>
Returns an iterator that visits every key in an unspecified order.
fn values(&self) -> Values<K, V, HamtRef>
Returns an iterator that visits every value in an unspecified order.
fn get<Q: ?Sized>(&self, k: &Q) -> Option<&V> where K: Borrow<Q>, Q: Hash + Eq
Returns a reference to the value corresponding to the given key, or None if there is no value associated with the key.
fn contains_key<Q: ?Sized>(&self, k: &Q) -> bool where K: Borrow<Q>, Q: Hash + Eq
Returns true if the map contains the given key.
fn insert<Q: ?Sized, R: ?Sized>(&self, k: &Q, v: &R) -> Self where K: Borrow<Q>, Q: Hash + Eq + ToOwned<Owned=K>, V: Borrow<R>, R: ToOwned<Owned=V>
fn remove<Q: ?Sized>(&self, k: &Q) -> Self where K: Borrow<Q>, Q: Hash + Eq
Returns a new map without an entry corresponding to the given key.
fn adjust<F, Q: ?Sized>(&self, key: &Q, f: F) -> Self where F: FnOnce(&V) -> V, K: Borrow<Q>, Q: Hash + Eq
Modifies the value tied to the given key with the function f
. Otherwise, the map returned
is identical.
fn update<F, Q: ?Sized>(&self, key: &Q, f: F) -> Self where F: FnOnce(&V) -> Option<V>, K: Borrow<Q>, Q: Hash + Eq + ToOwned<Owned=K>
Updates the value at the given key using f
. If f
returns None, then the entry
is removed.
fn alter<F, Q: ?Sized>(&self, key: &Q, f: F) -> Self where F: FnOnce(Option<&V>) -> Option<V>, K: Borrow<Q>, Q: Hash + Eq + ToOwned<Owned=K>
Updates the value at the given key using f
as in Self::update
. If no value exists for
the given key, then f
is passed None
.