pub struct RangeMapBlaze<T: Integer, V: Eq + Clone> { /* private fields */ }Expand description
A map from integers to values stored as a map of sorted & disjoint ranges to values.
Internally, the map stores the
ranges and values in a cache-efficient BTreeMap.
§Table of Contents
RangeMapBlazeConstructorsRangeMapBlazeSet OperationsRangeMapBlazeUnion- and Extend-like MethodsRangeMapBlazeComparisons- Additional Examples
§RangeMapBlaze Constructors
You can create RangeMapBlaze’s from unsorted and overlapping integers (or ranges), along with values.
However, if you know that your input is sorted and disjoint, you can speed up construction.
Here are the constructors, followed by a description of the performance, and then some examples.
| Methods | Input | Notes |
|---|---|---|
new/default | ||
from_iter/collect | iterator of (integer, value) | References to the pair or value is OK. |
from_iter/collect | iterator of (range, value) | References to the pair or value is OK. |
from_sorted_disjoint_map/into_range_set_blaze | SortedDisjointMap iterator | |
from /into | array of (integer, value) |
§Constructor Performance
The from_iter/collect constructors are designed to work fast on ‘clumpy’ data.
By ‘clumpy’, we mean that the number of ranges needed to represent the data is
small compared to the number of input integers. To understand this, consider the internals
of the constructors:
Internally, the from_iter/collect constructors take these steps:
- collect adjacent integers/ranges with equal values into disjoint ranges, O(n₁)
- sort the disjoint ranges by their
start, O(n₂ ln n₂) - merge ranges giving precedence to the originally right-most values, O(n₂)
- create a
BTreeMapfrom the now sorted & disjoint ranges, O(n₃ ln n₃)
where n₁ is the number of input integers/ranges, n₂ is the number of disjoint & unsorted ranges, and n₃ is the final number of sorted & disjoint ranges with equal values.
For example, an input of
(3, "a"), (2, "a"), (1, "a"), (4, "a"), (100, "c"), (5, "b"), (4, "b"), (5, "b"), becomes(1..=4, "a"), (100..=100, "c"), (4..=5, "b"), and then(1..=4, "a"), (4..=5, "b"), (100..=100, "c"), and finally(1..=4, "a"), (5..=5, "b"), (100..=100, "c").
What is the effect of clumpy data? Notice that if n₂ ≈ sqrt(n₁), then construction is O(n₁). Indeed, as long as n₂ ≤ n₁/ln(n₁), then construction is O(n₁). Moreover, we’ll see that set operations are O(n₃). Thus, if n₃ ≈ sqrt(n₁) then set operations are O(sqrt(n₁)), a quadratic improvement an O(n₁) implementation that ignores the clumps.
§Constructor Examples
use range_set_blaze::prelude::*;
// Create an empty set with 'new' or 'default'.
let a0 = RangeMapBlaze::<i32, &str>::new();
let a1 = RangeMapBlaze::<i32, &str>::default();
assert!(a0 == a1 && a0.is_empty());
// 'from_iter'/'collect': From an iterator of integers.
// Duplicates and out-of-order elements are fine.
// Values have right-to-left precedence.
let a0 = RangeMapBlaze::from_iter([(100, "b"), (1, "c"),(3, "a"), (2, "a"), (1, "a")]);
let a1: RangeMapBlaze<i32, &str> = [(100, "b"), (1, "c"), (3, "a"), (2, "a"), (1, "a")].into_iter().collect();
assert!(a0 == a1 && a0.to_string() == r#"(1..=3, "a"), (100..=100, "b")"#);
// 'from_iter'/'collect': From an iterator of inclusive ranges, start..=end.
// Overlapping, out-of-order, and empty ranges are fine.
// Values have right-to-left precedence.
#[allow(clippy::reversed_empty_ranges)]
let a0 = RangeMapBlaze::from_iter([(2..=2, "b"), (1..=2, "a"), (-10..=-5, "c"), (1..=0, "d")]);
#[allow(clippy::reversed_empty_ranges)]
let a1: RangeMapBlaze<i32, &str> = [(2..=2, "b"), (1..=2, "a"), (-10..=-5, "c"), (1..=0, "d")].into_iter().collect();
assert!(a0 == a1 && a0.to_string() == r#"(-10..=-5, "c"), (1..=2, "a")"#);
// If we know the ranges are already sorted and disjoint,
// we can avoid work and use 'from_sorted_disjoint_map'/'into_sorted_disjoint_map'.
let a0 = RangeMapBlaze::from_sorted_disjoint_map(CheckSortedDisjointMap::new([(-10..=-5, &"c"), (1..=2, &"a")]));
let a1: RangeMapBlaze<i32, &str> = CheckSortedDisjointMap::new([(-10..=-5, &"c"), (1..=2, &"a")]).into_range_map_blaze();
assert_eq!(a0, a1);
assert_eq!(a0.to_string(),r#"(-10..=-5, "c"), (1..=2, "a")"#);
// For compatibility with `BTreeMap`, we also support
// 'from'/'into' from arrays of integers.
let a0 = RangeMapBlaze::from([(100, "b"), (1, "c"),(3, "a"), (2, "a"), (1, "a")]);
let a1: RangeMapBlaze<i32, &str> = [(100, "b"), (1, "c"),(3, "a"), (2, "a"), (1, "a")].into();
assert_eq!(a0, a1);
assert_eq!(a0.to_string(), r#"(1..=3, "a"), (100..=100, "b")"#);§RangeMapBlaze Set Operations
You can perform set operations on RangeMapBlazes
and RangeSetBlazes using operators. In the table below, a, b, and c are RangeMapBlazes and s is a RangeSetBlaze.
| Set Operation | Operator | Multiway Method |
|---|---|---|
| union | a | b | [a, b, c].union() |
| intersection | a & b | [a, b, c].intersection() |
| intersection | a & s | n/a |
| difference | a - b | n/a |
| difference | a - s | n/a |
| symmetric difference | a ^ b | [a, b, c].symmetric_difference() |
| complement (to set) | !a | n/a |
| complement (to map) | a.complement_with(&value) | n/a |
The result of all operations is a new RangeMapBlaze except for !a, which returns a RangeSetBlaze.
The union of any number of maps is defined such that, for any overlapping keys, the values from the right-most input take precedence. This approach ensures that the data from the right-most inputs remains dominant when merging with later inputs. Likewise, for symmetric difference of three or more maps.
RangeMapBlaze also implements many other methods, such as insert, pop_first and split_off. Many of
these methods match those of BTreeMap.
§Set Operation Performance
Every operation is implemented as
- a single pass over the sorted & disjoint ranges
- the construction of a new
RangeMapBlaze
Thus, applying multiple operators creates intermediate
RangeMapBlaze’s. If you wish, you can avoid these intermediate
RangeMapBlaze’s by switching to the SortedDisjointMap API. The last example below
demonstrates this.
Several union-related operators — such as | (union) and |= (union append) — include performance
optimizations for common cases, including when one operand is much smaller than the other.
These optimizations reduce allocations and merging overhead.
See: Summary of Union and Extend-like Methods.
§Set Operation Examples
use range_set_blaze::prelude::*;
let a = RangeMapBlaze::from_iter([(2..=6, "a")]);
let b = RangeMapBlaze::from_iter([(1..=2, "b"), (5..=100, "b")]);
// Union of two 'RangeMapBlaze's. Alternatively, we can take ownership via 'a | b'.
// Values have right-to-left precedence.
let result = &a | &b;
assert_eq!(result.to_string(), r#"(1..=2, "b"), (3..=4, "a"), (5..=100, "b")"#);
// Intersection of two 'RangeMapBlaze's.
let result = &a & &b; // Alternatively, 'a & b'.
assert_eq!(result.to_string(), r#"(2..=2, "b"), (5..=6, "b")"#);
// Set difference of two 'RangeMapBlaze's.
let result = &a - &b; // Alternatively, 'a - b'.
assert_eq!(result.to_string(), r#"(3..=4, "a")"#);
// Symmetric difference of two 'RangeMapBlaze's.
let result = &a ^ &b; // Alternatively, 'a ^ b'.
assert_eq!(result.to_string(), r#"(1..=1, "b"), (3..=4, "a"), (7..=100, "b")"#);
// complement of a 'RangeMapBlaze' is a `RangeSetBlaze`.
let result = !&b; // Alternatively, '!b'.
assert_eq!(result.to_string(), "-2147483648..=0, 3..=4, 101..=2147483647"
);
// use `complement_with` to create a 'RangeMapBlaze'.
let result = b.complement_with(&"z");
assert_eq!(result.to_string(), r#"(-2147483648..=0, "z"), (3..=4, "z"), (101..=2147483647, "z")"#);
// Multiway union of 'RangeMapBlaze's.
let z = RangeMapBlaze::from_iter([(2..=2, "z"), (6..=200, "z")]);
let result = [&z, &a, &b].union();
assert_eq!(result.to_string(), r#"(1..=2, "b"), (3..=4, "a"), (5..=100, "b"), (101..=200, "z")"# );
// Multiway intersection of 'RangeMapBlaze's.
let result = [&z, &a, &b].intersection();
assert_eq!(result.to_string(), r#"(2..=2, "b"), (6..=6, "b")"#);
// Applying multiple operators
let result0 = &b - (&z | &a); // Creates an intermediate 'RangeMapBlaze'.
// Alternatively, we can use the 'SortedDisjointMap' API and avoid the intermediate 'RangeMapBlaze'.
let result1 = RangeMapBlaze::from_sorted_disjoint_map(
b.range_values() - (a.range_values() | z.range_values()));
assert_eq!(result0, result1);
assert_eq!(result0.to_string(), r#"(1..=1, "b")"#);§RangeMapBlaze Union- and Extend-like Methods
| Operation & Syntax | Input Type | Pre-merge Touching | Cases Optimized |
|---|---|---|---|
a |= b | RangeMapBlaze | - | 3 |
a |= &b | &RangeMapBlaze | - | 3 |
a | b | RangeMapBlaze | - | 3 |
a | &b | &RangeMapBlaze | - | 3 |
&a | b | RangeMapBlaze | - | 3 |
&a | &b | &RangeMapBlaze | - | 3 |
a.extend([(r, v)]) | iter (range, value) | Yes | 1 |
a.extend([(i, v)]) | iter (integer, value) | Yes | 1 |
a.extend_simple(...) | iter (range, value) | No | 1 |
a.extend_with(&b) | &RangeMapBlaze | - | 1 |
a.extend_from(b) | RangeMapBlaze | - | 1 |
b.append(&mut a) | &mut RangeMapBlaze | - | 1 |
Notes:
- Pre-merge Touching means adjacent or overlapping ranges with the same value are combined into a single range before insertions.
- Cases Optimized indicates how many usage scenarios have dedicated performance paths:
3= optimized for small-left, small-right, and similar-sized inputs1= optimized for small-right inputs only
§RangeMapBlaze Comparisons
RangeMapBlaze supports comparisons for equality and lexicographic order:
- Equality: Use
==and!=to check if twoRangeMapBlazeinstances are equal. TwoRangeMapBlazeinstances are considered equal if they contain the same ranges and associated values. - Ordering: If the values implement
Ord, you can use<,<=,>, and>=to compare twoRangeMapBlazeinstances. These comparisons are lexicographic, similar toBTreeMap, meaning they compare the ranges and their values in sequence. - Partial Ordering: If the values implement
PartialOrdbut notOrd, you can use thepartial_cmpmethod to compare twoRangeMapBlazeinstances. This method returns anOption<Ordering>that indicates the relative order of the instances orNoneif the values are not comparable.
See partial_cmp and cmp for more examples.
§Additional Examples
See the module-level documentation for additional examples.
Implementations§
Source§impl<T: Integer, V: Eq + Clone> RangeMapBlaze<T, V>
impl<T: Integer, V: Eq + Clone> RangeMapBlaze<T, V>
Sourcepub fn iter(&self) -> IterMap<T, &V, RangeValuesIter<'_, T, V>> ⓘ
pub fn iter(&self) -> IterMap<T, &V, RangeValuesIter<'_, T, V>> ⓘ
Gets an iterator that visits the integer elements in the RangeMapBlaze in
ascending and/or descending order. Double-ended.
Also see the RangeMapBlaze::ranges method.
§Examples
use range_set_blaze::RangeMapBlaze;
let map = RangeMapBlaze::from_iter([(1..=3,"a")]);
let mut map_iter = map.iter();
assert_eq!(map_iter.next(), Some((1, &"a")));
assert_eq!(map_iter.next(), Some((2, &"a")));
assert_eq!(map_iter.next(), Some((3, &"a")));
assert_eq!(map_iter.next(), None);Values returned by .next() are in ascending order.
Values returned by .next_back() are in descending order.
use range_set_blaze::RangeMapBlaze;
let map = RangeMapBlaze::from_iter([(3,"c"), (1,"a"), (2,"b")]);
let mut map_iter = map.iter();
assert_eq!(map_iter.next(), Some((1, &"a")));
assert_eq!(map_iter.next_back(), Some((3, &"c")));
assert_eq!(map_iter.next(), Some((2, &"b")));
assert_eq!(map_iter.next_back(), None);Sourcepub fn keys(&self) -> Keys<T, &V, RangeValuesIter<'_, T, V>> ⓘ
pub fn keys(&self) -> Keys<T, &V, RangeValuesIter<'_, T, V>> ⓘ
Gets an iterator that visits the integer elements in the RangeMapBlaze in
ascending and/or descending order. Double-ended.
For a consuming version, see the RangeMapBlaze::into_keys method.
§Examples
use range_set_blaze::RangeMapBlaze;
let map = RangeMapBlaze::from_iter([(1..=3,"a")]);
let mut keys_iter = map.keys();
assert_eq!(keys_iter.next(), Some(1));
assert_eq!(keys_iter.next(), Some(2));
assert_eq!(keys_iter.next(), Some(3));
assert_eq!(keys_iter.next(), None);Keys returned by .next() are in ascending order.
Keys returned by .next_back() are in descending order.
let map = RangeMapBlaze::from_iter([(3,"c"), (1,"a"), (2,"b")]);
let mut keys_iter = map.keys();
assert_eq!(keys_iter.next(), Some(1));
assert_eq!(keys_iter.next_back(), Some(3));
assert_eq!(keys_iter.next(), Some(2));
assert_eq!(keys_iter.next_back(), None);Sourcepub fn into_keys(self) -> IntoKeys<T, V> ⓘ
pub fn into_keys(self) -> IntoKeys<T, V> ⓘ
Gets an iterator that visits the integer elements in the RangeMapBlaze in
ascending and/or descending order. Double-ended.
The iterator consumes the RangeMapBlaze, yielding one integer at a time from its ranges.
For a non-consuming version, see the RangeMapBlaze::keys method.
§Examples
Iterating in ascending order:
use range_set_blaze::RangeMapBlaze;
let map = RangeMapBlaze::from_iter([(1..=3, "a")]);
let mut into_keys_iter = map.into_keys();
assert_eq!(into_keys_iter.next(), Some(1));
assert_eq!(into_keys_iter.next(), Some(2));
assert_eq!(into_keys_iter.next(), Some(3));
assert_eq!(into_keys_iter.next(), None);Iterating in both ascending and descending order:
let map = RangeMapBlaze::from_iter([(1..=3, "a"), (5..=5, "b")]);
let mut into_keys_iter = map.into_keys();
assert_eq!(into_keys_iter.next(), Some(1));
assert_eq!(into_keys_iter.next_back(), Some(5));
assert_eq!(into_keys_iter.next(), Some(2));
assert_eq!(into_keys_iter.next_back(), Some(3));
assert_eq!(into_keys_iter.next(), None);Keys returned by .next() are in ascending order.
Keys returned by .next_back() are in descending order.
Sourcepub fn values(&self) -> Values<T, &V, RangeValuesIter<'_, T, V>> ⓘ
pub fn values(&self) -> Values<T, &V, RangeValuesIter<'_, T, V>> ⓘ
Gets an iterator that visits the values in the RangeMapBlaze in
the order corresponding to the integer elements. Double-ended.
For a consuming version, see the RangeMapBlaze::into_values method.
§Examples
Iterating over values:
use range_set_blaze::RangeMapBlaze;
let map = RangeMapBlaze::from_iter([(3, "c"), (1, "a"), (2, "b")]);
let mut values_iter = map.values();
assert_eq!(values_iter.next(), Some(&"a"));
assert_eq!(values_iter.next(), Some(&"b"));
assert_eq!(values_iter.next(), Some(&"c"));
assert_eq!(values_iter.next(), None);Values returned by .next() are in the order of corresponding integer elements.
Values returned by .next_back() correspond to elements in descending integer order.
let map = RangeMapBlaze::from_iter([(3, "c"), (1, "a"), (2, "b")]);
let mut values_iter = map.values();
assert_eq!(values_iter.next(), Some(&"a"));
assert_eq!(values_iter.next_back(), Some(&"c"));
assert_eq!(values_iter.next(), Some(&"b"));
assert_eq!(values_iter.next_back(), None);Sourcepub fn into_values(self) -> IntoValues<T, V> ⓘ
pub fn into_values(self) -> IntoValues<T, V> ⓘ
Gets an iterator that visits the values in the RangeMapBlaze in
the order corresponding to the integer elements. Double-ended.
The iterator consumes the RangeMapBlaze, yielding one value at a time for
each integer in its ranges. For a non-consuming version, see the RangeMapBlaze::values method.
§Examples
Iterating over values in ascending order:
use range_set_blaze::RangeMapBlaze;
let map = RangeMapBlaze::from_iter([(3, "c"), (1, "a"), (2, "b")]);
let mut into_values_iter = map.into_values();
assert_eq!(into_values_iter.next(), Some("a"));
assert_eq!(into_values_iter.next(), Some("b"));
assert_eq!(into_values_iter.next(), Some("c"));
assert_eq!(into_values_iter.next(), None);Iterating over values in both ascending and descending order:
use range_set_blaze::RangeMapBlaze;
let map = RangeMapBlaze::from_iter([(1..=3, "a"), (5..=5, "b")]);
let mut into_values_iter = map.into_values();
assert_eq!(into_values_iter.next(), Some("a"));
assert_eq!(into_values_iter.next_back(), Some("b"));
assert_eq!(into_values_iter.next(), Some("a"));
assert_eq!(into_values_iter.next_back(), Some("a"));
assert_eq!(into_values_iter.next(), None);Values returned by .next() correspond to elements in ascending integer order.
Values returned by .next_back() correspond to elements in descending integer order.
Sourcepub fn first_key_value(&self) -> Option<(T, &V)>
pub fn first_key_value(&self) -> Option<(T, &V)>
Returns the first element in the set, if any. This element is always the minimum of all integer elements in the set.
§Examples
Basic usage:
use range_set_blaze::RangeMapBlaze;
let mut map = RangeMapBlaze::new();
assert_eq!(map.first_key_value(), None);
map.insert(1,"a");
assert_eq!(map.first_key_value(), Some((1, &"a")));
map.insert(2,"b");
assert_eq!(map.first_key_value(), Some((1, &"a")));Sourcepub fn get(&self, key: T) -> Option<&V>
pub fn get(&self, key: T) -> Option<&V>
Returns the element in the set, if any, that is equal to the value.
§Examples
use range_set_blaze::RangeMapBlaze;
let map = RangeMapBlaze::from_iter([(3,"c"), (1,"a"), (2,"b")]);
assert_eq!(map.get(2), Some(&"b"));
assert_eq!(map.get(4), None);Sourcepub fn get_key_value(&self, key: T) -> Option<(T, &V)>
pub fn get_key_value(&self, key: T) -> Option<(T, &V)>
Returns the key and value in the map, if any, that contains the given key.
§Examples
use range_set_blaze::RangeMapBlaze;
let map = RangeMapBlaze::from_iter([(3..=5, "c"), (1..=2, "a")]);
assert_eq!(map.get_key_value(2), Some((2, &"a")));
assert_eq!(map.get_key_value(4), Some((4, &"c")));
assert_eq!(map.get_key_value(6), None);Sourcepub fn last_key_value(&self) -> Option<(T, &V)>
pub fn last_key_value(&self) -> Option<(T, &V)>
Returns the last element in the set, if any. This element is always the maximum of all elements in the set.
§Examples
Basic usage:
use range_set_blaze::RangeMapBlaze;
let mut map = RangeMapBlaze::new();
assert_eq!(map.last_key_value(), None);
map.insert(1, "a");
assert_eq!(map.last_key_value(), Some((1, &"a")));
map.insert(2, "b");
assert_eq!(map.last_key_value(), Some((2, &"b")));Sourcepub fn from_sorted_disjoint_map<VR, I>(iter: I) -> Selfwhere
VR: ValueRef<Target = V>,
I: SortedDisjointMap<T, VR>,
pub fn from_sorted_disjoint_map<VR, I>(iter: I) -> Selfwhere
VR: ValueRef<Target = V>,
I: SortedDisjointMap<T, VR>,
Create a RangeMapBlaze from a SortedDisjointMap iterator.
For more about constructors and performance, see RangeMapBlaze Constructors.
§Examples
use range_set_blaze::prelude::*;
let a0 = RangeMapBlaze::from_sorted_disjoint_map(CheckSortedDisjointMap::new([(-10..=-5, &"a"), (1..=2, &"b")]));
let a1: RangeMapBlaze<i32,_> = CheckSortedDisjointMap::new([(-10..=-5, &"a"), (1..=2, &"b")]).into_range_map_blaze();
assert!(a0 == a1 && a0.to_string() == r#"(-10..=-5, "a"), (1..=2, "b")"#);Sourcepub fn append(&mut self, other: &mut Self)
pub fn append(&mut self, other: &mut Self)
Moves all elements from other into self, leaving other empty.
This method has right-to-left precedence: if any ranges overlap, values in other
will overwrite those in self.
§Performance
This method inserts each range from other into self one-by-one, with overall time
complexity O(n log m), where n is the number of ranges in other and m is the number
of ranges in self.
For large n, consider using the | operator, which performs a sorted merge and runs in O(n + m) time.
See: Summary of Union and Extend-like Methods.
§Examples
use range_set_blaze::RangeMapBlaze;
let mut a = RangeMapBlaze::from_iter([(1..=3,"a")]);
let mut b = RangeMapBlaze::from_iter([(3..=5,"b")]);
a.append(&mut b);
assert_eq!(a.len(), 5u64);
assert_eq!(b.len(), 0u64);
assert_eq!(a[1], "a");
assert_eq!(a[2], "a");
assert_eq!(a[3], "b");
assert_eq!(a[4], "b");
assert_eq!(a[5], "b");Sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Clears the map, removing all elements.
§Examples
use range_set_blaze::RangeMapBlaze;
let mut a = RangeMapBlaze::new();
a.insert(1, "a");
a.clear();
assert!(a.is_empty());Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true if the map contains no elements.
§Examples
use range_set_blaze::RangeMapBlaze;
let mut a = RangeMapBlaze::new();
assert!(a.is_empty());
a.insert(1, "a");
assert!(!a.is_empty());Sourcepub fn is_universal(&self) -> bool
pub fn is_universal(&self) -> bool
Returns true if the map contains all possible integers.
For type T, this means the union of ranges covers T::min_value() through T::max_value().
Complexity: O(1) using a precomputed length.
§Examples
use range_set_blaze::RangeMapBlaze;
// Multiple ranges covering all values is universal
let multi_universal = RangeMapBlaze::from_iter([
(0_u8..=100, "first"),
(101_u8..=255, "second")
]);
assert!(multi_universal.is_universal());
// Incomplete coverage is not universal
let incomplete = RangeMapBlaze::from_iter([(1_u8..=255, "missing_zero")]);
assert!(!incomplete.is_universal());Sourcepub fn contains_key(&self, key: T) -> bool
pub fn contains_key(&self, key: T) -> bool
Returns true if the set contains an element equal to the value.
§Examples
use range_set_blaze::RangeMapBlaze;
let map = RangeMapBlaze::from_iter([(3,"c"), (1,"a"), (2,"b")]);
assert_eq!(map.contains_key(1), true);
assert_eq!(map.contains_key(4), false);Sourcepub fn insert(&mut self, key: T, value: V) -> Option<V>
pub fn insert(&mut self, key: T, value: V) -> Option<V>
Adds a value to the set.
Returns whether the value was newly inserted. That is:
- If the set did not previously contain an equal value,
trueis returned. - If the set already contained an equal value,
falseis returned, and the entry is not updated.
§Performance
Inserting n items will take in O(n log m) time, where n is the number of inserted items and m is the number of ranges in self.
When n is large, consider using | which is O(n+m) time.
§Examples
use range_set_blaze::RangeMapBlaze;
let mut map = RangeMapBlaze::new();
assert_eq!(map.insert(37, "a"), None);
assert_eq!(map.is_empty(), false);
map.insert(37, "b");
assert_eq!(map.insert(37, "c"), Some("b"));
assert_eq!(map[37], "c");Sourcepub fn range<R>(&self, range: R) -> IntoIterMap<T, V> ⓘwhere
R: RangeBounds<T>,
pub fn range<R>(&self, range: R) -> IntoIterMap<T, V> ⓘwhere
R: RangeBounds<T>,
Constructs an iterator over a sub-range of elements in the set.
Not to be confused with RangeMapBlaze::ranges, which returns an iterator over the ranges in the set.
The simplest way is to use the range syntax min..max, thus range(min..max) will
yield elements from min (inclusive) to max (exclusive).
The range may also be entered as (Bound<T, V, VR>, Bound<T, V, VR>), so for example
range((Excluded(4), Included(10))) will yield a left-exclusive, right-inclusive
range from 4 to 10.
§Panics
Panics if start (inclusive) is greater than end (inclusive).
§Performance
Although this could be written to run in time O(ln(n)) in the number of ranges, it is currently O(n) in the number of ranges.
§Examples
use range_set_blaze::RangeMapBlaze;
use core::ops::Bound::Included;
let mut map = RangeMapBlaze::new();
map.insert(3, "a");
map.insert(5, "b");
map.insert(8, "c");
for (key, value) in map.range((Included(4), Included(8))) {
println!("{key}: {value}");
} // prints "5: b" and "8: c"
assert_eq!(Some((5, "b")), map.range(4..).next());Sourcepub fn ranges_insert(&mut self, range: RangeInclusive<T>, value: V) -> bool
pub fn ranges_insert(&mut self, range: RangeInclusive<T>, value: V) -> bool
Adds a range to the set.
Returns whether any values where newly inserted. That is:
- If the set did not previously contain some value in the range,
trueis returned. - If the set already contained every value in the range,
falseis returned, and the entry is not updated.
§Performance
Inserting n items will take in O(n log m) time, where n is the number of inserted items and m is the number of ranges in self.
When n is large, consider using | which is O(n+m) time.
§Examples
use range_set_blaze::RangeMapBlaze;
let mut map = RangeMapBlaze::new();
assert_eq!(map.ranges_insert(2..=5, "a"), true);
assert_eq!(map.ranges_insert(5..=6, "b"), true);
assert_eq!(map.ranges_insert(3..=4, "c"), false);
assert_eq!(map.len(), 5u64);Sourcepub fn remove(&mut self, key: T) -> Option<V>
pub fn remove(&mut self, key: T) -> Option<V>
If the set contains an element equal to the value, removes it from the set and drops it. Returns whether such an element was present.
§Examples
use range_set_blaze::RangeMapBlaze;
let mut map = RangeMapBlaze::new();
map.insert(1, "a");
assert_eq!(map.remove(1), Some("a"));
assert_eq!(map.remove(1), None);Sourcepub fn split_off(&mut self, key: T) -> Self
pub fn split_off(&mut self, key: T) -> Self
Splits the collection into two at the value. Returns a new collection with all elements greater than or equal to the value.
§Examples
Basic usage:
use range_set_blaze::RangeMapBlaze;
let mut a = RangeMapBlaze::new();
a.insert(1, "a");
a.insert(2, "b");
a.insert(3, "c");
a.insert(17, "d");
a.insert(41, "e");
let b = a.split_off(3);
assert_eq!(a, RangeMapBlaze::from_iter([(1..=1, "a"), (2..=2, "b")]));
assert_eq!(b, RangeMapBlaze::from_iter([(3..=3, "c"), (17..=17, "d"), (41..=41, "e")]));Sourcepub const fn len(&self) -> <T as Integer>::SafeLen
pub const fn len(&self) -> <T as Integer>::SafeLen
Returns the number of elements in the set.
The number is allowed to be very, very large.
§Examples
use range_set_blaze::prelude::*;
let mut a = RangeMapBlaze::new();
assert_eq!(a.len(), 0u64);
a.insert(1, "a");
assert_eq!(a.len(), 1u64);
let a = RangeMapBlaze::from_iter([
(-170_141_183_460_469_231_731_687_303_715_884_105_728_i128..=10, "a"),
(-10..=170_141_183_460_469_231_731_687_303_715_884_105_726, "a")]);
assert_eq!(
a.len(),
UIntPlusOne::UInt(340282366920938463463374607431768211455)
);Sourcepub fn new() -> Self
pub fn new() -> Self
Makes a new, empty RangeMapBlaze.
§Examples
use range_set_blaze::RangeMapBlaze;
let mut map = RangeMapBlaze::new();
// entries can now be inserted into the empty map
map.insert(1, "a");
assert_eq!(map[1], "a");Sourcepub fn extend_simple<I>(&mut self, iter: I)where
I: IntoIterator<Item = (RangeInclusive<T>, V)>,
pub fn extend_simple<I>(&mut self, iter: I)where
I: IntoIterator<Item = (RangeInclusive<T>, V)>,
Extends the RangeMapBlaze with an iterator of (range, value) pairs without pre-merging.
Unlike RangeMapBlaze::extend, this method does not merge adjacent or overlapping ranges
before inserting. Each (range, value) pair is added as-is, making it faster when the input
is already well-structured or disjoint.
This method has right-to-left precedence: later ranges in the iterator overwrite earlier ones.
See: Summary of Union and Extend-like Methods.
§Examples
use range_set_blaze::RangeMapBlaze;
let mut a = RangeMapBlaze::from_iter([(1..=4, "a")]);
a.extend_simple([(3..=5, "b"), (5..=5, "c")]);
assert_eq!(a, RangeMapBlaze::from_iter([(1..=2, "a"), (3..=4, "b"), (5..=5, "c")]));
let mut a = RangeMapBlaze::from_iter([(1..=4, "a")]);
a.extend([(3..=5, "b"), (5..=5, "c")]);
assert_eq!(a, RangeMapBlaze::from_iter([(1..=2, "a"), (3..=4, "b"), (5..=5, "c")]));
let mut a = RangeMapBlaze::from_iter([(3..=5, "b"), (5..=5, "c")]);
let mut b = RangeMapBlaze::from_iter([(1..=4, "a")]);
a |= b;
assert_eq!(a, RangeMapBlaze::from_iter([(1..=4, "a"), (5..=5, "c")]));Sourcepub fn extend_from(&mut self, other: Self)
pub fn extend_from(&mut self, other: Self)
Extends the RangeMapBlaze with the contents of an owned RangeMapBlaze.
This method follows standard right-to-left precedence: If the maps contain overlapping ranges,
values from other will overwrite those in self.
Compared to RangeMapBlaze::extend_with, this method can be more efficient because it can
consume the internal data structures of other directly, avoiding some cloning.
See: Summary of Union and Extend-like Methods.
§Examples
use range_set_blaze::RangeMapBlaze;
let mut a = RangeMapBlaze::from_iter([(1..=4, "a")]);
let mut b = RangeMapBlaze::from_iter([(3..=4, "b"), (5..=5, "c")]);
a.extend_from(b);
assert_eq!(a, RangeMapBlaze::from_iter([(1..=2, "a"), (3..=4, "b"), (5..=5, "c")]));Sourcepub fn extend_with(&mut self, other: &Self)
pub fn extend_with(&mut self, other: &Self)
Extends the RangeMapBlaze with the contents of a borrowed RangeMapBlaze.
This method follows standard right-to-left precedence: If the maps contain overlapping ranges,
values from other will overwrite those in self.
This method is simple and predictable but not the most efficient option when
the right-hand side is larger. For better performance when ownership is available,
consider using RangeMapBlaze::extend_from or the |= operator.
See: Summary of Union and Extend-like Methods.
§Examples
use range_set_blaze::RangeMapBlaze;
let mut a = RangeMapBlaze::from_iter([(1..=4, "a")]);
let mut b = RangeMapBlaze::from_iter([(3..=4, "b"), (5..=5, "c")]);
a.extend_from(b);
assert_eq!(a, RangeMapBlaze::from_iter([(1..=2, "a"), (3..=4, "b"), (5..=5, "c")]));Sourcepub fn pop_first(&mut self) -> Option<(T, V)>where
V: Clone,
pub fn pop_first(&mut self) -> Option<(T, V)>where
V: Clone,
Removes the first element from the set and returns it, if any. The first element is always the minimum element in the set.
Often, internally, the value must be cloned.
§Examples
use range_set_blaze::RangeMapBlaze;
let mut map = RangeMapBlaze::new();
map.insert(1, "a");
map.insert(2, "b");
while let Some((key, _val)) = map.pop_first() {
assert!(map.iter().all(|(k, _v)| k > key));
}
assert!(map.is_empty());Sourcepub fn pop_last(&mut self) -> Option<(T, V)>
pub fn pop_last(&mut self) -> Option<(T, V)>
Removes the last value from the set and returns it, if any. The last value is always the maximum value in the set.
Often, internally, the value must be cloned.
§Examples
use range_set_blaze::RangeMapBlaze;
let mut map = RangeMapBlaze::new();
map.insert(1, "a");
map.insert(2, "b");
while let Some((key, _val)) = map.pop_last() {
assert!(map.iter().all(|(k, _v)| k < key));
}
assert!(map.is_empty());Sourcepub fn range_values(&self) -> RangeValuesIter<'_, T, V> ⓘ
pub fn range_values(&self) -> RangeValuesIter<'_, T, V> ⓘ
An iterator that visits the ranges and values in the RangeMapBlaze,
Also see RangeMapBlaze::iter and RangeMapBlaze::into_range_values.
§Examples
use range_set_blaze::RangeMapBlaze;
let map = RangeMapBlaze::from_iter([(30..=40, "c"), (15..=25, "b"), (10..=20, "a")]);
let mut range_values = map.range_values();
assert_eq!(range_values.next(), Some((10..=20, &"a")));
assert_eq!(range_values.next(), Some((21..=25, &"b")));
assert_eq!(range_values.next(), Some((30..=40, &"c")));
assert_eq!(range_values.next(), None);Values returned by the iterator are returned in ascending order with right-to-left precedence.
use range_set_blaze::RangeMapBlaze;
let map = RangeMapBlaze::from_iter([(10..=20, "a"), (15..=25, "b"), (30..=40, "c")]);
let mut range_values = map.range_values();
assert_eq!(range_values.next(), Some((10..=14, &"a")));
assert_eq!(range_values.next(), Some((15..=25, &"b")));
assert_eq!(range_values.next(), Some((30..=40, &"c")));
assert_eq!(range_values.next(), None);Sourcepub fn into_range_values(self) -> IntoRangeValuesIter<T, V> ⓘ
pub fn into_range_values(self) -> IntoRangeValuesIter<T, V> ⓘ
An iterator that visits the ranges and values in the RangeMapBlaze. Double-ended.
Also see RangeMapBlaze::iter and RangeMapBlaze::range_values.
§Examples
extern crate alloc;
use alloc::rc::Rc;
use range_set_blaze::RangeMapBlaze;
let map = RangeMapBlaze::from_iter([(30..=40, "c"), (15..=25, "b"), (10..=20, "a")]);
let mut range_values = map.into_range_values();
assert_eq!(range_values.next(), Some((10..=20, Rc::new("a"))));
assert_eq!(range_values.next(), Some((21..=25, Rc::new("b"))));
assert_eq!(range_values.next(), Some((30..=40, Rc::new("c"))));
assert_eq!(range_values.next(), None);Values returned by the iterator are returned in ascending order with right-to-left precedence.
use alloc::rc::Rc;
use range_set_blaze::RangeMapBlaze;
let map = RangeMapBlaze::from_iter([(10..=20, "a"), (15..=25, "b"), (30..=40, "c")]);
let mut range_values = map.into_range_values();
assert_eq!(range_values.next(), Some((10..=14, Rc::new("a"))));
assert_eq!(range_values.next(), Some((15..=25, Rc::new("b"))));
assert_eq!(range_values.next(), Some((30..=40, Rc::new("c"))));
assert_eq!(range_values.next(), None);Sourcepub fn ranges(&self) -> MapRangesIter<'_, T, V> ⓘ
pub fn ranges(&self) -> MapRangesIter<'_, T, V> ⓘ
An iterator that visits the ranges in the RangeMapBlaze,
i.e., the integers as sorted & disjoint ranges.
Also see RangeMapBlaze::iter and RangeMapBlaze::into_range_values.
§Examples
use range_set_blaze::RangeMapBlaze;
let map = RangeMapBlaze::from_iter([(10..=20, "a"), (15..=25, "b"), (30..=40, "c")]);
let mut ranges = map.ranges();
assert_eq!(ranges.next(), Some(10..=25));
assert_eq!(ranges.next(), Some(30..=40));
assert_eq!(ranges.next(), None);Values returned by the iterator are returned in ascending order with right-to-left precedence.
use range_set_blaze::RangeMapBlaze;
let map = RangeMapBlaze::from_iter([(30..=40, "c"), (15..=25, "b"), (10..=20, "a")]);
let mut ranges = map.ranges();
assert_eq!(ranges.next(), Some(10..=25));
assert_eq!(ranges.next(), Some(30..=40));
assert_eq!(ranges.next(), None);Sourcepub fn into_ranges(self) -> MapIntoRangesIter<T, V> ⓘ
pub fn into_ranges(self) -> MapIntoRangesIter<T, V> ⓘ
An iterator that visits the ranges in the RangeMapBlaze,
i.e., the integers as sorted & disjoint ranges.
Also see RangeMapBlaze::iter and RangeMapBlaze::into_range_values.
§Examples
use range_set_blaze::RangeMapBlaze;
let map = RangeMapBlaze::from_iter([(10..=20, "a"), (15..=25, "b"), (30..=40, "c")]);
let mut ranges = map.into_ranges();
assert_eq!(ranges.next(), Some(10..=25));
assert_eq!(ranges.next(), Some(30..=40));
assert_eq!(ranges.next(), None);Values returned by the iterator are returned in ascending order with right-to-left precedence.
use range_set_blaze::RangeMapBlaze;
let map = RangeMapBlaze::from_iter([(30..=40, "c"), (15..=25, "b"), (10..=20, "a")]);
let mut ranges = map.into_ranges();
assert_eq!(ranges.next(), Some(10..=25));
assert_eq!(ranges.next(), Some(30..=40));
assert_eq!(ranges.next(), None);Sourcepub fn ranges_len(&self) -> usize
pub fn ranges_len(&self) -> usize
Returns the number of sorted & disjoint ranges in the set.
§Example
use range_set_blaze::RangeMapBlaze;
// We put in three ranges, but they are not sorted & disjoint.
let map = RangeMapBlaze::from_iter([(10..=20,"a"), (15..=25,"a"), (30..=40,"b")]);
// After RangeMapBlaze sorts & 'disjoint's them, we see two ranges.
assert_eq!(map.ranges_len(), 2);
assert_eq!(map.to_string(), r#"(10..=25, "a"), (30..=40, "b")"#);Sourcepub fn complement_with(&self, value: &V) -> Self
pub fn complement_with(&self, value: &V) -> Self
use range_set_blaze::RangeMapBlaze;
let map = RangeMapBlaze::from_iter([(10u16..=20, "a"), (15..=25, "b"), (30..=40, "c")]);
let complement = map.complement_with(&"z");
assert_eq!(complement.to_string(), r#"(0..=9, "z"), (26..=29, "z"), (41..=65535, "z")"#);Sourcepub fn range_values_len(&self) -> usize
pub fn range_values_len(&self) -> usize
Returns the number of sorted & disjoint ranges i n the set.
§Example
use range_set_blaze::RangeMapBlaze;
// We put in four ranges, but they are not sorted & disjoint.
let map = RangeMapBlaze::from_iter([(28..=35, "c"), (30..=40, "c"), (15..=25, "b"), (10..=20, "a")]);
// After RangeMapBlaze sorts & 'disjoint's them, we see three ranges.
assert_eq!(map.range_values_len(), 3);
assert_eq!(map.to_string(), r#"(10..=20, "a"), (21..=25, "b"), (28..=40, "c")"#);Sourcepub fn retain<F>(&mut self, f: F)
pub fn retain<F>(&mut self, f: F)
Retains only the elements specified by the predicate.
In other words, remove all pairs (k, v) for which f(&k, &mut v) returns false.
The elements are visited in ascending key order.
Because if visits every element in every range, it is expensive compared to
RangeMapBlaze::ranges_retain.
§Examples
use range_set_blaze::RangeMapBlaze;
let mut map: RangeMapBlaze<i32, i32> = (0..8).map(|x| (x, x*10)).collect();
// Keep only the elements with even-numbered keys.
map.retain(|&k, _| k % 2 == 0);
assert!(map.into_iter().eq(vec![(0, 0), (2, 20), (4, 40), (6, 60)]));Sourcepub fn ranges_retain<F>(&mut self, f: F)
pub fn ranges_retain<F>(&mut self, f: F)
Retains only the (range, value) pairs specified by the predicate.
In other words, removes all (range, value) pairs for which f(&range, &value)
returns false. The (range, value) pairs are visited in ascending range order.
§Examples
use range_set_blaze::RangeMapBlaze;
let mut map: RangeMapBlaze<i32, &str> = RangeMapBlaze::from_iter([(0..=3, "low"), (4..=7, "high")]);
// Keep only the ranges with a specific value.
map.ranges_retain(|range, &value| value == "low");
assert_eq!(map, RangeMapBlaze::from_iter([(0..=3, "low")]));Trait Implementations§
Source§impl<T, V> BitAnd<&RangeMapBlaze<T, V>> for &RangeMapBlaze<T, V>
impl<T, V> BitAnd<&RangeMapBlaze<T, V>> for &RangeMapBlaze<T, V>
Source§type Output = RangeMapBlaze<T, V>
type Output = RangeMapBlaze<T, V>
& operator.Source§impl<T, V> BitAnd<&RangeMapBlaze<T, V>> for RangeMapBlaze<T, V>
impl<T, V> BitAnd<&RangeMapBlaze<T, V>> for RangeMapBlaze<T, V>
Source§type Output = RangeMapBlaze<T, V>
type Output = RangeMapBlaze<T, V>
& operator.Source§impl<T, V> BitAnd<&RangeSetBlaze<T>> for &RangeMapBlaze<T, V>
impl<T, V> BitAnd<&RangeSetBlaze<T>> for &RangeMapBlaze<T, V>
Source§type Output = RangeMapBlaze<T, V>
type Output = RangeMapBlaze<T, V>
& operator.Source§impl<T, V> BitAnd<&RangeSetBlaze<T>> for RangeMapBlaze<T, V>
impl<T, V> BitAnd<&RangeSetBlaze<T>> for RangeMapBlaze<T, V>
Source§type Output = RangeMapBlaze<T, V>
type Output = RangeMapBlaze<T, V>
& operator.Source§impl<T, V> BitAnd<RangeMapBlaze<T, V>> for &RangeMapBlaze<T, V>
impl<T, V> BitAnd<RangeMapBlaze<T, V>> for &RangeMapBlaze<T, V>
Source§type Output = RangeMapBlaze<T, V>
type Output = RangeMapBlaze<T, V>
& operator.Source§impl<T, V> BitAnd<RangeSetBlaze<T>> for &RangeMapBlaze<T, V>
impl<T, V> BitAnd<RangeSetBlaze<T>> for &RangeMapBlaze<T, V>
Source§type Output = RangeMapBlaze<T, V>
type Output = RangeMapBlaze<T, V>
& operator.Source§impl<T, V> BitAnd<RangeSetBlaze<T>> for RangeMapBlaze<T, V>
Find the intersection between a RangeMapBlaze and a RangeSetBlaze. The result is a new RangeMapBlaze.
impl<T, V> BitAnd<RangeSetBlaze<T>> for RangeMapBlaze<T, V>
Find the intersection between a RangeMapBlaze and a RangeSetBlaze. The result is a new RangeMapBlaze.
Either, neither, or both inputs may be borrowed.
§Examples
use range_set_blaze::prelude::*;
let a = RangeMapBlaze::from_iter([(1..=100, "a")]);
let b = RangeSetBlaze::from_iter([2..=6]);
let result = &a & &b; // Alternatively, 'a & b'.
assert_eq!(result.to_string(), r#"(2..=6, "a")"#);placeholder
Source§type Output = RangeMapBlaze<T, V>
type Output = RangeMapBlaze<T, V>
& operator.Source§impl<T, V> BitAnd for RangeMapBlaze<T, V>
Intersects the contents of two RangeMapBlaze’s.
impl<T, V> BitAnd for RangeMapBlaze<T, V>
Intersects the contents of two RangeMapBlaze’s.
Either, neither, or both inputs may be borrowed.
§Examples
use range_set_blaze::prelude::*;
let a = RangeMapBlaze::from_iter([(1..=2, "a"), (5..=100, "a")]);
let b = RangeMapBlaze::from_iter([(2..=6, "b")]);
let result = &a & &b; // Alternatively, 'a & b'.
assert_eq!(result.to_string(), r#"(2..=2, "b"), (5..=6, "b")"#);placeholder
Source§type Output = RangeMapBlaze<T, V>
type Output = RangeMapBlaze<T, V>
& operator.Source§impl<T: Integer, V: Eq + Clone> BitOr<&RangeMapBlaze<T, V>> for &RangeMapBlaze<T, V>
impl<T: Integer, V: Eq + Clone> BitOr<&RangeMapBlaze<T, V>> for &RangeMapBlaze<T, V>
Source§fn bitor(self, other: &RangeMapBlaze<T, V>) -> RangeMapBlaze<T, V>
fn bitor(self, other: &RangeMapBlaze<T, V>) -> RangeMapBlaze<T, V>
Unions the contents of two RangeMapBlaze’s.
This operator has right precedence: when overlapping ranges are present, values on the right-hand side take priority over those self.
This method is optimized for three usage scenarios: when the left-hand side is much smaller, when the right-hand side is much smaller, and when both sides are of similar size.
Also See: Summary of Union and Extend-like Methods.
§Examples
use range_set_blaze::RangeMapBlaze;
let a = RangeMapBlaze::from_iter([(1..=2, "a"), (5..=100, "a")]);
let b = RangeMapBlaze::from_iter([(2..=6, "b")]);
let union = &a | &b; // Alternatively, 'a | b', etc.
assert_eq!(union, RangeMapBlaze::from_iter([(1..=1, "a"), (2..=6, "b"), (7..=100, "a")]));Source§type Output = RangeMapBlaze<T, V>
type Output = RangeMapBlaze<T, V>
| operator.Source§impl<T: Integer, V: Eq + Clone> BitOr<&RangeMapBlaze<T, V>> for RangeMapBlaze<T, V>
impl<T: Integer, V: Eq + Clone> BitOr<&RangeMapBlaze<T, V>> for RangeMapBlaze<T, V>
Source§type Output = RangeMapBlaze<T, V>
type Output = RangeMapBlaze<T, V>
Unions the contents of two RangeMapBlaze’s.
This operator has right precedence: when overlapping ranges are present, values on the right-hand side take priority over those self.
This method is optimized for three usage scenarios: when the left-hand side is much smaller, when the right-hand side is much smaller, and when both sides are of similar size.
Also See: Summary of Union and Extend-like Methods.
§Examples
use range_set_blaze::RangeMapBlaze;
let a = RangeMapBlaze::from_iter([(1..=2, "a"), (5..=100, "a")]);
let b = RangeMapBlaze::from_iter([(2..=6, "b")]);
let union = a | &b; // Alternatively, 'a | b', etc.
assert_eq!(union, RangeMapBlaze::from_iter([(1..=1, "a"), (2..=6, "b"), (7..=100, "a")]));Source§impl<T: Integer, V: Eq + Clone> BitOr<RangeMapBlaze<T, V>> for &RangeMapBlaze<T, V>
impl<T: Integer, V: Eq + Clone> BitOr<RangeMapBlaze<T, V>> for &RangeMapBlaze<T, V>
Source§fn bitor(self, other: RangeMapBlaze<T, V>) -> RangeMapBlaze<T, V>
fn bitor(self, other: RangeMapBlaze<T, V>) -> RangeMapBlaze<T, V>
Unions the contents of two RangeMapBlaze’s.
This operator has right precedence: when overlapping ranges are present, values on the right-hand side take priority over those self.
This method is optimized for three usage scenarios: when the left-hand side is much smaller, when the right-hand side is much smaller, and when both sides are of similar size.
Also See: Summary of Union and Extend-like Methods.
§Examples
use range_set_blaze::RangeMapBlaze;
let a = RangeMapBlaze::from_iter([(1..=2, "a"), (5..=100, "a")]);
let b = RangeMapBlaze::from_iter([(2..=6, "b")]);
let union = &a | b; // Alternatively, 'a | b', etc.
assert_eq!(union, RangeMapBlaze::from_iter([(1..=1, "a"), (2..=6, "b"), (7..=100, "a")]));Source§type Output = RangeMapBlaze<T, V>
type Output = RangeMapBlaze<T, V>
| operator.Source§impl<T: Integer, V: Eq + Clone> BitOr for RangeMapBlaze<T, V>
impl<T: Integer, V: Eq + Clone> BitOr for RangeMapBlaze<T, V>
Source§type Output = RangeMapBlaze<T, V>
type Output = RangeMapBlaze<T, V>
Unions the contents of two RangeMapBlaze’s.
This operator has right precedence: when overlapping ranges are present, values on the right-hand side take priority over those self.
This method is optimized for three usage scenarios: when the left-hand side is much smaller, when the right-hand side is much smaller, and when both sides are of similar size.
Also See: Summary of Union and Extend-like Methods.
§Examples
use range_set_blaze::RangeMapBlaze;
let a = RangeMapBlaze::from_iter([(1..=2, "a"), (5..=100, "a")]);
let b = RangeMapBlaze::from_iter([(2..=6, "b")]);
let union = a | b; // Alternatively, '&a | &b', etc.
assert_eq!(union, RangeMapBlaze::from_iter([(1..=1, "a"), (2..=6, "b"), (7..=100, "a")]));Source§impl<T: Integer, V: Eq + Clone> BitOrAssign<&RangeMapBlaze<T, V>> for RangeMapBlaze<T, V>
impl<T: Integer, V: Eq + Clone> BitOrAssign<&RangeMapBlaze<T, V>> for RangeMapBlaze<T, V>
Source§fn bitor_assign(&mut self, other: &Self)
fn bitor_assign(&mut self, other: &Self)
Adds the contents of another RangeMapBlaze to this one.
This operator has right precedence: when overlapping ranges are present, values on the right-hand side take priority over those self.
To get left precedence, swap the operands.
This method is optimized for three usage scenarios: when the left-hand side is much smaller, when the right-hand side is much smaller, and when both sides are of similar size
Also See: Summary of Union and Extend-like Methods.
§Examples
use range_set_blaze::RangeMapBlaze;
let mut a = RangeMapBlaze::from_iter([(3, "a"), (4, "e"), (5, "f"), (5, "g")]);
let mut b = RangeMapBlaze::from_iter([(1..=4, "b")]);
a |= &b;
assert_eq!(a, RangeMapBlaze::from_iter([(1..=4, "b"), (5..=5, "g")]));Source§impl<T: Integer, V: Eq + Clone> BitOrAssign for RangeMapBlaze<T, V>
impl<T: Integer, V: Eq + Clone> BitOrAssign for RangeMapBlaze<T, V>
Source§fn bitor_assign(&mut self, other: Self)
fn bitor_assign(&mut self, other: Self)
Adds the contents of another RangeMapBlaze to this one.
This operator has right precedence: when overlapping ranges are present, values on the right-hand side take priority over those self. To get left precedence, swap the operands.
This method is optimized for three usage scenarios: when the left-hand side is much smaller, when the right-hand side is much smaller, and when both sides are of similar size
Also See: Summary of Union and Extend-like Methods.
§Examples
use range_set_blaze::RangeMapBlaze;
let mut a = RangeMapBlaze::from_iter([(3, "a"), (4, "e"), (5, "f"), (5, "g")]);
let mut b = RangeMapBlaze::from_iter([(1..=4, "b")]);
a |= &b;
assert_eq!(a, RangeMapBlaze::from_iter([(1..=4, "b"), (5..=5, "g")]));Source§impl<T, V> BitXor<&RangeMapBlaze<T, V>> for &RangeMapBlaze<T, V>
impl<T, V> BitXor<&RangeMapBlaze<T, V>> for &RangeMapBlaze<T, V>
Source§type Output = RangeMapBlaze<T, V>
type Output = RangeMapBlaze<T, V>
^ operator.Source§impl<T, V> BitXor<&RangeMapBlaze<T, V>> for RangeMapBlaze<T, V>
impl<T, V> BitXor<&RangeMapBlaze<T, V>> for RangeMapBlaze<T, V>
Source§type Output = RangeMapBlaze<T, V>
type Output = RangeMapBlaze<T, V>
^ operator.Source§impl<T, V> BitXor<RangeMapBlaze<T, V>> for &RangeMapBlaze<T, V>
impl<T, V> BitXor<RangeMapBlaze<T, V>> for &RangeMapBlaze<T, V>
Source§type Output = RangeMapBlaze<T, V>
type Output = RangeMapBlaze<T, V>
^ operator.Source§impl<T, V> BitXor for RangeMapBlaze<T, V>
Symmetric difference the contents of two RangeMapBlaze’s.
impl<T, V> BitXor for RangeMapBlaze<T, V>
Symmetric difference the contents of two RangeMapBlaze’s.
Either, neither, or both inputs may be borrowed.
§Examples
use range_set_blaze::prelude::*;
let a = RangeMapBlaze::from_iter([(1..=2, "a"), (5..=100, "a")]);
let b = RangeMapBlaze::from_iter([(2..=6, "b")]);
let result = &a ^ &b; // Alternatively, 'a ^ b'.
assert_eq!(result.to_string(), r#"(1..=1, "a"), (3..=4, "b"), (7..=100, "a")"#);placeholder
Source§type Output = RangeMapBlaze<T, V>
type Output = RangeMapBlaze<T, V>
^ operator.Source§impl<T: Clone + Integer, V: Clone + Eq + Clone> Clone for RangeMapBlaze<T, V>
impl<T: Clone + Integer, V: Clone + Eq + Clone> Clone for RangeMapBlaze<T, V>
Source§fn clone(&self) -> RangeMapBlaze<T, V>
fn clone(&self) -> RangeMapBlaze<T, V>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<T: Integer, V: Eq + Clone> Default for RangeMapBlaze<T, V>
Creates a new, empty RangeMapBlaze.
impl<T: Integer, V: Eq + Clone> Default for RangeMapBlaze<T, V>
Creates a new, empty RangeMapBlaze.
§Examples
use range_set_blaze::RangeMapBlaze;
let a = RangeMapBlaze::<i32, &str>::default();
assert!(a.is_empty());Source§impl<T, V> Extend<(RangeInclusive<T>, V)> for RangeMapBlaze<T, V>
impl<T, V> Extend<(RangeInclusive<T>, V)> for RangeMapBlaze<T, V>
Source§fn extend<I>(&mut self, iter: I)where
I: IntoIterator<Item = (RangeInclusive<T>, V)>,
fn extend<I>(&mut self, iter: I)where
I: IntoIterator<Item = (RangeInclusive<T>, V)>,
Extends the RangeMapBlaze with the contents of an iterator of range-value pairs.
This method has right-to-left precedence — like BTreeMap and all other
RangeMapBlaze methods.
It first merges any adjacent or overlapping ranges with the same value, then adds them one by one.
For alternatives that skip merging or that accept integer-value pairs, see
RangeMapBlaze::extend_simple and the (integer, value) overload.
See: Summary of Union and Extend-like Methods.
§Examples
use range_set_blaze::RangeMapBlaze;
let mut a = RangeMapBlaze::from_iter([(1..=4, "a")]);
a.extend([(3..=5, "b"), (5..=5, "c")]);
assert_eq!(a, RangeMapBlaze::from_iter([(1..=2, "a"), (3..=4, "b"), (5..=5, "c")]));
// `extend_simple` is a more efficient for the case where the ranges a likely disjoint.
let mut a = RangeMapBlaze::from_iter([(1..=4, "a")]);
a.extend_simple([(3..=5, "b"), (5..=5, "c")]);
assert_eq!(a, RangeMapBlaze::from_iter([(1..=2, "a"), (3..=4, "b"), (5..=5, "c")]));
let mut a = RangeMapBlaze::from_iter([(1..=4, "a")]);
let mut b = RangeMapBlaze::from_iter([(3..=5, "b"), (5..=5, "c")]);
a |= b;
assert_eq!(a, RangeMapBlaze::from_iter([(1..=2, "a"), (3..=4, "b"), (5..=5, "c")]));Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)Source§impl<T, V> Extend<(T, V)> for RangeMapBlaze<T, V>
impl<T, V> Extend<(T, V)> for RangeMapBlaze<T, V>
Source§fn extend<I>(&mut self, iter: I)where
I: IntoIterator<Item = (T, V)>,
fn extend<I>(&mut self, iter: I)where
I: IntoIterator<Item = (T, V)>,
Extends the RangeMapBlaze with the contents of an iterator of integer-value pairs.
This method has right-to-left precedence: later values in the iterator take priority
over earlier ones, matching the behavior of standard BTreeMap::extend.
Each integer is treated as a singleton range. Adjacent integers with the same value
are merged before insertion. For alternatives that skip merging or accept full ranges,
see RangeMapBlaze::extend_simple and RangeMapBlaze::extend.
See: Summary of Union and Extend-like Methods.
§Examples
use range_set_blaze::RangeMapBlaze;
let mut a = RangeMapBlaze::from_iter([(3, "a"), (4, "e"), (5, "f"), (5, "g")]);
a.extend([(1..=4, "b")]);
assert_eq!(a, RangeMapBlaze::from_iter([(1..=4, "b"), (5..=5, "g")]));
let mut a = RangeMapBlaze::from_iter([(3, "a"), (4, "e"), (5, "f"), (5, "g")]);
let mut b = RangeMapBlaze::from_iter([(1..=4, "b")]);
a |= b;
assert_eq!(a, RangeMapBlaze::from_iter([(1..=4, "b"), (5..=5, "g")]));Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)Source§impl<T, V, const N: usize> From<[(T, V); N]> for RangeMapBlaze<T, V>
impl<T, V, const N: usize> From<[(T, V); N]> for RangeMapBlaze<T, V>
Source§fn from(arr: [(T, V); N]) -> Self
fn from(arr: [(T, V); N]) -> Self
For compatibility with BTreeMap you may create a RangeSetBlaze from an array of integers.
For more about constructors and performance, see RangeSetBlaze Constructors.
§Examples
use range_set_blaze::RangeSetBlaze;
let a0 = RangeSetBlaze::from([3, 2, 1, 100, 1]);
let a1: RangeSetBlaze<i32> = [3, 2, 1, 100, 1].into();
assert!(a0 == a1 && a0.to_string() == "1..=3, 100..=100")Source§impl<'a, T, V> FromIterator<&'a (RangeInclusive<T>, &'a V)> for RangeMapBlaze<T, V>
impl<'a, T, V> FromIterator<&'a (RangeInclusive<T>, &'a V)> for RangeMapBlaze<T, V>
Source§fn from_iter<I>(iter: I) -> Self
fn from_iter<I>(iter: I) -> Self
Create a RangeMapBlaze from an iterator of inclusive ranges, start..=end.
Overlapping, out-of-order, and empty ranges are fine.
In case of overlapping ranges, the last (right-most) value overrides the previous ones.
/// For more about constructors and performance, see RangeMapBlaze Constructors.
§Examples
use range_set_blaze::prelude::*;
let v = vec![(1..=0, &"d"), (-10..=-5, &"c"), (2..=2, &"b"), (1..=2, &"a")];
let a0: RangeMapBlaze<i32, &str> = RangeMapBlaze::from_iter(&v);
let a1: RangeMapBlaze<i32, &str> = (&v).into_iter().collect();
assert!(a0 == a1 && a0.to_string() == r#"(-10..=-5, "c"), (1..=2, "a")"#);Source§impl<'a, T: Integer, V: Eq + Clone> FromIterator<&'a (RangeInclusive<T>, V)> for RangeMapBlaze<T, V>
impl<'a, T: Integer, V: Eq + Clone> FromIterator<&'a (RangeInclusive<T>, V)> for RangeMapBlaze<T, V>
Source§fn from_iter<I>(iter: I) -> Selfwhere
I: IntoIterator<Item = &'a (RangeInclusive<T>, V)>,
fn from_iter<I>(iter: I) -> Selfwhere
I: IntoIterator<Item = &'a (RangeInclusive<T>, V)>,
Create a RangeMapBlaze from an iterator of inclusive ranges, start..=end.
Overlapping, out-of-order, and empty ranges are fine.
In case of overlapping ranges, the last (right-most) value overrides the previous ones.
/// For more about constructors and performance, see RangeMapBlaze Constructors.
§Examples
use range_set_blaze::prelude::*;
#[allow(clippy::reversed_empty_ranges)]
let vec_range = vec![(1..=0, "d"), (-10..=-5, "c"), (2..=2, "b"), (1..=2, "a") ];
let a0 = RangeMapBlaze::from_iter(&vec_range);
let a1: RangeMapBlaze<i32, &str> = vec_range.iter().collect();
assert!(a0 == a1 && a0.to_string() == r#"(-10..=-5, "c"), (1..=2, "a")"#);Source§impl<'a, T, V> FromIterator<&'a (T, &'a V)> for RangeMapBlaze<T, V>
impl<'a, T, V> FromIterator<&'a (T, &'a V)> for RangeMapBlaze<T, V>
Source§fn from_iter<I>(iter: I) -> Selfwhere
I: IntoIterator<Item = &'a (T, &'a V)>,
fn from_iter<I>(iter: I) -> Selfwhere
I: IntoIterator<Item = &'a (T, &'a V)>,
Create a RangeMapBlaze from an iterator of integers. Duplicates and out-of-order elements are fine.
In case of overlapping keys, the last (right-most) value overrides the previous ones.
For more about constructors and performance, see RangeMapBlaze Constructors.
§Examples
use range_set_blaze::RangeMapBlaze;
let v = vec![(1, &"c"), (100, &"b"), (1, &"a"), (2, &"a"), (3, &"a")];
let a0 = RangeMapBlaze::from_iter(&v);
let a1: RangeMapBlaze<i32, &str> = (&v).into_iter().collect();
assert!(a0 == a1 && a0.to_string() == r#"(1..=3, "a"), (100..=100, "b")"#);Source§impl<'a, T: Integer, V: Eq + Clone> FromIterator<&'a (T, V)> for RangeMapBlaze<T, V>
impl<'a, T: Integer, V: Eq + Clone> FromIterator<&'a (T, V)> for RangeMapBlaze<T, V>
Source§fn from_iter<I>(iter: I) -> Selfwhere
I: IntoIterator<Item = &'a (T, V)>,
fn from_iter<I>(iter: I) -> Selfwhere
I: IntoIterator<Item = &'a (T, V)>,
Create a RangeMapBlaze from an iterator of inclusive ranges, start..=end.
Overlapping, out-of-order, and empty ranges are fine.
In case of overlapping keys, the last (right-most) value overrides the previous ones.
For more about constructors and performance, see RangeMapBlaze Constructors.
§Examples
use range_set_blaze::prelude::*;
let v = vec![(2, "b"), (2, "a"), (1, "a")];
let a0 = RangeMapBlaze::from_iter(&v);
let a1: RangeMapBlaze<i32, &str> = v.iter().collect();
assert!(a0 == a1 && a0.to_string() == r#"(1..=2, "a")"#);Source§impl<'a, T, V> FromIterator<(RangeInclusive<T>, &'a V)> for RangeMapBlaze<T, V>
impl<'a, T, V> FromIterator<(RangeInclusive<T>, &'a V)> for RangeMapBlaze<T, V>
Source§fn from_iter<I>(iter: I) -> Self
fn from_iter<I>(iter: I) -> Self
Create a RangeMapBlaze from an iterator of inclusive ranges, start..=end.
Overlapping, out-of-order, and empty ranges are fine.
In case of overlapping keys, the last (right-most) value overrides the previous ones.
For more about constructors and performance, see RangeMapBlaze Constructors.
§Examples
use range_set_blaze::prelude::*;
#[allow(clippy::reversed_empty_ranges)]
let a0 = RangeMapBlaze::from_iter([(1..=0, &"d"), (-10..=-5, &"c"), (2..=2, &"b"), (1..=2, &"a")]);
#[allow(clippy::reversed_empty_ranges)]
let a1: RangeMapBlaze<i32, &str> = [(1..=0, &"d"), (-10..=-5, &"c"), (2..=2, &"b"), (1..=2, &"a")].into_iter().collect();
assert!(a0 == a1 && a0.to_string() == r#"(-10..=-5, "c"), (1..=2, "a")"#);Source§impl<T: Integer, V: Eq + Clone> FromIterator<(RangeInclusive<T>, V)> for RangeMapBlaze<T, V>
impl<T: Integer, V: Eq + Clone> FromIterator<(RangeInclusive<T>, V)> for RangeMapBlaze<T, V>
Source§fn from_iter<I>(iter: I) -> Selfwhere
I: IntoIterator<Item = (RangeInclusive<T>, V)>,
fn from_iter<I>(iter: I) -> Selfwhere
I: IntoIterator<Item = (RangeInclusive<T>, V)>,
Create a RangeMapBlaze from an iterator of inclusive ranges, start..=end.
Overlapping, out-of-order, and empty ranges are fine.
In case of overlapping ranges, the last (right-most) value overrides the previous ones.
For more about constructors and performance, see RangeMapBlaze Constructors.
§Examples
use range_set_blaze::RangeMapBlaze;
#[allow(clippy::reversed_empty_ranges)]
let a0 = RangeMapBlaze::from_iter([(2..=2, "b"), (1..=2, "a"), (-10..=-5, "c"), (1..=0, "d")]);
#[allow(clippy::reversed_empty_ranges)]
let a1: RangeMapBlaze<i32, &str> = [(2..=2, "b"), (1..=2, "a"), (-10..=-5, "c"), (1..=0, "d")].into_iter().collect();
assert!(a0 == a1 && a0.to_string() == r#"(-10..=-5, "c"), (1..=2, "a")"#);Source§impl<'a, T, V> FromIterator<(T, &'a V)> for RangeMapBlaze<T, V>
impl<'a, T, V> FromIterator<(T, &'a V)> for RangeMapBlaze<T, V>
Source§fn from_iter<I>(iter: I) -> Selfwhere
I: IntoIterator<Item = (T, &'a V)>,
fn from_iter<I>(iter: I) -> Selfwhere
I: IntoIterator<Item = (T, &'a V)>,
Create a RangeMapBlaze from an iterator of integers. Duplicates and out-of-order elements are fine.
In case of overlapping keys, the last (right-most) value overrides the previous ones.
For more about constructors and performance, see RangeMapBlaze Constructors.
§Examples
use range_set_blaze::RangeMapBlaze;
let a0 = RangeMapBlaze::from_iter([(1, &"c"), (3, &"a"), (2, &"a"), (1, &"a"), (100, &"b")]);
let a1: RangeMapBlaze<i32, &str> = [ (1, &"c"), (3, &"a"), (2, &"a"), (1, &"a"), (100, &"b")].into_iter().collect();
assert!(a0 == a1 && a0.to_string() == r#"(1..=3, "a"), (100..=100, "b")"#);Source§impl<T: Integer, V: Eq + Clone> FromIterator<(T, V)> for RangeMapBlaze<T, V>
impl<T: Integer, V: Eq + Clone> FromIterator<(T, V)> for RangeMapBlaze<T, V>
Source§fn from_iter<I>(iter: I) -> Selfwhere
I: IntoIterator<Item = (T, V)>,
fn from_iter<I>(iter: I) -> Selfwhere
I: IntoIterator<Item = (T, V)>,
Create a RangeMapBlaze from an iterator of pairs (integer, value).
Overlapping, out-of-order, and empty ranges are fine.
In case of overlapping keys, the last (right-most) value overrides the previous ones.
For more about constructors and performance, see RangeMapBlaze Constructors.
§Examples
use range_set_blaze::prelude::*;
#[allow(clippy::reversed_empty_ranges)]
let a0 = RangeMapBlaze::from_iter([(1, "c"), (3, "a"), (2, "a"), (1, "a"), (100, "b")]);
let a1: RangeMapBlaze<i32, &str> = [(1, "c"), (3, "a"), (2, "a"), (1, "a"), (100, "b")].into_iter().collect();
assert!(a0 == a1 && a0.to_string() == r#"(1..=3, "a"), (100..=100, "b")"#);Source§impl<'a, T: Integer, V: Eq + Clone> IntoIterator for &'a RangeMapBlaze<T, V>
impl<'a, T: Integer, V: Eq + Clone> IntoIterator for &'a RangeMapBlaze<T, V>
Source§impl<T, V> IntoIterator for RangeMapBlaze<T, V>
impl<T, V> IntoIterator for RangeMapBlaze<T, V>
Source§fn into_iter(self) -> IntoIterMap<T, V> ⓘ
fn into_iter(self) -> IntoIterMap<T, V> ⓘ
Gets an iterator for moving out the RangeSetBlaze’s integer contents.
Double-ended.
§Examples
use range_set_blaze::RangeSetBlaze;
let set = RangeSetBlaze::from_iter([1, 2, 3, 4]);
let v: Vec<_> = set.into_iter().collect();
assert_eq!(v, [1, 2, 3, 4]);
let set = RangeSetBlaze::from_iter([1, 2, 3, 4]);
let v: Vec<_> = set.into_iter().rev().collect();
assert_eq!(v, [4, 3, 2, 1]);Source§type IntoIter = IntoIterMap<T, V>
type IntoIter = IntoIterMap<T, V>
Source§impl<T, V> Not for &RangeMapBlaze<T, V>
Takes the complement of a RangeMapBlaze.
impl<T, V> Not for &RangeMapBlaze<T, V>
Takes the complement of a RangeMapBlaze.
Produces a RangeSetBlaze containing all integers not present
in the map’s key ranges.
§Example
use range_set_blaze::prelude::*;
let map =
RangeMapBlaze::from_iter([(10u8..=20, "a"), (15..=25, "b"),
(30..=40, "c")]);
let complement = !↦ // or `!map`
assert_eq!(complement.to_string(), "0..=9, 26..=29, 41..=255");placeholder
Source§impl<T, V> Not for RangeMapBlaze<T, V>
impl<T, V> Not for RangeMapBlaze<T, V>
Source§impl<T, V> Ord for RangeMapBlaze<T, V>
impl<T, V> Ord for RangeMapBlaze<T, V>
Source§fn cmp(&self, other: &Self) -> Ordering
fn cmp(&self, other: &Self) -> Ordering
We define an ordering on RangeMapBlaze. Following the convention of
BTreeMap, the ordering is lexicographic, not by subset/superset.
§Examples
use range_set_blaze::prelude::*;
let a = RangeMapBlaze::from_iter([(1..=3, "a"), (5..=100, "a")]);
let b = RangeMapBlaze::from_iter([(2..=2, "b")] );
assert!(a < b); // Lexicographic comparison
// More lexicographic comparisons
assert!(a <= b);
assert!(b > a);
assert!(b >= a);
assert!(a != b);
assert!(a == a);
use core::cmp::Ordering;
assert_eq!(a.cmp(&b), Ordering::Less);
// Floats aren't comparable, but we can convert them to comparable bits.
let a = RangeMapBlaze::from_iter([(2..=3, 1.0f32.to_bits()), (5..=100, 2.0f32.to_bits())]);
let b = RangeMapBlaze::from_iter([(2..=2, f32::NAN.to_bits())] );
assert_eq!(a.partial_cmp(&b), Some(Ordering::Less));1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl<T, V> PartialOrd for RangeMapBlaze<T, V>
impl<T, V> PartialOrd for RangeMapBlaze<T, V>
Source§fn partial_cmp(&self, other: &Self) -> Option<Ordering>
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
We define a partial ordering on RangeMapBlaze. Following the convention of
BTreeMap, the ordering is lexicographic, not by subset/superset.
§Examples
use range_set_blaze::prelude::*;
let a = RangeMapBlaze::from_iter([(1..=3, "a"), (5..=100, "a")]);
let b = RangeMapBlaze::from_iter([(2..=2, "b")] );
assert!(a < b); // Lexicographic comparison
// More lexicographic comparisons
assert!(a <= b);
assert!(b > a);
assert!(b >= a);
assert!(a != b);
assert!(a == a);
use core::cmp::Ordering;
assert_eq!(a.cmp(&b), Ordering::Less);
// Floats aren't comparable, but we can convert them to comparable bits.
let a = RangeMapBlaze::from_iter([(2..=3, 1.0f32.to_bits()), (5..=100, 2.0f32.to_bits())]);
let b = RangeMapBlaze::from_iter([(2..=2, f32::NAN.to_bits())] );
assert_eq!(a.partial_cmp(&b), Some(Ordering::Less));Source§impl<T, V> Sub<&RangeMapBlaze<T, V>> for &RangeMapBlaze<T, V>
impl<T, V> Sub<&RangeMapBlaze<T, V>> for &RangeMapBlaze<T, V>
Source§type Output = RangeMapBlaze<T, V>
type Output = RangeMapBlaze<T, V>
- operator.Source§impl<T, V> Sub<&RangeMapBlaze<T, V>> for RangeMapBlaze<T, V>
impl<T, V> Sub<&RangeMapBlaze<T, V>> for RangeMapBlaze<T, V>
Source§type Output = RangeMapBlaze<T, V>
type Output = RangeMapBlaze<T, V>
- operator.Source§impl<T, V> Sub<&RangeSetBlaze<T>> for &RangeMapBlaze<T, V>
impl<T, V> Sub<&RangeSetBlaze<T>> for &RangeMapBlaze<T, V>
Source§type Output = RangeMapBlaze<T, V>
type Output = RangeMapBlaze<T, V>
- operator.Source§impl<T, V> Sub<&RangeSetBlaze<T>> for RangeMapBlaze<T, V>
impl<T, V> Sub<&RangeSetBlaze<T>> for RangeMapBlaze<T, V>
Source§type Output = RangeMapBlaze<T, V>
type Output = RangeMapBlaze<T, V>
- operator.Source§impl<T, V> Sub<RangeMapBlaze<T, V>> for &RangeMapBlaze<T, V>
impl<T, V> Sub<RangeMapBlaze<T, V>> for &RangeMapBlaze<T, V>
Source§type Output = RangeMapBlaze<T, V>
type Output = RangeMapBlaze<T, V>
- operator.Source§impl<T, V> Sub<RangeSetBlaze<T>> for &RangeMapBlaze<T, V>
impl<T, V> Sub<RangeSetBlaze<T>> for &RangeMapBlaze<T, V>
Source§type Output = RangeMapBlaze<T, V>
type Output = RangeMapBlaze<T, V>
- operator.Source§impl<T, V> Sub<RangeSetBlaze<T>> for RangeMapBlaze<T, V>
Find the difference between a RangeMapBlaze and a RangeSetBlaze. The result is a new RangeMapBlaze.
impl<T, V> Sub<RangeSetBlaze<T>> for RangeMapBlaze<T, V>
Find the difference between a RangeMapBlaze and a RangeSetBlaze. The result is a new RangeMapBlaze.
Either, neither, or both inputs may be borrowed.
§Examples
use range_set_blaze::prelude::*;
let a = RangeMapBlaze::from_iter([(1..=100, "a")]);
let b = RangeSetBlaze::from_iter([2..=6]);
let result = &a - &b; // Alternatively, 'a - b'.
assert_eq!(result.to_string(), r#"(1..=1, "a"), (7..=100, "a")"#);placeholder
Source§type Output = RangeMapBlaze<T, V>
type Output = RangeMapBlaze<T, V>
- operator.Source§impl<T, V> Sub for RangeMapBlaze<T, V>
Difference of two RangeMapBlaze values (a - b).
impl<T, V> Sub for RangeMapBlaze<T, V>
Difference of two RangeMapBlaze values (a - b).
Either, neither, or both inputs may be borrowed.
§Example
use range_set_blaze::prelude::*;
let a = RangeMapBlaze::from_iter([(1..=2, "a"), (5..=100, "a")]);
let b = RangeMapBlaze::from_iter([(2..=6, "b")]);
let result = &a - &b; // or `a - b`
assert_eq!(result.to_string(),
r#"(1..=1, "a"), (7..=100, "a")"#);placeholder
Source§type Output = RangeMapBlaze<T, V>
type Output = RangeMapBlaze<T, V>
- operator.impl<T: Integer, V: Eq + Clone> Eq for RangeMapBlaze<T, V>
impl<T: Integer, V: Eq + Clone> StructuralPartialEq for RangeMapBlaze<T, V>
Auto Trait Implementations§
impl<T, V> Freeze for RangeMapBlaze<T, V>
impl<T, V> RefUnwindSafe for RangeMapBlaze<T, V>
impl<T, V> Send for RangeMapBlaze<T, V>
impl<T, V> Sync for RangeMapBlaze<T, V>
impl<T, V> Unpin for RangeMapBlaze<T, V>
impl<T, V> UnwindSafe for RangeMapBlaze<T, V>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more