RangeMapBlaze

Struct RangeMapBlaze 

Source
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

§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.

MethodsInputNotes
new/default
from_iter/collectiterator of (integer, value)References to the pair or value is OK.
from_iter/collectiterator of (range, value)References to the pair or value is OK.
from_sorted_disjoint_map/
into_range_set_blaze
SortedDisjointMap iterator
from /intoarray 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 BTreeMap from 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 OperationOperatorMultiway Method
uniona | b[a, b, c].union()
intersectiona & b[a, b, c].intersection()
intersectiona & sn/a
differencea - bn/a
differencea - sn/a
symmetric differencea ^ b[a, b, c].symmetric_difference()
complement (to set)!an/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

  1. a single pass over the sorted & disjoint ranges
  2. 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 & SyntaxInput TypePre-merge TouchingCases Optimized
a |= bRangeMapBlaze-3
a |= &b&RangeMapBlaze-3
a | bRangeMapBlaze-3
a | &b&RangeMapBlaze-3
&a | bRangeMapBlaze-3
&a | &b&RangeMapBlaze-3
a.extend([(r, v)])iter (range, value)Yes1
a.extend([(i, v)])iter (integer, value)Yes1
a.extend_simple(...)iter (range, value)No1
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 inputs
    • 1 = optimized for small-right inputs only

§RangeMapBlaze Comparisons

RangeMapBlaze supports comparisons for equality and lexicographic order:

  • Equality: Use == and != to check if two RangeMapBlaze instances are equal. Two RangeMapBlaze instances are considered equal if they contain the same ranges and associated values.
  • Ordering: If the values implement Ord, you can use <, <=, >, and >= to compare two RangeMapBlaze instances. These comparisons are lexicographic, similar to BTreeMap, meaning they compare the ranges and their values in sequence.
  • Partial Ordering: If the values implement PartialOrd but not Ord, you can use the partial_cmp method to compare two RangeMapBlaze instances. This method returns an Option<Ordering> that indicates the relative order of the instances or None if 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>

Source

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);
Source

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);
Source

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.

Source

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);
Source

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.

Source

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")));
Source

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);
Source

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);
Source

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")));
Source

pub fn from_sorted_disjoint_map<VR, I>(iter: I) -> Self
where 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")"#);
Source

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");
Source

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());
Source

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());
Source

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());
Source

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);
Source

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, true is returned.
  • If the set already contained an equal value, false is 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");
Source

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());
Source

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, true is returned.
  • If the set already contained every value in the range, false is 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);
Source

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);
Source

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")]));
Source

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)
);
Source

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");
Source

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")]));
Source

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")]));
Source

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")]));
Source

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());
Source

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());
Source

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);
Source

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);
Source

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);
Source

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);
Source

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")"#);
Source

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")"#);
Source

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")"#);
Source

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

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)]));
Source

pub fn ranges_retain<F>(&mut self, f: F)
where F: FnMut(&RangeInclusive<T>, &V) -> bool,

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>
where T: Integer, V: Eq + Clone,

Source§

type Output = RangeMapBlaze<T, V>

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: &RangeMapBlaze<T, V>) -> Self::Output

Performs the & operation. Read more
Source§

impl<T, V> BitAnd<&RangeMapBlaze<T, V>> for RangeMapBlaze<T, V>
where T: Integer, V: Eq + Clone,

Source§

type Output = RangeMapBlaze<T, V>

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: &RangeMapBlaze<T, V>) -> Self::Output

Performs the & operation. Read more
Source§

impl<T, V> BitAnd<&RangeSetBlaze<T>> for &RangeMapBlaze<T, V>
where T: Integer, V: Eq + Clone,

Source§

type Output = RangeMapBlaze<T, V>

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: &RangeSetBlaze<T>) -> Self::Output

Performs the & operation. Read more
Source§

impl<T, V> BitAnd<&RangeSetBlaze<T>> for RangeMapBlaze<T, V>
where T: Integer, V: Eq + Clone,

Source§

type Output = RangeMapBlaze<T, V>

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: &RangeSetBlaze<T>) -> Self::Output

Performs the & operation. Read more
Source§

impl<T, V> BitAnd<RangeMapBlaze<T, V>> for &RangeMapBlaze<T, V>
where T: Integer, V: Eq + Clone,

Source§

type Output = RangeMapBlaze<T, V>

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: RangeMapBlaze<T, V>) -> Self::Output

Performs the & operation. Read more
Source§

impl<T, V> BitAnd<RangeSetBlaze<T>> for &RangeMapBlaze<T, V>
where T: Integer, V: Eq + Clone,

Source§

type Output = RangeMapBlaze<T, V>

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: RangeSetBlaze<T>) -> Self::Output

Performs the & operation. Read more
Source§

