Struct druid::im::OrdMap

source ·
pub struct OrdMap<K, V> { /* private fields */ }
Expand description

An ordered map.

An immutable ordered map implemented as a B-tree.

Most operations on this type of map are O(log n). A HashMap is usually a better choice for performance, but the OrdMap has the advantage of only requiring an Ord constraint on the key, and of being ordered, so that keys always come out from lowest to highest, where a HashMap has no guaranteed ordering.

Implementations§

source§

impl<K, V> OrdMap<K, V>

source

pub fn new() -> OrdMap<K, V>

Construct an empty map.

source

pub fn unit(key: K, value: V) -> OrdMap<K, V>

Construct a map with a single mapping.

Examples
let map = OrdMap::unit(123, "onetwothree");
assert_eq!(
  map.get(&123),
  Some(&"onetwothree")
);
source

pub fn is_empty(&self) -> bool

Test whether a map is empty.

Time: O(1)

Examples
assert!(
  !ordmap!{1 => 2}.is_empty()
);
assert!(
  OrdMap::<i32, i32>::new().is_empty()
);
source

pub fn ptr_eq(&self, other: &OrdMap<K, V>) -> bool

Test whether two maps refer to the same content in memory.

This is true if the two sides are references to the same map, or if the two maps refer to the same root node.

This would return true if you’re comparing a map to itself, or if you’re comparing a map to a fresh clone of itself.

Time: O(1)

source

pub fn len(&self) -> usize

Get the size of a map.

Time: O(1)

Examples
assert_eq!(3, ordmap!{
  1 => 11,
  2 => 22,
  3 => 33
}.len());
source

pub fn clear(&mut self)

Discard all elements from the map.

This leaves you with an empty map, and all elements that were previously inside it are dropped.

Time: O(n)

Examples
let mut map = ordmap![1=>1, 2=>2, 3=>3];
map.clear();
assert!(map.is_empty());
source§

impl<K, V> OrdMap<K, V>where K: Ord,

source

pub fn get_max(&self) -> Option<&(K, V)>

Get the largest key in a map, along with its value. If the map is empty, return None.

Time: O(log n)

Examples
assert_eq!(Some(&(3, 33)), ordmap!{
  1 => 11,
  2 => 22,
  3 => 33
}.get_max());
source

pub fn get_min(&self) -> Option<&(K, V)>

Get the smallest key in a map, along with its value. If the map is empty, return None.

Time: O(log n)

Examples
assert_eq!(Some(&(1, 11)), ordmap!{
  1 => 11,
  2 => 22,
  3 => 33
}.get_min());
source

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

Get an iterator over the key/value pairs of a map.

source

pub fn range<R, BK>(&self, range: R) -> Iter<'_, K, V> where R: RangeBounds<BK>, K: Borrow<BK>, BK: Ord + ?Sized,

Create an iterator over a range of key/value pairs.

source

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

Get an iterator over a map’s keys.

source

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

Get an iterator over a map’s values.

source

pub fn diff<'a>(&'a self, other: &'a OrdMap<K, V>) -> DiffIter<'a, K, V>

Get an iterator over the differences between this map and another, i.e. the set of entries to add, update, or remove to this map in order to make it equal to the other map.

This function will avoid visiting nodes which are shared between the two maps, meaning that even very large maps can be compared quickly if most of their structure is shared.

Time: O(n) (where n is the number of unique elements across the two maps, minus the number of elements belonging to nodes shared between them)

source

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

Get the value for a key from a map.

Time: O(log n)

Examples
let map = ordmap!{123 => "lol"};
assert_eq!(
  map.get(&123),
  Some(&"lol")
);
source

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

Get the key/value pair for a key from a map.

Time: O(log n)

Examples
let map = ordmap!{123 => "lol"};
assert_eq!(
  map.get_key_value(&123),
  Some((&123, &"lol"))
);
source

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

Get the closest smaller entry in a map to a given key as a mutable reference.

If the map contains the given key, this is returned. Otherwise, the closest key in the map smaller than the given value is returned. If the smallest key in the map is larger than the given key, None is returned.

Examples
let map = ordmap![1 => 1, 3 => 3, 5 => 5];
assert_eq!(Some((&3, &3)), map.get_prev(&4));
source

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

Get the closest larger entry in a map to a given key as a mutable reference.

If the set contains the given value, this is returned. Otherwise, the closest value in the set larger than the given value is returned. If the largest value in the set is smaller than the given value, None is returned.

Examples
let map = ordmap![1 => 1, 3 => 3, 5 => 5];
assert_eq!(Some((&5, &5)), map.get_next(&4));
source

