pub(crate) struct LinkedList<L, T> {
head: Option<NonNull<T>>,
tail: Option<NonNull<T>>,
_marker: PhantomData<*const L>,
}Expand description
An intrusive linked list.
Currently, the list is not emptied on drop. It is the caller’s responsibility to ensure the list is empty before dropping it.
Fields§
§head: Option<NonNull<T>>Linked list head
tail: Option<NonNull<T>>Linked list tail
_marker: PhantomData<*const L>Node type marker.
Implementations§
Source§impl<L, T> LinkedList<L, T>
impl<L, T> LinkedList<L, T>
Sourcepub(crate) const fn new() -> LinkedList<L, T>
pub(crate) const fn new() -> LinkedList<L, T>
Creates an empty linked list.
Source§impl<L: Link> LinkedList<L, L::Target>
impl<L: Link> LinkedList<L, L::Target>
Sourcepub(crate) fn push_front(&mut self, val: L::Handle)
pub(crate) fn push_front(&mut self, val: L::Handle)
Adds an element first in the list.
Sourcepub(crate) fn pop_front(&mut self) -> Option<L::Handle>
pub(crate) fn pop_front(&mut self) -> Option<L::Handle>
Removes the first element from a list and returns it, or None if it is empty.
Sourcepub(crate) fn pop_back(&mut self) -> Option<L::Handle>
pub(crate) fn pop_back(&mut self) -> Option<L::Handle>
Removes the last element from a list and returns it, or None if it is empty.
Sourcepub(crate) fn is_empty(&self) -> bool
pub(crate) fn is_empty(&self) -> bool
Returns whether the linked list does not contain any node
Sourcepub(crate) unsafe fn remove(
&mut self,
node: NonNull<L::Target>,
) -> Option<L::Handle>
pub(crate) unsafe fn remove( &mut self, node: NonNull<L::Target>, ) -> Option<L::Handle>
Removes the specified node from the list
§Safety
The caller must ensure that exactly one of the following is true:
nodeis currently contained byself,nodeis not contained by any list,nodeis currently contained by some otherGuardedLinkedListand the caller has an exclusive access to that list. This condition is used by the linked list insync::Notify.
Source§impl<T: Link> LinkedList<T, T::Target>
impl<T: Link> LinkedList<T, T::Target>
pub(crate) fn drain_filter<F>(&mut self, filter: F) -> DrainFilter<'_, T, F> ⓘ
Source§impl<L: Link> LinkedList<L, L::Target>
impl<L: Link> LinkedList<L, L::Target>
Sourcepub(crate) fn into_guarded(
self,
guard_handle: L::Handle,
) -> GuardedLinkedList<L, L::Target>
pub(crate) fn into_guarded( self, guard_handle: L::Handle, ) -> GuardedLinkedList<L, L::Target>
Turns a linked list into the guarded version by linking the guard node with the head and tail nodes. Like with other nodes, you should guarantee that the guard node is pinned in memory.