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 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 unsafe fn peak(&mut self, ptr: *mut P::Target)
pub unsafe fn peak(&mut self, ptr: *mut P::Target)
Moves a node to the front of the list (e.g., for LRU updates).
§Safety
The pointer ptr must be valid and pointing to an element currently in the list
or a valid free element if properly managed (though typically used for re-ordering).
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),