pub fn contains_key<BK>(&self, k: &BK) -> boolwhere BK: Ord + ?Sized, K: Borrow<BK>,

Test for the presence of a key in a map.

Time: O(log n)

Examples
let map = ordmap!{123 => "lol"};
assert!(
  map.contains_key(&123)
);
assert!(
  !map.contains_key(&321)
);
source

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

Test whether a map is a submap of another map, meaning that all keys in our map must also be in the other map, with the same values.

Use the provided function to decide whether values are equal.

Time: O(n log n)

source

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

Test whether a map is a proper submap of another map, meaning that all keys in our map must also be in the other map, with the same values. To be a proper submap, ours must also contain fewer keys than the other map.

Use the provided function to decide whether values are equal.

Time: O(n log n)

source

pub fn is_submap<RM>(&self, other: RM) -> boolwhere V: PartialEq<V>, RM: Borrow<OrdMap<K, V>>,

Test whether a map is a submap of another map, meaning that all keys in our map must also be in the other map, with the same values.

Time: O(n log n)

Examples
let map1 = ordmap!{1 => 1, 2 => 2};
let map2 = ordmap!{1 => 1, 2 => 2, 3 => 3};
assert!(map1.is_submap(map2));
source

pub fn is_proper_submap<RM>(&self, other: RM) -> boolwhere V: PartialEq<V>, RM: Borrow<OrdMap<K, V>>,

Test whether a map is a proper submap of another map, meaning that all keys in our map must also be in the other map, with the same values. To be a proper submap, ours must also contain fewer keys than the other map.

Time: O(n log n)

Examples
let map1 = ordmap!{1 => 1, 2 => 2};
let map2 = ordmap!{1 => 1, 2 => 2, 3 => 3};
assert!(map1.is_proper_submap(map2));

let map3 = ordmap!{1 => 1, 2 => 2};
let map4 = ordmap!{1 => 1, 2 => 2};
assert!(!map3.is_proper_submap(map4));
source§

impl<K, V> OrdMap<K, V>where K: Ord + Clone, V: Clone,

source

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

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

Time: O(log n)

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

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

Get the closest smaller entry in a map to a given key as a mutable reference.

If the map contains the given key, this is returned. Otherwise, the closest key in the map smaller than the given value is returned. If the smallest key in the map is larger than the given key, None is returned.

Examples
let mut map = ordmap![1 => 1, 3 => 3, 5 => 5];
if let Some((key, value)) = map.get_prev_mut(&4) {
    *value = 4;
}
assert_eq!(ordmap![1 => 1, 3 => 4, 5 => 5], map);
source

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

Get the closest larger entry in a map to a given key as a mutable reference.

If the set contains the given value, this is returned. Otherwise, the closest value in the set larger than the given value is returned. If the largest value in the set is smaller than the given value, None is returned.

Examples
let mut map = ordmap![1 => 1, 3 => 3, 5 => 5];
if let Some((key, value)) = map.get_next_mut(&4) {
    *value = 4;
}
assert_eq!(ordmap![1 => 1, 3 => 3, 5 => 4], map);
source

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

Insert a key/value mapping into a map.

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

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

Time: O(log n)

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

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

Remove a key/value mapping from a map if it exists.

Time: O(log n)

Examples
let mut map = ordmap!{123 => "123", 456 => "456"};
map.remove(&123);
map.remove(&456);
assert!(map.is_empty());
source

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

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

Time: O(log n)

source

pub fn update(&self, key: K, value: V) -> OrdMap<K, 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, the previous value is overwritten.

Time: O(log n)

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

pub fn update_with<F>(self, k: K, v: V, f: F) -> OrdMap<K, V>where F: FnOnce(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 old value and the new value, and insert the result as the new value.

Time: O(log n)

source

pub fn update_with_key<F>(self, k: K, v: V, f: F) -> OrdMap<K, V>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(log n)

source

pub fn update_lookup_with_key<F>( self, k: K, v: V, f: F ) -> (Option<V>, OrdMap<K, V>)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(log n)

source

pub fn alter<F>(&self, f: F, k: K) -> OrdMap<K, V>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(log n)

source

pub fn without<BK>(&self, k: &BK) -> OrdMap<K, V>where BK: Ord + ?Sized, K: Borrow<BK>,

Remove a key/value pair from a map, if it exists.

Time: O(log n)

source

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

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

Time: O(log n)

source

pub fn extract_with_key<BK>(&self, k: &BK) -> Option<(K, V, OrdMap<K, V>)>where BK: Ord + ?Sized, K: Borrow<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(log n)

source

pub fn union(self, other: OrdMap<K, V>) -> OrdMap<K, V>

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

Time: O(n log n)

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

pub fn union_with<F>(self, other: OrdMap<K, V>, f: F) -> OrdMap<K, V>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 log n)

