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(HashBits, K, V)
Bitmap(Size, Bitmap, Vec<HamtRef>)
Collision(HashBits, Vec<(K, V)>)
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>>,
[src]
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,
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,
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>,
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,
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,
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>,
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>,
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
.
Trait Implementations
impl<K: Debug, V: Debug, HamtRef: Debug> Debug for Hamt<K, V, HamtRef>
[src]
impl<K: Clone, V: Clone, HamtRef: Clone> Clone for Hamt<K, V, HamtRef>
[src]
fn clone(&self) -> Hamt<K, V, HamtRef>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl<K, V, HamtRef> Eq for Hamt<K, V, HamtRef> where
K: Eq,
V: Eq,
HamtRef: Eq,
[src]
K: Eq,
V: Eq,
HamtRef: Eq,
impl<K, V, HamtRef> PartialEq for Hamt<K, V, HamtRef> where
K: PartialEq,
V: PartialEq,
HamtRef: PartialEq,
[src]
K: PartialEq,
V: PartialEq,
HamtRef: PartialEq,
fn eq(&self, other: &Hamt<K, V, HamtRef>) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0
This method tests for !=
.
impl<K, V, HamtRef> FromIterator<(K, V)> for Hamt<K, V, HamtRef> where
K: Eq + Hash + Clone,
V: Clone,
HamtRef: Clone + Deref<Target = Hamt<K, V, HamtRef>> + From<Hamt<K, V, HamtRef>>,
[src]
K: Eq + Hash + Clone,
V: Clone,
HamtRef: Clone + Deref<Target = Hamt<K, V, HamtRef>> + From<Hamt<K, V, HamtRef>>,
fn from_iter<T>(iterator: T) -> Self where
T: IntoIterator<Item = (K, V)>,
T: IntoIterator<Item = (K, V)>,
Creates a value from an iterator. Read more
impl<'a, K, V, HamtRef> FromIterator<(&'a K, &'a V)> for Hamt<K, V, HamtRef> where
K: Eq + Hash + Clone,
V: Clone,
HamtRef: Clone + Deref<Target = Hamt<K, V, HamtRef>> + From<Hamt<K, V, HamtRef>>,
[src]
K: Eq + Hash + Clone,
V: Clone,
HamtRef: Clone + Deref<Target = Hamt<K, V, HamtRef>> + From<Hamt<K, V, HamtRef>>,
fn from_iter<T>(iterator: T) -> Self where
T: IntoIterator<Item = (&'a K, &'a V)>,
T: IntoIterator<Item = (&'a K, &'a V)>,
Creates a value from an iterator. Read more
impl<'a, K, V, HamtRef> IntoIterator for &'a Hamt<K, V, HamtRef> where
K: 'a + Clone + Hash + Eq,
V: 'a + Clone,
HamtRef: 'a + Clone + Deref<Target = Hamt<K, V, HamtRef>> + From<Hamt<K, V, HamtRef>>,
[src]
K: 'a + Clone + Hash + Eq,
V: 'a + Clone,
HamtRef: 'a + Clone + Deref<Target = Hamt<K, V, HamtRef>> + From<Hamt<K, V, HamtRef>>,
type Item = (&'a K, &'a V)
The type of the elements being iterated over.
type IntoIter = Iter<'a, K, V, HamtRef>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
Creates an iterator from a value. Read more
impl<'a, K, Q: ?Sized, V, HamtRef> Index<&'a Q> for Hamt<K, V, HamtRef> where
K: Hash + Eq + Clone + Borrow<Q>,
V: Clone,
Q: Eq + Hash,
HamtRef: Clone + Deref<Target = Hamt<K, V, HamtRef>> + From<Hamt<K, V, HamtRef>>,
[src]
K: Hash + Eq + Clone + Borrow<Q>,
V: Clone,
Q: Eq + Hash,
HamtRef: Clone + Deref<Target = Hamt<K, V, HamtRef>> + From<Hamt<K, V, HamtRef>>,