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

Implementations

Creates a new IntMap.

Examples
use intmap::IntMap;

let mut map: IntMap<u64> = IntMap::new();
assert_eq!(map, IntMap::default());

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

Sets load rate of IntMap rounded to the first decimal point.

Values above 1.0 is allowed.

Examples
use intmap::IntMap;

let mut map: IntMap<u64> = IntMap::with_capacity(20);
map.set_load_factor(0.909); // Sets load factor to 90.9%

Returns current load_factor

Ensures that the IntMap has space for at least additional more elements

Insert key/value into the IntMap.

This function returns the previous value if any otherwise None.

Examples
use intmap::IntMap;

let mut map = IntMap::new();
assert_eq!(map.insert(21, "Eat my shorts"), None);
assert_eq!(map.insert(21, "Ay, caramba"), Some("Eat my shorts"));
assert_eq!(map.get(21), Some(&"Ay, caramba"));

Insert key/value into the IntMap if the key is not yet inserted.

This function returns true if key/value were inserted and false otherwise.

Examples
use intmap::IntMap;

let mut map = IntMap::new();
assert!(map.insert_checked(21, "Eat my shorts"));
assert!(!map.insert_checked(21, "Ay, caramba"));
assert_eq!(map.get(21), Some(&"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.

Gets the Entry that corresponds to the given key.

Examples
use intmap::{IntMap, Entry};

let mut counters = IntMap::new();

for number in [10, 30, 10, 40, 50, 50, 60, 50] {
    let counter = match counters.entry(number) {
        Entry::Occupied(entry) => entry.into_mut(),
        Entry::Vacant(entry) => entry.insert(0),
    };
    *counter += 1;
}

assert_eq!(counters.get(10), Some(&2));
assert_eq!(counters.get(20), None);
assert_eq!(counters.get(30), Some(&1));
assert_eq!(counters.get(40), Some(&1));
assert_eq!(counters.get(50), Some(&3));
assert_eq!(counters.get(60), Some(&1));

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

Returns the “default value” for a type. Read more

Deserialize this value from the given Serde deserializer. 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 !=.

Serialize this value into the given Serde serializer. Read more

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

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

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

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.