PopulatedBTreeSet

Struct PopulatedBTreeSet 

Source
pub struct PopulatedBTreeSet<T>(/* private fields */);
Expand description

A populated (i.e. guaranteed to be non-empty) ordered set based on a B-Tree.

Implementations§

Source§

impl<T> PopulatedBTreeSet<T>

Source

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

Source§

impl<T: Ord> PopulatedBTreeSet<T>

Source

pub fn new(value: T) -> PopulatedBTreeSet<T>

Creates a singleton set with the given value.

Source

pub fn difference<'a>(&'a self, other: &'a BTreeSet<T>) -> Difference<'a, T>

Visits the elements representing the difference, i.e., the elements that are in self but not in other, in ascending order.

Source

pub fn symmetric_difference<'a>( &'a self, other: &'a BTreeSet<T>, ) -> SymmetricDifference<'a, T>

Visits the elements representing the symmetric difference, i.e., the elements that are in self or in other but not in both, in ascending order.

Source

pub fn intersection<'a>(&'a self, other: &'a BTreeSet<T>) -> Intersection<'a, T>

Visits the elements representing the intersection, i.e., the elements that are both in self and other, in ascending order.

Source

pub fn contains<Q: Ord + ?Sized>(&self, value: &Q) -> bool
where T: Borrow<Q>,

Returns true if the populated set contains an element equal to the value.

The value may be any borrowed form of the set’s element type, but the ordering on the borrowed form must match the ordering on the element type.

Source

pub fn get<Q: Ord + ?Sized>(&self, value: &Q) -> Option<&T>
where T: Borrow<Q>,

Returns a reference to the element in the populated set, if any, that is equal to the value.

The value may be any borrowed form of the set’s element type, but the ordering on the borrowed form must match the ordering on the element type.

Source

pub fn is_disjoint(&self, other: &BTreeSet<T>) -> bool

Returns true if self has no elements in common with other. This is equivalent to checking for an empty intersection.

Source

pub fn is_subset(&self, other: &BTreeSet<T>) -> bool

Returns true if the set is a subset of another, i.e., other contains at least all the elements in self.

Source

pub fn is_superset(&self, other: &BTreeSet<T>) -> bool

Returns true if the set is a superset of another, i.e., self contains at least all the elements in other.

Source

pub fn first(&self) -> &T

Returns a reference to the first element in the populated set. This element is always the minimum of all elements in the set.

Source

pub fn last(&self) -> &T

Returns a reference to the last element in the populated set. This element is always the maximum of all elements in the set.

Source

pub fn pop_first(self) -> (T, BTreeSet<T>)

Removes the first element from the populated set and returns it along with the remaining set. The first element is always the minimum element in the set.

Source

pub fn pop_last(self) -> (BTreeSet<T>, T)

Removes the last element from the set and returns it, if any. The last element is always the maximum element in the set.

Source

pub fn insert(&mut self, value: T) -> bool

Adds a value to the populated set.

Returns whether the value was newly inserted. That is:

  • If the set did not previously contain an equal value, true is returned.
  • If the set already contained an equal value, false is returned, and the entry is not updated.
Source

pub fn replace(&mut self, value: T) -> Option<T>

Adds a value to the set, replacing the existing element, if any, that is equal to the value. Returns the replaced element.

Source

pub fn take<Q: Ord + ?Sized>( self, value: &Q, ) -> Result<(T, BTreeSet<T>), PopulatedBTreeSet<T>>
where T: Borrow<Q>,

Removes and returns the element in the set, if any, that is equal to the value.

The value may be any borrowed form of the set’s element type, but the ordering on the borrowed form must match the ordering on the element type.

Source

pub fn retain(self, predicate: impl FnMut(&T) -> bool) -> BTreeSet<T>

Retains only the elements specified by the predicate.

In other words, remove all elements e for which f(&e) returns false. The elements are visited in ascending order.

Source

pub fn append(&mut self, other: &mut BTreeSet<T>)

