pub struct NtBoxingListHead<E: NtBoxedListElement<L = L> + NtListElement<L>, L: NtTypedList<T = NtList>>(/* private fields */);
alloc
only.Expand description
A variant of NtListHead
that boxes every element on insertion.
This guarantees ownership and therefore all NtBoxingListHead
functions can be used without
resorting to unsafe
.
If you can, use this implementation over NtListHead
.
You need to implement the NtBoxedListElement
trait to designate a single list as the boxing one.
This also establishes clear ownership when a single element is part of more than one list.
See the module-level documentation for more details.
This structure substitutes the LIST_ENTRY
structure of the Windows NT API for the list header.
Implementations§
Source§impl<E, L> NtBoxingListHead<E, L>
impl<E, L> NtBoxingListHead<E, L>
Sourcepub fn new() -> impl New<Output = Self>
pub fn new() -> impl New<Output = Self>
Creates a new doubly linked list that owns all elements.
This function substitutes InitializeListHead
of the Windows NT API.
Sourcepub fn append(self: Pin<&mut Self>, other: Pin<&mut Self>)
pub fn append(self: Pin<&mut Self>, other: Pin<&mut Self>)
Moves all elements from other
to the end of the list.
This reuses all the nodes from other
and moves them into self
.
After this operation, other
becomes empty.
This operation computes in O(1) time.
Sourcepub fn back(self: Pin<&Self>) -> Option<&E>
pub fn back(self: Pin<&Self>) -> Option<&E>
Provides a reference to the last element, or None
if the list is empty.
This operation computes in O(1) time.
Sourcepub fn back_mut(self: Pin<&mut Self>) -> Option<&mut E>
pub fn back_mut(self: Pin<&mut Self>) -> Option<&mut E>
Provides a mutable reference to the last element, or None
if the list is empty.
This operation computes in O(1) time.
Sourcepub fn clear(self: Pin<&mut Self>)
pub fn clear(self: Pin<&mut Self>)
Removes all elements from the list, deallocating their memory.
Unlike NtListHead::clear
, this operation computes in O(n) time, because it
needs to traverse all elements to deallocate them.
Sourcepub fn front(self: Pin<&Self>) -> Option<&E>
pub fn front(self: Pin<&Self>) -> Option<&E>
Provides a reference to the first element, or None
if the list is empty.
This operation computes in O(1) time.
Sourcepub fn front_mut(self: Pin<&mut Self>) -> Option<&mut E>
pub fn front_mut(self: Pin<&mut Self>) -> Option<&mut E>
Provides a mutable reference to the first element, or None
if the list is empty.
This operation computes in O(1) time.
Sourcepub fn is_empty(self: Pin<&Self>) -> bool
pub fn is_empty(self: Pin<&Self>) -> bool
Returns true
if the list is empty.
This function substitutes IsListEmpty
of the Windows NT API.
This operation computes in O(1) time.
Sourcepub fn iter(self: Pin<&Self>) -> Iter<'_, E, L> ⓘ
pub fn iter(self: Pin<&Self>) -> Iter<'_, E, L> ⓘ
Returns an iterator yielding references to each element of the list.
Sourcepub fn iter_mut(self: Pin<&mut Self>) -> IterMut<'_, E, L> ⓘ
pub fn iter_mut(self: Pin<&mut Self>) -> IterMut<'_, E, L> ⓘ
Returns an iterator yielding mutable references to each element of the list.
Sourcepub fn len(self: Pin<&Self>) -> usize
pub fn len(self: Pin<&Self>) -> usize
Counts all elements and returns the length of the list.
This operation computes in O(n) time.
Sourcepub fn pop_back(self: Pin<&mut Self>) -> Option<Box<E>>
pub fn pop_back(self: Pin<&mut Self>) -> Option<Box<E>>
Removes the last element from the list and returns it, or None
if the list is empty.
This function substitutes RemoveTailList
of the Windows NT API.
This operation computes in O(1) time.
Sourcepub fn pop_front(self: Pin<&mut Self>) -> Option<Box<E>>
pub fn pop_front(self: Pin<&mut Self>) -> Option<Box<E>>
Removes the first element from the list and returns it, or None
if the list is empty.
This function substitutes RemoveHeadList
of the Windows NT API.
This operation computes in O(1) time.
Sourcepub fn push_back(self: Pin<&mut Self>, element: E)
pub fn push_back(self: Pin<&mut Self>, element: E)
Appends an element to the back of the list.
This function substitutes InsertTailList
of the Windows NT API.
This operation computes in O(1) time.
Sourcepub fn push_front(self: Pin<&mut Self>, element: E)
pub fn push_front(self: Pin<&mut Self>, element: E)
Appends an element to the front of the list.
This function substitutes InsertHeadList
of the Windows NT API.
This operation computes in O(1) time.
Sourcepub fn retain<F>(self: Pin<&mut Self>, f: F)
pub fn retain<F>(self: Pin<&mut Self>, f: F)
Retains only the elements specified by the predicate, passing a mutable reference to it.
In other words, remove all elements e
for which f(&mut e)
returns false
.
This method operates in place, visiting each element exactly once in the original order,
and preserves the order of the retained elements.
This function substitutes RemoveEntryList
of the Windows NT API.
This operation computes in O(n) time.
Trait Implementations§
Source§impl<E, L> Drop for NtBoxingListHead<E, L>
impl<E, L> Drop for NtBoxingListHead<E, L>
Source§impl<E, L> Extend<Box<E>> for Pin<&mut NtBoxingListHead<E, L>>
impl<E, L> Extend<Box<E>> for Pin<&mut NtBoxingListHead<E, L>>
Source§fn extend<T>(&mut self, iter: T)where
T: IntoIterator<Item = Box<E>>,
fn extend<T>(&mut self, iter: T)where
T: IntoIterator<Item = Box<E>>,
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)Source§impl<E, L> Extend<E> for Pin<&mut NtBoxingListHead<E, L>>
impl<E, L> Extend<E> for Pin<&mut NtBoxingListHead<E, L>>
Source§fn extend<T>(&mut self, iter: T)where
T: IntoIterator<Item = E>,
fn extend<T>(&mut self, iter: T)where
T: IntoIterator<Item = E>,
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)