Struct intrusive_collections::xor_linked_list::CursorMut
source · pub struct CursorMut<'a, A: Adapter>where
A::LinkOps: XorLinkedListOps,{ /* private fields */ }
Expand description
A cursor which provides mutable access to a XorLinkedList
.
Implementations§
source§impl<'a, A: Adapter> CursorMut<'a, A>where
A::LinkOps: XorLinkedListOps,
impl<'a, A: Adapter> CursorMut<'a, A>where
A::LinkOps: XorLinkedListOps,
sourcepub fn get(&self) -> Option<&<A::PointerOps as PointerOps>::Value>
pub fn get(&self) -> Option<&<A::PointerOps as PointerOps>::Value>
Returns a reference to the object that the cursor is currently pointing to.
This returns None if the cursor is currently pointing to the null object.
sourcepub fn as_cursor(&self) -> Cursor<'_, A>
pub fn as_cursor(&self) -> Cursor<'_, A>
Returns a read-only cursor pointing to the current element.
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
.
sourcepub fn move_next(&mut self)
pub fn move_next(&mut self)
Moves the cursor to the next element of the XorLinkedList
.
If the cursor is pointer to the null object then this will move it to
the first element of the XorLinkedList
. If it is pointing to the
last element of the XorLinkedList
then this will move it to the
null object.
sourcepub fn move_prev(&mut self)
pub fn move_prev(&mut self)
Moves the cursor to the previous element of the XorLinkedList
.
If the cursor is pointer to the null object then this will move it to
the last element of the XorLinkedList
. If it is pointing to the first
element of the XorLinkedList
then this will move it to the null object.
sourcepub fn peek_next(&self) -> Cursor<'_, A>
pub fn peek_next(&self) -> Cursor<'_, A>
Returns a cursor pointing to the next element of the XorLinkedList
.
If the cursor is pointer to the null object then this will return the
first element of the XorLinkedList
. If it is pointing to the last
element of the XorLinkedList
then this will return a null cursor.
sourcepub fn peek_prev(&self) -> Cursor<'_, A>
pub fn peek_prev(&self) -> Cursor<'_, A>
Returns a cursor pointing to the previous element of the XorLinkedList
.
If the cursor is pointer to the null object then this will return the
last element of the XorLinkedList
. If it is pointing to the first
element of the XorLinkedList
then this will return a null cursor.
sourcepub fn remove(&mut self) -> Option<<A::PointerOps as PointerOps>::Pointer>
pub fn remove(&mut self) -> Option<<A::PointerOps as PointerOps>::Pointer>
Removes the current element from the XorLinkedList
.
A pointer to the element that was removed is returned, and the cursor is
moved to point to the next element in the XorLinkedList
.
If the cursor is currently pointing to the null object then no element
is removed and None
is returned.
sourcepub fn replace_with(
&mut self,
val: <A::PointerOps as PointerOps>::Pointer,
) -> Result<<A::PointerOps as PointerOps>::Pointer, <A::PointerOps as PointerOps>::Pointer>
pub fn replace_with( &mut self, val: <A::PointerOps as PointerOps>::Pointer, ) -> Result<<A::PointerOps as PointerOps>::Pointer, <A::PointerOps as PointerOps>::Pointer>
Removes the current element from the XorLinkedList
and inserts another
object in its place.
A pointer to the element that was removed is returned, and the cursor is modified to point to the newly added element.
If the cursor is currently pointing to the null object then an error is
returned containing the given val
parameter.
§Panics
Panics if the new element is already linked to a different intrusive collection.
sourcepub fn insert_after(&mut self, val: <A::PointerOps as PointerOps>::Pointer)
pub fn insert_after(&mut self, val: <A::PointerOps as PointerOps>::Pointer)
Inserts a new element into the XorLinkedList
after the current one.
If the cursor is pointing at the null object then the new element is
inserted at the front of the XorLinkedList
.
§Panics
Panics if the new element is already linked to a different intrusive collection.
sourcepub fn insert_before(&mut self, val: <A::PointerOps as PointerOps>::Pointer)
pub fn insert_before(&mut self, val: <A::PointerOps as PointerOps>::Pointer)
Inserts a new element into the XorLinkedList
before the current one.
If the cursor is pointing at the null object then the new element is
inserted at the end of the XorLinkedList
.
§Panics
Panics if the new element is already linked to a different intrusive collection.
sourcepub fn splice_after(&mut self, list: XorLinkedList<A>)
pub fn splice_after(&mut self, list: XorLinkedList<A>)
Inserts the elements from the given XorLinkedList
after the current one.
If the cursor is pointing at the null object then the new elements are
inserted at the start of the XorLinkedList
.
sourcepub fn splice_before(&mut self, list: XorLinkedList<A>)
pub fn splice_before(&mut self, list: XorLinkedList<A>)
Moves all element from the given XorLinkedList
before the current one.
If the cursor is pointing at the null object then the new elements are
inserted at the end of the XorLinkedList
.
sourcepub fn split_after(&mut self) -> XorLinkedList<A>where
A: Clone,
pub fn split_after(&mut self) -> XorLinkedList<A>where
A: Clone,
Splits the list into two after the current element. This will return a new list consisting of everything after the cursor, with the original list retaining everything before.
If the cursor is pointing at the null object then the entire contents
of the XorLinkedList
are moved.
sourcepub fn split_before(&mut self) -> XorLinkedList<A>where
A: Clone,
pub fn split_before(&mut self) -> XorLinkedList<A>where
A: Clone,
Splits the list into two before the current element. This will return a new list consisting of everything before the cursor, with the original list retaining everything after.
If the cursor is pointing at the null object then the entire contents
of the XorLinkedList
are moved.
sourcepub fn into_ref(self) -> Option<&'a <A::PointerOps as PointerOps>::Value>
pub fn into_ref(self) -> Option<&'a <A::PointerOps as PointerOps>::Value>
Consumes CursorMut
and returns a reference to the object that
the cursor is currently pointing to. Unlike get,
the returned reference’s lifetime is tied to XorLinkedList
’s lifetime.
This returns None if the cursor is currently pointing to the null object.