Struct nekolib::ds::IntervalSet
source · 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 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<T: PartialEq + Ord> PartialEq<IntervalSet<T>> for IntervalSet<T>
impl<T: PartialEq + Ord> PartialEq<IntervalSet<T>> for IntervalSet<T>
source§fn eq(&self, other: &IntervalSet<T>) -> bool
fn eq(&self, other: &IntervalSet<T>) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.impl<T: Eq + Ord> Eq for IntervalSet<T>
impl<T: Ord> StructuralEq for IntervalSet<T>
impl<T: Ord> StructuralPartialEq for IntervalSet<T>
Auto Trait Implementations§
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> 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