Struct pfx::map::PrefixTreeMap
source · pub struct PrefixTreeMap<K, V> { /* private fields */ }Expand description
An ordered map from byte strings to arbitrary values, based on a prefix tree.
Implementations§
source§impl<K, V> PrefixTreeMap<K, V>
impl<K, V> PrefixTreeMap<K, V>
sourcepub const fn is_empty(&self) -> bool
pub const fn is_empty(&self) -> bool
Returns true if and only if this map contains no key-value pairs.
sourcepub fn get_entry<Q>(&self, key: &Q) -> Option<(&K, &V)>
pub fn get_entry<Q>(&self, key: &Q) -> Option<(&K, &V)>
Return a reference to the original key and value, if found.
sourcepub fn get_entry_mut<Q>(&mut self, key: &Q) -> Option<(&K, &mut V)>
pub fn get_entry_mut<Q>(&mut self, key: &Q) -> Option<(&K, &mut V)>
Return a reference to the original key and a mutable reference to the value, if found.
sourcepub fn get_mut<Q>(&mut self, key: &Q) -> Option<&mut V>
pub fn get_mut<Q>(&mut self, key: &Q) -> Option<&mut V>
Return a mutable reference to the value, if found.
sourcepub fn contains_key<Q>(&self, key: &Q) -> bool
pub fn contains_key<Q>(&self, key: &Q) -> bool
Returns true if and only if the given key is found in the map.
sourcepub fn remove_entry<Q>(&mut self, key: &Q) -> Option<(K, V)>
pub fn remove_entry<Q>(&mut self, key: &Q) -> Option<(K, V)>
If the key exists in the map, return the original key and the correpsonding value.
sourcepub fn remove<Q>(&mut self, key: &Q) -> Option<V>
pub fn remove<Q>(&mut self, key: &Q) -> Option<V>
If the key exists in the map, return the corresponding value.
sourcepub fn iter(&self) -> Iter<'_, K, V> ⓘ
pub fn iter(&self) -> Iter<'_, K, V> ⓘ
An iterator over pairs of references to keys and the corresponding values.
Iteration proceeds in lexicographic order, as determined by the byte sequence of keys.
sourcepub fn into_keys(self) -> IntoKeys<K, V> ⓘ
pub fn into_keys(self) -> IntoKeys<K, V> ⓘ
An iterator over the owned keys.
Iteration proceeds in lexicographic order, as determined by the byte sequence of keys.
sourcepub fn keys(&self) -> Keys<'_, K, V> ⓘ
pub fn keys(&self) -> Keys<'_, K, V> ⓘ
An iterator over the borrowed keys.
Iteration proceeds in lexicographic order, as determined by the byte sequence of keys.
sourcepub fn into_values(self) -> IntoValues<K, V> ⓘ
pub fn into_values(self) -> IntoValues<K, V> ⓘ
An iterator over the owned values.
Iteration proceeds in lexicographic order, as determined by the byte sequence of keys.
sourcepub fn values(&self) -> Values<'_, K, V> ⓘ
pub fn values(&self) -> Values<'_, K, V> ⓘ
An iterator over the borrowed values.
Iteration proceeds in lexicographic order, as determined by the byte sequence of keys.
sourcepub fn into_prefix_iter<Q>(self, prefix: &Q) -> NodeIntoIter<K, V> ⓘ
pub fn into_prefix_iter<Q>(self, prefix: &Q) -> NodeIntoIter<K, V> ⓘ
An iterator over owned key-value pairs of which the key starts with the given prefix.
Iteration proceeds in lexicographic order, as determined by the byte sequence of keys.
sourcepub fn prefix_iter<Q>(&self, prefix: &Q) -> NodeIter<'_, K, V> ⓘ
pub fn prefix_iter<Q>(&self, prefix: &Q) -> NodeIter<'_, K, V> ⓘ
An iterator over borrowed key-value pairs of which the key starts with the given prefix.
Iteration proceeds in lexicographic order, as determined by the byte sequence of keys.
sourcepub fn compact(&mut self)
pub fn compact(&mut self)
Removes all internal nodes that do not contain an entry.
This is useful for freeing up memory and speeding up iteration after
removing many key-value pairs from the map and/or after creating many
spurious nodes using the entry API (by not inserting into the nodes
created by .entry()).
source§impl<K, V> PrefixTreeMap<K, V>
impl<K, V> PrefixTreeMap<K, V>
sourcepub fn entry(&mut self, key: K) -> Entry<'_, K, V>
pub fn entry(&mut self, key: K) -> Entry<'_, K, V>
Return an object representing the (vacant or occupied) node of the tree corresponding to the given key.
This always creates a new node, even if you don’t end up inserting into
it. Avoid creating many spurious entries, or call PrefixTreeMap::compact
to remove useless (empty) nodes.
sourcepub fn insert(&mut self, key: K, value: V) -> Option<V>
pub fn insert(&mut self, key: K, value: V) -> Option<V>
Replaces and returns the previous value, if any.
This leaves the key in the map untouched if it already exists.
sourcepub fn union<I>(self, other: I) -> Selfwhere
I: IntoIterator<Item = (K, V)>,
pub fn union<I>(self, other: I) -> Selfwhere
I: IntoIterator<Item = (K, V)>,
Takes the union of self with another set of elements.
Elements that already exist in self will be overwritten by other.
sourcepub fn union_in_place<I>(&mut self, other: I)where
I: IntoIterator<Item = (K, V)>,
pub fn union_in_place<I>(&mut self, other: I)where
I: IntoIterator<Item = (K, V)>,
Takes the union of self with another set of elements.
Elements that already exist in self will be overwritten by other.
sourcepub fn intersection<I>(self, other: I) -> Self
pub fn intersection<I>(self, other: I) -> Self
Takes the intersection of self with another set of elements.
The intersection is solely based on the keys.
sourcepub fn difference<I>(self, other: I) -> Self
pub fn difference<I>(self, other: I) -> Self
Removes the items corresponding to keys in other from self.
sourcepub fn difference_in_place<I>(&mut self, other: I)
pub fn difference_in_place<I>(&mut self, other: I)
Removes the items corresponding to keys in other from self.
sourcepub fn symmetric_difference<I>(self, other: I) -> Selfwhere
I: IntoIterator<Item = (K, V)>,
pub fn symmetric_difference<I>(self, other: I) -> Selfwhere
I: IntoIterator<Item = (K, V)>,
Add elements that are missing from self, and remove elements contained in self.
Containment is tested by comparing keys only. Values are not checked for equality.
sourcepub fn symmetric_difference_in_place<I>(&mut self, other: I)where
I: IntoIterator<Item = (K, V)>,
pub fn symmetric_difference_in_place<I>(&mut self, other: I)where
I: IntoIterator<Item = (K, V)>,
Add elements that are missing from self, and remove elements contained in self.
Containment is tested by comparing keys only. Values are not checked for equality.
Trait Implementations§
source§impl<I, K, V> BitAnd<I> for PrefixTreeMap<K, V>
impl<I, K, V> BitAnd<I> for PrefixTreeMap<K, V>
Creates the intersection of self and other.
source§impl<I, K, V> BitAndAssign<I> for PrefixTreeMap<K, V>
impl<I, K, V> BitAndAssign<I> for PrefixTreeMap<K, V>
Creates the intersection of self and other.
source§fn bitand_assign(&mut self, other: I)
fn bitand_assign(&mut self, other: I)
&= operation. Read moresource§impl<I, K, V> BitOr<I> for PrefixTreeMap<K, V>
impl<I, K, V> BitOr<I> for PrefixTreeMap<K, V>
Creates the union of self and other.
source§impl<I, K, V> BitOrAssign<I> for PrefixTreeMap<K, V>
impl<I, K, V> BitOrAssign<I> for PrefixTreeMap<K, V>
Creates the union of self and other.
source§fn bitor_assign(&mut self, other: I)
fn bitor_assign(&mut self, other: I)
|= operation. Read moresource§impl<I, K, V> BitXor<I> for PrefixTreeMap<K, V>
impl<I, K, V> BitXor<I> for PrefixTreeMap<K, V>
Creates the symmetric difference of self and other.
source§impl<I, K, V> BitXorAssign<I> for PrefixTreeMap<K, V>
impl<I, K, V> BitXorAssign<I> for PrefixTreeMap<K, V>
Creates the symmetric difference of self and other.
source§fn bitxor_assign(&mut self, other: I)
fn bitxor_assign(&mut self, other: I)
^= operation. Read moresource§impl<K: Clone, V: Clone> Clone for PrefixTreeMap<K, V>
impl<K: Clone, V: Clone> Clone for PrefixTreeMap<K, V>
source§fn clone(&self) -> PrefixTreeMap<K, V>
fn clone(&self) -> PrefixTreeMap<K, V>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl<K, V> Default for PrefixTreeMap<K, V>
impl<K, V> Default for PrefixTreeMap<K, V>
source§impl<K, V> Extend<(K, V)> for PrefixTreeMap<K, V>
impl<K, V> Extend<(K, V)> for PrefixTreeMap<K, V>
source§fn extend<I>(&mut self, iter: I)where
I: IntoIterator<Item = (K, V)>,
fn extend<I>(&mut self, iter: I)where
I: IntoIterator<Item = (K, V)>,
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)source§impl<K, V> FromIterator<(K, V)> for PrefixTreeMap<K, V>
impl<K, V> FromIterator<(K, V)> for PrefixTreeMap<K, V>
source§impl<K, V, Q> Index<&Q> for PrefixTreeMap<K, V>
impl<K, V, Q> Index<&Q> for PrefixTreeMap<K, V>
source§impl<'a, K, V> IntoIterator for &'a PrefixTreeMap<K, V>
impl<'a, K, V> IntoIterator for &'a PrefixTreeMap<K, V>
source§impl<K, V> IntoIterator for PrefixTreeMap<K, V>
impl<K, V> IntoIterator for PrefixTreeMap<K, V>
source§impl<K: Ord, V: Ord> Ord for PrefixTreeMap<K, V>
impl<K: Ord, V: Ord> Ord for PrefixTreeMap<K, V>
source§fn cmp(&self, other: &PrefixTreeMap<K, V>) -> Ordering
fn cmp(&self, other: &PrefixTreeMap<K, V>) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl<K: PartialEq, V: PartialEq> PartialEq for PrefixTreeMap<K, V>
impl<K: PartialEq, V: PartialEq> PartialEq for PrefixTreeMap<K, V>
source§fn eq(&self, other: &PrefixTreeMap<K, V>) -> bool
fn eq(&self, other: &PrefixTreeMap<K, V>) -> bool
self and other values to be equal, and is used
by ==.source§impl<K: PartialOrd, V: PartialOrd> PartialOrd for PrefixTreeMap<K, V>
impl<K: PartialOrd, V: PartialOrd> PartialOrd for PrefixTreeMap<K, V>
source§fn partial_cmp(&self, other: &PrefixTreeMap<K, V>) -> Option<Ordering>
fn partial_cmp(&self, other: &PrefixTreeMap<K, V>) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self and other) and is used by the <=
operator. Read more