Struct avl::AvlTreeSet
source · [−]pub struct AvlTreeSet<T> { /* private fields */ }
Expand description
An ordered set implemented with an AVL tree.
use avl::AvlTreeSet;
let mut set = AvlTreeSet::new();
set.insert(0);
set.insert(1);
set.insert(2);
assert_eq!(set.get(&1), Some(&1));
set.remove(&1);
assert!(set.get(&1).is_none());
Implementations
sourceimpl<T: Ord> AvlTreeSet<T>
impl<T: Ord> AvlTreeSet<T>
sourceimpl<T> AvlTreeSet<T>
impl<T> AvlTreeSet<T>
sourcepub fn iter(&self) -> Iter<'_, T>ⓘNotable traits for Iter<'a, T>impl<'a, T> Iterator for Iter<'a, T> type Item = &'a T;
pub fn iter(&self) -> Iter<'_, T>ⓘNotable traits for Iter<'a, T>impl<'a, T> Iterator for Iter<'a, T> type Item = &'a T;
Gets an iterator over the values of the map in sorted order.
sourcepub fn get<Q>(&self, value: &Q) -> Option<&T> where
T: Borrow<Q>,
Q: Ord + ?Sized,
pub fn get<Q>(&self, value: &Q) -> Option<&T> where
T: Borrow<Q>,
Q: Ord + ?Sized,
Returns a reference to the value in the set that is equal to the given value.
The value may be any borrowed form of the set’s value type, but the ordering on the borrowed form must match the ordering on the value type.
sourcepub fn contains<Q>(&self, value: &Q) -> bool where
T: Borrow<Q>,
Q: Ord + ?Sized,
pub fn contains<Q>(&self, value: &Q) -> bool where
T: Borrow<Q>,
Q: Ord + ?Sized,
Returns true if the set contains a value.
The value may be any borrowed form of the set’s value type, but the ordering on the borrowed form must match the ordering on the value type.
sourcepub fn remove<Q>(&mut self, value: &Q) -> bool where
T: Borrow<Q>,
Q: Ord + ?Sized,
pub fn remove<Q>(&mut self, value: &Q) -> bool where
T: Borrow<Q>,
Q: Ord + ?Sized,
Removes a value from the set. Returns whether the value was previously in the set.
The value may be any borrowed form of the set’s value type, but the ordering on the borrowed form must match the ordering on the value type.
sourcepub fn take<Q>(&mut self, value: &Q) -> Option<T> where
T: Borrow<Q>,
Q: Ord + ?Sized,
pub fn take<Q>(&mut self, value: &Q) -> Option<T> where
T: Borrow<Q>,
Q: Ord + ?Sized,
Removes a value from the set. Returns the value if it was previously in the set.
The value may be any borrowed form of the set’s value type, but the ordering on the borrowed form must match the ordering on the value type.
sourcepub fn range<Q, R>(&self, range: R) -> Range<'_, T>ⓘNotable traits for Range<'a, T>impl<'a, T> Iterator for Range<'a, T> type Item = &'a T;
where
T: Borrow<Q>,
R: RangeBounds<Q>,
Q: Ord + ?Sized,
pub fn range<Q, R>(&self, range: R) -> Range<'_, T>ⓘNotable traits for Range<'a, T>impl<'a, T> Iterator for Range<'a, T> type Item = &'a T;
where
T: Borrow<Q>,
R: RangeBounds<Q>,
Q: Ord + ?Sized,
Gets an iterator over a sub-range of values in the set in sorted order.
The value may be any borrowed form of the set’s value type, but the ordering on the borrowed form must match the ordering on the value type.
Panics
Panics if range start > end
.
Panics if range start == end
and both bounds are Excluded
.
sourceimpl<T: Ord> AvlTreeSet<T>
impl<T: Ord> AvlTreeSet<T>
sourcepub fn append(&mut self, other: &mut Self)
pub fn append(&mut self, other: &mut Self)
Moves all values from other into self, leaving other empty.
sourcepub fn split_off<Q>(&mut self, key: &Q) -> Self where
T: Borrow<Q>,
Q: ?Sized + Ord,
pub fn split_off<Q>(&mut self, key: &Q) -> Self where
T: Borrow<Q>,
Q: ?Sized + Ord,
Splits the collection into two at the given key. Returns everything after the given key, including the key.
sourcepub fn union<'a>(&'a self, other: &'a Self) -> Union<'a, T>ⓘNotable traits for Union<'a, T>impl<'a, T: Ord> Iterator for Union<'a, T> type Item = &'a T;
pub fn union<'a>(&'a self, other: &'a Self) -> Union<'a, T>ⓘNotable traits for Union<'a, T>impl<'a, T: Ord> Iterator for Union<'a, T> type Item = &'a T;
Gets an iterator over the values of the union set,
i.e., all values in self
or other
, without duplicates,
in ascending order.
sourcepub fn intersection<'a>(&'a self, other: &'a Self) -> Intersection<'a, T>ⓘNotable traits for Intersection<'a, T>impl<'a, T: Ord> Iterator for Intersection<'a, T> type Item = &'a T;
pub fn intersection<'a>(&'a self, other: &'a Self) -> Intersection<'a, T>ⓘNotable traits for Intersection<'a, T>impl<'a, T: Ord> Iterator for Intersection<'a, T> type Item = &'a T;
Gets an iterator over the values of the intersection set,
i.e., all values that are botih in self
and other
,
in ascending order.
sourcepub fn difference<'a>(&'a self, other: &'a Self) -> Difference<'a, T>ⓘNotable traits for Difference<'a, T>impl<'a, T: Ord> Iterator for Difference<'a, T> type Item = &'a T;
pub fn difference<'a>(&'a self, other: &'a Self) -> Difference<'a, T>ⓘNotable traits for Difference<'a, T>impl<'a, T: Ord> Iterator for Difference<'a, T> type Item = &'a T;
Gets an iterator over the values of the difference between two sets,
i.e., all values that are in self
but not in other
,
in ascending order.
sourcepub fn symmetric_difference<'a>(
&'a self,
other: &'a Self
) -> SymmetricDifference<'a, T>ⓘNotable traits for SymmetricDifference<'a, T>impl<'a, T: Ord> Iterator for SymmetricDifference<'a, T> type Item = &'a T;
pub fn symmetric_difference<'a>(
&'a self,
other: &'a Self
) -> SymmetricDifference<'a, T>ⓘNotable traits for SymmetricDifference<'a, T>impl<'a, T: Ord> Iterator for SymmetricDifference<'a, T> type Item = &'a T;
Gets an iterator over the values of the symmectric difference of two sets,
i.e., all values in self
or other
, but not in both,
in ascending order.
sourcepub fn is_disjoint(&self, other: &Self) -> bool
pub fn is_disjoint(&self, other: &Self) -> 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: &Self) -> bool
pub fn is_subset(&self, other: &Self) -> bool
Returns true
if the set is a subset of another,
i.e., other
contains at least all the values in self
.
sourcepub fn is_superset(&self, other: &Self) -> bool
pub fn is_superset(&self, other: &Self) -> bool
Returns true
if the set is a superset of another,
i.e., self
contains at least all the values in other
.
Trait Implementations
sourceimpl<T: Ord + Clone> BitAnd<&'_ AvlTreeSet<T>> for &AvlTreeSet<T>
impl<T: Ord + Clone> BitAnd<&'_ AvlTreeSet<T>> for &AvlTreeSet<T>
sourcefn bitand(self, rhs: &AvlTreeSet<T>) -> AvlTreeSet<T>
fn bitand(self, rhs: &AvlTreeSet<T>) -> AvlTreeSet<T>
Returns the intersection of self
and rhs
as a new set.
type Output = AvlTreeSet<T>
type Output = AvlTreeSet<T>
The resulting type after applying the &
operator.
sourceimpl<T: Ord + Clone> BitOr<&'_ AvlTreeSet<T>> for &AvlTreeSet<T>
impl<T: Ord + Clone> BitOr<&'_ AvlTreeSet<T>> for &AvlTreeSet<T>
sourcefn bitor(self, rhs: &AvlTreeSet<T>) -> AvlTreeSet<T>
fn bitor(self, rhs: &AvlTreeSet<T>) -> AvlTreeSet<T>
Returns the union of self
and rhs
as a new set.
type Output = AvlTreeSet<T>
type Output = AvlTreeSet<T>
The resulting type after applying the |
operator.
sourceimpl<T: Ord + Clone> BitXor<&'_ AvlTreeSet<T>> for &AvlTreeSet<T>
impl<T: Ord + Clone> BitXor<&'_ AvlTreeSet<T>> for &AvlTreeSet<T>
sourcefn bitxor(self, rhs: &AvlTreeSet<T>) -> AvlTreeSet<T>
fn bitxor(self, rhs: &AvlTreeSet<T>) -> AvlTreeSet<T>
Returns the symmetric difference of self
and rhs
as a new set.
type Output = AvlTreeSet<T>
type Output = AvlTreeSet<T>
The resulting type after applying the ^
operator.
sourceimpl<T: Clone> Clone for AvlTreeSet<T>
impl<T: Clone> Clone for AvlTreeSet<T>
sourcefn clone(&self) -> AvlTreeSet<T>
fn clone(&self) -> AvlTreeSet<T>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl<T: Debug> Debug for AvlTreeSet<T>
impl<T: Debug> Debug for AvlTreeSet<T>
sourceimpl<'a, T> Extend<&'a T> for AvlTreeSet<T> where
T: Ord + Copy,
T: 'a,
impl<'a, T> Extend<&'a T> for AvlTreeSet<T> where
T: Ord + Copy,
T: 'a,
sourcefn extend<I>(&mut self, iter: I) where
I: IntoIterator<Item = &'a T>,
fn extend<I>(&mut self, iter: I) where
I: IntoIterator<Item = &'a T>,
Extends a collection with the contents of an iterator. Read more
sourcefn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)Extends a collection with exactly one element.
sourcefn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more
sourceimpl<T: Ord> Extend<T> for AvlTreeSet<T>
impl<T: Ord> Extend<T> for AvlTreeSet<T>
sourcefn extend<I>(&mut self, iter: I) where
I: IntoIterator<Item = T>,
fn extend<I>(&mut self, iter: I) where
I: IntoIterator<Item = T>,
Extends a collection with the contents of an iterator. Read more
sourcefn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)Extends a collection with exactly one element.
sourcefn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more
sourceimpl<T: Ord> FromIterator<T> for AvlTreeSet<T>
impl<T: Ord> FromIterator<T> for AvlTreeSet<T>
sourcefn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
Creates a value from an iterator. Read more
sourceimpl<T: Hash> Hash for AvlTreeSet<T>
impl<T: Hash> Hash for AvlTreeSet<T>
sourceimpl<'a, T> IntoIterator for &'a AvlTreeSet<T>
impl<'a, T> IntoIterator for &'a AvlTreeSet<T>
sourceimpl<T> IntoIterator for AvlTreeSet<T>
impl<T> IntoIterator for AvlTreeSet<T>
sourceimpl<T: Ord> Ord for AvlTreeSet<T>
impl<T: Ord> Ord for AvlTreeSet<T>
sourceimpl<T: PartialEq> PartialEq<AvlTreeSet<T>> for AvlTreeSet<T>
impl<T: PartialEq> PartialEq<AvlTreeSet<T>> for AvlTreeSet<T>
sourcefn eq(&self, other: &AvlTreeSet<T>) -> bool
fn eq(&self, other: &AvlTreeSet<T>) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &AvlTreeSet<T>) -> bool
fn ne(&self, other: &AvlTreeSet<T>) -> bool
This method tests for !=
.
sourceimpl<T: PartialOrd> PartialOrd<AvlTreeSet<T>> for AvlTreeSet<T>
impl<T: PartialOrd> PartialOrd<AvlTreeSet<T>> for AvlTreeSet<T>
sourcefn partial_cmp(&self, other: &AvlTreeSet<T>) -> Option<Ordering>
fn partial_cmp(&self, other: &AvlTreeSet<T>) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
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 · sourcefn le(&self, other: &Rhs) -> bool
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
sourceimpl<T: Ord + Clone> Sub<&'_ AvlTreeSet<T>> for &AvlTreeSet<T>
impl<T: Ord + Clone> Sub<&'_ AvlTreeSet<T>> for &AvlTreeSet<T>
sourcefn sub(self, rhs: &AvlTreeSet<T>) -> AvlTreeSet<T>
fn sub(self, rhs: &AvlTreeSet<T>) -> AvlTreeSet<T>
Returns the difference of self
and rhs
as a new set.
type Output = AvlTreeSet<T>
type Output = AvlTreeSet<T>
The resulting type after applying the -
operator.
impl<T: Eq> Eq for AvlTreeSet<T>
impl<T> StructuralEq for AvlTreeSet<T>
impl<T> StructuralPartialEq for AvlTreeSet<T>
Auto Trait Implementations
impl<T> RefUnwindSafe for AvlTreeSet<T> where
T: RefUnwindSafe,
impl<T> Send for AvlTreeSet<T> where
T: Send,
impl<T> Sync for AvlTreeSet<T> where
T: Sync,
impl<T> Unpin for AvlTreeSet<T>
impl<T> UnwindSafe for AvlTreeSet<T> where
T: RefUnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more