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
Allocate a new element and move it to the end of the list
Note: This fails when we’re out of memory
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
Provides a forward iterator.
Provides a forward iterator with mutable references.
Provides a cursor with editing operation at the front element.
Trait Implementations
Auto Trait Implementations
impl<T, P> !Send for LinkedList<T, P>impl<T, P> !Sync for LinkedList<T, P>impl<T, P> Unpin for LinkedList<T, P>