Struct nt_list::single_list::NtBoxingSingleListHead
source · pub struct NtBoxingSingleListHead<E: NtBoxedListElement<L = L> + NtListElement<L>, L: NtTypedList<T = NtSingleList>>(/* private fields */);
alloc
only.Expand description
A variant of NtSingleListHead
that boxes every element on insertion.
This guarantees ownership and therefore all NtBoxingSingleListHead
functions can be used without
resorting to unsafe
.
If you can, use this implementation over NtSingleListHead
.
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 SINGLE_LIST_ENTRY
structure of the Windows NT API for the list header.
Implementations§
source§impl<E, L> NtBoxingSingleListHead<E, L>
impl<E, L> NtBoxingSingleListHead<E, L>
sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Removes all elements from the list, deallocating their memory.
Unlike NtSingleListHead::clear
, this operation computes in O(n) time, because it
needs to traverse all elements to deallocate them.
sourcepub fn front(&self) -> Option<&E>
pub fn front(&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(&mut self) -> Option<&mut E>
pub fn front_mut(&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) -> bool
pub fn is_empty(&self) -> bool
Returns true
if the list is empty.
This operation computes in O(1) time.
sourcepub fn iter(&self) -> Iter<'_, E, L> ⓘ
pub fn iter(&self) -> Iter<'_, E, L> ⓘ
Returns an iterator yielding references to each element of the list.
sourcepub fn iter_mut(&mut self) -> IterMut<'_, E, L> ⓘ
pub fn iter_mut(&mut self) -> IterMut<'_, E, L> ⓘ
Returns an iterator yielding mutable references to each element of the list.
sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Counts all elements and returns the length of the list.
This operation computes in O(n) time.
sourcepub fn pop_front(&mut self) -> Option<Box<E>>
pub fn pop_front(&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 PopEntryList
of the Windows NT API.
This operation computes in O(1) time.
sourcepub fn push_front(&mut self, element: E)
pub fn push_front(&mut self, element: E)
Appends an element to the front of the list.
This function substitutes PushEntryList
of the Windows NT API.
This operation computes in O(1) time.
sourcepub fn retain<F>(&mut self, f: F)
pub fn retain<F>(&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 operation computes in O(n) time.