pub struct ValueSubkeyRangeSet { /* private fields */ }

Implementations§

Methods from Deref<Target = RangeSetBlaze<ValueSubkey>>§

source

pub fn iter(&self) -> Iter<T, RangesIter<'_, T>>

Gets an (double-ended) iterator that visits the integer elements in the RangeSetBlaze in ascending and/or descending order.

Also see the RangeSetBlaze::ranges method.

§Examples
use range_set_blaze::RangeSetBlaze;

let set = RangeSetBlaze::from_iter([1..=3]);
let mut set_iter = set.iter();
assert_eq!(set_iter.next(), Some(1));
assert_eq!(set_iter.next(), Some(2));
assert_eq!(set_iter.next(), Some(3));
assert_eq!(set_iter.next(), None);

Values returned by .next() are in ascending order. Values returned by .next_back() are in descending order.

use range_set_blaze::RangeSetBlaze;

let set = RangeSetBlaze::from_iter([3, 1, 2]);
let mut set_iter = set.iter();
assert_eq!(set_iter.next(), Some(1));
assert_eq!(set_iter.next_back(), Some(3));
assert_eq!(set_iter.next(), Some(2));
assert_eq!(set_iter.next_back(), None);
source

pub fn first(&self) -> Option<T>

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::RangeSetBlaze;

let mut set = RangeSetBlaze::new();
assert_eq!(set.first(), None);
set.insert(1);
assert_eq!(set.first(), Some(1));
set.insert(2);
assert_eq!(set.first(), Some(1));
source

pub fn get(&self, value: T) -> Option<T>

Returns the element in the set, if any, that is equal to the value.

§Examples
use range_set_blaze::RangeSetBlaze;

let set = RangeSetBlaze::from_iter([1, 2, 3]);
assert_eq!(set.get(2), Some(2));
assert_eq!(set.get(4), None);
source

pub fn last(&self) -> Option<T>

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::RangeSetBlaze;

let mut set = RangeSetBlaze::new();
assert_eq!(set.last(), None);
set.insert(1);
assert_eq!(set.last(), Some(1));
set.insert(2);
assert_eq!(set.last(), Some(2));
source

pub fn append(&mut self, other: &mut RangeSetBlaze<T>)

Moves all elements from other into self, leaving other empty.

§Performance

It adds the integers in other to self in O(n log m) time, where n is the number of ranges in other 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::RangeSetBlaze;

let mut a = RangeSetBlaze::from_iter([1..=3]);
let mut b = RangeSetBlaze::from_iter([3..=5]);

a.append(&mut b);

assert_eq!(a.len(), 5usize);
assert_eq!(b.len(), 0usize);

assert!(a.contains(1));
assert!(a.contains(2));
assert!(a.contains(3));
assert!(a.contains(4));
assert!(a.contains(5));
source

pub fn clear(&mut self)

Clears the set, removing all integer elements.

§Examples
use range_set_blaze::RangeSetBlaze;

let mut v = RangeSetBlaze::new();
v.insert(1);
v.clear();
assert!(v.is_empty());
source

pub fn is_empty(&self) -> bool

Returns true if the set contains no elements.

§Examples
use range_set_blaze::RangeSetBlaze;

let mut v = RangeSetBlaze::new();
assert!(v.is_empty());
v.insert(1);
assert!(!v.is_empty());
source

pub fn is_subset(&self, other: &RangeSetBlaze<T>) -> bool

Returns true if the set is a subset of another, i.e., other contains at least all the elements in self.

§Examples
use range_set_blaze::RangeSetBlaze;

let sup = RangeSetBlaze::from_iter([1..=3]);
let mut set = RangeSetBlaze::new();

assert_eq!(set.is_subset(&sup), true);
set.insert(2);
assert_eq!(set.is_subset(&sup), true);
set.insert(4);
assert_eq!(set.is_subset(&sup), false);
source

pub fn is_superset(&self, other: &RangeSetBlaze<T>) -> bool

Returns true if the set is a superset of another, i.e., self contains at least all the elements in other.

§Examples
use range_set_blaze::RangeSetBlaze;

let sub = RangeSetBlaze::from_iter([1, 2]);
let mut set = RangeSetBlaze::new();

assert_eq!(set.is_superset(&sub), false);

set.insert(0);
set.insert(1);
assert_eq!(set.is_superset(&sub), false);

set.insert(2);
assert_eq!(set.is_superset(&sub), true);
source

pub fn contains(&self, value: T) -> bool

Returns true if the set contains an element equal to the value.

