RangeTree

Struct RangeTree 

Source
pub struct RangeTree<TOrd: RType> { /* private fields */ }
Expand description

Main range-tree structure.

Implementations§

Source§

impl<TOrd: RType> RangeTree<TOrd>

Source

pub fn new(range: [TOrd; 2], full: bool) -> RangeTree<TOrd>

Create a new range tree.

  • range the [minimum, maximum] values (inclusive), for this range tree.
  • full When true, the tree is created with all values taken.
Source

pub fn clear(&mut self, full: bool)

Clear an existing range tree.

  • full When true, the tree is reset with all values taken.
Source

pub fn take(&mut self, value: TOrd)

Take a value from the tree.

Note: taking a value which is already taken will panic. use retake in cases when its not know.

Source

pub fn retake(&mut self, value: TOrd) -> bool

Take a value which may already be taken, returning true if the value didn’t already exist in the tree.

Source

pub fn take_any(&mut self) -> Option<TOrd>

Take any value from the range tree.

Source

pub fn has(&self, value: TOrd) -> bool

Check if the tree has this value (not taken).

Source

pub fn is_empty(&self) -> bool

Check if no values in the tree are taken.

Source

pub fn is_full(&self) -> bool

Check if all values in the tree are taken.

Source

pub fn release(&mut self, value: TOrd)

Release a value that has been taken.

Source

pub fn ranges_taken_as_vec(&self) -> Vec<[TOrd; 2]>

Return a vector containing [minimum, maximum] pairs (inclusive) of contiguous ranges which have been taken.

Source

pub fn ranges_untaken_as_vec(&self) -> Vec<[TOrd; 2]>

Return a vector containing [minimum, maximum] pairs (inclusive) of contiguous ranges which have not been taken.

Auto Trait Implementations§

§

impl<TOrd> Freeze for RangeTree<TOrd>
where TOrd: Freeze,

§

impl<TOrd> RefUnwindSafe for RangeTree<TOrd>
where TOrd: RefUnwindSafe,

§

impl<TOrd> !Send for RangeTree<TOrd>

§

impl<TOrd> !Sync for RangeTree<TOrd>

§

impl<TOrd> Unpin for RangeTree<TOrd>
where TOrd: Unpin,

§

impl<TOrd> UnwindSafe for RangeTree<TOrd>
where TOrd: UnwindSafe + 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> 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, 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.