Skip to main content

IntervalSet

Struct IntervalSet 

Source
pub struct IntervalSet<T: Ord> { /* private fields */ }
Expand description

区間の集合。

区間の追加・削除を行うことができる。

Implementations§

Source§

impl<T: Clone + Debug + Ord> IntervalSet<T>

Source

pub fn new() -> Self

空集合で初期化する。

Source

pub fn is_empty(&self) -> bool

集合が空であれば true を返す。

Source

pub fn insert<R: RangeBounds<T>>(&mut self, r: R)

区間 r を追加する。

Source

pub fn remove<R: RangeBounds<T>>(&mut self, r: R)

区間 r を削除する。

Source

pub fn clear(&mut self)

空集合に戻す。

Source

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);
Source

pub fn covering<R: RangeBounds<T>>( &self, r: &R, ) -> Option<(&Bound<T>, &Bound<T>)>

区間 r を含む区間の両端を返す。

Source

pub fn has_range<R: RangeBounds<T>>(&self, r: &R) -> bool

区間 r を含んでいれば true を返す。

Source

pub fn iter( &self, ) -> impl Iterator<Item = (&Bound<T>, &Bound<T>)> + DoubleEndedIterator + '_

Trait Implementations§

Source§

impl<T: Clone + Ord> Clone for IntervalSet<T>

Source§

fn clone(&self) -> IntervalSet<T>

Returns a duplicate 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<T: Debug + Ord> Debug for IntervalSet<T>

Source§

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

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

impl<T: PartialEq + Ord> PartialEq for IntervalSet<T>

Source§

fn eq(&self, other: &IntervalSet<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: Eq + Ord> Eq for IntervalSet<T>

Source§

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> 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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>,

Source§

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>,

Source§

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