Struct hamt::rc::HamtRc [] [src]

pub struct HamtRc<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> HamtRc<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(&self) -> Iter<K, V>

Returns a key value iterator.

fn keys(&self) -> Keys<K, V>

Returns an iterator that visits every key in an unspecified order.

fn values(&self) -> Values<K, V>

Returns an iterator that visits every value in an unspecified order.

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<Q: ?Sized, R: ?Sized>(&self, k: &Q, v: &R) -> Self where K: Borrow<Q>, Q: Hash + Eq + ToOwned<Owned=K>, V: Borrow<R>, R: ToOwned<Owned=V>

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.

fn adjust<F, Q: ?Sized>(&self, key: &Q, f: F) -> Self where F: FnOnce(&V) -> V, K: Borrow<Q>, Q: Hash + Eq

Modifies the value tied to the given key with the function f. Otherwise, the map returned is identical.

fn update<F, Q: ?Sized>(&self, key: &Q, f: F) -> Self where F: FnOnce(&V) -> Option<V>, K: Borrow<Q>, Q: Hash + Eq + ToOwned<Owned=K>

Updates the value at the given key using f. If f returns None, then the entry is removed.

fn alter<F, Q: ?Sized>(&self, key: &Q, f: F) -> Self where F: FnOnce(Option<&V>) -> Option<V>, K: Borrow<Q>, Q: Hash + Eq + ToOwned<Owned=K>

Updates the value at the given key using f as in Self::update. If no value exists for the given key, then f is passed None.

Trait Implementations

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

fn fmt(&self, __arg_0: &mut Formatter) -> Result

Formats the value using the given formatter.

impl<K: Clone, V: Clone> Clone for HamtRc<K, V>
[src]

fn clone(&self) -> HamtRc<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 HamtRc<K, V> where K: Eq, V: Eq
[src]

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

fn eq(&self, other: &HamtRc<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 HamtRc<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 HamtRc<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

impl<'a, K, V> IntoIterator for &'a HamtRc<K, V> where K: Hash + Eq + Clone + 'a, V: Clone + 'a
[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?

fn into_iter(self) -> Iter<'a, K, V>

Creates an iterator from a value. Read more

impl<'a, K, Q: ?Sized, V> Index<&'a Q> for HamtRc<K, V> where K: Hash + Eq + Clone + Borrow<Q>, V: Clone, Q: Eq + Hash
[src]

type Output = V

The returned type after indexing

fn index(&self, index: &Q) -> &Self::Output

The method for the indexing (Foo[Bar]) operation