Struct cretonne_codegen::bforest::Map [−][src]
pub struct Map<K, V, C> where
K: Copy,
V: Copy,
C: Comparator<K>, { /* fields omitted */ }
B-tree mapping from K
to V
using C
for comparing keys.
This is not a general-purpose replacement for BTreeMap
. See the module
documentation for more information about design tradeoffs.
Maps can be cloned, but that operation should only be used as part of cloning the whole forest they belong to. Cloning a map does not allocate new memory for the clone. It creates an alias of the same memory.
Methods
impl<K, V, C> Map<K, V, C> where
K: Copy,
V: Copy,
C: Comparator<K>,
[src]
impl<K, V, C> Map<K, V, C> where
K: Copy,
V: Copy,
C: Comparator<K>,
pub fn new() -> Self
[src]
pub fn new() -> Self
Make an empty map.
pub fn is_empty(&self) -> bool
[src]
pub fn is_empty(&self) -> bool
Is this an empty map?
pub fn get(&self, key: K, forest: &MapForest<K, V, C>, comp: &C) -> Option<V>
[src]
pub fn get(&self, key: K, forest: &MapForest<K, V, C>, comp: &C) -> Option<V>
Get the value stored for key
.
pub fn get_or_less(
&self,
key: K,
forest: &MapForest<K, V, C>,
comp: &C
) -> Option<(K, V)>
[src]
pub fn get_or_less(
&self,
key: K,
forest: &MapForest<K, V, C>,
comp: &C
) -> Option<(K, V)>
Look up the value stored for key
.
If it exists, return the stored key-value pair.
Otherwise, return the last key-value pair with a key that is less than or equal to key
.
If no stored keys are less than or equal to key
, return None
.
pub fn insert(
&mut self,
key: K,
value: V,
forest: &mut MapForest<K, V, C>,
comp: &C
) -> Option<V>
[src]
pub fn insert(
&mut self,
key: K,
value: V,
forest: &mut MapForest<K, V, C>,
comp: &C
) -> Option<V>
Insert key, value
into the map and return the old value stored for key
, if any.
pub fn remove(
&mut self,
key: K,
forest: &mut MapForest<K, V, C>,
comp: &C
) -> Option<V>
[src]
pub fn remove(
&mut self,
key: K,
forest: &mut MapForest<K, V, C>,
comp: &C
) -> Option<V>
Remove key
from the map and return the removed value for key
, if any.
pub fn clear(&mut self, forest: &mut MapForest<K, V, C>)
[src]
pub fn clear(&mut self, forest: &mut MapForest<K, V, C>)
Remove all entries.
pub fn retain<F>(&mut self, forest: &mut MapForest<K, V, C>, predicate: F) where
F: FnMut(K, &mut V) -> bool,
[src]
pub fn retain<F>(&mut self, forest: &mut MapForest<K, V, C>, predicate: F) where
F: FnMut(K, &mut V) -> bool,
Retains only the elements specified by the predicate.
Remove all key-value pairs where the predicate returns false.
The predicate is allowed to update the values stored in the map.
pub fn cursor<'a>(
&'a mut self,
forest: &'a mut MapForest<K, V, C>,
comp: &'a C
) -> MapCursor<'a, K, V, C>
[src]
pub fn cursor<'a>(
&'a mut self,
forest: &'a mut MapForest<K, V, C>,
comp: &'a C
) -> MapCursor<'a, K, V, C>
Create a cursor for navigating this map. The cursor is initially positioned off the end of the map.
ⓘImportant traits for MapIter<'a, K, V, C>pub fn iter<'a>(
&'a self,
forest: &'a MapForest<K, V, C>
) -> MapIter<'a, K, V, C>
[src]
pub fn iter<'a>(
&'a self,
forest: &'a MapForest<K, V, C>
) -> MapIter<'a, K, V, C>
Create an iterator traversing this map. The iterator type is (K, V)
.
Trait Implementations
impl<K: Clone, V: Clone, C: Clone> Clone for Map<K, V, C> where
K: Copy,
V: Copy,
C: Comparator<K>,
[src]
impl<K: Clone, V: Clone, C: Clone> Clone for Map<K, V, C> where
K: Copy,
V: Copy,
C: Comparator<K>,
fn clone(&self) -> Map<K, V, C>
[src]
fn clone(&self) -> Map<K, V, C>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl<K, V, C> Default for Map<K, V, C> where
K: Copy,
V: Copy,
C: Comparator<K>,
[src]
impl<K, V, C> Default for Map<K, V, C> where
K: Copy,
V: Copy,
C: Comparator<K>,