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§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§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> Freeze for RedBlackTreeSet<T, P>where
P: Freeze,
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