source

pub fn union_with_key<F>(self, other: OrdMap<K, V>, f: F) -> OrdMap<K, V>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 log n)

Examples
let map1 = ordmap!{1 => 1, 3 => 4};
let map2 = ordmap!{2 => 2, 3 => 5};
let expected = ordmap!{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) -> OrdMap<K, V>where I: IntoIterator<Item = OrdMap<K, V>>,

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 log n)

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

pub fn unions_with<I, F>(i: I, f: F) -> OrdMap<K, V>where I: IntoIterator<Item = OrdMap<K, V>>, 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 log n)

source

pub fn unions_with_key<I, F>(i: I, f: F) -> OrdMap<K, V>where I: IntoIterator<Item = OrdMap<K, V>>, 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 log n)

source

pub fn difference(self, other: OrdMap<K, V>) -> OrdMap<K, V>

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 log n)

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

pub fn symmetric_difference(self, other: OrdMap<K, V>) -> OrdMap<K, V>

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

Time: O(n log n)

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

pub fn difference_with<F>(self, other: OrdMap<K, V>, f: F) -> OrdMap<K, V>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.

This is an alias for the symmetric_difference_with method.

Time: O(n log n)

source

pub fn symmetric_difference_with<F>( self, other: OrdMap<K, V>, f: F ) -> OrdMap<K, V>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 log n)

source

pub fn difference_with_key<F>(self, other: OrdMap<K, V>, f: F) -> OrdMap<K, V>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.

This is an alias for the symmetric_difference_with_key method.

Time: O(n log n)

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

pub fn symmetric_difference_with_key<F>( self, other: OrdMap<K, V>, f: F ) -> OrdMap<K, V>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 log n)

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

pub fn relative_complement(self, other: OrdMap<K, V>) -> OrdMap<K, V>

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

Time: O(m log 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: OrdMap<K, V>) -> OrdMap<K, V>

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

Time: O(n log n)

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

pub fn intersection_with<B, C, F>(self, other: OrdMap<K, B>, f: F) -> OrdMap<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 log n)

source

pub fn intersection_with_key<B, C, F>( self, other: OrdMap<K, B>, f: F ) -> OrdMap<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 log n)

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

pub fn split<BK>(&self, split: &BK) -> (OrdMap<K, V>, OrdMap<K, V>)where BK: Ord + ?Sized, K: Borrow<BK>,

Split a map into two, with the left hand map containing keys which are smaller than split, and the right hand map containing keys which are larger than split.

The split mapping is discarded.

source

pub fn split_lookup<BK>( &self, split: &BK ) -> (OrdMap<K, V>, Option<V>, OrdMap<K, V>)where BK: Ord + ?Sized, K: Borrow<BK>,

Split a map into two, with the left hand map containing keys which are smaller than split, and the right hand map containing keys which are larger than split.

Returns both the two maps and the value of split.

source

pub fn take(&self, n: usize) -> OrdMap<K, V>

Construct a map with only the n smallest keys from a given map.

source

pub fn skip(&self, n: usize) -> OrdMap<K, V>

Construct a map with the n smallest keys removed from a given map.

source

pub fn without_min(&self) -> (Option<V>, OrdMap<K, V>)

Remove the smallest key from a map, and return its value as well as the updated map.

source

pub fn without_min_with_key(&self) -> (Option<(K, V)>, OrdMap<K, V>)

Remove the smallest key from a map, and return that key, its value as well as the updated map.

source

pub fn without_max(&self) -> (Option<V>, OrdMap<K, V>)

Remove the largest key from a map, and return its value as well as the updated map.

source

pub fn without_max_with_key(&self) -> (Option<(K, V)>, OrdMap<K, V>)

Remove the largest key from a map, and return that key, its value as well as the updated map.

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(log n)

Trait Implementations§

source§

impl<'a, K, V> Add<&'a OrdMap<K, V>> for &'a OrdMap<K, V>where K: Ord + Clone, V: Clone,

§

type Output = OrdMap<K, V>

The resulting type after applying the + operator.
source§