impl<T, V> BitAnd<RangeSetBlaze<T>> for RangeMapBlaze<T, V>
where T: Integer, V: Eq + Clone,

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>

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: RangeSetBlaze<T>) -> Self::Output

Performs the & operation. Read more
Source§

impl<T, V> BitAnd for RangeMapBlaze<T, V>
where T: Integer, V: Eq + Clone,

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>

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: RangeMapBlaze<T, V>) -> Self::Output

Performs the & operation. Read more
Source§

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>

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>

The resulting type after applying the | operator.
Source§

impl<T: Integer, V: Eq + Clone> BitOr<&RangeMapBlaze<T, V>> for RangeMapBlaze<T, V>

Source§

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§

fn bitor(self, other: &Self) -> Self

Performs the | operation. Read more
Source§

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>

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>

The resulting type after applying the | operator.
Source§

impl<T: Integer, V: Eq + Clone> BitOr for RangeMapBlaze<T, V>

Source§

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§

fn bitor(self, other: Self) -> Self

Performs the | operation. Read more
Source§

impl<T: Integer, V: Eq + Clone> BitOrAssign<&RangeMapBlaze<T, V>> for RangeMapBlaze<T, V>

Source§

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>

Source§

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>
where T: Integer, V: Eq + Clone,

Source§

type Output = RangeMapBlaze<T, V>

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: &RangeMapBlaze<T, V>) -> Self::Output

Performs the ^ operation. Read more
Source§

impl<T, V> BitXor<&RangeMapBlaze<T, V>> for RangeMapBlaze<T, V>
where T: Integer, V: Eq + Clone,

Source§

type Output = RangeMapBlaze<T, V>

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: &RangeMapBlaze<T, V>) -> Self::Output

Performs the ^ operation. Read more
Source§

impl<T, V> BitXor<RangeMapBlaze<T, V>> for &RangeMapBlaze<T, V>
where T: Integer, V: Eq + Clone,

Source§

type Output = RangeMapBlaze<T, V>

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: RangeMapBlaze<T, V>) -> Self::Output

Performs the ^ operation. Read more
Source§

impl<T, V> BitXor for RangeMapBlaze<T, V>
where T: Integer, V: Eq + Clone,

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>

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: RangeMapBlaze<T, V>) -> Self::Output

Performs the ^ operation. Read more
Source§

impl<T: Clone + Integer, V: Clone + Eq + Clone> Clone for RangeMapBlaze<T, V>

Source§

fn clone(&self) -> RangeMapBlaze<T, V>

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<T: Integer, V: Eq + Clone + Debug> Debug for RangeMapBlaze<T, V>

Source§

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

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

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§

fn default() -> Self

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

impl<T: Integer, V: Eq + Clone + Debug> Display for RangeMapBlaze<T, V>

Source§

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

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

impl<T, V> Extend<(RangeInclusive<T>, V)> for RangeMapBlaze<T, V>
where T: Integer, V: Eq + Clone,

Source§

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)

🔬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<T, V> Extend<(T, V)> for RangeMapBlaze<T, V>
where T: Integer, V: Eq + Clone,

Source§

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)

🔬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<T, V, const N: usize> From<[(T, V); N]> for RangeMapBlaze<T, V>
where T: Integer, V: Eq + Clone,

Source§

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>
where T: Integer, V: Eq + Clone,

Source§

fn from_iter<I>(iter: I) -> Self
where I: IntoIterator<Item = &'a (RangeInclusive<T>, &'a 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::*;

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>

Source§

fn from_iter<I>(iter: I) -> Self
where 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>
where T: Integer, V: Eq + Clone + 'a,

Source§

fn from_iter<I>(iter: I) -> Self
where 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>

Source§

fn from_iter<I>(iter: I) -> Self
where 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>
where T: Integer, V: Eq + Clone,

Source§

