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]
impl<K, V> Map<K, V> where
K: Eq + Hash,
V: Copy,
pub fn insert(&self, key: K, value: V) -> bool
[src]
pub fn insert(&self, key: K, value: V) -> bool
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"));
pub fn get(&self, key: &K) -> Option<V>
[src]
pub fn get(&self, key: &K) -> Option<V>
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);
pub fn remove(&self, key: &K) -> bool
[src]
pub fn remove(&self, key: &K) -> bool
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);