Struct BinaryHeap

Source
pub struct BinaryHeap<T, const N: usize> { /* private fields */ }
Expand description

An array-based binary heap, with N elements stored inline.

Implementations§

Source§

impl<T: Clone + Copy + Ord, const N: usize> BinaryHeap<T, N>

Source

pub const fn new() -> Self

Create a new empty binary heap.

Source

pub fn push(&mut self, value: T) -> Result<(), KernelError>

Push a value onto the binary heap.

value - The value to push onto the binary heap.

Returns Ok(()) if the value was pushed onto the binary heap, or an error if the heap cannot be extended (e.g. OOM).

Source

pub fn pop(&mut self) -> Option<T>

Pop the smallest value from the binary heap.

Returns the smallest value in the binary heap, or None if the heap is empty.

Source

pub fn is_empty(&self) -> bool

Check if the binary heap is empty.

Returns true if the binary heap is empty, false otherwise.

Source

pub fn peek(&self) -> Option<&T>

Peek at the smallest value in the binary heap.

Returns the smallest value in the binary heap, or None if the heap is empty.

Source

pub fn len(&self) -> usize

Get the number of elements in the binary heap.

Auto Trait Implementations§

§

impl<T, const N: usize> Freeze for BinaryHeap<T, N>
where T: Freeze,

§

impl<T, const N: usize> RefUnwindSafe for BinaryHeap<T, N>
where T: RefUnwindSafe,

§

impl<T, const N: usize> !Send for BinaryHeap<T, N>

§

impl<T, const N: usize> !Sync for BinaryHeap<T, N>

§

impl<T, const N: usize> Unpin for BinaryHeap<T, N>
where T: Unpin,

§

impl<T, const N: usize> UnwindSafe for BinaryHeap<T, N>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.