pub struct ContiguousIntegerSet<E: Integer + Copy> { /* private fields */ }
Expand description

Represents the set of integers in [start, end]. Ord is automatically derived so that comparison is done lexicographically with start first and end second.

Implementations§

source§

impl<E: Integer + Copy> ContiguousIntegerSet<E>

source

pub fn new(start: E, end: E) -> Self

Creates an integer set [start, end], where the end is inclusive.

source

pub fn get_start_and_end(&self) -> (E, E)

source

pub fn is_subset_of(&self, other: &ContiguousIntegerSet<E>) -> bool

source

pub fn is_strict_subset_of(&self, other: &ContiguousIntegerSet<E>) -> bool

source

pub fn slice<'a, I: Slicing<&'a ContiguousIntegerSet<E>, Option<ContiguousIntegerSet<E>>>>( &'a self, slicer: I ) -> Option<ContiguousIntegerSet<E>>

Trait Implementations§

source§

impl<E: Clone + Integer + Copy> Clone for ContiguousIntegerSet<E>

source§

fn clone(&self) -> ContiguousIntegerSet<E>

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<E: Integer + Copy> Coalesce<ContiguousIntegerSet<E>> for ContiguousIntegerSet<E>

returns an interval if only if the two intervals can be merged into a single non-empty interval. An empty interval can be merged with any other non-empty interval

source§

fn coalesce_with(&self, other: &Self) -> Option<Self>

source§

impl<E: Integer + Copy> Coalesce<E> for ContiguousIntegerSet<E>

source§

fn coalesce_with(&self, other: &E) -> Option<Self>

source§

impl<E> CoalesceIntervals<ContiguousIntegerSet<E>, E> for OrderedIntegerSet<E>
where E: Integer + Copy + ToPrimitive,

source§

impl<'a, V, B> CommonRefinementZip<B, (&'a ContiguousIntegerSet<B>, &'a V), ContiguousIntegerSet<B>, V> for Iter<'a, IntInterval<B>, V>
where B: 'a + Integer + Copy + ToPrimitive, V: 'a + Clone,

Example

use math::{
    interval::{traits::Interval, IntInterval},
    iter::CommonRefinementZip,
};
use std::collections::BTreeMap;

let m1: BTreeMap<IntInterval<usize>, i32> =
    vec![(IntInterval::new(0, 5), 5), (IntInterval::new(8, 10), 2)]
        .into_iter()
        .collect();

let m2: BTreeMap<IntInterval<usize>, i32> =
    vec![(IntInterval::new(2, 4), 8), (IntInterval::new(12, 13), 9)]
        .into_iter()
        .collect();

let mut iter = m1.iter().common_refinement_zip(m2.iter());
assert_eq!(
    Some((IntInterval::new(0, 1), vec![Some(5), None])),
    iter.next()
);
assert_eq!(
    Some((IntInterval::new(2, 4), vec![Some(5), Some(8)])),
    iter.next()
);
assert_eq!(
    Some((IntInterval::new(5, 5), vec![Some(5), None])),
    iter.next()
);
assert_eq!(
    Some((IntInterval::new(8, 10), vec![Some(2), None])),
    iter.next()
);
assert_eq!(
    Some((IntInterval::new(12, 13), vec![None, Some(9)])),
    iter.next()
);
assert_eq!(None, iter.next());
source§

fn get_interval_value_extractor( &self ) -> Box<dyn Fn(<Self as Iterator>::Item) -> (IntInterval<B>, V)>

source§

fn common_refinement_zip( self, other: Self ) -> CommonRefinementZipped<B, Self, X, P, V>

source§

fn into_common_refinement_zipped( self ) -> CommonRefinementZipped<B, Self, X, P, V>

source§

impl<'a, V, B> CommonRefinementZip<B, (ContiguousIntegerSet<B>, V), ContiguousIntegerSet<B>, V> for IntoIter<IntInterval<B>, V>
where B: 'a + Integer + Copy + ToPrimitive,

source§

fn get_interval_value_extractor( &self ) -> Box<dyn Fn(<Self as Iterator>::Item) -> (IntInterval<B>, V)>

source§

fn common_refinement_zip( self, other: Self ) -> CommonRefinementZipped<B, Self, X, P, V>

source§

fn into_common_refinement_zipped( self ) -> CommonRefinementZipped<B, Self, X, P, V>

source§

impl<I, V> CommonRefinementZip<i64, (ContiguousIntegerSet<i64>, V), ContiguousIntegerSet<i64>, V> for BinnedIntervalIter<I, V>

source§

fn get_interval_value_extractor( &self ) -> Box<dyn Fn(<Self as Iterator>::Item) -> (I64Interval, V)>

source§

fn common_refinement_zip( self, other: Self ) -> CommonRefinementZipped<B, Self, X, P, V>

source§

fn into_common_refinement_zipped( self ) -> CommonRefinementZipped<B, Self, X, P, V>

source§

impl<E: Debug + Integer + Copy> Debug for ContiguousIntegerSet<E>

source§

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

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

impl<E: Integer + Copy + ToPrimitive> Finite for ContiguousIntegerSet<E>

source§

fn size(&self) -> usize

source§

impl<E: Integer + Copy> From<ContiguousIntegerSet<E>> for ContiguousIntegerSetIter<E>

source§

fn from( contiguous_integer_set: ContiguousIntegerSet<E> ) -> ContiguousIntegerSetIter<E>

Converts to this type from the input type.
source§

impl<E: Hash + Integer + Copy> Hash for ContiguousIntegerSet<E>

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<E: Integer + Copy> Intersect<&ContiguousIntegerSet<E>, Option<ContiguousIntegerSet<E>>> for ContiguousIntegerSet<E>

source§

impl<E> Intersect<&ContiguousIntegerSet<E>, OrderedIntegerSet<E>> for OrderedIntegerSet<E>
where E: Integer + Copy + ToPrimitive,

source§

impl<E: Integer + Copy + ToPrimitive> Intersect<&OrderedIntegerSet<E>, OrderedIntegerSet<E>> for ContiguousIntegerSet<E>

source§

impl<E: Integer + Copy> Interval<E> for ContiguousIntegerSet<E>

source§

fn from_boundaries(start: E, end_inclusive: E) -> Self

source§

fn get_start(&self) -> E

source§

fn get_end(&self) -> E

source§

fn length(&self) -> E

source§

fn get_start_if_nonempty(&self) -> Option<T>

source§

fn get_end_if_nonempty(&self) -> Option<T>

source§

impl<E: Ord + Integer + Copy> Ord for ContiguousIntegerSet<E>

source§

fn cmp(&self, other: &ContiguousIntegerSet<E>) -> 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<E: PartialEq + Integer + Copy> PartialEq for ContiguousIntegerSet<E>

source§

fn eq(&self, other: &ContiguousIntegerSet<E>) -> 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<E: PartialOrd + Integer + Copy> PartialOrd for ContiguousIntegerSet<E>

source§

fn partial_cmp(&self, other: &ContiguousIntegerSet<E>) -> 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<E> Refineable<Vec<ContiguousIntegerSet<E>>> for ContiguousIntegerSet<E>
where E: Integer + Copy + ToPrimitive,

source§

impl<E> Sample<'_, ContiguousIntegerSetIter<E>, E, OrderedIntegerSet<E>> for ContiguousIntegerSet<E>
where E: Integer + Copy + ToPrimitive,

source§

fn sample_subset_without_replacement<'s: 'a>( &'s self, size: usize ) -> Result<O, String>

samples size elements without replacement size: the number of samples to be drawn returns Err if size is larger than the population size
source§

fn sample_with_replacement<'s: 'a>(&'s self, size: usize) -> Result<O, String>

source§

impl<E: Integer + Copy> Set<E> for ContiguousIntegerSet<E>

source§

fn is_empty(&self) -> bool

source§

fn contains(&self, item: &E) -> bool

source§

impl<E> Slicing<&ContiguousIntegerSet<E>, Option<ContiguousIntegerSet<E>>> for Range<usize>

source§

impl<E: Integer + Copy + ToPrimitive> Sub<&ContiguousIntegerSet<E>> for ContiguousIntegerSet<E>

§

type Output = OrderedIntegerSet<E>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: &ContiguousIntegerSet<E>) -> Self::Output

Performs the - operation. Read more
source§

impl<E: Integer + Copy + ToPrimitive> Sub<&ContiguousIntegerSet<E>> for OrderedIntegerSet<E>

§

type Output = OrderedIntegerSet<E>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: &ContiguousIntegerSet<E>) -> Self::Output

Performs the - operation. Read more
source§

impl<E: Integer + Copy + ToPrimitive> Sub<&OrderedIntegerSet<E>> for ContiguousIntegerSet<E>

§

type Output = OrderedIntegerSet<E>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: &OrderedIntegerSet<E>) -> Self::Output

