Skip to main content

TotalBTreeMap

Struct TotalBTreeMap 

Source
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>

Source

pub fn new() -> Self

Constructs a TotalBTreeMap in which all keys are associated with the common value.

Source§

impl<K, V, C> TotalBTreeMap<K, V, C>

Source

pub fn len(&self) -> usize

Returns the number of uncommon entries in the map.

Source

pub fn is_empty(&self) -> bool

Returns true if the map contains no uncommon entries.

Source

pub fn clear(&mut self)

Resets all entries in the map to the common value.

Source§

impl<K: Ord, V, C> TotalBTreeMap<K, V, C>

Source

pub fn contains_key<Q>(&self, key: &Q) -> bool
where K: Borrow<Q>, Q: Ord + ?Sized,

Returns true if the map contains an uncommon entry with the given key.

Source§

impl<K: Ord, V, C: Commonality<V>> TotalBTreeMap<K, V, C>

Source

pub fn get<Q>(&self, key: &Q) -> &V
where K: Borrow<Q>, Q: Ord + ?Sized,

Returns a reference to the value associated with the given key.

Source

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.

Source

pub fn remove<Q>(&mut self, key: &Q) -> V
where K: Borrow<Q>, Q: Ord + ?Sized,

Associates a key with the common value in the map, and returns the value previously associated with that key.

Source

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.

Source

pub fn uncommon_entry<'a, Q>( &'a mut self, key: &'a Q, ) -> Option<Entry<'a, Q, K, V, C>>
where K: Borrow<Q>, Q: Ord + ?Sized,

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>

Source

pub fn keys(&self) -> Keys<'_, K, V>

An iterator over all keys associated with uncommon values in the map, in sorted order.

Source

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.

Source

pub fn values(&self) -> Values<'_, K, V>

An iterator over all uncommon values in the map, in sorted order.

Source

pub fn into_values(self) -> IntoValues<K, V>

Creates a consuming iterator over all uncommon values in the map, in sorted order.

Source

pub fn iter(&self) -> Iter<'_, K, V>

An iterator over all uncommon entries in the map, in sorted order.

Source§

impl<K, V, C> TotalBTreeMap<K, V, C>

Source

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>

Source

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: Clone, V: Clone, C> Clone for TotalBTreeMap<K, V, C>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<K, V, C: Commonality<V>> Commonality<TotalBTreeMap<K, V, C>> for EmptyCommonality

Source§

fn common() -> TotalBTreeMap<K, V, C>

The common value of type V. Read more
Source§

fn is_common(value: &TotalBTreeMap<K, V, C>) -> bool

Returns true if value is the common value of type V. Self::is_common(Self::common()) must be true.
Source§

impl<K: Debug, V: Debug, C> Debug for TotalBTreeMap<K, V, C>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<K, V, C> Default for TotalBTreeMap<K, V, C>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

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>,

Deserialize this value from the given Serde deserializer. Read more
Source§

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)

Extends a collection with the contents of an iterator. Read more
Source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Source§

impl<K: Ord, V, C: Commonality<V>> FromIterator<(K, V)> for TotalBTreeMap<K, V, C>

Source§

fn from_iter<T: IntoIterator<Item = (K, V)>>(iter: T) -> Self

Creates a value from an iterator. Read more
Source§

impl<K: Hash, V: Hash, C> Hash for TotalBTreeMap<K, V, C>

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<K: Borrow<Q> + Ord, Q: Ord + ?Sized, V, C: Commonality<V>> Index<&Q> for TotalBTreeMap<K, V, C>

Source§

type Output = V

The returned type after indexing.
Source§

fn index(&self, index: &Q) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<'a, K, V, C> IntoIterator for &'a TotalBTreeMap<K, V, C>

Source§

type Item = (&'a K, &'a V)

The type of the elements being iterated over.
Source§

type IntoIter = Iter<'a, K, V>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<K, V, C> IntoIterator for TotalBTreeMap<K, V, C>

Source§

type Item = (K, V)

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter<K, V>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<K: Ord, V: Ord, C> Ord for TotalBTreeMap<K, V, C>

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<K: PartialEq, V: PartialEq, C> PartialEq for TotalBTreeMap<K, V, C>

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<K: PartialOrd, V: PartialOrd, C> PartialOrd for TotalBTreeMap<K, V, C>

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<K: Serialize, V: Serialize, C> Serialize for TotalBTreeMap<K, V, C>

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<K: Eq, V: Eq, C> Eq for TotalBTreeMap<K, V, C>

Auto Trait Implementations§

§

impl<K, V, C = DefaultCommonality> !Freeze for TotalBTreeMap<K, V, C>

§

impl<K, V, C> RefUnwindSafe for TotalBTreeMap<K, V, C>

§

impl<K, V, C> Send for TotalBTreeMap<K, V, C>
where V: Send, K: Send,

§

impl<K, V, C> Sync for TotalBTreeMap<K, V, C>
where V: Sync + Send, K: Sync,

§

impl<K, V, C> Unpin for TotalBTreeMap<K, V, C>
where V: Unpin,

§

impl<K, V, C> UnsafeUnpin for TotalBTreeMap<K, V, C>
where V: UnsafeUnpin,

§

impl<K, V, C> UnwindSafe for TotalBTreeMap<K, V, C>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,