pub struct InOMap<K, V>
where K: Eq + Clone, V: Clone,
{ /* private fields */ }

Implementations§

source§

impl<K, V> InOMap<K, V>
where K: Eq + Clone, V: Clone,

source

pub fn new() -> Self

source

pub fn is_empty(&self) -> bool

source

pub fn len(&self) -> usize

source§

impl<K, V> InOMap<K, V>
where K: Eq + Clone, V: Clone,

source

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

source§

impl<K, V> InOMap<K, V>
where K: Eq + Clone, V: Clone,

source

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

source

pub fn keys(&self) -> impl Iterator<Item = &K>

source

pub fn values(&self) -> impl Iterator<Item = &V>

source

pub fn clear(&mut self)

source§

impl<K, V> InOMap<K, V>
where V: Clone, K: Eq + Clone,

source

pub fn get<BK>(&self, key: &BK) -> Option<&V>
where BK: Eq + ?Sized, K: Borrow<BK> + PartialEq<BK>,

source

pub fn get_key_value<BK>(&self, key: &BK) -> Option<(&K, &V)>
where BK: Eq + ?Sized, K: Borrow<BK> + PartialEq<BK>,

source

pub fn contains_key<BK>(&self, k: &BK) -> bool
where BK: Eq + ?Sized, K: Borrow<BK> + PartialEq<BK>,

source

pub fn is_submap_by<B, RM, F>(&self, other: RM, cmp: F) -> bool
where B: Clone, F: FnMut(&V, &B) -> bool, RM: Borrow<InOMap<K, B>>,

source

pub fn is_proper_submap_by<B, RM, F>(&self, other: RM, cmp: F) -> bool
where B: Clone, F: FnMut(&V, &B) -> bool, RM: Borrow<InOMap<K, B>>,

source

pub fn is_submap<RM>(&self, other: RM) -> bool
where V: PartialEq, RM: Borrow<Self>,

source

pub fn is_proper_submap<RM>(&self, other: RM) -> bool
where V: PartialEq, RM: Borrow<Self>,

source§

impl<K, V> InOMap<K, V>
where V: Clone, K: Eq + Clone,

source

pub fn iter_mut(&mut self) -> IterMut<'_, (K, V)>

Get a mutable iterator over the values of a hash map.

Please note that the order is consistent between maps using the same hasher, but no other ordering guarantee is offered. Items will not come out in insertion order or sort order. They will, however, come out in the same order every time for the same map.

source

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

Get a mutable reference to the value for a key from a hash map.

Time: O(n)

Examples
let mut map = inOMap!{123 => "lol"};
if let Some(value) = map.get_mut(&123) {
    *value = "omg";
}
assert_eq!(
  map.get(&123),
  Some(&"omg")
);
source

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

Insert a key/value mapping into a map.

If the map already has a mapping for the given key, the previous value is overwritten.

Time: O(n)

Examples
let mut map = inOMap!{};
map.insert(123, "123");
map.insert(456, "456");
assert_eq!(
  map,
  inOMap!{123 => "123", 456 => "456"}
);
source

pub fn remove<BK>(&mut self, k: &BK) -> Option<V>
where BK: Eq + ?Sized, K: Borrow<BK> + PartialEq<BK>,

Remove a key/value pair from a map, if it exists, and return the removed value.

This is a copy-on-write operation, so that the parts of the set’s structure which are shared with other sets will be safely copied before mutating.

Time: O(n)

Examples
let mut map = inOMap!{123 => "123", 456 => "456"};
assert_eq!(Some("123"), map.remove(&123));
assert_eq!(Some("456"), map.remove(&456));
assert_eq!(None, map.remove(&789));
assert!(map.is_empty());
source

pub fn remove_with_key<BK>(&mut self, k: &BK) -> Option<(K, V)>
where BK: Eq + ?Sized, K: Borrow<BK> + PartialEq<BK>,

Remove a key/value pair from a map, if it exists, and return the removed key and value.

Time: O(n)

Examples
let mut map = inOMap!{123 => "123", 456 => "456"};
assert_eq!(Some((123, "123")), map.remove_with_key(&123));
assert_eq!(Some((456, "456")), map.remove_with_key(&456));
assert_eq!(None, map.remove_with_key(&789));
assert!(map.is_empty());
source

pub fn entry(&mut self, key: K) -> Entry<'_, K, V>

Get the Entry for a key in the map for in-place manipulation.

Time: O(n)

source

pub fn update(&self, k: K, v: V) -> Self

Construct a new hash map by inserting a key/value mapping into a map.

If the map already has a mapping for the given key, the previous value is overwritten.

Time: O(n)

Examples
let map = inOMap!{};
assert_eq!(
  map.update(123, "123"),
  inOMap!{123 => "123"}
);
source

