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

An OrderedIntegerSet consists of a sequence of ContiguousIntegerSet that are sorted in ascending order where successive intervals are not coalesceable, i.e., if intervals A and B are successive intervals, then A.end + 1 < B.start

E.g. An OrderedIntegerSet containing ContiguousIntegerSets [2,3] and [5,7] will represent the set of integers {2, 3, 5, 6, 7}

Implementations§

source§

impl<E: Integer + Copy + ToPrimitive> OrderedIntegerSet<E>

source

pub fn new() -> OrderedIntegerSet<E>

source

pub fn from_slice(slice: &[[E; 2]]) -> OrderedIntegerSet<E>

Creates an OrderedIntegerSet where the i-th interval is represented by the i-th two-element array in slice.

E.g. [[2, 3], [5, 7]] will create an OrderedIntegerSet representing {2, 3, 5, 6, 7}, where the contiguous integers are stored as ContiguousIntegerSets

Note that the intervals in the slice parameters do not have to be sorted or non-overlapping.

source

pub fn from_contiguous_integer_sets( sets: Vec<ContiguousIntegerSet<E>> ) -> OrderedIntegerSet<E>

source

pub fn from_ordered_coalesced_contiguous_integer_sets( sets: Vec<ContiguousIntegerSet<E>> ) -> OrderedIntegerSet<E>

source

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

Returns the smallest element in the set e.g. {[1,3], [4,8]} -> 1

source

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

Returns the largest element in the set e.g. {[1,3], [4,8]} -> 8

source

pub fn is_empty(&self) -> bool

source

pub fn first_and_last(&self) -> Option<(E, E)>

Returns both the smallest and the largest element in the set e.g. {[1,3], [4,8]} -> the tuple (1, 8)

source

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

The slicer can be any struct that implements the Slicing trait. For example, the Slicing trait has been implemented for the Range<usize> struct.

For an OrderedIntegerSet containing n elements, the Range<usize> object created by a..b will slice the integer set and return all the elements from the a-th (inclusive) to the b-th (exclusive) in the form of an OrderedIntegerSet

source

pub fn to_non_empty_intervals(&self) -> Self

source

pub fn into_non_empty_intervals(self) -> Self

source

pub fn remove_empty_intervals(&mut self)

source

pub fn get_intervals_by_ref(&self) -> &Vec<ContiguousIntegerSet<E>>

source

pub fn into_intervals(self) -> Vec<ContiguousIntegerSet<E>>

source

pub fn intervals_iter(&self) -> Iter<'_, ContiguousIntegerSet<E>>

source

pub fn num_intervals(&self) -> usize

Trait Implementations§

source§

impl<E: Clone + Integer + Copy + ToPrimitive> Clone for OrderedIntegerSet<E>

source§

fn clone(&self) -> OrderedIntegerSet<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> CoalesceIntervals<ContiguousIntegerSet<E>, E> for OrderedIntegerSet<E>
where E: Integer + Copy + ToPrimitive,

source§

impl<E: Integer + Copy + ToPrimitive> Collecting<E> for OrderedIntegerSet<E>

source§

fn collect(&mut self, item: E)

source§

impl<E: Debug + Integer + Copy + ToPrimitive> Debug for OrderedIntegerSet<E>

source§

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

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

impl<E: Integer + Copy + ToPrimitive> Default for OrderedIntegerSet<E>

source§

fn default() -> Self

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

impl<E: Integer + Copy + Sum + ToPrimitive> Finite for OrderedIntegerSet<E>

source§

fn size(&self) -> usize

source§

impl<E: Integer + Copy + ToPrimitive> From<OrderedIntegerSet<E>> for IntegerSetIter<E>

source§

fn from(ordered_integer_set: OrderedIntegerSet<E>) -> IntegerSetIter<E>

Converts to this type from the input type.
source§

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

source§

fn from(intervals: Vec<ContiguousIntegerSet<E>>) -> OrderedIntegerSet<E>

Converts to this type from the input type.
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> Intersect<&OrderedIntegerSet<E>, OrderedIntegerSet<E>> for OrderedIntegerSet<E>
where E: Integer + Copy + ToPrimitive,

source§

impl<E: PartialEq + Integer + Copy + ToPrimitive> PartialEq for OrderedIntegerSet<E>

source§

fn eq(&self, other: &OrderedIntegerSet<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> 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> Sample<'_, IntegerSetIter<E>, E, OrderedIntegerSet<E>> for OrderedIntegerSet<E>
where E: Integer + Copy + Sum + 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 + ToPrimitive> Set<E> for OrderedIntegerSet<E>

source§

fn is_empty(&self) -> bool

source§

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

source§

impl<E> Slicing<&OrderedIntegerSet<E>, OrderedIntegerSet<E>> for Range<usize>

source§

fn slice(self, input: &OrderedIntegerSet<E>) -> OrderedIntegerSet<E>

the end index is exclusive

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<&OrderedIntegerSet<E>> for OrderedIntegerSet<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 OrderedIntegerSet<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> 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<&OrderedIntegerSet<E>> for OrderedIntegerSet<E>

source§

fn sub_assign(&mut self, rhs: &OrderedIntegerSet<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 + ToPrimitive> SubAssign for OrderedIntegerSet<E>

source§

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

Performs the -= operation. Read more
source§

impl<E: Integer + Copy + ToPrimitive> ToIterator<'_, IntegerSetIter<E>, E> for OrderedIntegerSet<E>

source§

impl<E: Eq + Integer + Copy + ToPrimitive> Eq for OrderedIntegerSet<E>

source§

impl<E: Integer + Copy + ToPrimitive> StructuralEq for OrderedIntegerSet<E>

source§

impl<E: Integer + Copy + ToPrimitive> StructuralPartialEq for OrderedIntegerSet<E>

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

impl<E> UnwindSafe for OrderedIntegerSet<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