fn add( self, other: &'a OrdMap<K, V> ) -> <&'a OrdMap<K, V> as Add<&'a OrdMap<K, V>>>::Output

Performs the + operation. Read more
source§

impl<K, V> Add<OrdMap<K, V>> for OrdMap<K, V>where K: Ord + Clone, V: Clone,

§

type Output = OrdMap<K, V>

The resulting type after applying the + operator.
source§

fn add(self, other: OrdMap<K, V>) -> <OrdMap<K, V> as Add<OrdMap<K, V>>>::Output

Performs the + operation. Read more
source§

impl<K, V> AsRef<OrdMap<K, V>> for OrdMap<K, V>

source§

fn as_ref(&self) -> &OrdMap<K, V>

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

impl<K, V> Clone for OrdMap<K, V>

source§

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

Clone a map.

Time: O(1)

1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl<K: Clone + 'static, V: Data> Data for OrdMap<K, V>

source§

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

Determine whether two values are the same. Read more
source§

impl<K, V> Debug for OrdMap<K, V>where K: Ord + Debug, V: Debug,

source§

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

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

impl<K, V> Default for OrdMap<K, V>

source§

fn default() -> OrdMap<K, V>

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

impl<K, V, RK, RV> Extend<(RK, RV)> for OrdMap<K, V>where K: Ord + Clone + From<RK>, V: Clone + From<RV>,

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<'a, K, V, RK, RV, OK, OV> From<&'a [(RK, RV)]> for OrdMap<K, V>where K: Ord + Clone + From<OK>, V: Clone + From<OV>, OK: Borrow<RK>, OV: Borrow<RV>, RK: ToOwned<Owned = OK>, RV: ToOwned<Owned = OV>,

source§

fn from(m: &'a [(RK, RV)]) -> OrdMap<K, V>

Converts to this type from the input type.
source§

impl<'a, K, V, RK, RV, OK, OV> From<&'a BTreeMap<RK, RV, Global>> for OrdMap<K, V>where K: Ord + Clone + From<OK>, V: Clone + From<OV>, OK: Borrow<RK>, OV: Borrow<RV>, RK: Ord + ToOwned<Owned = OK>, RV: ToOwned<Owned = OV>,

source§

fn from(m: &'a BTreeMap<RK, RV, Global>) -> OrdMap<K, V>

Converts to this type from the input type.
source§

impl<'a, K, V, S> From<&'a HashMap<K, V, S>> for OrdMap<K, V>where K: Ord + Hash + Eq + Clone, V: Clone, S: BuildHasher,

source§

fn from(m: &'a HashMap<K, V, S>) -> OrdMap<K, V>

Converts to this type from the input type.
source§

impl<'a, K, V, OK, OV, RK, RV> From<&'a HashMap<RK, RV, RandomState>> for OrdMap<K, V>where K: Ord + Clone + From<OK>, V: Clone + From<OV>, OK: Borrow<RK>, OV: Borrow<RV>, RK: Hash + Eq + ToOwned<Owned = OK>, RV: ToOwned<Owned = OV>,

source§

fn from(m: &'a HashMap<RK, RV, RandomState>) -> OrdMap<K, V>

Converts to this type from the input type.
source§

impl<'a, K, V, RK, RV, OK, OV> From<&'a Vec<(RK, RV), Global>> for OrdMap<K, V>where K: Ord + Clone + From<OK>, V: Clone + From<OV>, OK: Borrow<RK>, OV: Borrow<RV>, RK: ToOwned<Owned = OK>, RV: ToOwned<Owned = OV>,

source§

fn from(m: &'a Vec<(RK, RV), Global>) -> OrdMap<K, V>

Converts to this type from the input type.
source§

impl<'m, 'k, 'v, K, V, OK, OV> From<&'m OrdMap<&'k K, &'v V>> for OrdMap<OK, OV>where K: Ord + ToOwned<Owned = OK> + ?Sized, V: ToOwned<Owned = OV> + ?Sized, OK: Ord + Clone + Borrow<K>, OV: Clone + Borrow<V>,

source§

fn from(m: &OrdMap<&K, &V>) -> OrdMap<OK, OV>

Converts to this type from the input type.
source§

impl<K, V, RK, RV> From<BTreeMap<RK, RV, Global>> for OrdMap<K, V>where K: Ord + Clone + From<RK>, V: Clone + From<RV>,

source§

fn from(m: BTreeMap<RK, RV, Global>) -> OrdMap<K, V>

Converts to this type from the input type.
source§

impl<K, V, S> From<HashMap<K, V, S>> for OrdMap<K, V>where K: Ord + Hash + Eq + Clone, V: Clone, S: BuildHasher,

source§

fn from(m: HashMap<K, V, S>) -> OrdMap<K, V>

Converts to this type from the input type.
source§

impl<K, V, RK, RV> From<HashMap<RK, RV, RandomState>> for OrdMap<K, V>where K: Ord + Clone + From<RK>, RK: Eq + Hash, V: Clone + From<RV>,

source§

fn from(m: HashMap<RK, RV, RandomState>) -> OrdMap<K, V>

Converts to this type from the input type.
source§

impl<K, V, RK, RV> From<Vec<(RK, RV), Global>> for OrdMap<K, V>where K: Ord + Clone + From<RK>, V: Clone + From<RV>,

source§

fn from(m: Vec<(RK, RV), Global>) -> OrdMap<K, V>

Converts to this type from the input type.
source§

impl<K, V, RK, RV> FromIterator<(RK, RV)> for OrdMap<K, V>where K: Ord + Clone + From<RK>, V: Clone + From<RV>,

source§

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

Creates a value from an iterator. Read more
source§

impl<K, V> Hash for OrdMap<K, V>where K: Ord + Hash, V: Hash,

source§

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

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, BK, K, V> Index<&'a BK> for OrdMap<K, V>where BK: Ord + ?Sized, K: Ord + Borrow<BK>,

§

type Output = V

The returned type after indexing.
source§

fn index(&self, key: &BK) -> &<OrdMap<K, V> as Index<&'a BK>>::Output

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

impl<'a, BK, K, V> IndexMut<&'a BK> for OrdMap<K, V>where BK: Ord + ?Sized, K: Ord + Clone + Borrow<BK>, V: Clone,

source§

fn index_mut(&mut self, key: &BK) -> &mut <OrdMap<K, V> as Index<&'a BK>>::Output

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

impl<'a, K, V> IntoIterator for &'a OrdMap<K, V>where K: Ord,

§

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) -> <&'a OrdMap<K, V> as IntoIterator>::IntoIter

Creates an iterator from a value. Read more
source§

impl<K, V> IntoIterator for OrdMap<K, V>where K: Ord + 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) -> <OrdMap<K, V> as IntoIterator>::IntoIter

Creates an iterator from a value. Read more
source§

impl<K, V> ListIter<V> for OrdMap<K, V>where K: Data + Ord, V: Data,

source§

fn for_each(&self, cb: impl FnMut(&V, usize))

Iterate over each data child.
source§

fn for_each_mut(&mut self, cb: impl FnMut(&mut V, usize))

Iterate over each data child. Keep track of changed data and update self.
source§

fn data_len(&self) -> usize

Return data length.
source§

impl<K, V> Ord for OrdMap<K, V>where K: Ord, V: Ord,

source§

fn cmp(&self, other: &OrdMap<K, V>) -> Ordering

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

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

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

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

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

fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd<Self>,

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

impl<K, V> PartialEq<OrdMap<K, V>> for OrdMap<K, V>where K: Ord + Eq, V: Eq,

source§

fn eq(&self, other: &OrdMap<K, V>) -> 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> PartialEq<OrdMap<K, V>> for OrdMap<K, V>where K: Ord + PartialEq<K>, V: PartialEq<V>,

source§

default fn eq(&self, other: &OrdMap<K, V>) -> 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> PartialOrd<OrdMap<K, V>> for OrdMap<K, V>where K: Ord, V: PartialOrd<V>,

source§

fn partial_cmp(&self, other: &OrdMap<K, V>) -> 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

This method 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

This method 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

This method 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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<K, V> Sum<OrdMap<K, V>> for OrdMap<K, V>where K: Ord + Clone, V: Clone,

source§

fn sum<I>(it: I) -> OrdMap<K, V>where I: Iterator<Item = OrdMap<K, V>>,

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

impl<K, V> Eq for OrdMap<K, V>where K: Ord + Eq, V: Eq,

Auto Trait Implementations§

§

impl<K, V> RefUnwindSafe for OrdMap<K, V>where K: RefUnwindSafe, V: RefUnwindSafe,

§

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

§

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

§

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

§

impl<K, V> UnwindSafe for OrdMap<K, V>where K: UnwindSafe + RefUnwindSafe, V: UnwindSafe + RefUnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> AnyEq for Twhere T: Any + PartialEq<T>,

source§

fn equals(&self, other: &(dyn Any + 'static)) -> bool

source§

fn as_any(&self) -> &(dyn Any + 'static)

source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

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

const: unstable · 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.

§

impl<T> RoundFrom<T> for T

§

fn round_from(x: T) -> T

Performs the conversion.
§

impl<T, U> RoundInto<U> for Twhere U: RoundFrom<T>,

§

fn round_into(self) -> U

Performs the conversion.
source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere 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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more