pub fn update_with<F>(&self, k: K, v: V, f: F) -> Self
where F: FnOnce(V, V) -> V,

Construct a new hash map by inserting a key/value mapping into a map.

If the map already has a mapping for the given key, we call the provided function with the old value and the new value, and insert the result as the new value.

Time: O(n)

source

pub fn update_with_key<F>(&self, k: K, v: V, f: F) -> Self
where F: FnOnce(&K, V, V) -> V,

Construct a new map by inserting a key/value mapping into a map.

If the map already has a mapping for the given key, we call the provided function with the key, the old value and the new value, and insert the result as the new value.

Time: O(n)

source

pub fn update_lookup_with_key<F>(&self, k: K, v: V, f: F) -> (Option<V>, Self)
where F: FnOnce(&K, &V, V) -> V,

Construct a new map by inserting a key/value mapping into a map, returning the old value for the key as well as the new map.

If the map already has a mapping for the given key, we call the provided function with the key, the old value and the new value, and insert the result as the new value.

Time: O(n)

source

pub fn alter<F>(&self, f: F, k: K) -> Self
where F: FnOnce(Option<V>) -> Option<V>,

Update the value for a given key by calling a function with the current value and overwriting it with the function’s return value.

The function gets an Option<V> and returns the same, so that it can decide to delete a mapping instead of updating the value, and decide what to do if the key isn’t in the map.

Time: O(n)

source

pub fn without<BK>(&self, k: &BK) -> Self
where BK: Eq + ?Sized, K: Borrow<BK> + PartialEq<BK>,

Construct a new map without the given key.

Construct a map that’s a copy of the current map, absent the mapping for key if it’s present.

Time: O(n)

source

pub fn retain<F>(&mut self, f: F)
where F: FnMut(&K, &V) -> bool,

Filter out values from a map which don’t satisfy a predicate.

This is slightly more efficient than filtering using an iterator, in that it doesn’t need to rehash the retained values, but it still needs to reconstruct the entire tree structure of the map.

Time: O(n ^ 2)

Examples
let mut map = inOMap!{1 => 1, 2 => 2, 3 => 3};
map.retain(|k, v| *k > 1);
let expected = inOMap!{2 => 2, 3 => 3};
assert_eq!(expected, map);
source

pub fn extract<BK>(&self, k: &BK) -> Option<(V, Self)>
where BK: Eq + ?Sized, K: Borrow<BK> + PartialEq<BK>,

Remove a key/value pair from a map, if it exists, and return the removed value as well as the updated map.

Time: O(n)

source

pub fn extract_with_key<BK>(&self, k: &BK) -> Option<(K, V, Self)>
where BK: Eq + ?Sized, K: Borrow<BK> + PartialEq<BK>,

Remove a key/value pair from a map, if it exists, and return the removed key and value as well as the updated list.

Time: O(n)

source

pub fn union(self, other: Self) -> Self

Construct the union of two maps, keeping the values in the current map when keys exist in both maps.

Time: O(n ^ 2)

Examples
let map1 = inOMap!{1 => 1, 3 => 3};
let map2 = inOMap!{2 => 2, 3 => 4};
let expected = inOMap!{ 2 => 2, 3 => 3, 1 => 1,};
assert_eq!(expected, map1.union(map2));
source

pub fn union_with<F>(self, other: Self, f: F) -> Self
where F: FnMut(V, V) -> V,

Construct the union of two maps, using a function to decide what to do with the value when a key is in both maps.

The function is called when a value exists in both maps, and receives the value from the current map as its first argument, and the value from the other map as the second. It should return the value to be inserted in the resulting map.

Time: O(n ^ 2)

source

pub fn union_with_key<F>(self, other: Self, f: F) -> Self
where F: FnMut(&K, V, V) -> V,

Construct the union of two maps, using a function to decide what to do with the value when a key is in both maps.

The function is called when a value exists in both maps, and receives a reference to the key as its first argument, the value from the current map as the second argument, and the value from the other map as the third argument. It should return the value to be inserted in the resulting map.

Time: O(n ^ 2)

Examples
let map1 = inOMap!{1 => 1, 3 => 4};
let map2 = inOMap!{2 => 2, 3 => 5};
let expected = inOMap!{1 => 1, 2 => 2, 3 => 9};
assert_eq!(expected, map1.union_with_key(
    map2,
    |key, left, right| left + right
));
source

pub fn unions<I>(i: I) -> Self
where I: IntoIterator<Item = Self>,

Construct the union of a sequence of maps, selecting the value of the leftmost when a key appears in more than one map.

Time: O(n ^ 2)

Examples
let map1 = inOMap!{1 => 1, 3 => 3};
let map2 = inOMap!{2 => 2};
let expected = inOMap!{2 => 2, 1 => 1, 3 => 3};
assert_eq!(expected, InOMap::unions(vec![map1, map2]));
source

