pub type GroupingVec<V> = GroupingContainer<usize, V, Vec<Option<V>>>;
Expand description

A grouping container based on the Vec type.

The vector is given map semantics with keys of type usize, which are used as indices for the vector. When inserting an element at a key, the vector is extended if needed so that it can hold an element with that index.

Aliased Type§

struct GroupingVec<V> { /* private fields */ }

Implementations§

source§

impl<K: Eq + Hash + Clone, V, T: BackingContainer<K, V>> GroupingContainer<K, V, T>

source

pub fn insert(&mut self, key: K, val: V, scope: Scope) -> bool

Inserts the key, value pair in the provided scope.

source

pub fn get(&self, key: &K) -> Option<&V>

Retrieves the value at the provided key.

It is equivalent to obtaining the backing container using backing_container and calling the get method.

source

pub fn begin_group(&mut self)

Begins a new group.

source

pub fn end_group(&mut self) -> Result<(), NoGroupToEndError>

Attempts to end the current group. Returns an error if there is no group to end.

source

pub fn extend<I: IntoIterator<Item = (K, V)>>(&mut self, iter: I)

Extends the GroupingMap with (key, value) pairs.

let mut cat_colors = GroupingHashMap::default();
cat_colors.extend(std::array::IntoIter::new([
   ("paganini", "black"),
   ("mint", "ginger"),
]));
assert_eq!(cat_colors.get(&"paganini"), Some(&"black"));
assert_eq!(cat_colors.get(&"mint"), Some(&"ginger"));
source

pub fn backing_container(&self) -> &T

Gets an immutable reference to the backing container.

It is not possible to obtain a mutable reference to the backing container, as mutations applied through such a reference could not be rolled back.

source

pub fn iter(&self) -> T::Iter<'_>

Iterate over all (key, value) tuples that are currently visible.

source

pub fn iter_all(&self) -> IterAll<'_, K, V, T>

Iterate over all (key, value) tuples in the container, including tuples that are not currently visible.

See the documentation on IterAll for information on how this iterator works.

To iterate over visible items only, use the GroupingContainer::iter method.

source

pub fn len(&self) -> usize

Returns the number of elements in the container.

source

pub fn is_empty(&self) -> bool

Returns whether the container is empty.

Trait Implementations§

source§

impl<K: Debug, V: Debug, T: Debug> Debug for GroupingContainer<K, V, T>

source§

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

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

impl<K, V, T: Default> Default for GroupingContainer<K, V, T>

source§

fn default() -> Self

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

impl<'de, K, V, T> Deserialize<'de> for GroupingContainer<K, V, T>where K: Eq + Hash + Deserialize<'de>, V: Deserialize<'de>, T: Deserialize<'de>,

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: Eq + Hash + Clone, V, T: BackingContainer<K, V>> FromIterator<(K, V)> for GroupingContainer<K, V, T>

source§

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

Creates a value from an iterator. Read more
source§

impl<K: Eq + Hash + Clone, V, T: BackingContainer<K, V>> FromIterator<Item<(K, V)>> for GroupingContainer<K, V, T>

source§

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

Creates a value from an iterator. Read more
source§

impl<K: Eq + Hash, V: PartialEq, T: PartialEq> PartialEq<GroupingContainer<K, V, T>> for GroupingContainer<K, V, T>

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<K, V, T> Serialize for GroupingContainer<K, V, T>where K: Serialize, V: Serialize, T: Serialize,

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 + Hash, V: Eq, T: Eq> Eq for GroupingContainer<K, V, T>