[−][src]Struct tinyset::u64set::Map6464
A map type that can use any key that fits in a u64
(i.e. that
satisfies trait Fits64
). This map type is very space-efficient
for keys that are small integers, while not being bad at storing
large integers.
Major caveat The Map6464<K,V>
defines an iterator that
iterates over (K, &V)
rather than (&K, &V)
. This is a break
with standard libray convention, and can be annoying if you are
translating code from HashMap
to Map6464
. The motivation for
this is several-fold:
-
Map6464
does not storeK
orV
directly in its data structures (which would waste space), so there is no reference to the data to take. This does not make it impossible, but does mean we would have to fabricate aK
and return a reference to it, which is awkward and ugly. -
There is no inefficiency involved in returning
K
, since it is necessarily no larger than a pointer (except on a 32-bit system).
Examples
use tinyset::Map6464; let mut a: Map6464<char,usize> = Map6464::new(); a.insert('a', 1); a.insert('b', 2); assert_eq!(a.get(&'a'), Some(1)); assert_eq!(a.get(&'b'), Some(2));
Methods
impl<K: Fits64, V: Fits64> Map6464<K, V>
[src]
pub fn new() -> Self
[src]
Creates an empty Map6464
.
pub fn len(&self) -> usize
[src]
Returns the number of elements in the map.
pub fn insert(&mut self, k: K, v: V) -> Option<V>
[src]
Inserts a key-value pair into the map.
If the map did not have this key present, None is returned.
If the map did have this key present, the value is updated, and the old value is returned.
pub fn reserve(&mut self, additional: usize)
[src]
Reserves capacity for at least additional
more elements to
be inserted in the Map6464
. The collection may reserve more
space to avoid frequent reallocations.
pub fn remove(&mut self, k: &K) -> Option<V>
[src]
Removes a key from the map, returning the value at the key if the key was previously in the map.
pub fn get(&self, k: &K) -> Option<V>
[src]
Returns the value corresponding to the key.
ⓘImportant traits for Map6464Iter<'a, K, V>pub fn iter(&self) -> Map6464Iter<K, V>
[src]
An iterator visiting all key-value pairs in arbitrary order. The iterator element type is (K, &V).
Trait Implementations
impl<K: Clone + Fits64, V: Clone + Fits64> Clone for Map6464<K, V>
[src]
fn clone(&self) -> Map6464<K, V>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<K: Eq + Fits64, V: Eq + Fits64> Eq for Map6464<K, V>
[src]
impl<K: PartialEq + Fits64, V: PartialEq + Fits64> PartialEq<Map6464<K, V>> for Map6464<K, V>
[src]
Auto Trait Implementations
impl<K, V> Send for Map6464<K, V> where
K: Send,
V: Send,
K: Send,
V: Send,
impl<K, V> Sync for Map6464<K, V> where
K: Sync,
V: Sync,
K: Sync,
V: Sync,
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
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>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,