HashMap::clear
pub fn clear() Import
Source: use collections::map::{HashMap}; src/collections/map.hy Removes every entry, keeping the bucket count.
Called on a HashMap value as value.clear(…).
Contracts#
Checked according to --contracts (see Contracts).
ensures self.len == 0
Examples#
use collections::map::{HashMap};
use tests::assert;
let m: HashMap<int, int> = HashMap::new();
m.insert(1, 10);
m.clear();
assert!(m.is_empty());
assert!(!m.contains(1));
See also#
HashMap: A hash map from keys of typeKto values of typeV.HashMap::with_capacity: Creates an empty map with room for aboutcapbuckets before it grows.HashMap::new: Creates an empty map.HashMap::size: Returns the number of entries.HashMap::is_empty: Returnstruewhen the map has no entries.HashMap::capacity: Returns the number of buckets.HashMap::keys: Returns the keys, in insertion order.HashMap::values: Returns the values, in the insertion order of their keys.