Struct CursorMut

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

A cursor over a KeyNodeList with editing operations.

Implementations§

Source§

impl<'a, K, N, M> CursorMut<'a, K, N, M>

Source

pub fn is_null(&self) -> bool

Checks if the cursor is currently pointing to the null pair.

Source

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

Returns a reference to the key that the cursor is currently pointing to.

Returns None if the cursor is currently pointing to the null pair.

Source

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

Provides a reference to the front key of the cursor’s parent list, or None if the list is empty.

Source

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

Provides a reference to the back key of the cursor’s parent list, or None if the list is empty.

Source§

impl<'a, K, N, M> CursorMut<'a, K, N, M>
where K: Hash + Eq, M: Map<K, N>,

Source

pub fn node(&self) -> Option<&N>

Returns a reference to the node that the cursor is currently pointing to.

Returns None if the cursor is currently pointing to the null pair.

Source

pub fn front_node(&self) -> Option<&N>

Provides a reference to the front node of the cursor’s parent list, or None if the list is empty.

Source

pub fn back_node(&self) -> Option<&N>

Provides a reference to the back node of the cursor’s parent list, or None if the list is empty.

Source§

impl<'a, K, N, M> CursorMut<'a, K, N, M>
where K: Hash + Eq, N: Node<Key = K>, M: Map<K, N>,

Source

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

Returns a reference to the next key.

If the cursor is pointing to the null pair then this returns the first key of the KeyNodeList. If it is pointing to the last key of the KeyNodeList then this returns None.

Source

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

Returns a reference to the previous key.

If the cursor is pointing to the null pair then this returns the last key of the KeyNodeList. If it is pointing to the first key of the KeyNodeList then this returns None.

Source

pub fn next_node(&self) -> Option<&N>

Returns a reference to the next node.

If the cursor is pointing to the null pair then this returns the first node of the KeyNodeList. If it is pointing to the last node of the KeyNodeList then this returns None.

Source

pub fn prev_node(&self) -> Option<&N>

Returns a reference to the previous node.

If the cursor is pointing to the null pair then this returns the last node of the KeyNodeList. If it is pointing to the first node of the KeyNodeList then this returns None.

Source§

impl<'a, K, N, M> CursorMut<'a, K, N, M>
where K: Hash + Eq + Clone, N: Node<Key = K>, M: Map<K, N>,

Source

pub fn move_next(&mut self)

Moves the cursor to the next key-node pair of the KeyNodeList.

If the cursor is pointing to the null pair then this will move it to the first key-node pair of the KeyNodeList. If it is pointing to the last key-node pair of the KeyNodeList then this will move it to the null pair.

Source

pub fn move_prev(&mut self)

Moves the cursor to the previous key-node pair of the KeyNodeList.

If the cursor is pointing to the null pair then this will move it to the last key-node pair of the KeyNodeList. If it is pointing to the first key-node pair of the KeyNodeList then this will move it to the null pair.

Source§

impl<'a, K, N, M> CursorMut<'a, K, N, M>
where K: Clone,

Source

pub fn as_cursor(&self) -> Cursor<'_, K, N, M>

Returns a read-only cursor pointing to the current pair.

The lifetime of the returned Cursor is bound to that of the CursorMut, which means it cannot outlive the CursorMut and that the CursorMut is frozen for the lifetime of the Cursor.

Source§

impl<'a, K, N, M> CursorMut<'a, K, N, M>
where K: Hash + Eq, M: Map<K, N>,

Source

pub fn node_mut(&mut self) -> Option<&mut N>

Returns a mutable reference to the node that the cursor is currently pointing to.

Returns None if the cursor is currently pointing to the null pair.

Source

pub fn front_node_mut(&mut self) -> Option<&mut N>

Provides a mutable reference to the front node of the cursor’s parent list, or None if the list is empty.

Source

pub fn back_node_mut(&mut self) -> Option<&mut N>

