hashlink::linked_hash_map

Struct CursorMut

Source
pub struct CursorMut<'a, K, V, S> { /* private fields */ }
Expand description

The CursorMut struct and its implementation provide the basic mutable Cursor API for Linked lists as proposed in here, with several exceptions:

  • It behaves similarly to Rust’s Iterators, returning None when the end of the list is reached. A guard node is positioned between the head and tail of the linked list to facilitate this. If the cursor is over this guard node, None is returned, signaling the end or start of the list. From this position, the cursor can move in either direction as the linked list is circular, with the guard node connecting the two ends.
  • The current implementation does not include an index method, as it does not track the index of its elements. It provides access to each map entry as a tuple of (&K, &mut V).

Implementations§

Source§

impl<'a, K, V, S> CursorMut<'a, K, V, S>

Source

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

Returns an Option of the current element in the list, provided it is not the guard node, and None overwise.

Source

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

Retrieves the next element in the list (moving towards the end).

Source

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

Retrieves the previous element in the list (moving towards the front).

Source

pub fn move_next(&mut self)

Updates the pointer to the current element to the next element in the list (that is, moving towards the end).

Source

pub fn move_prev(&mut self)

Updates the pointer to the current element to the previous element in the list (that is, moving towards the front).

Source

pub fn insert_before(&mut self, key: K, value: V) -> Option<V>
where K: Eq + Hash, S: BuildHasher,

Inserts the provided key and value before the current element. It checks if an entry with the given key exists and, if so, replaces its value with the provided key parameter. The key is not updated; this matters for types that can be == without being identical.

If the entry doesn’t exist, it creates a new one. If a value has been updated, the function returns the old value wrapped with Some and None otherwise.

Source

pub fn insert_after(&mut self, key: K, value: V) -> Option<V>
where K: Eq + Hash, S: BuildHasher,

Inserts the provided key and value after the current element. It checks if an entry with the given key exists and, if so, replaces its value with the provided key parameter. The key is not updated; this matters for types that can be == without being identical.

If the entry doesn’t exist, it creates a new one. If a value has been updated, the function returns the old value wrapped with Some and None otherwise.

Auto Trait Implementations§

§

impl<'a, K, V, S> Freeze for CursorMut<'a, K, V, S>

§

impl<'a, K, V, S> RefUnwindSafe for CursorMut<'a, K, V, S>

§

impl<'a, K, V, S> !Send for CursorMut<'a, K, V, S>

§

impl<'a, K, V, S> !Sync for CursorMut<'a, K, V, S>

§

impl<'a, K, V, S> Unpin for CursorMut<'a, K, V, S>

§

impl<'a, K, V, S> !UnwindSafe for CursorMut<'a, K, V, S>

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.