pub struct BTreeMap<K, V, const N: usize>(/* private fields */);Expand description
An ordered map based on a B-Tree (with alloc) or a linear map (with heapless).
When heapless feature is enabled, this is a wrapper around heapless::LinearMap<K, V, N>.
Note: With heapless, iteration order is insertion order, not key order.
Implementations§
Source§impl<K, V, const N: usize> BTreeMap<K, V, N>
impl<K, V, const N: usize> BTreeMap<K, V, N>
Sourcepub fn get(&self, key: &K) -> Option<&V>
pub fn get(&self, key: &K) -> Option<&V>
Returns a reference to the value corresponding to the key.
Sourcepub fn contains_key(&self, key: &K) -> bool
pub fn contains_key(&self, key: &K) -> bool
Returns true if the map contains a value for the specified key.
Sourcepub fn insert(&mut self, key: K, value: V) -> Result<Option<V>>
pub fn insert(&mut self, key: K, value: V) -> Result<Option<V>>
Inserts a key-value pair into the map.
If the map did not have this key present, Ok(None) is returned.
If the map did have this key present, the value is updated, and Ok(Some(old_value)) is returned.
Returns Err if the map is at capacity (heapless only).
Trait Implementations§
impl<K, V, const N: usize> Eq for BTreeMap<K, V, N>
Auto Trait Implementations§
impl<K, V, const N: usize> Freeze for BTreeMap<K, V, N>
impl<K, V, const N: usize> RefUnwindSafe for BTreeMap<K, V, N>where
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V, const N: usize> Send for BTreeMap<K, V, N>
impl<K, V, const N: usize> Sync for BTreeMap<K, V, N>
impl<K, V, const N: usize> Unpin for BTreeMap<K, V, N>
impl<K, V, const N: usize> UnsafeUnpin for BTreeMap<K, V, N>
impl<K, V, const N: usize> UnwindSafe for BTreeMap<K, V, N>where
K: RefUnwindSafe,
V: RefUnwindSafe,
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