pub struct IntSpan { /* private fields */ }
Implementations
sourceimpl IntSpan
impl IntSpan
INTERFACE: Set creation and contents
pub fn new() -> Self
pub fn from(runlist: &str) -> Self
pub fn from_pair(lower: i32, upper: i32) -> Self
pub fn get_neg_inf(&self) -> i32
pub fn get_pos_inf(&self) -> i32
pub fn clear(&mut self)
pub fn edge_size(&self) -> usize
pub fn span_size(&self) -> usize
pub fn to_vec(&self) -> Vec<i32>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
pub fn ranges(&self) -> Vec<i32>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
pub fn contains(&self, n: i32) -> bool
pub fn min(&self) -> i32
pub fn max(&self) -> i32
sourceimpl IntSpan
impl IntSpan
INTERFACE: Set cardinality
pub fn cardinality(&self) -> i32
pub fn is_empty(&self) -> bool
pub fn is_neg_inf(&self) -> bool
pub fn is_pos_inf(&self) -> bool
pub fn is_infinite(&self) -> bool
pub fn is_finite(&self) -> bool
pub fn is_universal(&self) -> bool
sourceimpl IntSpan
impl IntSpan
INTERFACE: Member operations (mutate original set)
pub fn add_pair(&mut self, lower: i32, upper: i32)
pub fn add_n(&mut self, n: i32)
pub fn add_ranges(&mut self, ranges: &[i32])
pub fn merge(&mut self, other: &Self)
pub fn add_vec(&mut self, ints: &[i32])
pub fn add_runlist(&mut self, runlist: &str)
pub fn invert(&mut self)
pub fn remove_pair(&mut self, lower: i32, upper: i32)
pub fn remove_n(&mut self, n: i32)
pub fn remove_ranges(&mut self, ranges: &[i32])
pub fn subtract(&mut self, other: &Self)
pub fn remove_vec(&mut self, ints: &[i32])
pub fn remove_runlist(&mut self, runlist: &str)
sourceimpl IntSpan
impl IntSpan
INTERFACE: Indexing
sourcepub fn at(&self, index: i32) -> i32
pub fn at(&self, index: i32) -> i32
Returns the index-th element of set, indices start from 1
.
Negative indices count backwards from the end of the set.
sourcepub fn index(&self, element: i32) -> i32
pub fn index(&self, element: i32) -> i32
Returns the index of an element in the set, indices start from 1
pub fn slice(&self, from: i32, to: i32) -> IntSpan
sourceimpl IntSpan
impl IntSpan
INTERFACE: Inter-set OPs
sourcepub fn overlap(&self, other: &Self) -> i32
pub fn overlap(&self, other: &Self) -> i32
overlap
Returns the size of intersection of two sets.
set.overlap(&other)
equivalent to set.intersect(&other).cardinality()
let set = IntSpan::from("1");
let other = IntSpan::from("1");
assert_eq!(set.overlap(&other), 1);
let other = IntSpan::from("2");
assert_eq!(set.overlap(&other), 0);
let set = IntSpan::from("1-5");
let other = IntSpan::from("1-10");
assert_eq!(set.overlap(&other), 5);
let set = IntSpan::from("1-5,6");
let other = IntSpan::from("6-10");
assert_eq!(set.overlap(&other), 1);
sourcepub fn distance(&self, other: &Self) -> i32
pub fn distance(&self, other: &Self) -> i32
Returns the distance between sets, measured as follows.
-
If the sets overlap, then the distance is negative and given by
- set.overlap(&other)
-
If the sets do not overlap, $d is positive and given by the distance on the integer line between the two closest islands of the sets.
let set = IntSpan::from("1");
let other = IntSpan::from("1");
assert_eq!(set.distance(&other), -1);
let other = IntSpan::from("");
assert_eq!(set.distance(&other), 0);
let other = IntSpan::from("2");
assert_eq!(set.distance(&other), 1);
let set = IntSpan::from("1-5");
let other = IntSpan::from("1-10");
assert_eq!(set.distance(&other), -5);
let other = IntSpan::from("10-15");
assert_eq!(set.distance(&other), 5);
let set = IntSpan::from("1-5,6");
let other = IntSpan::from("6-10");
assert_eq!(set.distance(&other), -1);
let set = IntSpan::from("1-5,10-15");
let other = IntSpan::from("5-9");
assert_eq!(set.distance(&other), -1);
let other = IntSpan::from("6");
assert_eq!(set.distance(&other), 1);
let other = IntSpan::from("7");
assert_eq!(set.distance(&other), 2);
let other = IntSpan::from("7-9");
assert_eq!(set.distance(&other), 1);
let other = IntSpan::from("16-20");
assert_eq!(set.distance(&other), 1);
let other = IntSpan::from("17-20");
assert_eq!(set.distance(&other), 2);
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for IntSpan
impl Send for IntSpan
impl Sync for IntSpan
impl Unpin for IntSpan
impl UnwindSafe for IntSpan
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more