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>

source

pub const fn new() -> Self

Creates an empty set. The same as Default.

source

pub const fn len(&self) -> usize

Returns the number of items in this set.

source

pub const fn is_empty(&self) -> bool

Returns true if and only if this set is empty.

source

pub fn contains<Q>(&self, item: &Q) -> bool
where Q: ?Sized + AsRef<[u8]>,

Returns true if the key is found in the map, false otherwise.

source

pub fn remove<Q>(&mut self, key: &Q) -> bool
where Q: ?Sized + AsRef<[u8]>,

Removes a key if it existed. Returns true if a removal happened, and false if the key did not exist in the first place.

source

pub fn iter(&self) -> Iter<'_, T>

Returns an iterator over the borrowed items.

source

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>

source

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.

source

pub fn union<I>(self, other: I) -> Self
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.

source

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.

source

pub fn intersection<I>(&self, other: I) -> Self
where 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.

source

pub fn difference<I>(self, other: I) -> Self
where I: IntoIterator, I::Item: AsRef<[u8]>,

Removes the items of other from self.

source

pub fn difference_in_place<I>(&mut self, other: I)
where I: IntoIterator, I::Item: AsRef<[u8]>,

Removes the items of other from self.

source

pub fn symmetric_difference<I>(self, other: I) -> Self
where I: IntoIterator<Item = T>,

Add elements that are missing from self, and remove elements contained in self.

source

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>
where T: AsRef<[u8]>, I: IntoIterator<Item = T>,

Produces the intersection of self and other.

§

type Output = PrefixTreeSet<T>

The resulting type after applying the & operator.
source§

fn bitand(self, other: I) -> Self::Output

Performs the & operation. Read more
source§

impl<T, I> BitAnd<I> for PrefixTreeSet<T>
where T: AsRef<[u8]>, I: IntoIterator<Item = T>,

Produces the intersection of self and other.

§

type Output = PrefixTreeSet<T>

The resulting type after applying the & operator.
source§

fn bitand(self, other: I) -> Self::Output

Performs the & operation. Read more
source§

impl<T, I> BitAndAssign<I> for PrefixTreeSet<T>
where T: AsRef<[u8]>, I: IntoIterator<Item = T>,

Produces the intersection of self and other.

source§

fn bitand_assign(&mut self, other: I)

Performs the &= operation. Read more
source§

impl<T, I> BitOr<I> for PrefixTreeSet<T>
where T: AsRef<[u8]>, I: IntoIterator<Item = T>,

Produces the union of self and other.

§

type Output = PrefixTreeSet<T>

The resulting type after applying the | operator.
source§

fn bitor(self, other: I) -> Self::Output

Performs the | operation. Read more
source§

impl<T, I> BitOrAssign<I> for PrefixTreeSet<T>
where T: AsRef<[u8]>, I: IntoIterator<Item = T>,

Produces the union of self and other.

source§

fn bitor_assign(&mut self, other: I)

Performs the |= operation. Read more
source§

impl<T, I> BitXor<I> for PrefixTreeSet<T>
where T: AsRef<[u8]>, I: IntoIterator<Item = T>,

Produces the symmetric difference of self and other.

§

type Output = PrefixTreeSet<T>

The resulting type after applying the ^ operator.
source§

fn bitxor(self, other: I) -> Self::Output

Performs the ^ operation. Read more
source§

impl<T, I> BitXorAssign<I> for PrefixTreeSet<T>
where T: AsRef<[u8]>, I: IntoIterator<Item = T>,

Produces the symmetric difference of self and other.

source§

fn bitxor_assign(&mut self, other: I)

Performs the ^= operation. Read more
source§

impl<T: Clone> Clone for PrefixTreeSet<T>

source§

fn clone(&self) -> PrefixTreeSet<T>

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<T: Debug> Debug for PrefixTreeSet<T>

source§

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

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

impl<T> Default for PrefixTreeSet<T>

source§

fn default() -> Self

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

impl<T: AsRef<[u8]>> Extend<T> for PrefixTreeSet<T>

source§

fn extend<I>(&mut self, iter: I)
where I: IntoIterator<Item = T>,

Extends a collection with the contents of an iterator. Read more
source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
source§

impl<K, const N: usize> From<[K; N]> for PrefixTreeSet<K>
where K: AsRef<[u8]>,

source§

fn from(items: [K; N]) -> Self

Converts to this type from the input type.
source§

impl<T: AsRef<[u8]>> FromIterator<T> for PrefixTreeSet<T>

source§

fn from_iter<I>(iter: I) -> Self
where I: IntoIterator<Item = T>,

Creates a value from an iterator. Read more
source§

impl<T: Hash> Hash for PrefixTreeSet<T>

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<'a, T> IntoIterator for &'a PrefixTreeSet<T>

§

type IntoIter = Iter<'a, T>

Which kind of iterator are we turning this into?
§

type Item = &'a T

The type of the elements being iterated over.
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl<T> IntoIterator for PrefixTreeSet<T>

§

type IntoIter = IntoIter<T>

Which kind of iterator are we turning this into?
§

type Item = T

The type of the elements being iterated over.
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl<T: Ord> Ord for PrefixTreeSet<T>

source§

fn cmp(&self, other: &PrefixTreeSet<T>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl<T: PartialEq> PartialEq for PrefixTreeSet<T>

source§

fn eq(&self, other: &PrefixTreeSet<T>) -> 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<T: PartialOrd> PartialOrd for PrefixTreeSet<T>

source§

fn partial_cmp(&self, other: &PrefixTreeSet<T>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

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

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

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

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<T: Eq> Eq for PrefixTreeSet<T>

source§

impl<T> StructuralPartialEq for PrefixTreeSet<T>

Auto Trait Implementations§

§

impl<T> Freeze for PrefixTreeSet<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for PrefixTreeSet<T>
where T: RefUnwindSafe,

§

impl<T> Send for PrefixTreeSet<T>
where T: Send,

§

impl<T> Sync for PrefixTreeSet<T>
where T: Sync,

§

impl<T> Unpin for PrefixTreeSet<T>
where T: Unpin,

§

impl<T> UnwindSafe for PrefixTreeSet<T>
where T: 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> 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, 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.