pub struct SetCursor<'a, K, C>where
    K: 'a + Copy,
    C: 'a + Comparator<K>,{ /* private fields */ }
Expand description

A position in a Set used to navigate and modify the ordered set.

A cursor always points at an element in the set, or “off the end” which is a position after the last element in the set.

Implementations§

source§

impl<'a, K, C> SetCursor<'a, K, C>where K: Copy, C: Comparator<K>,

source

pub fn is_empty(&self) -> bool

Is this cursor pointing to an empty set?

source

pub fn next(&mut self) -> Option<K>

Move cursor to the next element and return it.

If the cursor reaches the end, return None and leave the cursor at the off-the-end position.

source

pub fn prev(&mut self) -> Option<K>

Move cursor to the previous element and return it.

If the cursor is already pointing at the first element, leave it there and return None.

source

pub fn elem(&self) -> Option<K>

Get the current element, or None if the cursor is at the end.

source

pub fn goto(&mut self, elem: K) -> bool

Move this cursor to elem.

If elem is in the set, place the cursor at elem and return true.

If elem is not in the set, place the cursor at the next larger element (or the end) and return false.

source

pub fn goto_first(&mut self) -> Option<K>

Move this cursor to the first element.

source

pub fn insert(&mut self, elem: K) -> bool

Try to insert elem into the set and leave the cursor at the inserted element.

If the set did not contain elem, insert it and return true.

If elem is already present, don’t change the set, place the cursor at goto(elem), and return false.

source

pub fn remove(&mut self) -> Option<K>

Remove the current element (if any) and return it. This advances the cursor to the next element after the removed one.

Auto Trait Implementations§

§

impl<'a, K, C> RefUnwindSafe for SetCursor<'a, K, C>where C: RefUnwindSafe, K: RefUnwindSafe,

§

impl<'a, K, C> Send for SetCursor<'a, K, C>where C: Sync, K: Send,

§

impl<'a, K, C> Sync for SetCursor<'a, K, C>where C: Sync, K: Sync,

§

impl<'a, K, C> Unpin for SetCursor<'a, K, C>where K: Unpin,

§

impl<'a, K, C> !UnwindSafe for SetCursor<'a, K, C>

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