Struct rpds::set::red_black_tree_set::RedBlackTreeSet
source · pub struct RedBlackTreeSet<T, P = RcK>where
T: Ord,
P: SharedPointerKind,{ /* private fields */ }
Expand description
A persistent set with structural sharing. This implementation uses a red-black tree.
Complexity
Let n be the number of elements in the set.
Temporal complexity
Operation | Average | Worst case |
---|---|---|
new() | Θ(1) | Θ(1) |
insert() | Θ(log(n)) | Θ(log(n)) |
remove() | Θ(log(n)) | Θ(log(n)) |
get() | Θ(log(n)) | Θ(log(n)) |
contains() | Θ(log(n)) | Θ(log(n)) |
size() | Θ(1) | Θ(1) |
clone() | Θ(1) | Θ(1) |
iterator creation | Θ(log(n)) | Θ(log(n)) |
iterator step | Θ(1) | Θ(log(n)) |
iterator full | Θ(n) | Θ(n) |
Implementation details
This is a thin wrapper around a RedBlackTreeMap
.
Implementations§
source§impl<T> RedBlackTreeSet<T, ArcTK>where
T: Ord,
impl<T> RedBlackTreeSet<T, ArcTK>where
T: Ord,
pub fn new_sync() -> RedBlackTreeSetSync<T>
source§impl<T> RedBlackTreeSet<T>where
T: Ord,
impl<T> RedBlackTreeSet<T>where
T: Ord,
pub fn new() -> RedBlackTreeSet<T>
source§impl<T, P> RedBlackTreeSet<T, P>where
T: Ord,
P: SharedPointerKind,
impl<T, P> RedBlackTreeSet<T, P>where
T: Ord,
P: SharedPointerKind,
pub fn new_with_ptr_kind() -> RedBlackTreeSet<T, P>
pub fn insert(&self, v: T) -> RedBlackTreeSet<T, P>
pub fn insert_mut(&mut self, v: T)
pub fn remove<V>(&self, v: &V) -> RedBlackTreeSet<T, P>
pub fn remove_mut<V>(&mut self, v: &V) -> bool
pub fn get<V>(&self, v: &V) -> Option<&T>
pub fn contains<V>(&self, v: &V) -> bool
pub fn first(&self) -> Option<&T>
pub fn last(&self) -> Option<&T>
pub fn is_disjoint<PO>(&self, other: &RedBlackTreeSet<T, PO>) -> boolwhere
PO: SharedPointerKind,
pub fn is_subset<PO>(&self, other: &RedBlackTreeSet<T, PO>) -> boolwhere
PO: SharedPointerKind,
pub fn is_superset<PO>(&self, other: &RedBlackTreeSet<T, PO>) -> boolwhere
PO: SharedPointerKind,
pub fn size(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn iter(&self) -> Iter<'_, T, P>
pub fn range<Q, RB>(&self, range: RB) -> RangeIter<'_, T, RB, Q, P>
Trait Implementations§
source§impl<T, P> Clone for RedBlackTreeSet<T, P>where
T: Ord,
P: SharedPointerKind,
impl<T, P> Clone for RedBlackTreeSet<T, P>where
T: Ord,
P: SharedPointerKind,
source§fn clone(&self) -> RedBlackTreeSet<T, P>
fn clone(&self) -> RedBlackTreeSet<T, P>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl<T, P> Debug for RedBlackTreeSet<T, P>
impl<T, P> Debug for RedBlackTreeSet<T, P>
source§impl<T, P> Default for RedBlackTreeSet<T, P>where
T: Ord,
P: SharedPointerKind,
impl<T, P> Default for RedBlackTreeSet<T, P>where
T: Ord,
P: SharedPointerKind,
source§fn default() -> RedBlackTreeSet<T, P>
fn default() -> RedBlackTreeSet<T, P>
Returns the “default value” for a type. Read more
source§impl<'de, T, P> Deserialize<'de> for RedBlackTreeSet<T, P>
impl<'de, T, P> Deserialize<'de> for RedBlackTreeSet<T, P>
source§fn deserialize<D: Deserializer<'de>>(
deserializer: D
) -> Result<RedBlackTreeSet<T, P>, D::Error>
fn deserialize<D: Deserializer<'de>>( deserializer: D ) -> Result<RedBlackTreeSet<T, P>, D::Error>
Deserialize this value from the given Serde deserializer. Read more
source§impl<T, P> Display for RedBlackTreeSet<T, P>
impl<T, P> Display for RedBlackTreeSet<T, P>
source§impl<T, P> FromIterator<T> for RedBlackTreeSet<T, P>where
T: Ord,
P: SharedPointerKind,
impl<T, P> FromIterator<T> for RedBlackTreeSet<T, P>where
T: Ord,
P: SharedPointerKind,
source§fn from_iter<I: IntoIterator<Item = T>>(into_iter: I) -> RedBlackTreeSet<T, P>
fn from_iter<I: IntoIterator<Item = T>>(into_iter: I) -> RedBlackTreeSet<T, P>
Creates a value from an iterator. Read more
source§impl<T, P: SharedPointerKind> Hash for RedBlackTreeSet<T, P>
impl<T, P: SharedPointerKind> Hash for RedBlackTreeSet<T, P>
source§impl<'a, T, P> IntoIterator for &'a RedBlackTreeSet<T, P>where
T: Ord,
P: SharedPointerKind,
impl<'a, T, P> IntoIterator for &'a RedBlackTreeSet<T, P>where
T: Ord,
P: SharedPointerKind,
source§impl<T: Ord, P> Ord for RedBlackTreeSet<T, P>where
P: SharedPointerKind,
impl<T: Ord, P> Ord for RedBlackTreeSet<T, P>where
P: SharedPointerKind,
source§fn cmp(&self, other: &RedBlackTreeSet<T, P>) -> Ordering
fn cmp(&self, other: &RedBlackTreeSet<T, P>) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
source§impl<T, P, PO> PartialEq<RedBlackTreeSet<T, PO>> for RedBlackTreeSet<T, P>
impl<T, P, PO> PartialEq<RedBlackTreeSet<T, PO>> for RedBlackTreeSet<T, P>
source§fn eq(&self, other: &RedBlackTreeSet<T, PO>) -> bool
fn eq(&self, other: &RedBlackTreeSet<T, PO>) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl<T: Ord, P, PO> PartialOrd<RedBlackTreeSet<T, PO>> for RedBlackTreeSet<T, P>where
P: SharedPointerKind,
PO: SharedPointerKind,
impl<T: Ord, P, PO> PartialOrd<RedBlackTreeSet<T, PO>> for RedBlackTreeSet<T, P>where
P: SharedPointerKind,
PO: SharedPointerKind,
source§fn partial_cmp(&self, other: &RedBlackTreeSet<T, PO>) -> Option<Ordering>
fn partial_cmp(&self, other: &RedBlackTreeSet<T, PO>) -> Option<Ordering>
1.0.0 · source§fn 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 moresource§impl<T, P> Serialize for RedBlackTreeSet<T, P>
impl<T, P> Serialize for RedBlackTreeSet<T, P>
impl<T, P> Eq for RedBlackTreeSet<T, P>where
T: Ord,
P: SharedPointerKind,
Auto Trait Implementations§
impl<T, P> RefUnwindSafe for RedBlackTreeSet<T, P>where
P: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, P> Send for RedBlackTreeSet<T, P>
impl<T, P> Sync for RedBlackTreeSet<T, P>
impl<T, P> Unpin for RedBlackTreeSet<T, P>
impl<T, P> UnwindSafe for RedBlackTreeSet<T, P>where
P: UnwindSafe,
T: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more