TreeMap::remove
pub fn remove(K k) -> bool Import
Source: use collections::tree::{TreeMap}; src/collections/tree.hy Removes the entry for k.
Returns true when there was one.
Called on a TreeMap value as value.remove(…).
Parameters#
| Name | Type |
|---|---|
k | K |
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::tree::{TreeMap};
use tests::assert;
let m: TreeMap<int, int> = TreeMap::new();
m.insert(5, 50);
m.insert(3, 30);
assert!(m.remove(5));
assert!(!m.contains(5));
assert!(m.min_key(-1) == 3);
See also#
TreeMap: An ordered map from keys of typeKto values of typeV.TreeMap::new: Creates an empty map.TreeMap::empty: Creates an empty map; the same asTreeMap::new.TreeMap::size: Returns the number of entries.TreeMap::is_empty: Returnstruewhen the map has no entries.TreeMap::clear: Removes every entry.TreeMap::iter: Returns an iterator over the entries in ascending key order.TreeMap::insert: Storesvunderk, replacing any value already there.