Struct linked_list::Cursor [] [src]

pub struct Cursor<'a, T: 'a> { /* fields omitted */ }

A Cursor is like an iterator, except that it can freely seek back-and-forth, and can safely mutate the list during iteration. This is because the lifetime of its yielded references are tied to its own lifetime, instead of just the underlying list. This means cursors cannot yield multiple elements at once.

Cursors always rest between two elements in the list, and index in a logically circular way. To accomadate this, there is a "ghost" non-element that yields None between the head and tail of the List.

When created, cursors start between the ghost and the front of the list. That is, next will yield the front of the list, and prev will yield None. Calling prev again will yield the tail.

Methods

impl<'a, T> Cursor<'a, T>
[src]

Resets the cursor to lie between the first and last element in the list.

Gets the next element in the list.

Gets the previous element in the list.

Gets the next element in the list, without moving the cursor head.

Gets the previous element in the list, without moving the cursor head.

Inserts an element at the cursor's location in the list, and moves the cursor head to lie before it. Therefore, the new element will be yielded by the next call to next.

Removes the next element in the list, without moving the cursor. Returns None if the list is empty, or if next is the ghost element

Inserts the entire list's contents right after the cursor.

Calls next the specified number of times.

Calls prev the specified number of times.