VecMap

Struct VecMap 

Source
pub struct VecMap<A: Array>(/* private fields */);
Expand description

A map backed by a SmallVec of key value pairs.

Implementations§

Source§

impl<K, V, A: Array<Item = (K, V)>> VecMap<A>

Source

pub fn map_values<R, B: Array<Item = (K, R)>, F: FnMut(V) -> R>( self, f: F, ) -> VecMap<B>

map values while keeping keys

Source§

impl<A: Array> VecMap<A>

Source

pub fn is_empty(&self) -> bool

Source

pub fn empty() -> Self

Source

pub fn len(&self) -> usize

number of mappings

Source

pub fn retain<F: FnMut(&A::Item) -> bool>(&mut self, f: F)

retain all pairs matching a predicate

Source

pub fn into_inner(self) -> SmallVec<A>

Source

pub fn single(item: A::Item) -> Self

Creates a vecmap with a single item

Source§

impl<K: Ord + 'static, V, A: Array<Item = (K, V)>> VecMap<A>

Source

pub fn insert(&mut self, key: K, value: V) -> Option<V>

Source

pub fn inner_join_with<W, F>(&mut self, that: &impl AbstractVecMap<K, W>, f: F)
where K: Ord + Clone, F: Fn(&K, V, &W) -> Option<V>,

Source

pub fn left_join_with<W, F>(&mut self, that: &impl AbstractVecMap<K, W>, f: F)
where K: Ord + Clone, F: Fn(&K, V, Option<&W>) -> Option<V>,

Source

pub fn right_join_with<W, F>(&mut self, that: &impl AbstractVecMap<K, W>, f: F)
where K: Ord + Clone, F: Fn(&K, Option<V>, &W) -> Option<V>,

Source

pub fn outer_join_with<W, F>(&mut self, that: &impl AbstractVecMap<K, W>, f: F)
where K: Ord + Clone, F: Fn(OuterJoinArg<&K, V, &W>) -> Option<V>,

Source

pub fn merge_with<B: Array<Item = (K, V)>>(&mut self, that: VecMap<B>)

in-place merge with another map of the same type. The merge is right-biased, so on collisions the values from the rhs will win.

Source

pub fn combine_with<B: Array<Item = A::Item>, F: Fn(V, V) -> V>( &mut self, that: VecMap<B>, f: F, )

in-place combine with another map of the same type. The given function allows to select the value in case of collisions.

Source§

impl<K: Ord + 'static, V, A: Array<Item = (K, V)>> VecMap<A>

Source

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

Trait Implementations§

Source§

impl<K, V, A: Array<Item = (K, V)>> AbstractVecMap<K, V> for VecMap<A>

Source§

fn as_slice(&self) -> &[A::Item]

Source§

fn is_empty(&self) -> bool

Source§

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

Source§

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

lookup of a mapping. Time complexity is O(log N). Binary search.
Source§

fn outer_join<W, R, F, A>( &self, that: &impl AbstractVecMap<K, W>, f: F, ) -> VecMap<A>
where K: Ord + Clone, A: Array<Item = (K, R)>, F: Fn(OuterJoinArg<&K, &V, &W>) -> Option<R>,

Perform an outer join with another VecMap, producing a new result
Source§

fn left_join<W, R, F, A>( &self, that: &impl AbstractVecMap<K, W>, f: F, ) -> VecMap<A>
where K: Ord + Clone, F: Fn(&K, &V, Option<&W>) -> Option<R>, A: Array<Item = (K, R)>,

Source§

fn right_join<W, R, F, A>( &self, that: &impl AbstractVecMap<K, W>, f: F, ) -> VecMap<A>
where K: Ord + Clone, F: Fn(&K, Option<&V>, &W) -> Option<R>, A: Array<Item = (K, R)>,

Source§

fn inner_join<W, R, F, A>( &self, that: &impl AbstractVecMap<K, W>, f: F, ) -> VecMap<A>
where K: Ord + Clone, F: Fn(&K, &V, &W) -> Option<R>, A: Array<Item = (K, R)>,

Source§

impl<A: Array> AsRef<[<A as Array>::Item]> for VecMap<A>

Source§

fn as_ref(&self) -> &[A::Item]

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<T: Clone, A: Array<Item = T>> Clone for VecMap<A>

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<T: Debug, A: Array<Item = T>> Debug for VecMap<A>

Source§

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

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

impl<A: Array> Default for VecMap<A>

Source§

fn default() -> Self

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

impl<'de, K, V, A: Array<Item = (K, V)>> Deserialize<'de> for VecMap<A>
where K: Deserialize<'de> + Ord + PartialEq + Clone, V: Deserialize<'de>,

Source§

fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>

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

impl<K: Ord + 'static, V, A: Array<Item = (K, V)>> Extend<<A as Array>::Item> for VecMap<A>

Source§

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

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, V, A: Array<Item = (K, V)>> From<BTreeMap<K, V>> for VecMap<A>

Source§

fn from(value: BTreeMap<K, V>) -> Self

Converts to this type from the input type.
Source§

impl<A: Array> From<VecMap<A>> for SmallVec<A>

Source§

fn from(value: VecMap<A>) -> Self

Converts to this type from the input type.
Source§

impl<A: Array> From<VecMap<A>> for VecSet<A>

Source§

fn from(value: VecMap<A>) -> Self

Converts to this type from the input type.
Source§

impl<K: Ord, V, A: Array<Item = (K, V)>> FromIterator<(K, V)> for VecMap<A>

Source§

fn from_iter<I: IntoIterator<Item = A::Item>>(iter: I) -> Self

Creates a value from an iterator. Read more
Source§

impl<T: Hash, A: Array<Item = T>> Hash for VecMap<A>

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<'a, K: 'a, V: 'a, A: Array<Item = (K, V)>> IntoIterator for &'a VecMap<A>

Source§

type Item = &'a <A as Array>::Item

The type of the elements being iterated over.
Source§

type IntoIter = VecMapIter<Iter<'a, <A as Array>::Item>>

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<A: Array> IntoIterator for VecMap<A>

Source§

type Item = <A as Array>::Item

The type of the elements being iterated over.
Source§

type IntoIter = VecMapIter<IntoIter<A>>

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<T: Ord, A: Array<Item = T>> Ord for VecMap<A>

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<T: PartialEq, A: Array<Item = T>> PartialEq for VecMap<A>

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<T: PartialOrd, A: Array<Item = T>> PartialOrd for VecMap<A>

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, V, A: Array<Item = (K, V)>> Serialize for VecMap<A>
where K: Serialize, V: Serialize,

Source§

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

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

impl<T: Eq, A: Array<Item = T>> Eq for VecMap<A>

Auto Trait Implementations§

§

impl<A> Freeze for VecMap<A>
where A: Freeze,

§

impl<A> RefUnwindSafe for VecMap<A>

§

impl<A> Send for VecMap<A>
where <A as Array>::Item: Send,

§

impl<A> Sync for VecMap<A>
where A: Sync,

§

impl<A> Unpin for VecMap<A>
where A: Unpin,

§

impl<A> UnwindSafe for VecMap<A>
where A: UnwindSafe, <A as Array>::Item: RefUnwindSafe,

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