pub struct LinkedList<T> { /* private fields */ }
Expand description

A doubly-linked list owning its nodes.

Based on std::collections::LinkedList and https://rust-unofficial.github.io/too-many-lists.

Examples

Create a new list:

let mut list_a = LinkedList::new();
let mut list_b = LinkedList::new();

Add element to the end of a list with an allocator:

static ALLOCATOR: Bump = unsafe { Bump::new(NonNull::new_unchecked(0x2001E000 as *mut u8), 5_000) };
list_a.emplace_back(MyStruct { id: 42 }, &ALLOCATOR);
list_a.emplace_back(MyStruct { id: 54 }, &ALLOCATOR);

Nodes in the same list can be allocated in different memory sections.

Move an element from one to another list:

let node = list_a.pop_front();
list_a.push_back(node);

Implementations

Create an empty list

Allocate a new element and move it to the end of the list

Note: This fails when we’re out of memory

Insert a node at the end on the list

Remove and return the first node from the list if there is any

Insert a node exactly before a given node

Note: prefer Self::insert_when() if possible

Insert a node before the first succeeding match given a comparison criteria.

Example

Insert task pausing before the element where the next wake-up time next_wut() is larger than the one of pausing.

/* create and populate list */
let pausing: Task = /* omitted */;
tasks_sleeping.insert_when(
    pausing,
    |pausing, task| {
        pausing.next_wut() > task.next_wut()
    });

Get a reference to the first value of the list if there is a node

Get a reference to last value of the list if there is a node

Get the current length of the list

Provides a forward iterator.

Provides a forward iterator with mutable references.

Provides a cursor with editing operation at the front element.

Trait Implementations

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.