fn from_iter<I>(iter: I) -> Self
where I: IntoIterator<Item = (RangeInclusive<T>, &'a 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::*;

#[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>

Source§

fn from_iter<I>(iter: I) -> Self
where 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>
where T: Integer, V: Eq + Clone + 'a,

Source§

fn from_iter<I>(iter: I) -> Self
where 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>

Source§

fn from_iter<I>(iter: I) -> Self
where 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<T: Hash + Integer, V: Hash + Eq + Clone> Hash for RangeMapBlaze<T, V>

Source§

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

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<T: Integer, V: Eq + Clone> Index<T> for RangeMapBlaze<T, V>

Source§

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

Returns a reference to the value corresponding to the supplied key.

§Panics

Panics if the key is not present in the BTreeMap.

Source§

type Output = V

The returned type after indexing.
Source§

impl<'a, T: Integer, V: Eq + Clone> IntoIterator for &'a RangeMapBlaze<T, V>

Source§

type IntoIter = IterMap<T, &'a V, RangeValuesIter<'a, T, V>>

Which kind of iterator are we turning this into?
Source§

type Item = (T, &'a V)

The type of the elements being iterated over.
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<T, V> IntoIterator for RangeMapBlaze<T, V>
where T: Integer, V: Eq + Clone,

Source§

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 Item = (T, V)

The type of the elements being iterated over.
Source§

type IntoIter = IntoIterMap<T, V>

Which kind of iterator are we turning this into?
Source§

impl<T, V> Not for &RangeMapBlaze<T, V>
where T: Integer, V: Eq + Clone,

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 = !&map;                // or `!map`
assert_eq!(complement.to_string(), "0..=9, 26..=29, 41..=255");

placeholder

Source§

type Output = RangeSetBlaze<T>

The resulting type after applying the ! operator.
Source§

fn not(self) -> Self::Output

Performs the unary ! operation. Read more
Source§

impl<T, V> Not for RangeMapBlaze<T, V>
where T: Integer, V: Eq + Clone,

Source§

type Output = RangeSetBlaze<T>

The resulting type after applying the ! operator.
Source§

fn not(self) -> Self::Output

Performs the unary ! operation. Read more
Source§

impl<T, V> Ord for RangeMapBlaze<T, V>
where T: Integer, V: Eq + Clone + Ord,

Source§

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) -> Self
where Self: Sized,

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

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

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

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

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

impl<T: PartialEq + Integer, V: PartialEq + Eq + Clone> PartialEq for RangeMapBlaze<T, V>

Source§

fn eq(&self, other: &RangeMapBlaze<T, V>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T, V> PartialOrd for RangeMapBlaze<T, V>
where T: Integer, V: Eq + Clone + Ord,

Source§

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));
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<T, V> Sub<&RangeMapBlaze<T, V>> for &RangeMapBlaze<T, V>
where T: Integer, V: Eq + Clone,

Source§

type Output = RangeMapBlaze<T, V>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &RangeMapBlaze<T, V>) -> Self::Output

Performs the - operation. Read more
Source§

impl<T, V> Sub<&RangeMapBlaze<T, V>> for RangeMapBlaze<T, V>
where T: Integer, V: Eq + Clone,

Source§

type Output = RangeMapBlaze<T, V>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &RangeMapBlaze<T, V>) -> Self::Output

Performs the - operation. Read more
Source§

impl<T, V> Sub<&RangeSetBlaze<T>> for &RangeMapBlaze<T, V>
where T: Integer, V: Eq + Clone,

Source§

type Output = RangeMapBlaze<T, V>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &RangeSetBlaze<T>) -> Self::Output

Performs the - operation. Read more
Source§

impl<T, V> Sub<&RangeSetBlaze<T>> for RangeMapBlaze<T, V>
where T: Integer, V: Eq + Clone,

Source§

type Output = RangeMapBlaze<T, V>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &RangeSetBlaze<T>) -> Self::Output

Performs the - operation. Read more
Source§

impl<T, V> Sub<RangeMapBlaze<T, V>> for &RangeMapBlaze<T, V>
where T: Integer, V: Eq + Clone,

Source§

type Output = RangeMapBlaze<T, V>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: RangeMapBlaze<T, V>) -> Self::Output

Performs the - operation. Read more
Source§

impl<T, V> Sub<RangeSetBlaze<T>> for &RangeMapBlaze<T, V>
where T: Integer, V: Eq + Clone,

Source§

type Output = RangeMapBlaze<T, V>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: RangeSetBlaze<T>) -> Self::Output

Performs the - operation. Read more
Source§

impl<T, V> Sub<RangeSetBlaze<T>> for RangeMapBlaze<T, V>
where T: Integer, V: Eq + Clone,

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>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: RangeSetBlaze<T>) -> Self::Output

Performs the - operation. Read more
Source§

impl<T, V> Sub for RangeMapBlaze<T, V>
where T: Integer, V: Eq + Clone,

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>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: RangeMapBlaze<T, V>) -> Self::Output

Performs the - operation. Read more
Source§

impl<T: Integer, V: Eq + Clone> Eq for RangeMapBlaze<T, V>

Source§

impl<T: Integer, V: Eq + Clone> StructuralPartialEq for RangeMapBlaze<T, V>

Auto Trait Implementations§

§

impl<T, V> Freeze for RangeMapBlaze<T, V>
where <T as Integer>::SafeLen: Freeze,

§

impl<T, V> RefUnwindSafe for RangeMapBlaze<T, V>

§

impl<T, V> Send for RangeMapBlaze<T, V>
where <T as Integer>::SafeLen: Send, V: Send,

§

impl<T, V> Sync for RangeMapBlaze<T, V>
where <T as Integer>::SafeLen: Sync, V: Sync,

§

impl<T, V> Unpin for RangeMapBlaze<T, V>
where <T as Integer>::SafeLen: Unpin,

§

impl<T, V> UnwindSafe for RangeMapBlaze<T, V>

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V