Struct math::set::contiguous_integer_set::ContiguousIntegerSet
source · 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>
impl<E: Integer + Copy> ContiguousIntegerSet<E>
sourcepub fn new(start: E, end: E) -> Self
pub fn new(start: E, end: E) -> Self
Creates an integer set [start, end]
, where the end
is inclusive.
pub fn get_start_and_end(&self) -> (E, E)
pub fn is_subset_of(&self, other: &ContiguousIntegerSet<E>) -> bool
pub fn is_strict_subset_of(&self, other: &ContiguousIntegerSet<E>) -> bool
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>
impl<E: Clone + Integer + Copy> Clone for ContiguousIntegerSet<E>
source§fn clone(&self) -> ContiguousIntegerSet<E>
fn clone(&self) -> ContiguousIntegerSet<E>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl<E: Integer + Copy> Coalesce<ContiguousIntegerSet<E>> for ContiguousIntegerSet<E>
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
fn coalesce_with(&self, other: &Self) -> Option<Self>
source§impl<E: Integer + Copy> Coalesce<E> for ContiguousIntegerSet<E>
impl<E: Integer + Copy> Coalesce<E> for ContiguousIntegerSet<E>
fn coalesce_with(&self, other: &E) -> Option<Self>
source§impl<E> CoalesceIntervals<ContiguousIntegerSet<E>, E> for OrderedIntegerSet<E>
impl<E> CoalesceIntervals<ContiguousIntegerSet<E>, E> for OrderedIntegerSet<E>
fn to_coalesced_intervals(&self) -> Vec<ContiguousIntegerSet<E>>
fn coalesce_intervals_inplace(&mut self)
fn into_coalesced(self) -> Self
source§impl<'a, V, B> CommonRefinementZip<B, (&'a ContiguousIntegerSet<B>, &'a V), ContiguousIntegerSet<B>, V> for Iter<'a, IntInterval<B>, V>
impl<'a, V, B> CommonRefinementZip<B, (&'a ContiguousIntegerSet<B>, &'a V), ContiguousIntegerSet<B>, V> for Iter<'a, IntInterval<B>, V>
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());
fn get_interval_value_extractor( &self ) -> Box<dyn Fn(<Self as Iterator>::Item) -> (IntInterval<B>, V)>
fn common_refinement_zip( self, other: Self ) -> CommonRefinementZipped<B, Self, X, P, V> ⓘ
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>
impl<'a, V, B> CommonRefinementZip<B, (ContiguousIntegerSet<B>, V), ContiguousIntegerSet<B>, V> for IntoIter<IntInterval<B>, V>
fn get_interval_value_extractor( &self ) -> Box<dyn Fn(<Self as Iterator>::Item) -> (IntInterval<B>, V)>
fn common_refinement_zip( self, other: Self ) -> CommonRefinementZipped<B, Self, X, P, V> ⓘ
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>
impl<I, V> CommonRefinementZip<i64, (ContiguousIntegerSet<i64>, V), ContiguousIntegerSet<i64>, V> for BinnedIntervalIter<I, V>
fn get_interval_value_extractor( &self ) -> Box<dyn Fn(<Self as Iterator>::Item) -> (I64Interval, V)>
fn common_refinement_zip( self, other: Self ) -> CommonRefinementZipped<B, Self, X, P, V> ⓘ
fn into_common_refinement_zipped( self ) -> CommonRefinementZipped<B, Self, X, P, V> ⓘ
source§impl<E: Integer + Copy + ToPrimitive> Finite for ContiguousIntegerSet<E>
impl<E: Integer + Copy + ToPrimitive> Finite for ContiguousIntegerSet<E>
source§impl<E: Integer + Copy> From<ContiguousIntegerSet<E>> for ContiguousIntegerSetIter<E>
impl<E: Integer + Copy> From<ContiguousIntegerSet<E>> for ContiguousIntegerSetIter<E>
source§fn from(
contiguous_integer_set: ContiguousIntegerSet<E>
) -> ContiguousIntegerSetIter<E> ⓘ
fn from( contiguous_integer_set: ContiguousIntegerSet<E> ) -> ContiguousIntegerSetIter<E> ⓘ
Converts to this type from the input type.
source§impl<E: Integer + Copy> Intersect<&ContiguousIntegerSet<E>, Option<ContiguousIntegerSet<E>>> for ContiguousIntegerSet<E>
impl<E: Integer + Copy> Intersect<&ContiguousIntegerSet<E>, Option<ContiguousIntegerSet<E>>> for ContiguousIntegerSet<E>
fn intersect( &self, other: &ContiguousIntegerSet<E> ) -> Option<ContiguousIntegerSet<E>>
fn has_non_empty_intersection_with( &self, other: &ContiguousIntegerSet<E> ) -> bool
source§impl<E> Intersect<&ContiguousIntegerSet<E>, OrderedIntegerSet<E>> for OrderedIntegerSet<E>
impl<E> Intersect<&ContiguousIntegerSet<E>, OrderedIntegerSet<E>> for OrderedIntegerSet<E>
fn intersect(&self, other: &ContiguousIntegerSet<E>) -> OrderedIntegerSet<E>
fn has_non_empty_intersection_with( &self, other: &ContiguousIntegerSet<E> ) -> bool
source§impl<E: Integer + Copy + ToPrimitive> Intersect<&OrderedIntegerSet<E>, OrderedIntegerSet<E>> for ContiguousIntegerSet<E>
impl<E: Integer + Copy + ToPrimitive> Intersect<&OrderedIntegerSet<E>, OrderedIntegerSet<E>> for ContiguousIntegerSet<E>
fn intersect(&self, other: &OrderedIntegerSet<E>) -> OrderedIntegerSet<E>
fn has_non_empty_intersection_with(&self, other: &OrderedIntegerSet<E>) -> bool
source§impl<E: Ord + Integer + Copy> Ord for ContiguousIntegerSet<E>
impl<E: Ord + Integer + Copy> Ord for ContiguousIntegerSet<E>
source§fn cmp(&self, other: &ContiguousIntegerSet<E>) -> Ordering
fn cmp(&self, other: &ContiguousIntegerSet<E>) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
source§impl<E: PartialEq + Integer + Copy> PartialEq for ContiguousIntegerSet<E>
impl<E: PartialEq + Integer + Copy> PartialEq for ContiguousIntegerSet<E>
source§fn eq(&self, other: &ContiguousIntegerSet<E>) -> bool
fn eq(&self, other: &ContiguousIntegerSet<E>) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl<E: PartialOrd + Integer + Copy> PartialOrd for ContiguousIntegerSet<E>
impl<E: PartialOrd + Integer + Copy> PartialOrd for ContiguousIntegerSet<E>
source§fn partial_cmp(&self, other: &ContiguousIntegerSet<E>) -> Option<Ordering>
fn partial_cmp(&self, other: &ContiguousIntegerSet<E>) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
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 moresource§impl<E> Refineable<Vec<ContiguousIntegerSet<E>>> for ContiguousIntegerSet<E>
impl<E> Refineable<Vec<ContiguousIntegerSet<E>>> for ContiguousIntegerSet<E>
fn get_common_refinement( &self, other: &ContiguousIntegerSet<E> ) -> IntegerIntervalRefinement<E>
source§impl<E> Sample<'_, ContiguousIntegerSetIter<E>, E, OrderedIntegerSet<E>> for ContiguousIntegerSet<E>
impl<E> Sample<'_, ContiguousIntegerSetIter<E>, E, OrderedIntegerSet<E>> for ContiguousIntegerSet<E>
source§fn sample_subset_without_replacement<'s: 'a>(
&'s self,
size: usize
) -> Result<O, String>
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 sizefn sample_with_replacement<'s: 'a>(&'s self, size: usize) -> Result<O, String>
source§impl<E> Slicing<&ContiguousIntegerSet<E>, Option<ContiguousIntegerSet<E>>> for Range<usize>
impl<E> Slicing<&ContiguousIntegerSet<E>, Option<ContiguousIntegerSet<E>>> for Range<usize>
fn slice( self, input: &ContiguousIntegerSet<E> ) -> Option<ContiguousIntegerSet<E>>
source§impl<E: Integer + Copy + ToPrimitive> Sub<&ContiguousIntegerSet<E>> for ContiguousIntegerSet<E>
impl<E: Integer + Copy + ToPrimitive> Sub<&ContiguousIntegerSet<E>> for ContiguousIntegerSet<E>
§type Output = OrderedIntegerSet<E>
type Output = OrderedIntegerSet<E>
The resulting type after applying the
-
operator.source§impl<E: Integer + Copy + ToPrimitive> Sub<&ContiguousIntegerSet<E>> for OrderedIntegerSet<E>
impl<E: Integer + Copy + ToPrimitive> Sub<&ContiguousIntegerSet<E>> for OrderedIntegerSet<E>
§type Output = OrderedIntegerSet<E>
type Output = OrderedIntegerSet<E>
The resulting type after applying the
-
operator.source§impl<E: Integer + Copy + ToPrimitive> Sub<&OrderedIntegerSet<E>> for ContiguousIntegerSet<E>
impl<E: Integer + Copy + ToPrimitive> Sub<&OrderedIntegerSet<E>> for ContiguousIntegerSet<E>
§type Output = OrderedIntegerSet<E>
type Output = OrderedIntegerSet<E>
The resulting type after applying the
-
operator.source§impl<E: Integer + Copy + ToPrimitive> Sub<ContiguousIntegerSet<E>> for OrderedIntegerSet<E>
impl<E: Integer + Copy + ToPrimitive> Sub<ContiguousIntegerSet<E>> for OrderedIntegerSet<E>
§type Output = OrderedIntegerSet<E>
type Output = OrderedIntegerSet<E>
The resulting type after applying the
-
operator.source§impl<E: Integer + Copy + ToPrimitive> Sub<OrderedIntegerSet<E>> for ContiguousIntegerSet<E>
impl<E: Integer + Copy + ToPrimitive> Sub<OrderedIntegerSet<E>> for ContiguousIntegerSet<E>
§type Output = OrderedIntegerSet<E>
type Output = OrderedIntegerSet<E>
The resulting type after applying the
-
operator.source§impl<E: Integer + Copy + ToPrimitive> Sub for ContiguousIntegerSet<E>
impl<E: Integer + Copy + ToPrimitive> Sub for ContiguousIntegerSet<E>
§type Output = OrderedIntegerSet<E>
type Output = OrderedIntegerSet<E>
The resulting type after applying the
-
operator.source§impl<E: Integer + Copy + ToPrimitive> SubAssign<&ContiguousIntegerSet<E>> for OrderedIntegerSet<E>
impl<E: Integer + Copy + ToPrimitive> SubAssign<&ContiguousIntegerSet<E>> for OrderedIntegerSet<E>
source§fn sub_assign(&mut self, rhs: &ContiguousIntegerSet<E>)
fn sub_assign(&mut self, rhs: &ContiguousIntegerSet<E>)
Performs the
-=
operation. Read moresource§impl<E: Integer + Copy + ToPrimitive> SubAssign<ContiguousIntegerSet<E>> for OrderedIntegerSet<E>
impl<E: Integer + Copy + ToPrimitive> SubAssign<ContiguousIntegerSet<E>> for OrderedIntegerSet<E>
source§fn sub_assign(&mut self, rhs: ContiguousIntegerSet<E>)
fn sub_assign(&mut self, rhs: ContiguousIntegerSet<E>)
Performs the
-=
operation. Read moresource§impl<E: Integer + Copy + Hash> SubsetIndexable<ContiguousIntegerSet<E>, ContiguousIntegerSet<E>> for OrderedIntervalPartitions<E>
impl<E: Integer + Copy + Hash> SubsetIndexable<ContiguousIntegerSet<E>, ContiguousIntegerSet<E>> for OrderedIntervalPartitions<E>
fn get_set_containing( &self, subset: &ContiguousIntegerSet<E> ) -> Option<ContiguousIntegerSet<E>>
source§impl<T> SubsetIndexable<ContiguousIntegerSet<i64>, ContiguousIntegerSet<i64>> for IntegerIntervalMap<T>
impl<T> SubsetIndexable<ContiguousIntegerSet<i64>, ContiguousIntegerSet<i64>> for IntegerIntervalMap<T>
fn get_set_containing(&self, subset: &I64Interval) -> Option<I64Interval>
source§impl<E: Integer + Copy> ToIterator<'_, ContiguousIntegerSetIter<E>, E> for ContiguousIntegerSet<E>
impl<E: Integer + Copy> ToIterator<'_, ContiguousIntegerSetIter<E>, E> for ContiguousIntegerSet<E>
fn to_iter(&self) -> ContiguousIntegerSetIter<E> ⓘ
impl<E: Copy + Integer + Copy> Copy for ContiguousIntegerSet<E>
impl<E: Eq + Integer + Copy> Eq for ContiguousIntegerSet<E>
impl<E: Integer + Copy> StructuralEq for ContiguousIntegerSet<E>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more