pub struct HashTrieMap<K, V, P = RcK, H: BuildHasher = RandomState>{ /* private fields */ }
Expand description

A persistent map with structural sharing. This implementation uses a hash array mapped trie.

Complexity

Let n be the number of elements in the map.

Temporal complexity

OperationAverageWorst case
new()Θ(1)Θ(1)
insert()Θ(1)Θ(n)
remove()Θ(1)Θ(n)
get()Θ(1)Θ(n)
contains_key()Θ(1)Θ(n)
size()Θ(1)Θ(1)
clone()Θ(1)Θ(1)
iterator creationΘ(1)Θ(1)
iterator stepΘ(1)Θ(1)
iterator fullΘ(n)Θ(n)

Implementation details

This implementation uses a hash array mapped trie. Details can be found in Ideal Hash Trees.

See the Node documentation for details.

Implementations§

source§

impl<K, V> HashTrieMap<K, V>
where K: Eq + Hash,

source

pub fn new() -> HashTrieMap<K, V>

source

pub fn new_with_degree(degree: u8) -> HashTrieMap<K, V>

source§

impl<K, V> HashTrieMap<K, V, ArcTK>
where K: Eq + Hash,

source§

impl<K, V, P, H> HashTrieMap<K, V, P, H>
where K: Eq + Hash, H: Clone + BuildHasher, P: SharedPointerKind,

source

pub fn new_with_hasher_and_ptr_kind( hasher_builder: H ) -> HashTrieMap<K, V, P, H>

source

pub fn new_with_hasher_and_degree_and_ptr_kind( hasher_builder: H, degree: u8 ) -> HashTrieMap<K, V, P, H>

source

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

source

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

source

pub fn insert(&self, key: K, value: V) -> HashTrieMap<K, V, P, H>

source

pub fn insert_mut(&mut self, key: K, value: V)

source

pub fn remove<Q>(&self, key: &Q) -> HashTrieMap<K, V, P, H>
where K: Borrow<Q>, Q: Hash + Eq + ?Sized,

source

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

source

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

source

pub fn size(&self) -> usize

source

pub fn is_empty(&self) -> bool

source

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

source

pub fn keys(&self) -> IterKeys<'_, K, V, P>

source

pub fn values(&self) -> IterValues<'_, K, V, P>

source§

impl<K, V, P, H> HashTrieMap<K, V, P, H>
where K: Eq + Hash + Clone, V: Clone, H: Clone + BuildHasher, P: SharedPointerKind,

source

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

Trait Implementations§

source§

impl<K, V, P, H> Clone for HashTrieMap<K, V, P, H>
where K: Eq + Hash, H: Clone + BuildHasher, P: SharedPointerKind,

source§

fn clone(&self) -> HashTrieMap<K, V, P, H>

Returns a copy 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, P, H: Debug + BuildHasher> Debug for HashTrieMap<K, V, P, H>

source§

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

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

impl<K, V, P, H> Default for HashTrieMap<K, V, P, H>

source§

fn default() -> HashTrieMap<K, V, P, H>

Returns the “default value” for a type. Read more
source§

impl<'de, K, V, P, H> Deserialize<'de> for HashTrieMap<K, V, P, H>
where K: Eq + Hash + Deserialize<'de>, V: Deserialize<'de>, H: BuildHasher + Clone + Default, P: SharedPointerKind,

source§

fn deserialize<D: Deserializer<'de>>( deserializer: D ) -> Result<HashTrieMap<K, V, P, H>, D::Error>

Deserialize this value from the given Serde deserializer. Read more
source§

impl<K, V, P, H> Display for HashTrieMap<K, V, P, H>

source§

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

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

impl<K, V, P, H> FromIterator<(K, V)> for HashTrieMap<K, V, P, H>

source§

fn from_iter<I: IntoIterator<Item = (K, V)>>( into_iter: I ) -> HashTrieMap<K, V, P, H>

Creates a value from an iterator. Read more
source§

impl<'a, K, Q, V, P, H> Index<&'a Q> for HashTrieMap<K, V, P, H>
where K: Eq + Hash + Borrow<Q>, Q: Hash + Eq + ?Sized, H: Clone + BuildHasher, P: SharedPointerKind,

§

type Output = V

The returned type after indexing.
source§

fn index(&self, key: &Q) -> &V

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

impl<'a, K, V, P, H> IntoIterator for &'a HashTrieMap<K, V, P, H>

§

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

The type of the elements being iterated over.
§

type IntoIter = Map<IterPtr<'a, K, V, P>, fn(_: &'a SharedPointer<Entry<K, V>, P>) -> (&'a K, &'a V)>

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

fn into_iter(self) -> Iter<'a, K, V, P>

Creates an iterator from a value. Read more
source§

impl<K, V: PartialEq, P, PO, H> PartialEq<HashTrieMap<K, V, PO, H>> for HashTrieMap<K, V, P, H>

source§

fn eq(&self, other: &HashTrieMap<K, V, PO, H>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<K, V, P, H> Serialize for HashTrieMap<K, V, P, H>

source§

fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>

Serialize this value into the given Serde serializer. Read more
source§

impl<K, V: Eq, P, H> Eq for HashTrieMap<K, V, P, H>
where K: Hash + Eq, H: Clone + BuildHasher, P: SharedPointerKind,

Auto Trait Implementations§

§

impl<K, V, P, H> RefUnwindSafe for HashTrieMap<K, V, P, H>

§

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

§

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

§

impl<K, V, P, H> Unpin for HashTrieMap<K, V, P, H>
where H: Unpin,

§

impl<K, V, P, H> UnwindSafe for HashTrieMap<K, V, P, H>

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

§

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> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

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

§

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

§

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.
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,