Struct intrusive_collections::singly_linked_list::CursorMut
[−]
[src]
pub struct CursorMut<'a, A: Adapter<Link = Link> + 'a> { /* fields omitted */ }
A cursor which provides mutable access to a SinglyLinkedList
.
Methods
impl<'a, A: Adapter<Link = Link>> CursorMut<'a, A>
[src]
fn is_null(&self) -> bool
Checks if the cursor is currently pointing to the null object.
fn get(&self) -> Option<&'a A::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.
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
.
fn move_next(&mut self)
Moves the cursor to the next element of the SinglyLinkedList
.
If the cursor is pointer to the null object then this will move it to
the first element of the SinglyLinkedList
. If it is pointing to the
last element of the SinglyLinkedList
then this will move it to the
null object.
fn remove_next(&mut self) -> Option<A::Pointer>
Removes the next element from the SinglyLinkedList
.
A pointer to the element that was removed is returned, and the cursor is not moved.
If the cursor is currently pointing to the last element of the
SinglyLinkedList
then no element is removed and None
is returned.
fn replace_next_with(
&mut self,
val: A::Pointer
) -> Result<A::Pointer, A::Pointer>
&mut self,
val: A::Pointer
) -> Result<A::Pointer, A::Pointer>
Removes the next element from the SinglyLinkedList
and inserts
another object in its place.
A pointer to the element that was removed is returned, and the cursor is not moved.
If the cursor is currently pointing to the last element of the
SinglyLinkedList
then no element is added or removed and an error is
returned containing the given val
parameter.
Panics
Panics if the new element is already linked to a different intrusive collection.
fn insert_after(&mut self, val: A::Pointer)
Inserts a new element into the SinglyLinkedList
after the current one.
If the cursor is pointing at the null object then the new element is
inserted at the front of the SinglyLinkedList
.
Panics
Panics if the new element is already linked to a different intrusive collection.
fn splice_after(&mut self, list: SinglyLinkedList<A>)
Inserts the elements from the given SinglyLinkedList
after the current
one.
If the cursor is pointing at the null object then the new elements are
inserted at the start of the SinglyLinkedList
.
Note that if the cursor is not pointing to the last element of the
SinglyLinkedList
then the given list must be scanned to find its last
element. This has linear time complexity.
fn split_after(&mut self) -> SinglyLinkedList<A> where
A: Clone,
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 SinglyLinkedList
are moved.