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() -> RedBlackTreeSet<T, ArcTK>
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,
Sourcepub fn ptr_eq<PO>(&self, other: &RedBlackTreeSet<T, PO>) -> boolwhere
PO: SharedPointerKind,
pub fn ptr_eq<PO>(&self, other: &RedBlackTreeSet<T, PO>) -> boolwhere
PO: SharedPointerKind,
Test whether the two sets refer to the same content in memory.
This would return true if you’re comparing a set to itself, or if you’re comparing a set to a fresh clone of itself.
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, ) -> Map<Map<IterPtr<'_, T, (), P>, fn(&SharedPointer<Entry<T, ()>, P>) -> (&T, &())>, fn((&T, &())) -> &T> ⓘ
pub fn range<Q, RB>( &self, range: RB, ) -> Map<Map<RangeIterPtr<'_, T, (), RB, Q, P>, fn(&SharedPointer<Entry<T, ()>, P>) -> (&T, &())>, fn((&T, &())) -> &T> ⓘ
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 duplicate 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: D,
) -> Result<RedBlackTreeSet<T, P>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<RedBlackTreeSet<T, P>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
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>(into_iter: I) -> RedBlackTreeSet<T, P>where
I: IntoIterator<Item = T>,
fn from_iter<I>(into_iter: I) -> RedBlackTreeSet<T, P>where
I: IntoIterator<Item = T>,
Creates a value from an iterator. Read more
Source§impl<T, P> Hash for RedBlackTreeSet<T, P>
impl<T, P> 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, P> Ord for RedBlackTreeSet<T, P>where
T: Ord,
P: SharedPointerKind,
impl<T, P> Ord for RedBlackTreeSet<T, P>where
T: Ord,
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, P, PO> PartialOrd<RedBlackTreeSet<T, PO>> for RedBlackTreeSet<T, P>
impl<T, P, PO> PartialOrd<RedBlackTreeSet<T, PO>> for RedBlackTreeSet<T, P>
Source§impl<T, P> Serialize for RedBlackTreeSet<T, P>
impl<T, P> Serialize for RedBlackTreeSet<T, P>
Source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
Serialize this value into the given Serde serializer. Read more
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more