Method in collections::map · HashMap coil-stdlib

HashMap::remove

pub fn remove(K k) -> bool
Import
use collections::map::{HashMap};
Source: src/collections/map.hy

Removes the entry for k.

Returns true when there was one.

Called on a HashMap value as value.remove(…).

Parameters#

NameType
kK

Returns#

bool

Contracts#

Checked according to --contracts (see Contracts).

ensures !result || self.len == old(self.len) - 1
ensures result || self.len == old(self.len)

Examples#

use collections::map::{HashMap};
use tests::assert;
let m: HashMap<string, int> = HashMap::new();
m.insert("a", 1);
assert!(m.remove("a"));
assert!(!m.remove("a"));
assert!(m.is_empty());

See also#

↑ ↓ navigate ↵ open