§Examples
use range_set_blaze::RangeSetBlaze;

let set = RangeSetBlaze::from_iter([1, 2, 3]);
assert_eq!(set.contains(1), true);
assert_eq!(set.contains(4), false);
source

pub fn is_disjoint(&self, other: &RangeSetBlaze<T>) -> bool

Returns true if self has no elements in common with other. This is equivalent to checking for an empty intersection.

§Examples
use range_set_blaze::RangeSetBlaze;

let a = RangeSetBlaze::from_iter([1..=3]);
let mut b = RangeSetBlaze::new();

assert_eq!(a.is_disjoint(&b), true);
b.insert(4);
assert_eq!(a.is_disjoint(&b), true);
b.insert(1);
assert_eq!(a.is_disjoint(&b), false);
source

pub fn insert(&mut self, value: T) -> bool

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::RangeSetBlaze;

let mut set = RangeSetBlaze::new();

assert_eq!(set.insert(2), true);
assert_eq!(set.insert(2), false);
assert_eq!(set.len(), 1usize);
source

pub fn range<R>(&self, range: R) -> IntoIter<T>
where R: RangeBounds<T>,

Constructs an iterator over a sub-range of elements in the set.

Not to be confused with RangeSetBlaze::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>, Bound<T>), so for example range((Excluded(4), Included(10))) will yield a left-exclusive, right-inclusive range from 4 to 10.

§Panics

Panics if range start > end. Panics if range start == end and both bounds are Excluded.

§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::RangeSetBlaze;
use core::ops::Bound::Included;

let mut set = RangeSetBlaze::new();
set.insert(3);
set.insert(5);
set.insert(8);
for elem in set.range((Included(4), Included(8))) {
    println!("{elem}");
}
assert_eq!(Some(5), set.range(4..).next());
source

pub fn ranges_insert(&mut self, range: RangeInclusive<T>) -> 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::RangeSetBlaze;

let mut set = RangeSetBlaze::new();

assert_eq!(set.ranges_insert(2..=5), true);
assert_eq!(set.ranges_insert(5..=6), true);
assert_eq!(set.ranges_insert(3..=4), false);
assert_eq!(set.len(), 5usize);
source

pub fn remove(&mut self, value: T) -> bool

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::RangeSetBlaze;

let mut set = RangeSetBlaze::new();

set.insert(2);
assert!(set.remove(2));
assert!(!set.remove(2));
source

pub fn split_off(&mut self, value: T) -> RangeSetBlaze<T>

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::RangeSetBlaze;

let mut a = RangeSetBlaze::new();
a.insert(1);
a.insert(2);
a.insert(3);
a.insert(17);
a.insert(41);

let b = a.split_off(3);

assert_eq!(a, RangeSetBlaze::from_iter([1, 2]));
assert_eq!(b, RangeSetBlaze::from_iter([3, 17, 41]));
source

pub fn take(&mut self, value: T) -> Option<T>

Removes and returns the element in the set, if any, that is equal to the value.

§Examples
use range_set_blaze::RangeSetBlaze;

let mut set = RangeSetBlaze::from_iter([1, 2, 3]);
assert_eq!(set.take(2), Some(2));
assert_eq!(set.take(2), None);
source

pub fn replace(&mut self, value: T) -> Option<T>

Adds a value to the set, replacing the existing element, if any, that is equal to the value. Returns the replaced element.

Note: This is very similar to insert. It is included for consistency with BTreeSet.

§Examples
use range_set_blaze::RangeSetBlaze;

let mut set = RangeSetBlaze::new();
assert!(set.replace(5).is_none());
assert!(set.replace(5).is_some());
source

pub 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::RangeSetBlaze;

let mut v = RangeSetBlaze::new();
assert_eq!(v.len(), 0usize);
v.insert(1);
assert_eq!(v.len(), 1usize);

let v = RangeSetBlaze::from_iter([
    -170_141_183_460_469_231_731_687_303_715_884_105_728i128..=10,
    -10..=170_141_183_460_469_231_731_687_303_715_884_105_726,
]);
assert_eq!(
    v.len(),
    340_282_366_920_938_463_463_374_607_431_768_211_455u128
);
source

pub fn pop_first(&mut self) -> Option<T>

Removes the first element from the set and returns it, if any. The first element is always the minimum element in the set.

§Examples
use range_set_blaze::RangeSetBlaze;

let mut set = RangeSetBlaze::new();

set.insert(1);
while let Some(n) = set.pop_first() {
    assert_eq!(n, 1);
}
assert!(set.is_empty());
source

