[][src]Struct idmap::IdMap

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.

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]

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]

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]

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]

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]

impl<K: IntegerId, V, T: EntryTable<K, V>> Extend<(K, V)> for IdMap<K, V, T>[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]

impl<K: IntegerId, V, T: EntryTable<K, V>> FromIterator<(K, V)> for IdMap<K, V, T>[src]

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.

impl<K: IntegerId, V, T: EntryTable<K, V>> Index<K> for IdMap<K, V, T>[src]

type Output = V

The returned type after indexing.

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?

impl<'a, K: IntegerId + 'a, V: 'a, T: 'a> IntoIterator for &'a IdMap<K, V, T> where
    T: EntryTable<K, V>, 
[src]

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?

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]

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?

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]

Checks if two have the same contents, ignoring the order.

impl<K, V, T> Serialize for IdMap<K, V, T> where
    K: IntegerId,
    K: Serialize,
    V: Serialize,
    T: EntryTable<K, V>, 
[src]

Auto Trait Implementations

impl<K, V, T> RefUnwindSafe for IdMap<K, V, T> where
    K: RefUnwindSafe,
    T: RefUnwindSafe,
    V: RefUnwindSafe

impl<K, V, T> Send for IdMap<K, V, T> where
    K: Send,
    T: Send,
    V: Send

impl<K, V, T> Sync for IdMap<K, V, T> where
    K: Sync,
    T: Sync,
    V: Sync

impl<K, V, T> Unpin for IdMap<K, V, T> where
    K: Unpin,
    T: Unpin,
    V: Unpin

impl<K, V, T> UnwindSafe for IdMap<K, V, T> where
    K: UnwindSafe,
    T: UnwindSafe,
    V: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<I> IntoIterator for I where
    I: Iterator
[src]

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?

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.