pub struct HashTrieMap<K, V, P = RcK, H = RandomState>where
H: BuildHasher,
P: SharedPointerKind,{ /* 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
| Operation | Average | Worst 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>
impl<K, V> HashTrieMap<K, V>
pub fn new() -> HashTrieMap<K, V>
pub fn new_with_degree(degree: u8) -> HashTrieMap<K, V>
Source§impl<K, V> HashTrieMap<K, V, ArcTK>
impl<K, V> HashTrieMap<K, V, ArcTK>
pub fn new_sync() -> HashTrieMap<K, V, ArcTK>
pub fn new_sync_with_degree(degree: u8) -> HashTrieMap<K, V, ArcTK>
Source§impl<K, V, P, H> HashTrieMap<K, V, P, H>
impl<K, V, P, H> HashTrieMap<K, V, P, H>
pub fn new_with_hasher_and_ptr_kind( hasher_builder: H, ) -> HashTrieMap<K, V, P, H>
pub fn new_with_hasher_and_degree_and_ptr_kind( hasher_builder: H, degree: u8, ) -> HashTrieMap<K, V, P, H>
pub fn get<Q>(&self, key: &Q) -> Option<&V>
pub fn get_key_value<Q>(&self, key: &Q) -> Option<(&K, &V)>
pub fn insert(&self, key: K, value: V) -> HashTrieMap<K, V, P, H>
pub fn insert_mut(&mut self, key: K, value: V)
pub fn remove<Q>(&self, key: &Q) -> HashTrieMap<K, V, P, H>
pub fn remove_mut<Q>(&mut self, key: &Q) -> bool
pub fn contains_key<Q>(&self, key: &Q) -> bool
Sourcepub fn ptr_eq<PO, HO>(&self, other: &HashTrieMap<K, V, PO, HO>) -> boolwhere
PO: SharedPointerKind,
HO: BuildHasher,
pub fn ptr_eq<PO, HO>(&self, other: &HashTrieMap<K, V, PO, HO>) -> boolwhere
PO: SharedPointerKind,
HO: BuildHasher,
Test whether the two maps refer to the same content in memory.
This would return true if you’re comparing a map to itself, or if you’re comparing a map to a fresh clone of itself.
pub fn size(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn iter( &self, ) -> Map<IterPtr<'_, K, V, P>, fn(&SharedPointer<Entry<K, V>, P>) -> (&K, &V)> ⓘ
pub fn keys( &self, ) -> Map<Map<IterPtr<'_, K, V, P>, fn(&SharedPointer<Entry<K, V>, P>) -> (&K, &V)>, fn((&K, &V)) -> &K> ⓘ
pub fn values( &self, ) -> Map<Map<IterPtr<'_, K, V, P>, fn(&SharedPointer<Entry<K, V>, P>) -> (&K, &V)>, fn((&K, &V)) -> &V> ⓘ
Trait Implementations§
Source§impl<'a> Add<HashTrieMap<String, Value, ArcTK>> for AttrsRef<'a>
为 AttrsRef 实现自定义的 + 运算符,用于直接添加属性映射
当使用 + 运算符时,会直接使用提供的属性映射更新当前节点的属性
impl<'a> Add<HashTrieMap<String, Value, ArcTK>> for AttrsRef<'a>
为 AttrsRef 实现自定义的 + 运算符,用于直接添加属性映射 当使用 + 运算符时,会直接使用提供的属性映射更新当前节点的属性
Source§impl<K, V, P, H> Clone for HashTrieMap<K, V, P, H>
impl<K, V, P, H> Clone for HashTrieMap<K, V, P, H>
Source§fn clone(&self) -> HashTrieMap<K, V, P, H>
fn clone(&self) -> HashTrieMap<K, V, P, H>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<K, V, P, H> Debug for HashTrieMap<K, V, P, H>
impl<K, V, P, H> Debug for HashTrieMap<K, V, P, H>
Source§impl<K, V, P, H> Default for HashTrieMap<K, V, P, H>
impl<K, V, P, H> Default for HashTrieMap<K, V, P, H>
Source§fn default() -> HashTrieMap<K, V, P, H>
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,
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: D,
) -> Result<HashTrieMap<K, V, P, H>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<HashTrieMap<K, V, P, H>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<K, V, P, H> Display for HashTrieMap<K, V, P, H>
impl<K, V, P, H> Display for HashTrieMap<K, V, P, H>
Source§impl<K, V, P, H> FromIterator<(K, V)> for HashTrieMap<K, V, P, H>
impl<K, V, P, H> FromIterator<(K, V)> for HashTrieMap<K, V, P, H>
Source§fn from_iter<I>(into_iter: I) -> HashTrieMap<K, V, P, H>where
I: IntoIterator<Item = (K, V)>,
fn from_iter<I>(into_iter: I) -> HashTrieMap<K, V, P, H>where
I: IntoIterator<Item = (K, V)>,
Creates a value from an iterator. Read more
Source§impl<K, Q, V, P, H> Index<&Q> for HashTrieMap<K, V, P, H>where
H: BuildHasher + Clone,
K: Eq + Hash + Borrow<Q>,
Q: Hash + Eq + ?Sized,
P: SharedPointerKind,
impl<K, Q, V, P, H> Index<&Q> for HashTrieMap<K, V, P, H>where
H: BuildHasher + Clone,
K: Eq + Hash + Borrow<Q>,
Q: Hash + Eq + ?Sized,
P: SharedPointerKind,
Source§impl<'a, K, V, P, H> IntoIterator for &'a HashTrieMap<K, V, P, H>
impl<'a, K, V, P, H> IntoIterator for &'a HashTrieMap<K, V, P, H>
Source§impl<K, V, P, PO, H> PartialEq<HashTrieMap<K, V, PO, H>> for HashTrieMap<K, V, P, H>where
K: Eq + Hash,
V: PartialEq,
H: BuildHasher + Clone,
P: SharedPointerKind,
PO: SharedPointerKind,
impl<K, V, P, PO, H> PartialEq<HashTrieMap<K, V, PO, H>> for HashTrieMap<K, V, P, H>where
K: Eq + Hash,
V: PartialEq,
H: BuildHasher + Clone,
P: SharedPointerKind,
PO: SharedPointerKind,
Source§impl<K, V, P, H> Serialize for HashTrieMap<K, V, P, H>where
K: Eq + Hash + Serialize,
V: Serialize,
H: BuildHasher + Clone + Default,
P: SharedPointerKind,
impl<K, V, P, H> Serialize for HashTrieMap<K, V, P, H>where
K: Eq + Hash + Serialize,
V: Serialize,
H: BuildHasher + Clone + Default,
P: SharedPointerKind,
Source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl<K, V, P, H> Eq for HashTrieMap<K, V, P, H>
Auto Trait Implementations§
impl<K, V, P, H> Freeze for HashTrieMap<K, V, P, H>
impl<K, V, P, H> RefUnwindSafe for HashTrieMap<K, V, P, H>
impl<K, V, P, H> Send for HashTrieMap<K, V, P, H>
impl<K, V, P, H> Sync for HashTrieMap<K, V, P, H>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more