pub fn unions_with<I, F>(i: I, f: F) -> Self
where I: IntoIterator<Item = Self>, F: Fn(V, V) -> V,

Construct the union of a sequence of maps, using a function to decide what to do with the value when a key is in more than one map.

The function is called when a value exists in multiple maps, and receives the value from the current map as its first argument, and the value from the next map as the second. It should return the value to be inserted in the resulting map.

Time: O(n ^ 2)

source

pub fn unions_with_key<I, F>(i: I, f: F) -> Self
where I: IntoIterator<Item = Self>, F: Fn(&K, V, V) -> V,

Construct the union of a sequence of maps, using a function to decide what to do with the value when a key is in more than one map.

The function is called when a value exists in multiple maps, and receives a reference to the key as its first argument, the value from the current map as the second argument, and the value from the next map as the third argument. It should return the value to be inserted in the resulting map.

Time: O(n ^ 2)

source

pub fn difference(self, other: Self) -> Self

👎Deprecated since 2.0.1: to avoid conflicting behaviors between std and imbl, the difference alias for symmetric_difference will be removed.

Construct the symmetric difference between two maps by discarding keys which occur in both maps.

This is an alias for the symmetric_difference method.

Time: O(n ^ 2)

Examples
let map1 = inOMap!{1 => 1, 3 => 4};
let map2 = inOMap!{2 => 2, 3 => 5};
let expected = inOMap!{1 => 1, 2 => 2};
assert_eq!(expected, map1.difference(map2));
source

pub fn symmetric_difference(self, other: Self) -> Self

Construct the symmetric difference between two maps by discarding keys which occur in both maps.

Time: O(n ^ 2)

Examples
let map1 = inOMap!{1 => 1, 3 => 4};
let map2 = inOMap!{2 => 2, 3 => 5};
let expected = inOMap!{1 => 1, 2 => 2};
assert_eq!(expected, map1.symmetric_difference(map2));
source

pub fn difference_with<F>(self, other: Self, f: F) -> Self
where F: FnMut(V, V) -> Option<V>,

👎Deprecated since 2.0.1: to avoid conflicting behaviors between std and imbl, the difference_with alias for symmetric_difference_with will be removed.

Construct the symmetric difference between two maps by using a function to decide what to do if a key occurs in both.

This is an alias for the symmetric_difference_with method.

Time: O(n ^ 2)

source

pub fn symmetric_difference_with<F>(self, other: Self, f: F) -> Self
where F: FnMut(V, V) -> Option<V>,

Construct the symmetric difference between two maps by using a function to decide what to do if a key occurs in both.

Time: O(n ^ 2)

source

pub fn difference_with_key<F>(self, other: Self, f: F) -> Self
where F: FnMut(&K, V, V) -> Option<V>,

👎Deprecated since 2.0.1: to avoid conflicting behaviors between std and imbl, the difference_with_key alias for symmetric_difference_with_key will be removed.

Construct the symmetric difference between two maps by using a function to decide what to do if a key occurs in both. The function receives the key as well as both values.

This is an alias for the symmetric_difference_with_key method.

Time: O(n ^ 2)

Examples
let map1 = inOMap!{1 => 1, 3 => 4};
let map2 = inOMap!{2 => 2, 3 => 5};
let expected = inOMap!{1 => 1, 3 => 9,  2 => 2,};
assert_eq!(expected, map1.difference_with_key(
    map2,
    |key, left, right| Some(left + right)
));
source

pub fn symmetric_difference_with_key<F>(self, other: Self, f: F) -> Self
where F: FnMut(&K, V, V) -> Option<V>,

Construct the symmetric difference between two maps by using a function to decide what to do if a key occurs in both. The function receives the key as well as both values.

Time: O(n ^ 2)

Examples
let map1 = inOMap!{1 => 1, 3 => 4};
let map2 = inOMap!{2 => 2, 3 => 5};
let expected = inOMap!{1 => 1, 3 => 9,  2 => 2,};
assert_eq!(expected, map1.symmetric_difference_with_key(
    map2,
    |key, left, right| Some(left + right)
));
source

pub fn relative_complement(self, other: Self) -> Self

Construct the relative complement between two maps by discarding keys which occur in other.

Time: O(m * n) where m is the size of the other map

Examples
let map1 = ordmap!{1 => 1, 3 => 4};
let map2 = ordmap!{2 => 2, 3 => 5};
let expected = ordmap!{1 => 1};
assert_eq!(expected, map1.relative_complement(map2));
source

pub fn intersection(self, other: Self) -> Self

Construct the intersection of two maps, keeping the values from the current map.

Time: O(n ^ 2)

