Struct hamt::arc::HamtArc
[−]
[src]
pub struct HamtArc<K, V> { // some fields omitted }
A persistent hash array mapped trie implementation using reference counting.
Keys are required to implement Hash
and Eq
like std::collections::HashMap
, but
both keys and values are also required to implement Clone
. If you have an expensive
to clone key or value type like a String
or Vec
, you can wrap it in a reference
counting smart pointer.
Methods
impl<K, V> HamtArc<K, V> where K: Hash + Eq + Clone, V: Clone
[src]
fn new() -> Self
Creates an empty map.
fn len(&self) -> usize
Returns how many key value pairs are in the map.
fn is_empty(&self) -> bool
Returns true if there are no key value pairs in the map, false otherwise.
fn iter<'a>(&'a self) -> Iter<'a, K, V>
Returns a key value iterator.
fn get<Q: ?Sized>(&self, k: &Q) -> Option<&V> where K: Borrow<Q>, Q: Hash + Eq
Returns a reference to the value corresponding to the given key, or None if there is no value associated with the key.
fn contains_key<Q: ?Sized>(&self, k: &Q) -> bool where K: Borrow<Q>, Q: Hash + Eq
Returns true if the map contains the given key.
fn insert(&self, k: K, v: V) -> Self
Returns a new map that includes the given key value pair, replacing the old value if the key was already in the map.
fn remove<Q: ?Sized>(&self, k: &Q) -> Self where K: Borrow<Q>, Q: Hash + Eq
Returns a new map without an entry corresponding to the given key.
Trait Implementations
impl<K: Debug, V: Debug> Debug for HamtArc<K, V>
[src]
impl<K: Clone, V: Clone> Clone for HamtArc<K, V>
[src]
fn clone(&self) -> HamtArc<K, V>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl<K, V> Eq for HamtArc<K, V> where K: Eq, V: Eq
[src]
impl<K, V> PartialEq for HamtArc<K, V> where K: PartialEq, V: PartialEq
[src]
fn eq(&self, other: &HamtArc<K, V>) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0
This method tests for !=
.
impl<K, V> FromIterator<(K, V)> for HamtArc<K, V> where K: Eq + Hash + Clone, V: Clone
[src]
fn from_iter<T>(iterator: T) -> Self where T: IntoIterator<Item=(K, V)>
Creates a value from an iterator. Read more
impl<'a, K, V> FromIterator<(&'a K, &'a V)> for HamtArc<K, V> where K: Eq + Hash + Clone, V: Clone
[src]
fn from_iter<T>(iterator: T) -> Self where T: IntoIterator<Item=(&'a K, &'a V)>
Creates a value from an iterator. Read more