Struct zerovec::hashmap::ZeroHashMap
source · pub struct ZeroHashMap<'a, K, V>{ /* private fields */ }
Expand description
A perfect zerohashmap optimized for lookups over immutable keys.
§Examples
use zerovec::ZeroHashMap;
let hashmap =
ZeroHashMap::<i32, str>::from_iter([(0, "a"), (1, "b"), (2, "c")]);
assert_eq!(hashmap.get(&0), Some("a"));
assert_eq!(hashmap.get(&2), Some("c"));
assert_eq!(hashmap.get(&4), None);
Implementations§
source§impl<'a, K, V> ZeroHashMap<'a, K, V>
impl<'a, K, V> ZeroHashMap<'a, K, V>
sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
The number of elements in the ZeroHashMap
.
sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Whether the ZeroHashMap
is empty.
source§impl<'a, K, V> ZeroHashMap<'a, K, V>
impl<'a, K, V> ZeroHashMap<'a, K, V>
sourcepub fn contains_key(&self, key: &K) -> bool
pub fn contains_key(&self, key: &K) -> bool
Returns whether key
is contained in this hashmap
§Example
use zerovec::ZeroHashMap;
let hashmap = ZeroHashMap::<str, str>::from_iter([("a", "A"), ("z", "Z")]);
assert!(hashmap.contains_key("a"));
assert!(!hashmap.contains_key("p"));
source§impl<'a, K, V> ZeroHashMap<'a, K, V>
impl<'a, K, V> ZeroHashMap<'a, K, V>
pub fn iter<'b>( &'b self, ) -> impl ExactSizeIterator<Item = (&'b <K as ZeroMapKV<'a>>::GetType, &'b <V as ZeroMapKV<'a>>::GetType)>
pub fn iter_keys<'b>( &'b self, ) -> impl ExactSizeIterator<Item = &'b <K as ZeroMapKV<'a>>::GetType>
pub fn iter_values<'b>( &'b self, ) -> impl ExactSizeIterator<Item = &'b <V as ZeroMapKV<'a>>::GetType>
Trait Implementations§
source§impl<'a, K, V> Debug for ZeroHashMap<'a, K, V>
impl<'a, K, V> Debug for ZeroHashMap<'a, K, V>
source§impl<'de, 'a, K, V> Deserialize<'de> for ZeroHashMap<'a, K, V>where
K: ZeroMapKV<'a> + ?Sized,
V: ZeroMapKV<'a> + ?Sized,
K::Container: Deserialize<'de>,
V::Container: Deserialize<'de>,
'de: 'a,
impl<'de, 'a, K, V> Deserialize<'de> for ZeroHashMap<'a, K, V>where
K: ZeroMapKV<'a> + ?Sized,
V: ZeroMapKV<'a> + ?Sized,
K::Container: Deserialize<'de>,
V::Container: Deserialize<'de>,
'de: 'a,
source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl<'a, K, V, A, B> FromIterator<(A, B)> for ZeroHashMap<'a, K, V>
impl<'a, K, V, A, B> FromIterator<(A, B)> for ZeroHashMap<'a, K, V>
source§fn from_iter<T: IntoIterator<Item = (A, B)>>(iter: T) -> Self
fn from_iter<T: IntoIterator<Item = (A, B)>>(iter: T) -> Self
Build a ZeroHashMap
from an iterator returning (K, V) tuples.
§Example
use zerovec::ZeroHashMap;
let hashmap = ZeroHashMap::<i32, str>::from_iter([
(1, "a"),
(2, "b"),
(3, "c"),
(4, "d"),
]);
assert_eq!(hashmap.get(&1), Some("a"));
assert_eq!(hashmap.get(&2), Some("b"));
assert_eq!(hashmap.get(&3), Some("c"));
assert_eq!(hashmap.get(&4), Some("d"));
source§impl<'a, K, V> Serialize for ZeroHashMap<'a, K, V>
impl<'a, K, V> Serialize for ZeroHashMap<'a, K, V>
Auto Trait Implementations§
impl<'a, K, V> Freeze for ZeroHashMap<'a, K, V>
impl<'a, K, V> RefUnwindSafe for ZeroHashMap<'a, K, V>where
<K as ZeroMapKV<'a>>::Container: RefUnwindSafe,
<V as ZeroMapKV<'a>>::Container: RefUnwindSafe,
K: ?Sized,
V: ?Sized,
impl<'a, K, V> Send for ZeroHashMap<'a, K, V>
impl<'a, K, V> Sync for ZeroHashMap<'a, K, V>
impl<'a, K, V> Unpin for ZeroHashMap<'a, K, V>
impl<'a, K, V> UnwindSafe for ZeroHashMap<'a, K, V>where
<K as ZeroMapKV<'a>>::Container: UnwindSafe,
<V as ZeroMapKV<'a>>::Container: UnwindSafe,
K: ?Sized,
V: ?Sized,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more