Type Definition concache::crossbeam::Map[][src]

type Map<K, V> = MapHandle<K, V>;

A shared, concurrent hash map.

See MapHandle for how to interact with this map.

Methods

impl<K, V> Map<K, V> where
    K: Eq + Hash,
    V: Copy
[src]

Inserts a key-value pair into the map.

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

If the map did have this key present, the value is updated, and false is returned. The key is not updated, though; this matters for types that can be == without being identical.

Examples

use concache::crossbeam::Map;

let mut map = Map::with_capacity(16);
assert_eq!(map.insert(37, "a"), true);
assert_eq!(map.is_empty(), false);

map.insert(37, "b");
assert_eq!(map.insert(37, "c"), false);
assert_eq!(map.get(&37), Some("c"));

Returns a reference to the value corresponding to the key.

Examples

use concache::crossbeam::Map;

let mut map = Map::with_capacity(16);
map.insert(1, "a");
assert_eq!(map.get(&1), Some("a"));
assert_eq!(map.get(&2), None);

Removes a key from the map, returning true if the key was previously in the map.

Examples

use concache::crossbeam::Map;

let mut map = Map::with_capacity(16);
map.insert(1, "a");
assert_eq!(map.remove(&1), true);
assert_eq!(map.remove(&1), false);

Trait Implementations

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

Formats the value using the given formatter. Read more