[−][src]Struct idmap::IdMap
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.
Implementations
impl<K: IntegerId, V> IdMap<K, V, DirectEntryTable<K, V>>
[src]
pub fn new_direct() -> Self
[src]
pub fn with_capacity_direct(capacity: usize) -> Self
[src]
impl<K: IntegerId, V> IdMap<K, V>
[src]
pub fn new() -> Self
[src]
Create an empty IdMap using a DenseEntryTable
and OrderedIdTable
pub 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]
pub fn new_other() -> Self
[src]
Create an empty IdMap
with a custom entry table type.
pub fn with_capacity_other(capacity: usize) -> Self
[src]
Create a new IdMap
with the specified capacity but a custom entry table.
pub fn is_empty(&self) -> bool
[src]
pub fn len(&self) -> usize
[src]
pub fn max_id(&self) -> Option<u64>
[src]
pub fn contains_key<Q: Borrow<K>>(&self, key: Q) -> bool
[src]
pub fn get<Q: Borrow<K>>(&self, key: Q) -> Option<&V>
[src]
pub fn get_mut<Q: Borrow<K>>(&mut self, key: Q) -> Option<&mut V>
[src]
pub fn insert(&mut self, key: K, value: V) -> Option<V>
[src]
pub fn remove<Q: Borrow<K>>(&mut self, key: Q) -> Option<V>
[src]
pub fn entry(&mut self, key: K) -> Entry<K, V, T>
[src]
pub fn iter(&self) -> Iter<K, V, T>
[src]
pub fn iter_mut(&mut self) -> IterMut<K, V, T>
[src]
pub fn keys(&self) -> Keys<K, V, T>
[src]
pub fn values(&self) -> Values<K, V, T>
[src]
pub fn values_mut(&mut self) -> ValuesMut<K, V, T>
[src]
pub fn clear(&mut self)
[src]
pub fn retain<F>(&mut self, func: F) where
F: FnMut(&K, &mut V) -> bool,
[src]
F: FnMut(&K, &mut V) -> bool,
Retains only the elements specified by the predicate.
let mut map: IdMap<usize, usize> = (0..8).map(|x|(x, x*10)).collect(); map.retain(|k, _| k % 2 == 0); assert_eq!( map.into_iter().collect::<Vec<_>>(), vec![(0, 0), (2, 20), (4, 40), (6, 60)] );
pub fn reserve(&mut self, amount: usize)
[src]
Reserve space for the specified number of additional elements
pub 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<K, V, T> Clone for IdMap<K, V, T> where
K: IntegerId + Clone,
V: Clone,
T: EntryTable<K, V>,
[src]
K: IntegerId + Clone,
V: Clone,
T: EntryTable<K, V>,
fn clone(&self) -> Self
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<K: IntegerId, V: Debug, T: EntryTable<K, V>> Debug for IdMap<K, V, T>
[src]
impl<K: IntegerId, V, T: EntryTable<K, V>> Default for IdMap<K, V, T>
[src]
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]
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>,
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]
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>,
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)>,
impl<'a, K: IntegerId, V, T: EntryTable<K, V>> Index<&'a K> for IdMap<K, V, T>
[src]
impl<K: IntegerId, V, T: EntryTable<K, V>> Index<K> for IdMap<K, V, T>
[src]
impl<'a, K: IntegerId, V, T: EntryTable<K, V>> IndexMut<&'a K> for IdMap<K, V, T>
[src]
impl<K: IntegerId, V, T: EntryTable<K, V>> IndexMut<K> 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]
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]
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]
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]
#[must_use]fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
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>,
Auto Trait Implementations
impl<K, V, T> RefUnwindSafe for IdMap<K, V, T> where
K: RefUnwindSafe,
T: RefUnwindSafe,
V: RefUnwindSafe,
K: RefUnwindSafe,
T: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V, T> Send for IdMap<K, V, T> where
K: Send,
T: Send,
V: Send,
K: Send,
T: Send,
V: Send,
impl<K, V, T> Sync for IdMap<K, V, T> where
K: Sync,
T: Sync,
V: Sync,
K: Sync,
T: Sync,
V: Sync,
impl<K, V, T> Unpin for IdMap<K, V, T> where
K: Unpin,
T: Unpin,
V: Unpin,
K: Unpin,
T: Unpin,
V: Unpin,
impl<K, V, T> UnwindSafe for IdMap<K, V, T> where
K: UnwindSafe,
T: UnwindSafe,
V: UnwindSafe,
K: UnwindSafe,
T: UnwindSafe,
V: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<I> IntoIterator for I where
I: Iterator,
[src]
I: Iterator,
type Item = <I as Iterator>::Item
The type of the elements being iterated over.
type IntoIter = I
Which kind of iterator are we turning this into?
fn into_iter(self) -> I
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,