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!(set.contains(&1));
set.remove(&1);
assert!(!set.contains(&1));
Implementations§
source§impl<T: Ord> AvlTreeSet<T>
impl<T: Ord> AvlTreeSet<T>
source§impl<T> AvlTreeSet<T>
impl<T> AvlTreeSet<T>
sourcepub fn iter(&self) -> Iter<'_, T> ⓘ
pub fn iter(&self) -> Iter<'_, 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) -> boolwhere
T: Borrow<Q>,
Q: Ord + ?Sized,
pub fn contains<Q>(&self, value: &Q) -> boolwhere 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) -> boolwhere
T: Borrow<Q>,
Q: Ord + ?Sized,
pub fn remove<Q>(&mut self, value: &Q) -> boolwhere 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> ⓘwhere
T: Borrow<Q>,
R: RangeBounds<Q>,
Q: Ord + ?Sized,
pub fn range<Q, R>(&self, range: R) -> Range<'_, 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
.
source§impl<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) -> Selfwhere
T: Borrow<Q>,
Q: ?Sized + Ord,
pub fn split_off<Q>(&mut self, key: &Q) -> Selfwhere 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> ⓘ
pub fn union<'a>(&'a self, other: &'a Self) -> Union<'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> ⓘ
pub fn intersection<'a>(&'a self, other: &'a Self) -> Intersection<'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> ⓘ
pub fn difference<'a>(&'a self, other: &'a Self) -> Difference<'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> ⓘ
pub fn symmetric_difference<'a>( &'a self, other: &'a Self ) -> SymmetricDifference<'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§
source§impl<T: Ord + Clone> BitAnd<&AvlTreeSet<T>> for &AvlTreeSet<T>
impl<T: Ord + Clone> BitAnd<&AvlTreeSet<T>> for &AvlTreeSet<T>
source§fn 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>
&
operator.source§impl<T: Ord + Clone> BitOr<&AvlTreeSet<T>> for &AvlTreeSet<T>
impl<T: Ord + Clone> BitOr<&AvlTreeSet<T>> for &AvlTreeSet<T>
source§fn 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>
|
operator.source§impl<T: Ord + Clone> BitXor<&AvlTreeSet<T>> for &AvlTreeSet<T>
impl<T: Ord + Clone> BitXor<&AvlTreeSet<T>> for &AvlTreeSet<T>
source§fn 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>
^
operator.source§impl<T: Clone> Clone for AvlTreeSet<T>
impl<T: Clone> Clone for AvlTreeSet<T>
source§fn clone(&self) -> AvlTreeSet<T>
fn clone(&self) -> AvlTreeSet<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 AvlTreeSet<T>
impl<T: Debug> Debug for AvlTreeSet<T>
source§impl<'a, T> Extend<&'a T> for AvlTreeSet<T>where
T: Ord + Copy + 'a,
impl<'a, T> Extend<&'a T> for AvlTreeSet<T>where T: Ord + Copy + 'a,
source§fn 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>,
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: Ord> Extend<T> for AvlTreeSet<T>
impl<T: Ord> Extend<T> for AvlTreeSet<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: Ord> FromIterator<T> for AvlTreeSet<T>
impl<T: Ord> FromIterator<T> for AvlTreeSet<T>
source§fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
source§impl<T: Hash> Hash for AvlTreeSet<T>
impl<T: Hash> Hash for AvlTreeSet<T>
source§impl<'a, T> IntoIterator for &'a AvlTreeSet<T>
impl<'a, T> IntoIterator for &'a AvlTreeSet<T>
source§impl<T> IntoIterator for AvlTreeSet<T>
impl<T> IntoIterator for AvlTreeSet<T>
source§impl<T: Ord> Ord for AvlTreeSet<T>
impl<T: Ord> Ord for AvlTreeSet<T>
source§fn cmp(&self, other: &AvlTreeSet<T>) -> Ordering
fn cmp(&self, other: &AvlTreeSet<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<AvlTreeSet<T>> for AvlTreeSet<T>
impl<T: PartialEq> PartialEq<AvlTreeSet<T>> for AvlTreeSet<T>
source§fn eq(&self, other: &AvlTreeSet<T>) -> bool
fn eq(&self, other: &AvlTreeSet<T>) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl<T: PartialOrd> PartialOrd<AvlTreeSet<T>> for AvlTreeSet<T>
impl<T: PartialOrd> PartialOrd<AvlTreeSet<T>> for AvlTreeSet<T>
source§fn partial_cmp(&self, other: &AvlTreeSet<T>) -> Option<Ordering>
fn partial_cmp(&self, other: &AvlTreeSet<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 moresource§impl<T: Ord + Clone> Sub<&AvlTreeSet<T>> for &AvlTreeSet<T>
impl<T: Ord + Clone> Sub<&AvlTreeSet<T>> for &AvlTreeSet<T>
source§fn 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>
-
operator.