pub struct IntervalCollection<T: Num + PartialOrd + Clone + Display, U: Num + PartialOrd + Display> { /* private fields */ }Expand description
Result of combine_intervals: a collection of Intervals. This can be converted to a Vec of Intervals, or converted to a Counter (only integer and positive counts instead of values) or Set (any Interval with value >0 is included and if possible combined with neighbouring intervals).
§Examples
use std::collections::HashMap;
use intervalues::{Interval, IntervalCollection, combine_intervals, BaseInterval};
// Two intervals, from 0 to 2 with count 1 and 1 to 3 with count 2
let input: Vec<[i64; 3]> = vec!([0, 2, 1], [1, 3, 2]);
let input = input.iter()
.map(|x| Interval::new(x[0], x[1], x[2]))
.collect();
let out: IntervalCollection<i64,i64> = combine_intervals(input);
assert_eq!(out.to_vec_as_counter()[0], Interval::default());
assert_eq!(out.to_vec()[1], Interval::new(1, 2, 3));
assert_eq!(out.to_vec_as_set(), vec!(BaseInterval::new(0, 3)))Implementations§
Source§impl<T, U> IntervalCollection<T, U>
impl<T, U> IntervalCollection<T, U>
pub fn new() -> Self
pub fn print(&self) -> String
pub fn get_lb(&self) -> T
pub fn get_ub(&self) -> T
pub fn len(&self) -> usize
pub fn get_bounds(&self) -> (T, T)
pub fn contains_num(&self, num: T) -> bool
pub fn get_value(&self, num: T) -> U
pub fn contains_interval(&self, interval: Interval<T, U>) -> bool
pub fn get_value_of_interval_by_parts( &self, interval: Interval<T, U>, ) -> IntervalCollection<T, U>
pub fn get_partially_overlaps_interval(&self, other: &Interval<T, U>) -> bool
pub fn get_partially_overlaps(&self, other: IntervalCollection<T, U>) -> bool
pub fn from_vec(vec: Vec<Interval<T, U>>) -> Self
pub fn to_vec_owned(self) -> Vec<Interval<T, U>>
pub fn to_vec(&self) -> Vec<Interval<T, U>>
pub fn to_vec_as_set(&self) -> Vec<BaseInterval<T>>
Source§impl<T, U> IntervalCollection<T, U>
impl<T, U> IntervalCollection<T, U>
pub fn total_value(&self) -> U
Source§impl<T, U> IntervalCollection<T, U>where
T: Num + PartialOrd + Clone + Copy + Display,
U: Num + PartialOrd + Clone + Copy + ToPrimitive + Sum + Display,
impl<T, U> IntervalCollection<T, U>where
T: Num + PartialOrd + Clone + Copy + Display,
U: Num + PartialOrd + Clone + Copy + ToPrimitive + Sum + Display,
pub fn to_vec_as_counter(&self) -> Vec<Interval<T, usize>>
Trait Implementations§
Source§impl<T: Clone + Num + PartialOrd + Clone + Display, U: Clone + Num + PartialOrd + Display> Clone for IntervalCollection<T, U>
impl<T: Clone + Num + PartialOrd + Clone + Display, U: Clone + Num + PartialOrd + Display> Clone for IntervalCollection<T, U>
Source§fn clone(&self) -> IntervalCollection<T, U>
fn clone(&self) -> IntervalCollection<T, U>
Returns a duplicate 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<T: Debug + Num + PartialOrd + Clone + Display, U: Debug + Num + PartialOrd + Display> Debug for IntervalCollection<T, U>
impl<T: Debug + Num + PartialOrd + Clone + Display, U: Debug + Num + PartialOrd + Display> Debug for IntervalCollection<T, U>
Source§impl<T, U> Display for IntervalCollection<T, U>
impl<T, U> Display for IntervalCollection<T, U>
Source§impl<T: Hash + Num + PartialOrd + Clone + Display, U: Hash + Num + PartialOrd + Display> Hash for IntervalCollection<T, U>
impl<T: Hash + Num + PartialOrd + Clone + Display, U: Hash + Num + PartialOrd + Display> Hash for IntervalCollection<T, U>
Source§impl<T: PartialEq + Num + PartialOrd + Clone + Display, U: PartialEq + Num + PartialOrd + Display> PartialEq for IntervalCollection<T, U>
impl<T: PartialEq + Num + PartialOrd + Clone + Display, U: PartialEq + Num + PartialOrd + Display> PartialEq for IntervalCollection<T, U>
impl<T: Eq + Num + PartialOrd + Clone + Display, U: Eq + Num + PartialOrd + Display> Eq for IntervalCollection<T, U>
impl<T: Num + PartialOrd + Clone + Display, U: Num + PartialOrd + Display> StructuralPartialEq for IntervalCollection<T, U>
Auto Trait Implementations§
impl<T, U> Freeze for IntervalCollection<T, U>
impl<T, U> RefUnwindSafe for IntervalCollection<T, U>where
T: RefUnwindSafe,
U: RefUnwindSafe,
impl<T, U> Send for IntervalCollection<T, U>
impl<T, U> Sync for IntervalCollection<T, U>
impl<T, U> Unpin for IntervalCollection<T, U>
impl<T, U> UnwindSafe for IntervalCollection<T, U>where
T: UnwindSafe,
U: 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<F> Match for F
impl<F> Match for F
Source§fn matches<T>(&self) -> boolwhere
T: TryCastFrom<Self>,
fn matches<T>(&self) -> boolwhere
T: TryCastFrom<Self>,
Returns
true if self can be cast into the target type T.Source§impl<F, T> TryCastFrom<F> for Twhere
T: CastFrom<F>,
impl<F, T> TryCastFrom<F> for Twhere
T: CastFrom<F>,
Source§fn can_cast_from(_: &F) -> bool
fn can_cast_from(_: &F) -> bool
Test if
value can be cast into Self.Source§fn opt_cast_from(f: F) -> Option<T>
fn opt_cast_from(f: F) -> Option<T>
Returns
Some(Self) if the source value can be cast into Self, otherwise None.Source§impl<F, T> TryCastInto<T> for Fwhere
T: TryCastFrom<F>,
impl<F, T> TryCastInto<T> for Fwhere
T: TryCastFrom<F>,
Source§fn can_cast_into(&self) -> bool
fn can_cast_into(&self) -> bool
Test if
self can be cast into T.Source§fn opt_cast_into(self) -> Option<T>
fn opt_cast_into(self) -> Option<T>
Returns
Some(T) if self can be cast into T, otherwise None.Source§fn try_cast_into<Err, OnErr>(self, on_err: OnErr) -> Result<T, Err>where
OnErr: FnOnce(&Self) -> Err,
fn try_cast_into<Err, OnErr>(self, on_err: OnErr) -> Result<T, Err>where
OnErr: FnOnce(&Self) -> Err,
Returns
Ok(T) if self can be cast into T, otherwise calls on_err.