[][src]Struct rpds::map::red_black_tree_map::RedBlackTreeMap

pub struct RedBlackTreeMap<K, V> { /* fields omitted */ }

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]

#[must_use]
pub fn new() -> RedBlackTreeMap<K, V>
[src]

#[must_use]
pub fn get<Q: ?Sized>(&self, key: &Q) -> Option<&V> where
    K: Borrow<Q>,
    Q: Ord
[src]

#[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>
[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> where
    K: Borrow<Q>,
    Q: Ord
[src]

pub fn remove_mut<Q: ?Sized>(&mut self, key: &Q) -> bool where
    K: Borrow<Q>,
    Q: Ord
[src]

#[must_use]
pub fn contains_key<Q: ?Sized>(&self, key: &Q) -> bool where
    K: Borrow<Q>,
    Q: Ord
[src]

#[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>
[src]

#[must_use]
pub fn keys(&self) -> IterKeys<K, V>
[src]

#[must_use]
pub fn values(&self) -> IterValues<K, V>
[src]

#[must_use]
pub fn range<Q: ?Sized, RB>(&self, range: RB) -> RangeIter<K, V, RB, Q> where
    K: Borrow<Q>,
    Q: Ord,
    RB: RangeBounds<Q>, 
[src]

Trait Implementations

impl<K, V> Default for RedBlackTreeMap<K, V> where
    K: Ord
[src]

impl<K, V: PartialEq> PartialEq<RedBlackTreeMap<K, V>> for RedBlackTreeMap<K, V> where
    K: Ord
[src]

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0
[src]

This method tests for !=.

impl<K: Ord, V: PartialOrd> PartialOrd<RedBlackTreeMap<K, V>> for RedBlackTreeMap<K, V>[src]

#[must_use]
fn lt(&self, other: &Rhs) -> bool
1.0.0
[src]

This method tests less than (for self and other) and is used by the < operator. Read more

#[must_use]
fn le(&self, other: &Rhs) -> bool
1.0.0
[src]

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

#[must_use]
fn gt(&self, other: &Rhs) -> bool
1.0.0
[src]

This method tests greater than (for self and other) and is used by the > operator. Read more

#[must_use]
fn ge(&self, other: &Rhs) -> bool
1.0.0
[src]

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl<K, V: Eq> Eq for RedBlackTreeMap<K, V> where
    K: Ord
[src]

impl<K: Ord, V: Ord> Ord for RedBlackTreeMap<K, V>[src]

fn max(self, other: Self) -> Self
1.21.0
[src]

Compares and returns the maximum of two values. Read more

fn min(self, other: Self) -> Self
1.21.0
[src]

Compares and returns the minimum of two values. Read more

impl<K, V> Clone for RedBlackTreeMap<K, V> where
    K: Ord
[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl<'a, K, V> IntoIterator for &'a RedBlackTreeMap<K, V> where
    K: Ord
[src]

type Item = (&'a K, &'a V)

The type of the elements being iterated over.

type IntoIter = Iter<'a, K, V>

Which kind of iterator are we turning this into?

impl<K: Debug, V: Debug> Debug for RedBlackTreeMap<K, V>[src]

impl<K, V> Display for RedBlackTreeMap<K, V> where
    K: Ord + Display,
    V: Display
[src]

impl<K: Hash, V: Hash> Hash for RedBlackTreeMap<K, V> where
    K: Ord
[src]

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0
[src]

Feeds a slice of this type into the given [Hasher]. Read more

impl<'a, K, Q: ?Sized, V> Index<&'a Q> for RedBlackTreeMap<K, V> where
    K: Ord + Borrow<Q>,
    Q: Ord
[src]

type Output = V

The returned type after indexing.

impl<K, V> FromIterator<(K, V)> for RedBlackTreeMap<K, V> where
    K: Ord
[src]

impl<K, V> Serialize for RedBlackTreeMap<K, V> where
    K: Ord + Serialize,
    V: Serialize
[src]

impl<'de, K, V> Deserialize<'de> for RedBlackTreeMap<K, V> where
    K: Ord + Deserialize<'de>,
    V: Deserialize<'de>, 
[src]

Auto Trait Implementations

impl<K, V> Send for RedBlackTreeMap<K, V> where
    K: Send + Sync,
    V: Send + Sync

impl<K, V> Sync for RedBlackTreeMap<K, V> where
    K: Send + Sync,
    V: Send + Sync

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> From for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]