Struct intmap::IntMap
[−]
[src]
pub struct IntMap<V> { /* fields omitted */ }
Methods
impl<V> IntMap<V>
[src]
fn new() -> Self
fn with_capacity(capacity: usize) -> Self
Creates a new IntMap with a at least capacity, all sizes is a power of 2.
Examples
use intmap::IntMap; let mut map: IntMap<u64> = IntMap::with_capacity(20);
fn insert(&mut self, key: u64, value: V) -> bool
Insert key/value into the IntMap.
Examples
use intmap::IntMap; let mut map = IntMap::new(); map.insert(21, "Eat my shorts");
fn get(&self, key: u64) -> Option<&V>
Get value from the IntMap.
Examples
use intmap::IntMap; let mut map: IntMap<u64> = IntMap::new(); map.insert(21, 42); let val = map.get(21); assert!(val.is_some()); assert_eq!(*val.unwrap(), 42); assert!(map.contains_key(21));
fn get_mut(&mut self, key: u64) -> Option<&mut V>
Get mutable value from the IntMap.
Examples
use intmap::IntMap; let mut map: IntMap<u64> = IntMap::new(); map.insert(21, 42); assert_eq!(*map.get(21).unwrap(), 42); assert!(map.contains_key(21)); { let mut val = map.get_mut(21).unwrap(); *val+=1; } assert_eq!(*map.get(21).unwrap(), 43);
fn remove(&mut self, key: u64) -> Option<V>
Remove value from the IntMap.
Examples
use intmap::IntMap; let mut map: IntMap<u64> = IntMap::new(); map.insert(21, 42); let val = map.remove(21); assert!(val.is_some()); assert_eq!(val.unwrap(), 42); assert!(!map.contains_key(21));
fn contains_key(&self, key: u64) -> bool
Returns true if key is in map.
Examples
use intmap::IntMap; let mut map: IntMap<u64> = IntMap::new(); map.insert(21, 42); assert!(map.contains_key(21));
fn clear(&mut self)
Removes all elements from map.
Examples
use intmap::IntMap; let mut map: IntMap<u64> = IntMap::new(); map.insert(21, 42); map.clear(); assert_eq!(map.len(), 0);
fn is_empty(&mut self) -> bool
Returns true if map is empty
Examples
use intmap::IntMap; let mut map: IntMap<u64> = IntMap::new(); map.insert(21, 42); assert!(!map.is_empty()); map.remove(21); assert!(map.is_empty());
fn iter<'a>(&self) -> Iter<u64, V>
fn keys(&mut self) -> Keys<u64, V>
fn values(&mut self) -> Values<u64, V>
fn iter_mut<'a>(&mut self) -> IterMut<u64, V>
fn len(&self) -> usize
Number of elements in map.
fn load(&self) -> u64
Force count number of slots filled.
fn load_rate(&self) -> f64
fn capacity(&self) -> usize
Total number of slots available.