[−][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]
#[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>
[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]
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>
[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]
K: Borrow<Q>,
Q: Ord,
RB: RangeBounds<Q>,
Trait Implementations
impl<'a, K, V> IntoIterator for &'a RedBlackTreeMap<K, V> where
K: Ord,
[src]
K: Ord,
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?
fn into_iter(self) -> Iter<'a, K, V>
[src]
impl<K, V: Eq> Eq for RedBlackTreeMap<K, V> where
K: Ord,
[src]
K: Ord,
impl<K, V> Clone for RedBlackTreeMap<K, V> where
K: Ord,
[src]
K: Ord,
fn clone(&self) -> RedBlackTreeMap<K, V>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<K: Ord, V: PartialOrd> PartialOrd<RedBlackTreeMap<K, V>> for RedBlackTreeMap<K, V>
[src]
fn partial_cmp(&self, other: &RedBlackTreeMap<K, V>) -> Option<Ordering>
[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: PartialEq> PartialEq<RedBlackTreeMap<K, V>> for RedBlackTreeMap<K, V> where
K: Ord,
[src]
K: Ord,
fn eq(&self, other: &RedBlackTreeMap<K, V>) -> bool
[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl<K, V> Default for RedBlackTreeMap<K, V> where
K: Ord,
[src]
K: Ord,
fn default() -> RedBlackTreeMap<K, V>
[src]
impl<K: Ord, V: Ord> Ord for RedBlackTreeMap<K, V>
[src]
fn cmp(&self, other: &RedBlackTreeMap<K, V>) -> Ordering
[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: Hash, V: Hash> Hash for RedBlackTreeMap<K, V> 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,
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]
K: Ord + Borrow<Q>,
Q: Ord,
impl<K, V> FromIterator<(K, V)> for RedBlackTreeMap<K, V> where
K: Ord,
[src]
K: Ord,
fn from_iter<I: IntoIterator<Item = (K, V)>>(
into_iter: I
) -> RedBlackTreeMap<K, V>
[src]
into_iter: I
) -> RedBlackTreeMap<K, V>
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]
K: Ord + Display,
V: Display,
impl<K, V> Serialize for RedBlackTreeMap<K, V> where
K: Ord + Serialize,
V: Serialize,
[src]
K: Ord + Serialize,
V: Serialize,
impl<'de, K, V> Deserialize<'de> for RedBlackTreeMap<K, V> where
K: Ord + Deserialize<'de>,
V: Deserialize<'de>,
[src]
K: Ord + Deserialize<'de>,
V: Deserialize<'de>,
fn deserialize<D: Deserializer<'de>>(
deserializer: D
) -> Result<RedBlackTreeMap<K, V>, D::Error>
[src]
deserializer: D
) -> Result<RedBlackTreeMap<K, V>, D::Error>
Auto Trait Implementations
impl<K, V> Send for RedBlackTreeMap<K, V> where
K: Send + Sync,
V: Send + Sync,
K: Send + Sync,
V: Send + Sync,
impl<K, V> Sync for RedBlackTreeMap<K, V> where
K: Send + Sync,
V: Send + Sync,
K: Send + Sync,
V: Send + Sync,
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
try_from
)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> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,