[−][src]Struct rpds::map::red_black_tree_map::RedBlackTreeMap
A persistent map with structural sharing. This implementation uses a red-black tree.
Complexity
Let n be the number of elements in the map.
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_key() | Θ(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 implementation uses a red-black tree as described in "Purely Functional Data Structures" by Chris Okasaki, page 27. Deletion is implemented according to the paper "Red-Black Trees with Types" by Stefan Kahrs (reference implementation)
Methods
impl<K, V> RedBlackTreeMap<K, V> where
K: Ord,
[src]
K: Ord,
#[must_use]
pub fn new() -> RedBlackTreeMap<K, V>
[src]
impl<K, V, P> RedBlackTreeMap<K, V, P> where
K: Ord,
P: SharedPointerKind,
[src]
K: Ord,
P: SharedPointerKind,
#[must_use]
pub fn new_with_ptr_kind() -> RedBlackTreeMap<K, V, P>
[src]
#[must_use]
pub fn get<Q: ?Sized>(&self, key: &Q) -> Option<&V> where
K: Borrow<Q>,
Q: Ord,
[src]
K: Borrow<Q>,
Q: Ord,
#[must_use]
pub fn first(&self) -> Option<(&K, &V)>
[src]
#[must_use]
pub fn last(&self) -> Option<(&K, &V)>
[src]
#[must_use]
pub fn insert(&self, key: K, value: V) -> RedBlackTreeMap<K, V, P>
[src]
pub fn insert_mut(&mut self, key: K, value: V)
[src]
#[must_use]
pub fn remove<Q: ?Sized>(&self, key: &Q) -> RedBlackTreeMap<K, V, P> where
K: Borrow<Q>,
Q: Ord,
[src]
K: Borrow<Q>,
Q: Ord,
pub fn remove_mut<Q: ?Sized>(&mut self, key: &Q) -> bool where
K: Borrow<Q>,
Q: Ord,
[src]
K: Borrow<Q>,
Q: Ord,
#[must_use]
pub fn contains_key<Q: ?Sized>(&self, key: &Q) -> bool where
K: Borrow<Q>,
Q: Ord,
[src]
K: Borrow<Q>,
Q: Ord,
#[must_use]
pub fn size(&self) -> usize
[src]
#[must_use]
pub fn is_empty(&self) -> bool
[src]
#[must_use]
pub fn iter(&self) -> Iter<K, V, P>
[src]
#[must_use]
pub fn keys(&self) -> IterKeys<K, V, P>
[src]
#[must_use]
pub fn values(&self) -> IterValues<K, V, P>
[src]
#[must_use]
pub fn range<Q: ?Sized, RB>(&self, range: RB) -> RangeIter<K, V, RB, Q, P> where
K: Borrow<Q>,
Q: Ord,
RB: RangeBounds<Q>,
[src]
K: Borrow<Q>,
Q: Ord,
RB: RangeBounds<Q>,
Trait Implementations
impl<K, V: Eq, P> Eq for RedBlackTreeMap<K, V, P> where
K: Ord,
P: SharedPointerKind,
[src]
K: Ord,
P: SharedPointerKind,
impl<K, V, P> Default for RedBlackTreeMap<K, V, P> where
K: Ord,
P: SharedPointerKind,
[src]
K: Ord,
P: SharedPointerKind,
fn default() -> RedBlackTreeMap<K, V, P>
[src]
impl<K, V, P> Clone for RedBlackTreeMap<K, V, P> where
K: Ord,
P: SharedPointerKind,
[src]
K: Ord,
P: SharedPointerKind,
fn clone(&self) -> RedBlackTreeMap<K, V, P>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<K: Ord, V: PartialOrd, P, PO> PartialOrd<RedBlackTreeMap<K, V, PO>> for RedBlackTreeMap<K, V, P> where
P: SharedPointerKind,
PO: SharedPointerKind,
[src]
P: SharedPointerKind,
PO: SharedPointerKind,
fn partial_cmp(&self, other: &RedBlackTreeMap<K, V, PO>) -> Option<Ordering>
[src]
#[must_use]
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl<K: Ord, V: Ord, P> Ord for RedBlackTreeMap<K, V, P> where
P: SharedPointerKind,
[src]
P: SharedPointerKind,
fn cmp(&self, other: &RedBlackTreeMap<K, V, P>) -> Ordering
[src]
fn max(self, other: Self) -> Self
1.21.0[src]
fn min(self, other: Self) -> Self
1.21.0[src]
fn clamp(self, min: Self, max: Self) -> Self
[src]
impl<K, V: PartialEq, P, PO> PartialEq<RedBlackTreeMap<K, V, PO>> for RedBlackTreeMap<K, V, P> where
K: Ord,
P: SharedPointerKind,
PO: SharedPointerKind,
[src]
K: Ord,
P: SharedPointerKind,
PO: SharedPointerKind,
fn eq(&self, other: &RedBlackTreeMap<K, V, PO>) -> bool
[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'a, K, V, P> IntoIterator for &'a RedBlackTreeMap<K, V, P> where
K: Ord,
P: SharedPointerKind,
[src]
K: Ord,
P: SharedPointerKind,
type Item = (&'a K, &'a V)
The type of the elements being iterated over.
type IntoIter = Iter<'a, K, V, P>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Iter<'a, K, V, P>
[src]
impl<K: Hash, V: Hash, P: SharedPointerKind> Hash for RedBlackTreeMap<K, V, P> where
K: Ord,
[src]
K: Ord,
fn hash<H: Hasher>(&self, state: &mut H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<'a, K, Q: ?Sized, V, P> Index<&'a Q> for RedBlackTreeMap<K, V, P> where
K: Ord + Borrow<Q>,
Q: Ord,
P: SharedPointerKind,
[src]
K: Ord + Borrow<Q>,
Q: Ord,
P: SharedPointerKind,
impl<K, V, P> Display for RedBlackTreeMap<K, V, P> where
K: Ord + Display,
V: Display,
P: SharedPointerKind,
[src]
K: Ord + Display,
V: Display,
P: SharedPointerKind,
impl<K: Debug, V: Debug, P: Debug> Debug for RedBlackTreeMap<K, V, P> where
P: SharedPointerKind,
[src]
P: SharedPointerKind,
impl<K, V, P> FromIterator<(K, V)> for RedBlackTreeMap<K, V, P> where
K: Ord,
P: SharedPointerKind,
[src]
K: Ord,
P: SharedPointerKind,
fn from_iter<I: IntoIterator<Item = (K, V)>>(
into_iter: I
) -> RedBlackTreeMap<K, V, P>
[src]
into_iter: I
) -> RedBlackTreeMap<K, V, P>
impl<K, V, P> Serialize for RedBlackTreeMap<K, V, P> where
K: Ord + Serialize,
V: Serialize,
P: SharedPointerKind,
[src]
K: Ord + Serialize,
V: Serialize,
P: SharedPointerKind,
impl<'de, K, V, P> Deserialize<'de> for RedBlackTreeMap<K, V, P> where
K: Ord + Deserialize<'de>,
V: Deserialize<'de>,
P: SharedPointerKind,
[src]
K: Ord + Deserialize<'de>,
V: Deserialize<'de>,
P: SharedPointerKind,
fn deserialize<D: Deserializer<'de>>(
deserializer: D
) -> Result<RedBlackTreeMap<K, V, P>, D::Error>
[src]
deserializer: D
) -> Result<RedBlackTreeMap<K, V, P>, D::Error>
Auto Trait Implementations
impl<K, V, P> Unpin for RedBlackTreeMap<K, V, P> where
K: Unpin,
P: Unpin,
V: Unpin,
K: Unpin,
P: Unpin,
V: Unpin,
impl<K, V, P> Sync for RedBlackTreeMap<K, V, P> where
K: Sync,
P: Sync,
V: Sync,
K: Sync,
P: Sync,
V: Sync,
impl<K, V, P> Send for RedBlackTreeMap<K, V, P> where
K: Send,
P: Send,
V: Send,
K: Send,
P: Send,
V: Send,
impl<K, V, P> UnwindSafe for RedBlackTreeMap<K, V, P> where
K: UnwindSafe,
P: UnwindSafe,
V: UnwindSafe,
K: UnwindSafe,
P: UnwindSafe,
V: UnwindSafe,
impl<K, V, P> RefUnwindSafe for RedBlackTreeMap<K, V, P> where
K: RefUnwindSafe,
P: RefUnwindSafe,
V: RefUnwindSafe,
K: RefUnwindSafe,
P: RefUnwindSafe,
V: RefUnwindSafe,
Blanket Implementations
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> DeserializeOwned for T where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,