pub fn pop_last(&mut self) -> Option<T>

Removes the last value from the set and returns it, if any. The last value is always the maximum value in the set.

§Examples
use range_set_blaze::RangeSetBlaze;

let mut set = RangeSetBlaze::new();

set.insert(1);
while let Some(n) = set.pop_last() {
    assert_eq!(n, 1);
}
assert!(set.is_empty());
source

pub fn ranges(&self) -> RangesIter<'_, T>

An iterator that visits the ranges in the RangeSetBlaze, i.e., the integers as sorted & disjoint ranges.

Also see RangeSetBlaze::iter and RangeSetBlaze::into_ranges.

§Examples
use range_set_blaze::RangeSetBlaze;

let set = RangeSetBlaze::from_iter([10..=20, 15..=25, 30..=40]);
let mut ranges = set.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:

use range_set_blaze::RangeSetBlaze;

let set = RangeSetBlaze::from_iter([30..=40, 15..=25, 10..=20]);
let mut ranges = set.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::RangeSetBlaze;

// We put in three ranges, but they are not sorted & disjoint.
let set = RangeSetBlaze::from_iter([10..=20, 15..=25, 30..=40]);
// After RangeSetBlaze sorts & 'disjoint's them, we see two ranges.
assert_eq!(set.ranges_len(), 2);
assert_eq!(set.to_string(), "10..=25, 30..=40");
source

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

Retains only the elements specified by the predicate.

In other words, remove all integers e for which f(&e) returns false. The integer elements are visited in ascending order.

§Examples
use range_set_blaze::RangeSetBlaze;

let mut set = RangeSetBlaze::from_iter([1..=6]);
// Keep only the even numbers.
set.retain(|k| k % 2 == 0);
assert_eq!(set, RangeSetBlaze::from_iter([2, 4, 6]));

Trait Implementations§

source§

impl Clone for ValueSubkeyRangeSet

source§

fn clone(&self) -> ValueSubkeyRangeSet

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for ValueSubkeyRangeSet

source§

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

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

impl Default for ValueSubkeyRangeSet

source§

fn default() -> ValueSubkeyRangeSet

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

impl DerefMut for ValueSubkeyRangeSet

source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
source§

impl<'de> Deserialize<'de> for ValueSubkeyRangeSet

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

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

impl Display for ValueSubkeyRangeSet

source§

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

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

impl FromStr for ValueSubkeyRangeSet

§

type Err = VeilidAPIError

The associated error which can be returned from parsing.
source§

fn from_str(value: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
source§

impl Hash for ValueSubkeyRangeSet

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 JsonSchema for ValueSubkeyRangeSet

source§

fn is_referenceable() -> bool

Whether JSON Schemas generated for this type should be re-used where possible using the $ref keyword. Read more
source§

fn schema_name() -> String

The name of the generated JSON Schema. Read more
source§

fn schema_id() -> Cow<'static, str>

Returns a string that uniquely identifies the schema produced by this type. Read more
source§

fn json_schema(gen: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
source§

impl Ord for ValueSubkeyRangeSet

source§

fn cmp(&self, other: &ValueSubkeyRangeSet) -> Ordering

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

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

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

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

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

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

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

impl PartialEq for ValueSubkeyRangeSet

source§

fn eq(&self, other: &ValueSubkeyRangeSet) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd for ValueSubkeyRangeSet

source§

fn partial_cmp(&self, other: &ValueSubkeyRangeSet) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

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

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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

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

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

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

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

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

impl Serialize for ValueSubkeyRangeSet

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

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

impl Deref for ValueSubkeyRangeSet

§

type Target = RangeSetBlaze<u32>

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl Eq for ValueSubkeyRangeSet

source§

impl StructuralPartialEq for ValueSubkeyRangeSet

Auto Trait Implementations§

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> CmpAssign for T
where T: Ord,

source§

fn min_assign(&mut self, other: T)

source§

fn max_assign(&mut self, other: T)

source§

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

source§

fn __clone_box(&self, _: Private) -> *mut ()

source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

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

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

fn in_current_span(self) -> Instrumented<Self>

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

impl<T, U> Into<U> for 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> NoneValue for T
where T: Default,

§

type NoneType = T

source§

fn null_value() -> T

The none-equivalent value.
source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

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

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

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

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

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

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

source§

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

§

type Error = Infallible

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

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

Performs the conversion.
source§

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

§

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

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

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

Performs the conversion.
source§

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

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

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

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

fn with_current_subscriber(self) -> WithDispatch<Self>

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

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,