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

A position in a Map used to navigate and modify the ordered map.

A cursor always points at a key-value pair in the map, or “off the end” which is a position after the last entry in the map.

Implementations§

source§

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

source

pub fn is_empty(&self) -> bool

Is this cursor pointing to an empty map?

source

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

Move cursor to the next key-value pair 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, V)>

Move cursor to the previous key-value pair and return it.

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

source

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

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

source

pub fn value(&self) -> Option<V>

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

source

pub fn value_mut(&mut self) -> Option<&mut V>

Get a mutable reference to the current value, or None if the cursor is at the end.

source

pub fn goto(&mut self, elem: K) -> Option<V>

Move this cursor to key.

If key is in the map, place the cursor at key and return the corresponding value.

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

source

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

Move this cursor to the first element.

source

pub fn insert(&mut self, key: K, value: V) -> Option<V>

Insert (key, value)) into the map and leave the cursor at the inserted pair.

If the map did not contain key, return None.

If key is already present, replace the existing with value and return the old value.

source

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

Remove the current entry (if any) and return the mapped value. This advances the cursor to the next entry after the removed one.

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

impl<'a, K, V, C> !UnwindSafe for MapCursor<'a, K, V, 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,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · 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.
const: unstable · 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.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.