Struct idmap::IdMap
[−]
[src]
pub struct IdMap<K: IntegerId, V, T: EntryTable<K, V> = DenseEntryTable<K, V>> { /* fields omitted */ }
A map of mostly-contiguous IntegerId
keys to values, backed by a Vec
.
This is parametric over the type of the underlying EntryTable
, which controls its behavior
By default it's equivelant to an OrderedIdMap
,
though you can explicitly request a DirectIdMap
instead.
From the user's presepctive, this is equivelant to a nice wrapper around a Vec<Option<(K, V)>>
,
that preserves insertion order and saves some space for missing keys.
More details on the possible internal representations
are documented in the OrderedIdMap
and DirectIdMap
aliases.
Methods
impl<K: IntegerId, V> IdMap<K, V, DirectEntryTable<K, V>>
[src]
fn new_direct() -> Self
[src]
fn with_capacity_direct(capacity: usize) -> Self
[src]
impl<K: IntegerId, V> IdMap<K, V>
[src]
fn new() -> Self
[src]
Create an empty IdMap using a DenseEntryTable
and OrderedIdTable
fn with_capacity(capacity: usize) -> Self
[src]
Create an IdMap with the specified capacity, using an OrderedIdTable
impl<K: IntegerId, V, T: EntryTable<K, V>> IdMap<K, V, T>
[src]
fn new_other() -> Self
[src]
Create an empty IdMap
with a custom entry table type.
fn with_capacity_other(capacity: usize) -> Self
[src]
Create a new IdMap
with the specified capacity but a custom entry table.
fn is_empty(&self) -> bool
[src]
fn len(&self) -> usize
[src]
fn max_id(&self) -> Option<u64>
[src]
fn get<Q: Borrow<K>>(&self, key: Q) -> Option<&V>
[src]
fn get_mut<Q: Borrow<K>>(&mut self, key: Q) -> Option<&mut V>
[src]
fn insert(&mut self, key: K, value: V) -> Option<V>
[src]
fn remove<Q: Borrow<K>>(&mut self, key: Q) -> Option<V>
[src]
fn entry(&mut self, key: K) -> Entry<K, V, T>
[src]
fn iter(&self) -> Iter<K, V, T>
[src]
fn iter_mut(&mut self) -> IterMut<K, V, T>
[src]
fn keys(&self) -> Keys<K, V, T>
[src]
fn values(&self) -> Values<K, V, T>
[src]
fn values_mut(&mut self) -> ValuesMut<K, V, T>
[src]
fn clear(&mut self)
[src]
fn retain<F>(&mut self, func: F) where
F: FnMut(&K, &V) -> bool,
[src]
F: FnMut(&K, &V) -> bool,
Retains only the elements specified by the predicate. ```
use idmap::VecMap;
let mut map: IdMap
fn reserve(&mut self, amount: usize)
[src]
Reserve space for the specified number of additional elements
fn raw_debug(&self) -> RawDebug<K, V, T> where
K: Debug,
V: Debug,
[src]
K: Debug,
V: Debug,
Give a wrapper that will debug the underlying representation of this IdMap
Trait Implementations
impl<'de, K, V, T> Deserialize<'de> for IdMap<K, V, T> where
K: Deserialize<'de>,
T: EntryTable<K, V>,
K: IntegerId,
V: Deserialize<'de>,
[src]
K: Deserialize<'de>,
T: EntryTable<K, V>,
K: IntegerId,
V: Deserialize<'de>,
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
[src]
Deserialize this value from the given Serde deserializer. Read more
impl<K, V, T> Serialize for IdMap<K, V, T> where
K: IntegerId,
K: Serialize,
V: Serialize,
T: EntryTable<K, V>,
[src]
K: IntegerId,
K: Serialize,
V: Serialize,
T: EntryTable<K, V>,
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>
[src]
Serialize this value into the given Serde serializer. Read more
impl<K: Clone + IntegerId, V: Clone, T: Clone + EntryTable<K, V>> Clone for IdMap<K, V, T>
[src]
fn clone(&self) -> IdMap<K, V, T>
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<K, V1, T1, V2, T2> PartialEq<IdMap<K, V2, T2>> for IdMap<K, V1, T1> where
K: IntegerId,
V1: PartialEq<V2>,
T1: EntryTable<K, V1>,
T2: EntryTable<K, V2>,
[src]
K: IntegerId,
V1: PartialEq<V2>,
T1: EntryTable<K, V1>,
T2: EntryTable<K, V2>,
Checks if two have the same contents, ignoring the order.
fn eq(&self, other: &IdMap<K, V2, T2>) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl<K: IntegerId, V, T: EntryTable<K, V>> Default for IdMap<K, V, T>
[src]
impl<K: IntegerId, V, T: EntryTable<K, V>> Index<K> for IdMap<K, V, T>
[src]
type Output = V
The returned type after indexing.
fn index(&self, key: K) -> &V
[src]
Performs the indexing (container[index]
) operation.
impl<K: IntegerId, V, T: EntryTable<K, V>> IndexMut<K> for IdMap<K, V, T>
[src]
fn index_mut(&mut self, key: K) -> &mut V
[src]
Performs the mutable indexing (container[index]
) operation.
impl<'a, K: IntegerId, V, T: EntryTable<K, V>> Index<&'a K> for IdMap<K, V, T>
[src]
type Output = V
The returned type after indexing.
fn index(&self, key: &'a K) -> &V
[src]
Performs the indexing (container[index]
) operation.
impl<'a, K: IntegerId, V, T: EntryTable<K, V>> IndexMut<&'a K> for IdMap<K, V, T>
[src]
fn index_mut(&mut self, key: &'a K) -> &mut V
[src]
Performs the mutable indexing (container[index]
) operation.
impl<K: IntegerId, V: Debug, T: EntryTable<K, V>> Debug for IdMap<K, V, T>
[src]
impl<K: IntegerId, V, T: EntryTable<K, V>> IntoIterator for IdMap<K, V, T>
[src]
type Item = (K, V)
The type of the elements being iterated over.
type IntoIter = <T as IntoIterator>::IntoIter
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
[src]
Creates an iterator from a value. Read more
impl<'a, K: IntegerId + 'a, V: 'a, T: 'a> IntoIterator for &'a IdMap<K, V, T> where
T: EntryTable<K, V>,
[src]
T: EntryTable<K, V>,
type Item = (&'a K, &'a V)
The type of the elements being iterated over.
type IntoIter = Iter<'a, K, V, T>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
[src]
Creates an iterator from a value. Read more
impl<'a, K, V, T> IntoIterator for &'a mut IdMap<K, V, T> where
T: EntryTable<K, V>,
K: IntegerId + 'a,
V: 'a,
T: 'a,
[src]
T: EntryTable<K, V>,
K: IntegerId + 'a,
V: 'a,
T: 'a,
type Item = (&'a K, &'a mut V)
The type of the elements being iterated over.
type IntoIter = IterMut<'a, K, V, T>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
[src]
Creates an iterator from a value. Read more
impl<K: IntegerId, V, T: EntryTable<K, V>> Extend<(K, V)> for IdMap<K, V, T>
[src]
fn extend<I: IntoIterator<Item = (K, V)>>(&mut self, iter: I)
[src]
Extends a collection with the contents of an iterator. Read more
impl<K: IntegerId, V, T: EntryTable<K, V>> FromIterator<(K, V)> for IdMap<K, V, T>
[src]
fn from_iter<I>(iterable: I) -> Self where
I: IntoIterator<Item = (K, V)>,
[src]
I: IntoIterator<Item = (K, V)>,
Creates a value from an iterator. Read more
impl<'a, K, V, T> FromIterator<(&'a K, &'a V)> for IdMap<K, V, T> where
K: IntegerId + Clone + 'a,
V: Clone + 'a,
T: EntryTable<K, V>,
[src]
K: IntegerId + Clone + 'a,
V: Clone + 'a,
T: EntryTable<K, V>,
fn from_iter<I>(iterable: I) -> Self where
I: IntoIterator<Item = (&'a K, &'a V)>,
[src]
I: IntoIterator<Item = (&'a K, &'a V)>,
Creates a value from an iterator. Read more
impl<'a, K, V, T> Extend<(&'a K, &'a V)> for IdMap<K, V, T> where
K: IntegerId + Clone + 'a,
V: Clone + 'a,
T: EntryTable<K, V>,
[src]
K: IntegerId + Clone + 'a,
V: Clone + 'a,
T: EntryTable<K, V>,