pub struct IntervalSet<T: Ord> { /* private fields */ }Expand description
区間の集合。
区間の追加・削除を行うことができる。
Implementations§
Source§impl<T: Clone + Debug + Ord> IntervalSet<T>
impl<T: Clone + Debug + Ord> IntervalSet<T>
Sourcepub fn insert<R: RangeBounds<T>>(&mut self, r: R)
pub fn insert<R: RangeBounds<T>>(&mut self, r: R)
区間 r を追加する。
Sourcepub fn remove<R: RangeBounds<T>>(&mut self, r: R)
pub fn remove<R: RangeBounds<T>>(&mut self, r: R)
区間 r を削除する。
Sourcepub fn mex<'a>(&'a self, x: &'a T) -> Bound<&'a T>
pub fn mex<'a>(&'a self, x: &'a T) -> Bound<&'a T>
x 以上の値で、集合中の区間に含まれない最小のものを返す。
§Examples
use std::ops::Bound::{Included, Excluded, Unbounded};
use nekolib::ds::IntervalSet;
let mut s = IntervalSet::new();
s.insert(1..5);
s.insert(7..=10);
s.insert(15..);
assert_eq!(s.mex(&0), Included(&0));
assert_eq!(s.mex(&1), Included(&5));
assert_eq!(s.mex(&6), Included(&6));
assert_eq!(s.mex(&7), Excluded(&10));
assert_eq!(s.mex(&15), Unbounded);Sourcepub fn covering<R: RangeBounds<T>>(
&self,
r: &R,
) -> Option<(&Bound<T>, &Bound<T>)>
pub fn covering<R: RangeBounds<T>>( &self, r: &R, ) -> Option<(&Bound<T>, &Bound<T>)>
区間 r を含む区間の両端を返す。
Sourcepub fn has_range<R: RangeBounds<T>>(&self, r: &R) -> bool
pub fn has_range<R: RangeBounds<T>>(&self, r: &R) -> bool
区間 r を含んでいれば true を返す。
pub fn iter( &self, ) -> impl Iterator<Item = (&Bound<T>, &Bound<T>)> + DoubleEndedIterator + '_
Trait Implementations§
Source§impl<T: Clone + Ord> Clone for IntervalSet<T>
impl<T: Clone + Ord> Clone for IntervalSet<T>
Source§fn clone(&self) -> IntervalSet<T>
fn clone(&self) -> IntervalSet<T>
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 moreimpl<T: Eq + Ord> Eq for IntervalSet<T>
impl<T: Ord> StructuralPartialEq for IntervalSet<T>
Auto Trait Implementations§
impl<T> Freeze for IntervalSet<T>
impl<T> RefUnwindSafe for IntervalSet<T>where
T: RefUnwindSafe,
impl<T> Send for IntervalSet<T>where
T: Send,
impl<T> Sync for IntervalSet<T>where
T: Sync,
impl<T> Unpin for IntervalSet<T>
impl<T> UnsafeUnpin for IntervalSet<T>
impl<T> UnwindSafe for IntervalSet<T>where
T: RefUnwindSafe,
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