Moves all elements from other into self, leaving other empty.

Source§

impl<T> PopulatedBTreeSet<T>

Source

pub fn clear(self) -> BTreeSet<T>

Unpopulates the underlying set and returns it.

Source

pub fn len(&self) -> NonZeroUsize

Returns the number of elements in the set.

Trait Implementations§

Source§

impl<T: Ord + Clone> BitOr<&BTreeSet<T>> for &PopulatedBTreeSet<T>

Source§

type Output = PopulatedBTreeSet<T>

The resulting type after applying the | operator.
Source§

fn bitor(self, other: &BTreeSet<T>) -> Self::Output

Performs the | operation. Read more
Source§

impl<T: Ord + Clone> BitOr<&PopulatedBTreeSet<T>> for &BTreeSet<T>

Source§

type Output = PopulatedBTreeSet<T>

The resulting type after applying the | operator.
Source§

fn bitor(self, other: &PopulatedBTreeSet<T>) -> Self::Output

Performs the | operation. Read more
Source§

impl<T: Ord + Clone> BitOr<&PopulatedBTreeSet<T>> for &PopulatedBTreeSet<T>

Source§

type Output = PopulatedBTreeSet<T>

The resulting type after applying the | operator.
Source§

fn bitor(self, other: &PopulatedBTreeSet<T>) -> Self::Output

Performs the | operation. Read more
Source§

impl<T: Clone> Clone for PopulatedBTreeSet<T>

Source§

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

Returns a duplicate 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 PopulatedBTreeSet<T>

Source§

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

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

impl<T> From<PopulatedBTreeSet<T>> for BTreeSet<T>

Source§

fn from(populated_btree_set: PopulatedBTreeSet<T>) -> BTreeSet<T>

Converts to this type from the input type.
Source§

impl<T: Ord> FromPopulatedIterator<T> for PopulatedBTreeSet<T>

Source§

fn from_populated_iter(iter: impl IntoPopulatedIterator<Item = T>) -> Self

Converts a PopulatedIterator into Self.
Source§

impl<T: Hash> Hash for PopulatedBTreeSet<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 PopulatedBTreeSet<T>

Source§

type Item = &'a T

The type of the elements being iterated over.
Source§

type IntoIter = Iter<'a, T>

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

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<T> IntoIterator for PopulatedBTreeSet<T>

Source§

type Item = T

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter<T>

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

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<'a, T> IntoPopulatedIterator for &'a PopulatedBTreeSet<T>

Source§

type PopulatedIntoIter = PopulatedIter<'a, T>

Source§

fn into_populated_iter(self) -> PopulatedIter<'a, T>

Converts the type into a PopulatedIterator.
Source§

impl<T: Ord> Ord for PopulatedBTreeSet<T>

Source§

fn cmp(&self, other: &PopulatedBTreeSet<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,

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

impl<T: PartialEq> PartialEq for PopulatedBTreeSet<T>

Source§

fn eq(&self, other: &PopulatedBTreeSet<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: PartialOrd> PartialOrd for PopulatedBTreeSet<T>

Source§

fn partial_cmp(&self, other: &PopulatedBTreeSet<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

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

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

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<T> TryFrom<BTreeSet<T>> for PopulatedBTreeSet<T>

Source§

type Error = BTreeSet<T>

The type returned in the event of a conversion error.
Source§

fn try_from(btree_set: BTreeSet<T>) -> Result<PopulatedBTreeSet<T>, Self::Error>

Performs the conversion.
Source§

impl<T: Eq> Eq for PopulatedBTreeSet<T>

Source§

impl<T> StructuralPartialEq for PopulatedBTreeSet<T>

Auto Trait Implementations§

§

impl<T> Freeze for PopulatedBTreeSet<T>

§

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

§

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

§

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

§

impl<T> Unpin for PopulatedBTreeSet<T>

§

impl<T> UnwindSafe for PopulatedBTreeSet<T>
where T: RefUnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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,

Source§

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

Source§

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

Source§

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.