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>
impl<'a, K, N, M> CursorMut<'a, K, N, M>
Sourcepub fn key(&self) -> Option<&K>
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§impl<'a, K, N, M> CursorMut<'a, K, N, M>
impl<'a, K, N, M> CursorMut<'a, K, N, M>
Sourcepub fn node(&self) -> Option<&N>
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.
Sourcepub fn front_node(&self) -> Option<&N>
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§impl<'a, K, N, M> CursorMut<'a, K, N, M>
impl<'a, K, N, M> CursorMut<'a, K, N, M>
Sourcepub fn next_key(&self) -> Option<&K>
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
.
Sourcepub fn prev_key(&self) -> Option<&K>
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
.
Sourcepub fn next_node(&self) -> Option<&N>
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
.
Sourcepub fn prev_node(&self) -> Option<&N>
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>
impl<'a, K, N, M> CursorMut<'a, K, N, M>
Sourcepub fn move_next(&mut self)
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.
Sourcepub fn move_prev(&mut self)
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>
impl<'a, K, N, M> CursorMut<'a, K, N, M>
Sourcepub fn node_mut(&mut self) -> Option<&mut N>
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.
Sourcepub fn front_node_mut(&mut self) -> Option<&mut N>
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.
Sourcepub fn back_node_mut(&mut self) -> Option<&mut N>
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>
impl<'a, K, N, M> CursorMut<'a, K, N, M>
Sourcepub fn insert_after<T: Into<N>>(
&mut self,
key: K,
node: T,
) -> Result<(), (K, T)>
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
.
Sourcepub fn insert_before<T: Into<N>>(
&mut self,
key: K,
node: T,
) -> Result<(), (K, T)>
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
.
Sourcepub fn insert_key_after(&mut self, key: K) -> Result<(), K>
pub fn insert_key_after(&mut self, key: K) -> Result<(), K>
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
.
Sourcepub fn insert_key_before(&mut self, key: K) -> Result<(), K>
pub fn insert_key_before(&mut self, key: K) -> Result<(), K>
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
.
Sourcepub fn remove_current(&mut self) -> Option<(K, N)>
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.
Sourcepub fn push_front<T: Into<N>>(&mut self, key: K, node: T) -> Result<(), (K, T)>
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.
Sourcepub fn push_back<T: Into<N>>(&mut self, key: K, node: T) -> Result<(), (K, T)>
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.
Sourcepub fn pop_front(&mut self) -> Option<(K, N)>
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.
Sourcepub fn pop_back(&mut self) -> Option<(K, N)>
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.