[][src]Trait heaparray::CopyMap

pub trait CopyMap<K, V>: Container where
    K: Copy + Eq
{ fn get(&self, key: K) -> Option<&V>;
fn get_mut(&mut self, key: K) -> Option<&mut V>;
fn insert(&mut self, k: K, v: V) -> Option<V>; }

Trait for a container indexed by a value that implements Copy and Eq.

Required methods

fn get(&self, key: K) -> Option<&V>

Get a reference to a value from this map.

Takes a key by value and returns a reference to the corresponding data, or None if the key doesn't exist in the map.

fn get_mut(&mut self, key: K) -> Option<&mut V>

Get a mutable reference to a value from this map.

Takes a key by value and returns a mutable reference to the corresponding data, or None if the key doesn't exist in the map.

fn insert(&mut self, k: K, v: V) -> Option<V>

Inserts a key-value pair into the map.

If the map did not have this key present, None is returned.

If the map did have this key present, the value is updated, and the old value is returned. Note that the key itself isn't necessarily updated.

Loading content...

Implementors

impl<A, R, E, L> CopyMap<usize, E> for RcArray<A, R, E, L> where
    A: LabelledArray<E, R>,
    R: RefCounter<L>, 
[src]

fn get(&self, key: usize) -> Option<&E>[src]

Get a reference into this array. Returns None if:

  • The index given is out-of-bounds

fn get_mut(&mut self, key: usize) -> Option<&mut E>[src]

Get a mutable reference into this array. Returns None if:

  • The array is referenced by another pointer
  • The index given is out-of-bounds

fn insert(&mut self, key: usize, value: E) -> Option<E>[src]

Insert an element into this array. Returns None if:

  • The array is referenced by another pointer
  • The index given is out-of-bounds
  • There was nothing in the slot previously

impl<E, L, P> CopyMap<usize, E> for SafeArray<E, L, P> where
    P: SafeArrayPtr<E, L>, 
[src]

Loading content...