Struct intrusive_collections::linked_list::LinkedList
[−]
[src]
pub struct LinkedList<A: Adaptor<Link>> { // some fields omitted }
An intrusive doubly-linked list.
Methods
impl<A: Adaptor<Link>> LinkedList<A>
[src]
fn new(adaptor: A) -> LinkedList<A>
Creates an empty LinkedList
.
fn is_empty(&self) -> bool
Returns true if the
LinkedList` is empty.
fn cursor(&self) -> Cursor<A>
Returns a null Cursor
for this list.
fn cursor_mut(&mut self) -> CursorMut<A>
Returns a null CursorMut
for this list.
unsafe fn cursor_from_ptr(&self, ptr: *const A::Container) -> Cursor<A>
Creates a Cursor
from a pointer to an element.
Safety
ptr
must be a pointer to an object that is part of this list.
unsafe fn cursor_mut_from_ptr(&mut self, ptr: *const A::Container) -> CursorMut<A>
Creates a CursorMut
from a pointer to an element.
Safety
ptr
must be a pointer to an object that is part of this list.
fn front(&self) -> Cursor<A>
Returns a Cursor
pointing to the first element of the list. If the
list is empty then a null cursor is returned.
fn front_mut(&mut self) -> CursorMut<A>
Returns a CursorMut
pointing to the first element of the list. If the
the list is empty then a null cursor is returned.
fn back(&self) -> Cursor<A>
Returns a Cursor
pointing to the last element of the list. If the list
is empty then a null cursor is returned.
fn back_mut(&mut self) -> CursorMut<A>
Returns a CursorMut
pointing to the last element of the list. If the
list is empty then a null cursor is returned.
fn iter(&self) -> Iter<A>
Gets an iterator over the objects in the LinkedList
.
fn drain<F>(&mut self, f: F) where F: FnMut(IntrusiveRef<A::Container>)
Calls the given function for each element in the LinkedList
before
removing it from the list.
This will unlink all objects currently in the list.
If the given function panics then all elements in the LinkedList
will
still be unlinked, but the function will not be called for any elements
after the one that panicked.
fn clear(&mut self)
Removes all elements from the LinkedList
.
This will unlink all object currently in the list, which requires
iterating through all elements in the LinkedList
.
fn fast_clear(&mut self)
Empties the LinkedList
without unlinking objects in it.
Since this does not unlink any objects, any attempts to link these
objects into another LinkedList
will fail but will not cause any
memory unsafety. To unlink those objects manually, you must call the
unsafe_unlink
function on them.
This is the only function that can be safely called after an object has
been moved or dropped while still being linked into this LinkedList
.
fn take(&mut self) -> LinkedList<A> where A: Clone
Takes all the elements out of the LinkedList
, leaving it empty. The
taken elements are returned as a new LinkedList
.
fn push_front(&mut self, val: IntrusiveRef<A::Container>)
Inserts a new element at the start of the LinkedList
.
fn push_back(&mut self, val: IntrusiveRef<A::Container>)
Inserts a new element at the end of the LinkedList
.
fn pop_front(&mut self) -> Option<IntrusiveRef<A::Container>>
Removes the first element of the LinkedList
.
This returns None
if the LinkedList
is empty.
fn pop_back(&mut self) -> Option<IntrusiveRef<A::Container>>
Removes the last element of the LinkedList
.
This returns None
if the LinkedList
is empty.
Trait Implementations
impl<A: Adaptor<Link> + Sync> Sync for LinkedList<A> where A::Container: Sync
[src]
impl<A: Adaptor<Link> + Send> Send for LinkedList<A> where A::Container: Send + Sync
[src]
impl<'a, A: Adaptor<Link> + 'a> IntoIterator for &'a LinkedList<A>
[src]
type Item = &'a A::Container
The type of the elements being iterated over.
type IntoIter = Iter<'a, A>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Iter<'a, A>
Creates an iterator from a value. Read more
impl<A: Adaptor<Link> + Default> Default for LinkedList<A>
[src]
fn default() -> LinkedList<A>
Returns the "default value" for a type. Read more