Examples
let map1 = inOMap!{1 => 1, 2 => 2};
let map2 = inOMap!{2 => 3, 3 => 4};
let expected = inOMap!{2 => 2};
assert_eq!(expected, map1.intersection(map2));
source

pub fn intersection_with<B, C, F>( self, other: InOMap<K, B>, f: F ) -> InOMap<K, C>
where B: Clone, C: Clone, F: FnMut(V, B) -> C,

Construct the intersection of two maps, calling a function with both values for each key and using the result as the value for the key.

Time: O(n ^ 2)

source

pub fn intersection_with_key<B, C, F>( self, other: InOMap<K, B>, f: F ) -> InOMap<K, C>
where B: Clone, C: Clone, F: FnMut(&K, V, B) -> C,

Construct the intersection of two maps, calling a function with the key and both values for each key and using the result as the value for the key.

Time: O(n ^ 2)

Examples
let map1 = inOMap!{1 => 1, 2 => 2};
let map2 = inOMap!{2 => 3, 3 => 4};
let expected = inOMap!{2 => 5};
assert_eq!(expected, map1.intersection_with_key(
    map2,
    |key, left, right| left + right
));

Trait Implementations§

source§

impl<'a, K, V> Add for &'a InOMap<K, V>
where V: Clone, K: Eq + Clone,

§

type Output = InOMap<K, V>

The resulting type after applying the + operator.
source§

fn add(self, other: Self) -> Self::Output

Performs the + operation. Read more
source§

impl<K, V> Add for InOMap<K, V>
where V: Clone, K: Eq + Clone,

§

type Output = InOMap<K, V>

The resulting type after applying the + operator.
source§

fn add(self, other: Self) -> Self::Output

Performs the + operation. Read more
source§

impl<K, V> AsRef<InOMap<K, V>> for InOMap<K, V>
where K: Eq + Clone, V: Clone,

source§

fn as_ref(&self) -> &Self

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

impl<K, V> Clone for InOMap<K, V>
where K: Eq + Clone + Clone, V: Clone + Clone,

source§

fn clone(&self) -> InOMap<K, V>

Returns a copy 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> Debug for InOMap<K, V>
where V: Clone + Debug, K: Eq + Debug + Clone,

source§

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

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

impl<K, V> Default for InOMap<K, V>
where K: Clone + Eq, V: Clone,

source§

fn default() -> Self

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

impl<'de, K, V> Deserialize<'de> for InOMap<K, V>
where K: Deserialize<'de> + Clone + Eq + Deref, V: Deserialize<'de> + Clone, <K as Deref>::Target: Eq,

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, V, RK, RV> Extend<(RK, RV)> for InOMap<K, V>
where V: Clone + From<RV>, K: Eq + Clone + From<RK>,

source§

fn extend<I>(&mut self, iter: I)
where I: IntoIterator<Item = (RK, RV)>,

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> FromIterator<(K, V)> for InOMap<K, V>
where V: Clone, K: Eq + Clone,

source§

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

Creates a value from an iterator. Read more
source§

impl<'a, BK, K, V> Index<&'a BK> for InOMap<K, V>
where V: Clone, BK: Eq + ?Sized, K: Eq + Clone + Borrow<BK> + PartialEq<BK>,

§

type Output = V

The returned type after indexing.
source§

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

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

impl<'a, BK, K, V> IndexMut<&'a BK> for InOMap<K, V>
where BK: Eq + ?Sized, K: Eq + Clone + Borrow<BK> + PartialEq<BK>, V: Clone,

source§

fn index_mut(&mut self, key: &BK) -> &mut Self::Output

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

impl<'a, K, V> IntoIterator for &'a InOMap<K, V>
where K: Eq + Clone, V: Clone,

§

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

The type of the elements being iterated over.
§

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> IntoIterator for InOMap<K, V>
where K: Eq + Clone, V: Clone,

§

type Item = (K, V)

The type of the elements being iterated over.
§

type IntoIter = ConsumingIter<(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> PartialEq for InOMap<K, V>
where K: Eq + Clone, V: Eq + Clone,

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> Serialize for InOMap<K, V>
where K: Serialize + Eq + Clone, V: Serialize + Clone,

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, V> Sum for InOMap<K, V>
where V: Clone, K: Eq + Clone,

source§

fn sum<I>(it: I) -> Self
where I: Iterator<Item = Self>,

Method which takes an iterator and generates Self from the elements by “summing up” the items.

Auto Trait Implementations§

§

impl<K, V> RefUnwindSafe for InOMap<K, V>

§

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

§

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

§

impl<K, V> Unpin for InOMap<K, V>
where K: Unpin, V: Unpin,

§

impl<K, V> UnwindSafe for InOMap<K, V>

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

§

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

§

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

§

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