Hamt

Enum Hamt 

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

Implementations§

Source§

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

Source

pub fn new() -> Self

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

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

Returns a key value iterator.

Source

pub fn keys(&self) -> Keys<'_, K, V, HamtRef>

Returns an iterator that visits every key in an unspecified order.

Source

pub fn values(&self) -> Values<'_, K, V, HamtRef>

Returns an iterator that visits every value in an unspecified order.

Source

pub fn get<Q>(&self, k: &Q) -> Option<&V>
where K: Borrow<Q>, Q: Hash + Eq + ?Sized,

Returns a reference to the value corresponding to the given key, or None if there is no value associated with the key.

Source

pub fn contains_key<Q>(&self, k: &Q) -> bool
where K: Borrow<Q>, Q: Hash + Eq + ?Sized,

Returns true if the map contains the given key.

Source

pub fn insert<Q, R>(&self, k: &Q, v: &R) -> Self
where K: Borrow<Q>, Q: Hash + Eq + ToOwned<Owned = K> + ?Sized, V: Borrow<R>, R: ToOwned<Owned = V> + ?Sized,

Source

pub fn remove<Q>(&self, k: &Q) -> Self
where K: Borrow<Q>, Q: Hash + Eq + ?Sized,

Returns a new map without an entry corresponding to the given key.

Source

pub fn adjust<F, Q>(&self, key: &Q, f: F) -> Self
where F: FnOnce(&V) -> V, K: Borrow<Q>, Q: Hash + Eq + ?Sized,

Modifies the value tied to the given key with the function f. Otherwise, the map returned is identical.

Source

pub fn update<F, Q>(&self, key: &Q, f: F) -> Self
where F: FnOnce(&V) -> Option<V>, K: Borrow<Q>, Q: Hash + Eq + ToOwned<Owned = K> + ?Sized,

Updates the value at the given key using f. If f returns None, then the entry is removed.

Source

pub fn alter<F, Q>(&self, key: &Q, f: F) -> Self
where F: FnOnce(Option<&V>) -> Option<V>, K: Borrow<Q>, Q: Hash + Eq + ToOwned<Owned = K> + ?Sized,

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§

Source§

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

Source§

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

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

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

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<K, V> From<Hamt<K, V, ArcTrick<K, V>>> for ArcTrick<K, V>

Source§

fn from(t: Hamt<K, V, ArcTrick<K, V>>) -> Self

Converts to this type from the input type.
Source§

impl<K, V> From<Hamt<K, V, RcTrick<K, V>>> for RcTrick<K, V>

Source§

fn from(t: Hamt<K, V, RcTrick<K, V>>) -> Self

Converts to this type from the input type.
Source§

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

Source§

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

Creates a value from an iterator. Read more
Source§

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

Source§

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

Creates a value from an iterator. Read more
Source§

impl<'a, K, Q, V, HamtRef> Index<&'a Q> for Hamt<K, V, HamtRef>
where K: Hash + Eq + Clone + Borrow<Q>, V: Clone, Q: Eq + Hash + ?Sized, HamtRef: Clone + Deref<Target = Hamt<K, V, HamtRef>> + From<Hamt<K, V, HamtRef>>,

Source§

type Output = V

The returned type after indexing.
Source§

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

Performs the indexing (container[index]) operation. Read more
Source§

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

Source§

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

The type of the elements being iterated over.
Source§

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

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

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

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

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

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

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

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.