Struct intmap::IntMap [−][src]
pub struct IntMap<V> { /* fields omitted */ }
Implementations
Creates a new IntMap with at least the given capacity, rounded to the next power of two.
Examples
use intmap::IntMap;
let mut map: IntMap<u64> = IntMap::with_capacity(20);
Ensures that the IntMap has space for at least additional
more elements
Insert key/value into the IntMap.
Examples
use intmap::IntMap;
let mut map = IntMap::new();
map.insert(21, "Eat my shorts");
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));
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);
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));
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));
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);
Retains only the elements specified by the predicate.
In other words, remove all elements such that f(key, &value)
returns false.
Examples
use intmap::IntMap;
let mut map: IntMap<u64> = IntMap::new();
map.insert(1, 11);
map.insert(2, 12);
map.insert(4, 13);
// retain only the odd values
map.retain(|k, v| *v % 2 == 1);
assert_eq!(map.len(), 2);
assert!(map.contains_key(1));
assert!(map.contains_key(4));
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());
pub fn values_mut(&mut self) -> ValuesMut<'_, u64, V>ⓘ
Trait Implementations
Extends a collection with the contents of an iterator. Read more
🔬 This is a nightly-only experimental API. (
extend_one
)Extends a collection with exactly one element.
🔬 This is a nightly-only experimental API. (
extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more
Auto Trait Implementations
impl<V> RefUnwindSafe for IntMap<V> where
V: RefUnwindSafe,
impl<V> UnwindSafe for IntMap<V> where
V: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more