pub struct TotalBTreeMap<K, V, C = DefaultCommonality> { /* private fields */ }Expand description
An ordered map in which every possible key has an associated value. Only entries with uncommon values are actually stored in the map; all other keys are presumed to be associated with a common value.
See the crate documentation for more information.
The API is more-or-less a subset of that of BTreeMap. However, methods that treat this type
like a collection (for example, len() and iter()) operate only on
the uncommon entries.
Implementations§
Source§impl<K, V, C> TotalBTreeMap<K, V, C>
impl<K, V, C> TotalBTreeMap<K, V, C>
Source§impl<K, V, C> TotalBTreeMap<K, V, C>
impl<K, V, C> TotalBTreeMap<K, V, C>
Source§impl<K: Ord, V, C> TotalBTreeMap<K, V, C>
impl<K: Ord, V, C> TotalBTreeMap<K, V, C>
Source§impl<K: Ord, V, C: Commonality<V>> TotalBTreeMap<K, V, C>
impl<K: Ord, V, C: Commonality<V>> TotalBTreeMap<K, V, C>
Sourcepub fn get<Q>(&self, key: &Q) -> &V
pub fn get<Q>(&self, key: &Q) -> &V
Returns a reference to the value associated with the given key.
Sourcepub fn insert(&mut self, key: K, value: V) -> V
pub fn insert(&mut self, key: K, value: V) -> V
Associates a key with a value in the map, and returns the value previously associated with that key.
Sourcepub fn remove<Q>(&mut self, key: &Q) -> V
pub fn remove<Q>(&mut self, key: &Q) -> V
Associates a key with the common value in the map, and returns the value previously associated with that key.
Sourcepub fn entry(&mut self, key: K) -> Entry<'_, K, K, V, C>
pub fn entry(&mut self, key: K) -> Entry<'_, K, K, V, C>
Gets the given key’s associated entry in the map for in-place manipulation.
Sourcepub fn uncommon_entry<'a, Q>(
&'a mut self,
key: &'a Q,
) -> Option<Entry<'a, Q, K, V, C>>
pub fn uncommon_entry<'a, Q>( &'a mut self, key: &'a Q, ) -> Option<Entry<'a, Q, K, V, C>>
Gets the given key’s associated entry in the map if it has an uncommon value; otherwise returns None.
In contrast with Self::entry, this method accepts the key in borrowed form.
Source§impl<K, V, C> TotalBTreeMap<K, V, C>
impl<K, V, C> TotalBTreeMap<K, V, C>
Sourcepub fn keys(&self) -> Keys<'_, K, V> ⓘ
pub fn keys(&self) -> Keys<'_, K, V> ⓘ
An iterator over all keys associated with uncommon values in the map, in sorted order.
Sourcepub fn into_keys(self) -> IntoKeys<K, V> ⓘ
pub fn into_keys(self) -> IntoKeys<K, V> ⓘ
Creates a consuming iterator over all keys associated with uncommon values in the map, in sorted order.
Sourcepub fn values(&self) -> Values<'_, K, V> ⓘ
pub fn values(&self) -> Values<'_, K, V> ⓘ
An iterator over all uncommon values in the map, in sorted order.
Sourcepub fn into_values(self) -> IntoValues<K, V> ⓘ
pub fn into_values(self) -> IntoValues<K, V> ⓘ
Creates a consuming iterator over all uncommon values in the map, in sorted order.
Source§impl<K, V, C> TotalBTreeMap<K, V, C>
impl<K, V, C> TotalBTreeMap<K, V, C>
Sourcepub fn as_btree_map(&self) -> &BTreeMap<K, V>
pub fn as_btree_map(&self) -> &BTreeMap<K, V>
Returns a view into the underlying BTreeMap of a TotalBTreeMap, which contains the uncommon entries.
Source§impl<K: Ord, V, C: Commonality<V>> TotalBTreeMap<K, V, C>
impl<K: Ord, V, C: Commonality<V>> TotalBTreeMap<K, V, C>
Sourcepub fn as_btree_map_mut(&mut self) -> AsBTreeMapMut<'_, K, V, C>
pub fn as_btree_map_mut(&mut self) -> AsBTreeMapMut<'_, K, V, C>
Returns a mutable view into the underlying BTreeMap of a TotalBTreeMap, from which mutating iterators can be obtained by calling BTreeMap::values_mut or BTreeMap::iter_mut.
By directly mutating the underlying BTreeMap, it is possible to store uncommon entries in the map temporarily. When the returned view is dropped, all uncommon entries will be removed, restoring the invariant of TotalBTreeMap.
You don’t need this method if you are only mutating individual entries; use the entry method instead.
Trait Implementations§
Source§impl<K, V, C: Commonality<V>> Commonality<TotalBTreeMap<K, V, C>> for EmptyCommonality
impl<K, V, C: Commonality<V>> Commonality<TotalBTreeMap<K, V, C>> for EmptyCommonality
Source§fn common() -> TotalBTreeMap<K, V, C>
fn common() -> TotalBTreeMap<K, V, C>
V. Read moreSource§fn is_common(value: &TotalBTreeMap<K, V, C>) -> bool
fn is_common(value: &TotalBTreeMap<K, V, C>) -> bool
value is the common value of type V. Self::is_common(Self::common())
must be true.Source§impl<K, V, C> Default for TotalBTreeMap<K, V, C>
impl<K, V, C> Default for TotalBTreeMap<K, V, C>
Source§impl<'de, K: Deserialize<'de> + Ord, V: Deserialize<'de>, C: Commonality<V>> Deserialize<'de> for TotalBTreeMap<K, V, C>
impl<'de, K: Deserialize<'de> + Ord, V: Deserialize<'de>, C: Commonality<V>> Deserialize<'de> for TotalBTreeMap<K, V, C>
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>,
Source§impl<K: Ord, V, C: Commonality<V>> Extend<(K, V)> for TotalBTreeMap<K, V, C>
impl<K: Ord, V, C: Commonality<V>> Extend<(K, V)> for TotalBTreeMap<K, V, C>
Source§fn extend<T: IntoIterator<Item = (K, V)>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = (K, V)>>(&mut self, iter: T)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)