pub struct BTreeMap<K, V> { /* private fields */ }Expand description
Ordered map based on an in-memory copy-on-write B+ tree
Implementations§
Source§impl<K, V> BTreeMap<K, V>
impl<K, V> BTreeMap<K, V>
Sourcepub fn insert(&mut self, key: K, value: V) -> Option<V>
pub fn insert(&mut self, key: K, value: V) -> Option<V>
Insert an entry, returning the existing value if present
Sourcepub fn remove(&mut self, key: &K) -> Option<V>
pub fn remove(&mut self, key: &K) -> Option<V>
Remove an entry, returning the existing value if present
We follow the advice of the Deletion without rebalancing in multiway search trees paper, which suggests “rebalancing on deletion not only is unnecessary but may be harmful.”
Sourcepub fn get(&self, key: &K) -> Option<&V>where
K: Ord,
pub fn get(&self, key: &K) -> Option<&V>where
K: Ord,
Get a shared reference to the value associated with the given key
Sourcepub fn get_mut(&mut self, key: &K) -> Option<&mut V>
pub fn get_mut(&mut self, key: &K) -> Option<&mut V>
Get an exclusive reference to the value associated with the given key
Sourcepub fn contains_key(&self, key: &K) -> boolwhere
K: Ord,
pub fn contains_key(&self, key: &K) -> boolwhere
K: Ord,
Check whether the key is present in the map
Trait Implementations§
Source§impl<K, V> Extend<(K, V)> for BTreeMap<K, V>
impl<K, V> Extend<(K, V)> for BTreeMap<K, V>
Source§fn extend<I>(&mut self, iter: I)where
I: IntoIterator<Item = (K, V)>,
fn extend<I>(&mut self, iter: I)where
I: IntoIterator<Item = (K, V)>,
Extends a collection with the contents of an iterator. Read more
Source§fn extend_one(&mut self, item: T)
fn extend_one(&mut self, item: T)
🔬This is a nightly-only experimental API. (
extend_one)Extends a collection with exactly one element.
Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (
extend_one)Reserves capacity in a collection for the given number of additional elements. Read more
Auto Trait Implementations§
impl<K, V> Freeze for BTreeMap<K, V>
impl<K, V> RefUnwindSafe for BTreeMap<K, V>where
Arc<Node<K, V>>: RefUnwindSafe,
impl<K, V> Send for BTreeMap<K, V>
impl<K, V> Sync for BTreeMap<K, V>
impl<K, V> Unpin for BTreeMap<K, V>
impl<K, V> UnsafeUnpin for BTreeMap<K, V>where
Arc<Node<K, V>>: UnsafeUnpin,
impl<K, V> UnwindSafe for BTreeMap<K, V>where
Arc<Node<K, V>>: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more