Provides a mutable reference to the back node of the cursor’s parent list, or None if the list is empty.

Source§

impl<'a, K, N, M> CursorMut<'a, K, N, M>
where K: Hash + Eq + Clone, N: Node<Key = K>, M: Map<K, N>,

Source

pub fn insert_after<T: Into<N>>( &mut self, key: K, node: T, ) -> Result<(), (K, T)>

Inserts a new key-node pair into the KeyNodeList after the current one.

If the cursor is pointing at the null pair then the new pair is inserted at the front of the KeyNodeList.

If key already exists, returns an error containing key and node.

Source

pub fn insert_before<T: Into<N>>( &mut self, key: K, node: T, ) -> Result<(), (K, T)>

Inserts a new key-node pair into the KeyNodeList before the current one.

If the cursor is pointing at the null pair then the new pair is inserted at the end of the KeyNodeList.

If key already exists, returns an error containing key and node.

Source

pub fn insert_key_after(&mut self, key: K) -> Result<(), K>
where (): Into<N>,

Inserts a key into the KeyNodeList after the current one.

If the cursor is pointing at the null pair then the key is inserted at the front of the KeyNodeList.

If key already exists, returns an error containing key.

Source

pub fn insert_key_before(&mut self, key: K) -> Result<(), K>
where (): Into<N>,

Inserts a key into the KeyNodeList before the current one.

If the cursor is pointing at the null pair then the key is inserted at the front of the KeyNodeList.

If key already exists, returns an error containing key.

Source

pub fn remove_current(&mut self) -> Option<(K, N)>

Removes the current pair from the KeyNodeList.

The pair that was removed is returned, and the cursor is moved to point to the next pair in the KeyNodeList.

If the cursor is currently pointing to the null pair then no pair is removed and None is returned.

Source

pub fn push_front<T: Into<N>>(&mut self, key: K, node: T) -> Result<(), (K, T)>

Appends an pair to the front of the cursor’s parent list. The pair that the cursor points to is unchanged, even if it is the null pair.

If key already exists, returns an error containing key and node.

This operation should compute in O(1) time on average.

Source

pub fn push_back<T: Into<N>>(&mut self, key: K, node: T) -> Result<(), (K, T)>

Appends an pair to the back of the cursor’s parent list. The pair that the cursor points to is unchanged, even if it is the null pair.

If key already exists, returns an error containing key and node.

This operation should compute in O(1) time on average.

Source

pub fn pop_front(&mut self) -> Option<(K, N)>

Removes the first pair from the cursor’s parent list and returns it, or None if the list is empty. The pair the cursor points to remains unchanged, unless it was pointing to the front pair. In that case, it points to the new front pair.

This operation should compute in O(1) time on average.

Source

pub fn pop_back(&mut self) -> Option<(K, N)>

Removes the last pair from the cursor’s parent list and returns it, or None if the list is empty. The pair the cursor points to remains unchanged, unless it was pointing to the back pair. In that case, it points to the null pair.

This operation should compute in O(1) time on average.

Trait Implementations§

Source§

impl<'a, K, N, M> Debug for CursorMut<'a, K, N, M>
where K: Hash + Eq + Debug, N: Node<Key = K> + Debug, M: Map<K, N>,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, K, N, M> Freeze for CursorMut<'a, K, N, M>
where K: Freeze,

§

impl<'a, K, N, M> RefUnwindSafe for CursorMut<'a, K, N, M>

§

impl<'a, K, N, M> Send for CursorMut<'a, K, N, M>
where K: Send, M: Send, N: Send,

§

impl<'a, K, N, M> Sync for CursorMut<'a, K, N, M>
where K: Sync, M: Sync, N: Sync,

§

impl<'a, K, N, M> Unpin for CursorMut<'a, K, N, M>
where K: Unpin,

§

impl<'a, K, N, M> !UnwindSafe for CursorMut<'a, K, N, M>

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.