Struct intmap::IntMap[][src]

pub struct IntMap<V> { /* fields omitted */ }

Implementations

Creates a new IntMap.

Examples
use intmap::IntMap;

let mut map: IntMap<u64> = IntMap::new();

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());

Number of elements in map.

Force count number of slots filled.

Total number of slots available.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

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

Creates a value from an iterator. Read more

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

Creates an iterator from a value. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.