pub struct SocketMap<A: Hash + Eq, V: Tagged<A>> { /* private fields */ }
Expand description
A map that stores values and summarizes tag counts.
This provides a similar insertion/removal API to HashMap
for individual
key/value pairs. Unlike a regular HashMap
, the key type A
is required to
implement IterShadows
, and V
to implement Tagged
.
Since A
implements IterShadows
, a given value a : A
has zero or more
shadow values. Since the shadow relationship is transitive, we call any
value v
that is reachable by following shadows of a
one of a
’s
“ancestors”, and we say a
is a “descendant” of v
.
In addition to keys and values, this map stores the number of values
present in the map for all descendants of each key. These counts are
separated into buckets for different tags of type V::Tag
.
Implementations§
Source§impl<A, V> SocketMap<A, V>
impl<A, V> SocketMap<A, V>
Sourcepub fn get(&self, key: &A) -> Option<&V>
pub fn get(&self, key: &A) -> Option<&V>
Gets a reference to the value associated with the given key, if any.
Sourcepub fn entry(&mut self, key: A) -> Entry<'_, A, V>
pub fn entry(&mut self, key: A) -> Entry<'_, A, V>
Provides an Entry
for the given key for in-place manipulation.
This is similar to the API provided by HashMap::entry
. Callers can
match on the result to perform different actions depending on whether
the map has a value for the key or not.
Sourcepub fn descendant_counts(
&self,
key: &A,
) -> impl ExactSizeIterator<Item = &(V::Tag, NonZeroUsize)>
pub fn descendant_counts( &self, key: &A, ) -> impl ExactSizeIterator<Item = &(V::Tag, NonZeroUsize)>
Returns counts of tags for values at keys that shadow key
.
This is equivalent to iterating over all keys in the map, filtering for
those keys for which key
is one of their shadows, then calling
Tagged::tag
on the value for each of those keys, and then computing
the number of occurrences for each tag.