[][src]Struct hamst::Hamt

pub struct Hamt<K, V, H> { /* fields omitted */ }

HAMT with shareable nodes

The structure is immutable from root to leaves, where each node of this structure is also independently shareable, including on different thread.

Implementations

impl<H: Hasher + Default, K: PartialEq + Eq + Hash, V> Hamt<K, V, H>[src]

pub fn new() -> Self[src]

Create a new empty HAMT

pub fn is_empty(&self) -> bool[src]

Check if the HAMT is empty

pub fn size(&self) -> usize[src]

Return the number of elements in this HAMT

pub fn thaw(&self) -> HamtMut<K, V, H>[src]

Thaw this HAMT into a HAMT that can be mutated

pub fn mutate_freeze<E, F>(&self, f: F) -> Result<Self, E> where
    F: FnOnce(&mut HamtMut<K, V, H>) -> Result<(), E>, 
[src]

Temporary create a mutable HAMT from an immutable one, and apply the callback f to the mutable reference, then thaw into the resulting HAMT

let empty : Hamt<u32, u32, DefaultHasher> = Hamt::new();
let result = reference.freeze(|x| {
    x.insert(10, 20)?;
    x.insert(20, 30)
}).expect("it works");

pub fn mutate_freeze_ret<E, F, R>(&self, f: F) -> Result<(Self, R), E> where
    F: FnOnce(&mut HamtMut<K, V, H>) -> Result<R, E>, 
[src]

Similar to 'mutate_freeze' and also returns the result of f too

impl<H: Hasher + Default, K: Hash + Eq, V> Hamt<K, V, H>[src]

pub fn lookup(&self, k: &K) -> Option<&V>[src]

Try to get the element related to key K

pub fn contains_key(&self, k: &K) -> bool[src]

Check if the key is contained into the HAMT

pub fn iter(&self) -> HamtIter<'_, K, V>

Notable traits for HamtIter<'a, K, V>

impl<'a, K, V> Iterator for HamtIter<'a, K, V> type Item = (&'a K, &'a V);
[src]

Create a new iterator for this HAMT

Trait Implementations

impl<H, K, V> Clone for Hamt<K, V, H>[src]

impl<H: Hasher + Default, K: Eq + Hash, V> Default for Hamt<K, V, H>[src]

impl<H: Default + Hasher, K: Eq + Hash, V: Eq> Eq for Hamt<K, V, H>[src]

impl<'a, H, K, V> From<&'a Hamt<K, V, H>> for HamtMut<K, V, H>[src]

impl<H: Default + Hasher, K: Eq + Hash + Clone, V: Clone> FromIterator<(K, V)> for Hamt<K, V, H>[src]

impl<H: Default + Hasher, K: Eq + Hash, V: PartialEq> PartialEq<Hamt<K, V, H>> for Hamt<K, V, H>[src]

Auto Trait Implementations

impl<K, V, H> RefUnwindSafe for Hamt<K, V, H> where
    H: RefUnwindSafe,
    K: RefUnwindSafe,
    V: RefUnwindSafe

impl<K, V, H> Send for Hamt<K, V, H> where
    H: Send,
    K: Send + Sync,
    V: Send + Sync

impl<K, V, H> Sync for Hamt<K, V, H> where
    H: Sync,
    K: Send + Sync,
    V: Send + Sync

impl<K, V, H> Unpin for Hamt<K, V, H> where
    H: Unpin

impl<K, V, H> UnwindSafe for Hamt<K, V, H> where
    H: UnwindSafe,
    K: RefUnwindSafe,
    V: RefUnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.