Struct linked_list::List
source · pub struct List<G: AdapterWrapped> { /* private fields */ }
Expand description
A linked list.
Elements in the list are wrapped and ownership is transferred to the list while the element is in the list.
Implementations§
source§impl<G: AdapterWrapped> List<G>
impl<G: AdapterWrapped> List<G>
sourcepub fn push_back(&mut self, data: G::Wrapped)
pub fn push_back(&mut self, data: G::Wrapped)
Adds the given object to the end (back) of the list.
It is dropped if it’s already on this (or another) list; this can happen for reference-counted objects, so dropping means decrementing the reference count.
sourcepub unsafe fn insert_after(
&mut self,
existing: NonNull<G::EntryType>,
data: G::Wrapped
)
pub unsafe fn insert_after( &mut self, existing: NonNull<G::EntryType>, data: G::Wrapped )
Inserts the given object after existing
.
It is dropped if it’s already on this (or another) list; this can happen for reference-counted objects, so dropping means decrementing the reference count.
Safety
Callers must ensure that existing
points to a valid entry that is on the list.
sourcepub unsafe fn remove(&mut self, data: &G::Wrapped) -> Option<G::Wrapped>
pub unsafe fn remove(&mut self, data: &G::Wrapped) -> Option<G::Wrapped>
Removes the given entry.
Safety
Callers must ensure that data
is either on this list. It being on another
list leads to memory unsafety.
sourcepub fn pop_front(&mut self) -> Option<G::Wrapped>
pub fn pop_front(&mut self) -> Option<G::Wrapped>
Removes the element currently at the front of the list and returns it.
Returns None
if the list is empty.
sourcepub fn front(&self) -> Option<&G::EntryType>
pub fn front(&self) -> Option<&G::EntryType>
Returns the first element of the list, if one exists.
sourcepub fn back(&self) -> Option<&G::EntryType>
pub fn back(&self) -> Option<&G::EntryType>
Returns the last element of the list, if one exists.
sourcepub fn cursor_front(&self) -> Cursor<'_, G>
pub fn cursor_front(&self) -> Cursor<'_, G>
Returns a cursor starting on the first (front) element of the list.