pub struct DLinkedList<P, Tag>{ /* private fields */ }dlist only.Expand description
An intrusive doubly linked list.
Supports O(1) insertion and removal at both ends.
Implementations§
Source§impl<P, Tag> DLinkedList<P, Tag>
impl<P, Tag> DLinkedList<P, Tag>
Sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Clears the list, dropping all of its elements if the pointer type P owns them.
Sourcepub unsafe fn remove_node(&mut self, item: &P::Target)
pub unsafe fn remove_node(&mut self, item: &P::Target)
Remove a node from the middle of the list
NOTE: Due to we need to support Arc, item should be immutable reference.
§Safety
The item must be already in the list, otherwise will lead to UB.
Sourcepub unsafe fn peak(&mut self, item: &P::Target)
pub unsafe fn peak(&mut self, item: &P::Target)
Moves a node to the front of the list (e.g., for LRU updates).
NOTE: Due to we need to support Arc, item should be immutable reference.
§Safety
The item must be in the list, otherwise will lead to UB.
Sourcepub fn push_front(&mut self, item: P)
pub fn push_front(&mut self, item: P)
Pushes an element to the front of the list.
Sourcepub fn pop_front(&mut self) -> Option<P>
pub fn pop_front(&mut self) -> Option<P>
Removes and returns the element at the front of the list.
Sourcepub fn pop_back(&mut self) -> Option<P>
pub fn pop_back(&mut self) -> Option<P>
Removes and returns the element at the back of the list.
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.
pub fn print<U: Debug>(&self)
std only.Sourcepub fn iter<'a>(&'a self) -> DLinkedListIterator<'a, P, Tag> ⓘ
pub fn iter<'a>(&'a self) -> DLinkedListIterator<'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) -> DLinkedListDrainer<'a, P, Tag> ⓘ
pub fn drain<'a>(&'a mut self) -> DLinkedListDrainer<'a, P, Tag> ⓘ
Returns a draining iterator that removes items from the list.
Crucial for cleaning up lists containing owned pointers (like Box).
§Note
The iterator removes elements from the front of the list (FIFO order),