pub struct Dict<K, V, Seq> { /* private fields */ }
Expand description
A mergable dictionary.
This dict must contain a Mergable
value. This determines the semantics on conflict. For example if the value is a Cell
then last-write-wins semantics will be used. However if the value is a Bag
then multiple values inserted into the same key will be kept. If the value is a Counter
than conflicting values will be summed.
Implementations§
source§impl<K: Clone + Eq + Hash, V: Mergable, SF: SequenceFactory> Dict<K, V, Sequence<SF>>
impl<K: Clone + Eq + Hash, V: Mergable, SF: SequenceFactory> Dict<K, V, Sequence<SF>>
pub fn entry(&mut self, key: K) -> DictEntry<'_, K, V, SF>
pub fn get<Q: Hash + Eq>(&self, k: &Q) -> Option<&V>where K: Borrow<Q>,
pub fn get_mut<Q: Hash + Eq>(&mut self, k: &Q) -> Option<&mut V>where K: Borrow<Q>,
sourcepub fn insert(&mut self, ctx: &mut Context<SF>, k: K, v: V)
pub fn insert(&mut self, ctx: &mut Context<SF>, k: K, v: V)
Insert a value into the map.
-
Note that if the value is already in the map the two values will be merged. If you do not want this to occur
delete
the value first. -
Also note that this updates the key’s creation time meaning that deletes on the previous key will no longer be respected.
-
TODO: Weird revival stuff.
sourcepub fn remove<Q>(&mut self, ctx: &mut Context<SF>, k: K) -> Option<V>where
K: Borrow<Q>,
Q: Hash + Eq + ?Sized,
pub fn remove<Q>(&mut self, ctx: &mut Context<SF>, k: K) -> Option<V>where K: Borrow<Q>, Q: Hash + Eq + ?Sized,
Remove a value from the map.
Note that the semantics of this operation can be confusing read the description carefully.
This removes the known version of the element in the map and all older versions. Unknown modifications will not prevent deletion but if the element has been insert
ed again after the version that we are aware of that insert will be preserved. Also note that due to merging semantics that may result in values from the known version “reappearing”.