Struct pfx::set::PrefixTreeSet
source · pub struct PrefixTreeSet<T> { /* private fields */ }Expand description
An ordered set based on a prefix tree.
Implementations§
source§impl<T> PrefixTreeSet<T>
impl<T> PrefixTreeSet<T>
sourcepub fn contains<Q>(&self, item: &Q) -> bool
pub fn contains<Q>(&self, item: &Q) -> bool
Returns true if the key is found in the map, false otherwise.
sourcepub fn remove<Q>(&mut self, key: &Q) -> bool
pub fn remove<Q>(&mut self, key: &Q) -> bool
Removes a key if it existed. Returns true if a removal happened,
and false if the key did not exist in the first place.
sourcepub fn compact(&mut self)
pub fn compact(&mut self)
Removes all internal nodes which are not useful.
See the documentation of crate::map::PrefixTreeMap::compact
for more details on why this is useful.
source§impl<T: AsRef<[u8]>> PrefixTreeSet<T>
impl<T: AsRef<[u8]>> PrefixTreeSet<T>
sourcepub fn insert(&mut self, key: T) -> bool
pub fn insert(&mut self, key: T) -> bool
Inserts the key if it did not exist.
Returns true if an insertion happened, and false if the key already existed.
sourcepub fn union<I>(self, other: I) -> Selfwhere
I: IntoIterator<Item = T>,
pub fn union<I>(self, other: I) -> Selfwhere
I: IntoIterator<Item = T>,
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 = T>,
pub fn union_in_place<I>(&mut self, other: I)where
I: IntoIterator<Item = T>,
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) -> Selfwhere
I: IntoIterator<Item = T>,
pub fn intersection<I>(&self, other: I) -> Selfwhere
I: IntoIterator<Item = T>,
Takes the intersection of self with another set of elements.
This takes &self by reference and not self by value because
computing the intersection always incurs the allocation of a new
set. For the same reason, there is no intersection_in_place()
method, either.
sourcepub fn difference<I>(self, other: I) -> Self
pub fn difference<I>(self, other: I) -> Self
Removes the items of 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 of other from self.
sourcepub fn symmetric_difference<I>(self, other: I) -> Selfwhere
I: IntoIterator<Item = T>,
pub fn symmetric_difference<I>(self, other: I) -> Selfwhere
I: IntoIterator<Item = T>,
Add elements that are missing from self, and remove elements contained in self.
sourcepub fn symmetric_difference_in_place<I>(&mut self, other: I)where
I: IntoIterator<Item = T>,
pub fn symmetric_difference_in_place<I>(&mut self, other: I)where
I: IntoIterator<Item = T>,
Add elements that are missing from self, and remove elements contained in self.
Trait Implementations§
source§impl<T, I> BitAnd<I> for &PrefixTreeSet<T>
impl<T, I> BitAnd<I> for &PrefixTreeSet<T>
Produces the intersection of self and other.
source§impl<T, I> BitAnd<I> for PrefixTreeSet<T>
impl<T, I> BitAnd<I> for PrefixTreeSet<T>
Produces the intersection of self and other.
source§impl<T, I> BitAndAssign<I> for PrefixTreeSet<T>
impl<T, I> BitAndAssign<I> for PrefixTreeSet<T>
Produces 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<T, I> BitOr<I> for PrefixTreeSet<T>
impl<T, I> BitOr<I> for PrefixTreeSet<T>
Produces the union of self and other.
source§impl<T, I> BitOrAssign<I> for PrefixTreeSet<T>
impl<T, I> BitOrAssign<I> for PrefixTreeSet<T>
Produces 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<T, I> BitXor<I> for PrefixTreeSet<T>
impl<T, I> BitXor<I> for PrefixTreeSet<T>
Produces the symmetric difference of self and other.
source§impl<T, I> BitXorAssign<I> for PrefixTreeSet<T>
impl<T, I> BitXorAssign<I> for PrefixTreeSet<T>
Produces 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<T: Clone> Clone for PrefixTreeSet<T>
impl<T: Clone> Clone for PrefixTreeSet<T>
source§fn clone(&self) -> PrefixTreeSet<T>
fn clone(&self) -> PrefixTreeSet<T>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl<T: Debug> Debug for PrefixTreeSet<T>
impl<T: Debug> Debug for PrefixTreeSet<T>
source§impl<T> Default for PrefixTreeSet<T>
impl<T> Default for PrefixTreeSet<T>
source§impl<T: AsRef<[u8]>> Extend<T> for PrefixTreeSet<T>
impl<T: AsRef<[u8]>> Extend<T> for PrefixTreeSet<T>
source§fn extend<I>(&mut self, iter: I)where
I: IntoIterator<Item = T>,
fn extend<I>(&mut self, iter: I)where
I: IntoIterator<Item = T>,
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<T: AsRef<[u8]>> FromIterator<T> for PrefixTreeSet<T>
impl<T: AsRef<[u8]>> FromIterator<T> for PrefixTreeSet<T>
source§fn from_iter<I>(iter: I) -> Selfwhere
I: IntoIterator<Item = T>,
fn from_iter<I>(iter: I) -> Selfwhere
I: IntoIterator<Item = T>,
source§impl<T: Hash> Hash for PrefixTreeSet<T>
impl<T: Hash> Hash for PrefixTreeSet<T>
source§impl<'a, T> IntoIterator for &'a PrefixTreeSet<T>
impl<'a, T> IntoIterator for &'a PrefixTreeSet<T>
source§impl<T> IntoIterator for PrefixTreeSet<T>
impl<T> IntoIterator for PrefixTreeSet<T>
source§impl<T: Ord> Ord for PrefixTreeSet<T>
impl<T: Ord> Ord for PrefixTreeSet<T>
source§fn cmp(&self, other: &PrefixTreeSet<T>) -> Ordering
fn cmp(&self, other: &PrefixTreeSet<T>) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl<T: PartialEq> PartialEq for PrefixTreeSet<T>
impl<T: PartialEq> PartialEq for PrefixTreeSet<T>
source§fn eq(&self, other: &PrefixTreeSet<T>) -> bool
fn eq(&self, other: &PrefixTreeSet<T>) -> bool
self and other values to be equal, and is used
by ==.source§impl<T: PartialOrd> PartialOrd for PrefixTreeSet<T>
impl<T: PartialOrd> PartialOrd for PrefixTreeSet<T>
source§fn partial_cmp(&self, other: &PrefixTreeSet<T>) -> Option<Ordering>
fn partial_cmp(&self, other: &PrefixTreeSet<T>) -> 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