Struct bern_kernel::mem::linked_list::LinkedList[][src]

pub struct LinkedList<T, P> where
    P: PoolAllocator<Node<T>> + 'static, 
{ /* fields omitted */ }
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 with ArrayPool allocator:

static POOL: ArrayPool<Node<MyStruct>,16> = ArrayPool::new([None; 16]);
let mut list_a = LinkedList::new(&POOL);
let mut list_b = LinkedList::new(&POOL);

Add element to the end of a list:

list_a.emplace_back(MyStruct { id: 42 });
list_a.emplace_back(MyStruct { id: 54 });

Move an element from one to another list:

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

Implementations

Create a new list from an allocator

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 failed 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

Performs the conversion.

Performs the conversion.

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.