Struct nekolib::ds::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 copy 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<IntervalSet<T>> for IntervalSet<T>

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method 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> StructuralEq for IntervalSet<T>

source§

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> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. 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 Twhere 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 Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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 Twhere V: MultiLane<T>,

§

fn vzip(self) -> V