Performs the - operation. Read more
source§

impl<E: Integer + Copy + ToPrimitive> Sub<ContiguousIntegerSet<E>> for OrderedIntegerSet<E>

§

type Output = OrderedIntegerSet<E>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: ContiguousIntegerSet<E>) -> Self::Output

Performs the - operation. Read more
source§

impl<E: Integer + Copy + ToPrimitive> Sub<OrderedIntegerSet<E>> for ContiguousIntegerSet<E>

§

type Output = OrderedIntegerSet<E>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: OrderedIntegerSet<E>) -> Self::Output

Performs the - operation. Read more
source§

impl<E: Integer + Copy + ToPrimitive> Sub for ContiguousIntegerSet<E>

§

type Output = OrderedIntegerSet<E>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: ContiguousIntegerSet<E>) -> Self::Output

Performs the - operation. Read more
source§

impl<E: Integer + Copy + ToPrimitive> SubAssign<&ContiguousIntegerSet<E>> for OrderedIntegerSet<E>

source§

fn sub_assign(&mut self, rhs: &ContiguousIntegerSet<E>)

Performs the -= operation. Read more
source§

impl<E: Integer + Copy + ToPrimitive> SubAssign<ContiguousIntegerSet<E>> for OrderedIntegerSet<E>

source§

