Trait idmap::table::EntryTable [−][src]
pub trait EntryTable<K: IntegerId, V>: EntryIterable<K, V> + IntoIterator<Item = (K, V)> {
Show 15 methods
fn new() -> Self;
fn with_capacity(capacity: usize) -> Self;
fn len(&self) -> usize;
fn get(&self, key: &K) -> Option<&V>;
fn get_mut(&mut self, key: &K) -> Option<&mut V>;
fn insert(&mut self, key: K, value: V) -> Option<V>;
fn insert_vacant(&mut self, key: K, value: V) -> &mut V;
fn swap_remove(&mut self, key: &K) -> Option<V>;
fn retain<F>(&mut self, func: F)
where
F: FnMut(&K, &mut V) -> bool;
fn clear(&mut self);
fn reserve(&mut self, amount: usize);
fn raw_debug(&self) -> &dyn Debug
where
K: Debug,
V: Debug;
fn max_id(&self) -> Option<u64>;
fn cloned(&self) -> Self
where
K: Clone,
V: Clone;
fn is_empty(&self) -> bool { ... }
}
Expand description
Stores an IdMap
’s actual entries, which controls the actual behavior of the map.
There are currently two primary implementations:
DenseEntryTable
stores the entries more compactly and preserves insertion order, but it needs a separateIdTable
to map the keys to indexes in the entry list.DirectEntryTable
doesn’t need any extraIdTable
book-keeping or indirection in order to associate keys with entries, though it can’t preserve ordering and wastes more space when keys are missing. For these reasons, it’s not the default though it can be used as an optimization when you know that the key indexes of the entries will be densely packed.
Required methods
fn with_capacity(capacity: usize) -> Self
fn with_capacity(capacity: usize) -> Self
Create a new table, initialized to the specified capacity
Get a mutable reference to the entry corresponding to the specified key
Insert a value and associate it with the specified key, returning the previous value
fn insert_vacant(&mut self, key: K, value: V) -> &mut V
fn insert_vacant(&mut self, key: K, value: V) -> &mut V
Insert a value into a vacant slot, returning a reference to the new value
fn swap_remove(&mut self, key: &K) -> Option<V>
fn swap_remove(&mut self, key: &K) -> Option<V>
Remove the value associated with the specified key.
This potentially disrupts internal ordering
Retain the specified entries in the map, returning if any indexes changed
Give a value that will debug the table