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.

Trait Implementations

impl<K, V, HamtRef> Eq for Hamt<K, V, HamtRef> where K: Eq, V: Eq, HamtRef: Eq

impl<K, V, HamtRef> PartialEq for Hamt<K, V, HamtRef> where K: PartialEq, V: PartialEq, HamtRef: PartialEq

fn eq(&self, other: &Hamt<K, V, HamtRef>) -> bool

fn ne(&self, other: &Rhs) -> bool

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>>

fn from_iter<T>(iterator: T) -> Self where T: IntoIterator<Item=(K, V)>

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>>

fn from_iter<T>(iterator: T) -> Self where T: IntoIterator<Item=(&'a K, &'a V)>

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>>

type Item = (&'a K, &'a V)

type IntoIter = Iter<'a, K, V, HamtRef>

fn into_iter(self) -> Self::IntoIter

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>>

type Output = V

fn index(&self, index: &Q) -> &Self::Output

Derived Implementations

impl<K: Clone, V: Clone, HamtRef: Clone> Clone for Hamt<K, V, HamtRef>

fn clone(&self) -> Hamt<K, V, HamtRef>

fn clone_from(&mut self, source: &Self)

impl<K: Debug, V: Debug, HamtRef: Debug> Debug for Hamt<K, V, HamtRef>

fn fmt(&self, __arg_0: &mut Formatter) -> Result