# Module heapless::sorted_linked_list

source ·
Expand description

A fixed sorted priority linked list, similar to `BinaryHeap` but with different properties on `push`, `pop`, etc. For example, the sorting of the list will never `memcpy` the underlying value, so having large objects in the list will not cause a performance hit.

## Examples

    use heapless::sorted_linked_list::{SortedLinkedList, Max};
    let mut ll: SortedLinkedList<_, _, Max, 3> = SortedLinkedList::new_usize();

    // The largest value will always be first
    ll.push(1).unwrap();
    assert_eq!(ll.peek(), Some(&1));

    ll.push(2).unwrap();
    assert_eq!(ll.peek(), Some(&2));

    ll.push(3).unwrap();
    assert_eq!(ll.peek(), Some(&3));

    // This will not fit in the queue.
    assert_eq!(ll.push(4), Err(4));

## Structs

- FindMut
  Comes from `SortedLinkedList::find_mut`.
- Iter
  Iterator for the linked list.
- LinkedIndexU8
  Index for the `SortedLinkedList` with specific backing storage.
- LinkedIndexU16
  Index for the `SortedLinkedList` with specific backing storage.
- LinkedIndexUsize
  Index for the `SortedLinkedList` with specific backing storage.
- Max
  Marker for Max sorted `SortedLinkedList`.
- Min
  Marker for Min sorted `SortedLinkedList`.
- Node
  A node in the `SortedLinkedList`.
- SortedLinkedList
  The linked list.

## Traits

- Kind
  The linked list kind: min-list or max-list
- SortedLinkedListIndex
  Trait for defining an index for the linked list, never implemented by users.