fn sub_assign(&mut self, rhs: ContiguousIntegerSet<E>)

Performs the -= operation. Read more
source§

impl<E: Integer + Copy + Hash> SubsetIndexable<ContiguousIntegerSet<E>, ContiguousIntegerSet<E>> for OrderedIntervalPartitions<E>

source§

impl<T> SubsetIndexable<ContiguousIntegerSet<i64>, ContiguousIntegerSet<i64>> for IntegerIntervalMap<T>

source§

impl<E: Integer + Copy> ToIterator<'_, ContiguousIntegerSetIter<E>, E> for ContiguousIntegerSet<E>

source§

impl<E: Copy + Integer + Copy> Copy for ContiguousIntegerSet<E>

source§

impl<E: Eq + Integer + Copy> Eq for ContiguousIntegerSet<E>

source§

impl<E: Integer + Copy> StructuralEq for ContiguousIntegerSet<E>

source§

impl<E: Integer + Copy> StructuralPartialEq for ContiguousIntegerSet<E>

Auto Trait Implementations§

§

impl<E> RefUnwindSafe for ContiguousIntegerSet<E>
where E: RefUnwindSafe,

§

impl<E> Send for ContiguousIntegerSet<E>
where E: Send,

§

impl<E> Sync for ContiguousIntegerSet<E>
where E: Sync,

§

impl<E> Unpin for ContiguousIntegerSet<E>
where E: Unpin,

§

impl<E> UnwindSafe for ContiguousIntegerSet<E>
where E: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

source§

fn into(self) -> U

Calls U::from(self).

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

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

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

Initializes a with the given initializer. Read more
§

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

Dereferences the given pointer. Read more
§

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

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

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

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

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

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

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

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

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

§

type Error = Infallible

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

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

Performs the conversion.
source§

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

§

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

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

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

Performs the conversion.
§

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

§

fn vzip(self) -> V