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>
impl<T> PopulatedBTreeSet<T>
pub fn iter(&self) -> PopulatedIter<'_, T>
Source§impl<T: Ord> PopulatedBTreeSet<T>
impl<T: Ord> PopulatedBTreeSet<T>
Sourcepub fn new(value: T) -> PopulatedBTreeSet<T>
pub fn new(value: T) -> PopulatedBTreeSet<T>
Creates a singleton set with the given value.
Sourcepub fn difference<'a>(&'a self, other: &'a BTreeSet<T>) -> Difference<'a, T>
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.
Sourcepub fn symmetric_difference<'a>(
&'a self,
other: &'a BTreeSet<T>,
) -> SymmetricDifference<'a, T>
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.
Sourcepub fn intersection<'a>(&'a self, other: &'a BTreeSet<T>) -> Intersection<'a, T>
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.
Sourcepub fn contains<Q: Ord + ?Sized>(&self, value: &Q) -> boolwhere
T: Borrow<Q>,
pub fn contains<Q: Ord + ?Sized>(&self, value: &Q) -> boolwhere
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.
Sourcepub fn get<Q: Ord + ?Sized>(&self, value: &Q) -> Option<&T>where
T: Borrow<Q>,
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.
Sourcepub fn is_disjoint(&self, other: &BTreeSet<T>) -> bool
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.
Sourcepub fn is_subset(&self, other: &BTreeSet<T>) -> bool
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.
Sourcepub fn is_superset(&self, other: &BTreeSet<T>) -> bool
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.
Sourcepub fn first(&self) -> &T
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.
Sourcepub fn last(&self) -> &T
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.
Sourcepub fn pop_first(self) -> (T, BTreeSet<T>)
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.
Sourcepub fn pop_last(self) -> (BTreeSet<T>, T)
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.
Sourcepub fn insert(&mut self, value: T) -> bool
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.
Sourcepub fn replace(&mut self, value: T) -> Option<T>
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.
Sourcepub fn take<Q: Ord + ?Sized>(
self,
value: &Q,
) -> Result<(T, BTreeSet<T>), PopulatedBTreeSet<T>>where
T: Borrow<Q>,
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§impl<T> PopulatedBTreeSet<T>
impl<T> PopulatedBTreeSet<T>
Trait Implementations§
Source§impl<T: Ord + Clone> BitOr<&PopulatedBTreeSet<T>> for &BTreeSet<T>
impl<T: Ord + Clone> BitOr<&PopulatedBTreeSet<T>> for &BTreeSet<T>
Source§type Output = PopulatedBTreeSet<T>
type Output = PopulatedBTreeSet<T>
| operator.Source§impl<T: Ord + Clone> BitOr<&PopulatedBTreeSet<T>> for &PopulatedBTreeSet<T>
impl<T: Ord + Clone> BitOr<&PopulatedBTreeSet<T>> for &PopulatedBTreeSet<T>
Source§type Output = PopulatedBTreeSet<T>
type Output = PopulatedBTreeSet<T>
| operator.Source§impl<T: Clone> Clone for PopulatedBTreeSet<T>
impl<T: Clone> Clone for PopulatedBTreeSet<T>
Source§fn clone(&self) -> PopulatedBTreeSet<T>
fn clone(&self) -> PopulatedBTreeSet<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 PopulatedBTreeSet<T>
impl<T: Debug> Debug for PopulatedBTreeSet<T>
Source§impl<T> From<PopulatedBTreeSet<T>> for BTreeSet<T>
impl<T> From<PopulatedBTreeSet<T>> for BTreeSet<T>
Source§fn from(populated_btree_set: PopulatedBTreeSet<T>) -> BTreeSet<T>
fn from(populated_btree_set: PopulatedBTreeSet<T>) -> BTreeSet<T>
Source§impl<T: Ord> FromPopulatedIterator<T> for PopulatedBTreeSet<T>
impl<T: Ord> FromPopulatedIterator<T> for PopulatedBTreeSet<T>
Source§fn from_populated_iter(iter: impl IntoPopulatedIterator<Item = T>) -> Self
fn from_populated_iter(iter: impl IntoPopulatedIterator<Item = T>) -> Self
PopulatedIterator into Self.Source§impl<T: Hash> Hash for PopulatedBTreeSet<T>
impl<T: Hash> Hash for PopulatedBTreeSet<T>
Source§impl<'a, T> IntoIterator for &'a PopulatedBTreeSet<T>
impl<'a, T> IntoIterator for &'a PopulatedBTreeSet<T>
Source§impl<T> IntoIterator for PopulatedBTreeSet<T>
impl<T> IntoIterator for PopulatedBTreeSet<T>
Source§impl<'a, T> IntoPopulatedIterator for &'a PopulatedBTreeSet<T>
impl<'a, T> IntoPopulatedIterator for &'a PopulatedBTreeSet<T>
type PopulatedIntoIter = PopulatedIter<'a, T>
Source§fn into_populated_iter(self) -> PopulatedIter<'a, T>
fn into_populated_iter(self) -> PopulatedIter<'a, T>
PopulatedIterator.