pub struct SLinkedList<P, Tag>{ /* private fields */ }slist only.Expand description
A singly linked list with head and tail pointers (FIFO queue).
Supports O(1) push to back and pop from front.
Implementations§
Source§impl<P, Tag> SLinkedList<P, Tag>
impl<P, Tag> SLinkedList<P, Tag>
Sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Clears the list pointers. Note: This does NOT drop the elements.
Use drain or drop if you need to release owned resources.
Sourcepub fn get_length(&self) -> u64
pub fn get_length(&self) -> u64
Returns the length of the list.
Sourcepub fn push_back(&mut self, item: P)
pub fn push_back(&mut self, item: P)
Appends an element to the back of the list (FIFO: enqueue).
Sourcepub fn pop_front(&mut self) -> Option<P>
pub fn pop_front(&mut self) -> Option<P>
Removes the first element and returns it (FIFO: dequeue).
Sourcepub fn is_front(&self, node: &P::Target) -> bool
pub fn is_front(&self, node: &P::Target) -> bool
Checks if the given node is the head of the list.
Sourcepub fn iter<'a>(&'a self) -> SLinkedListIterator<'a, P, Tag> ⓘ
pub fn iter<'a>(&'a self) -> SLinkedListIterator<'a, P, Tag> ⓘ
Returns an iterator over the list (borrowed).
§NOTE
If you plan on turn the raw pointer to owned, use drain instead
§Safety
The caller must ensure that the list is not modified in a way that can invalidate internal pointers (such as removing elements or dropping items) for the duration of the iterator’s use.
Sourcepub fn drain<'a>(&'a mut self) -> SLinkedListDrainer<'a, P, Tag> ⓘ
pub fn drain<'a>(&'a mut self) -> SLinkedListDrainer<'a, P, Tag> ⓘ
Returns a draining iterator that removes items from the list.