Struct nt_list::list::NtListHead
source · #[repr(C)]pub struct NtListHead<E: NtListElement<L>, L: NtTypedList<T = NtList>> { /* private fields */ }
Expand description
A doubly linked list header compatible to LIST_ENTRY
of the Windows NT API.
This variant requires elements to be allocated beforehand on a stable address and be
valid as long as the list is used.
As the Rust compiler cannot guarantee the validity of them, almost all NtListHead
functions are unsafe
.
You almost always want to use NtBoxingListHead
over this.
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> NtListHead<E, L>
impl<E, L> NtListHead<E, L>
sourcepub fn new() -> impl New<Output = Self>
pub fn new() -> impl New<Output = Self>
Creates a new doubly linked list.
This function substitutes InitializeListHead
of the Windows NT API.
sourcepub unsafe fn append(self: Pin<&mut Self>, other: Pin<&mut Self>)
pub unsafe 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 unsafe fn back(self: Pin<&Self>) -> Option<&E>
pub unsafe 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 unsafe fn back_mut(self: Pin<&mut Self>) -> Option<&mut E>
pub unsafe 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.
This operation computes in O(1) time, because it only resets the forward and backward links of the header.
sourcepub unsafe fn front(self: Pin<&Self>) -> Option<&E>
pub unsafe 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 unsafe fn front_mut(self: Pin<&mut Self>) -> Option<&mut E>
pub unsafe 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 unsafe fn iter(self: Pin<&Self>) -> Iter<'_, E, L> ⓘ
pub unsafe fn iter(self: Pin<&Self>) -> Iter<'_, E, L> ⓘ
Returns an iterator yielding references to each element of the list.
sourcepub unsafe fn iter_mut(self: Pin<&mut Self>) -> IterMut<'_, E, L> ⓘ
pub unsafe fn iter_mut(self: Pin<&mut Self>) -> IterMut<'_, E, L> ⓘ
Returns an iterator yielding mutable references to each element of the list.
sourcepub unsafe fn len(self: Pin<&Self>) -> usize
pub unsafe fn len(self: Pin<&Self>) -> usize
Counts all elements and returns the length of the list.
This operation computes in O(n) time.
sourcepub unsafe fn pop_back(self: Pin<&mut Self>) -> Option<&mut E>
pub unsafe fn pop_back(self: Pin<&mut Self>) -> Option<&mut 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 unsafe fn pop_front(self: Pin<&mut Self>) -> Option<&mut E>
pub unsafe fn pop_front(self: Pin<&mut Self>) -> Option<&mut 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 unsafe fn push_back(self: Pin<&mut Self>, element: &mut E)
pub unsafe fn push_back(self: Pin<&mut Self>, element: &mut 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 unsafe fn push_front(self: Pin<&mut Self>, element: &mut E)
pub unsafe fn push_front(self: Pin<&mut Self>, element: &mut 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 unsafe fn retain<F>(self: Pin<&mut Self>, f: F)
pub unsafe 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.