#[repr(C)]pub struct FixedSizeQueue<T, const CAPACITY: usize> { /* private fields */ }Expand description
Relocatable queue with compile time fixed size capacity. In contrast to its counterpart the
Queue it is movable.
Implementations§
Source§impl<T, const CAPACITY: usize> FixedSizeQueue<T, CAPACITY>
impl<T, const CAPACITY: usize> FixedSizeQueue<T, CAPACITY>
Sourcepub fn peek(&self) -> Option<&T>
pub fn peek(&self) -> Option<&T>
Returns a reference to the element from the beginning of the queue without removing it.
If the queue is empty it returns None.
Sourcepub fn peek_mut(&mut self) -> Option<&mut T>
pub fn peek_mut(&mut self) -> Option<&mut T>
Returns a mutable reference to the element from the beginning of the queue without removing it.
If the queue is empty it returns None.
Sourcepub fn pop(&mut self) -> Option<T>
pub fn pop(&mut self) -> Option<T>
Removes the element from the beginning of the queue. If the queue is empty it returns None.
Sourcepub fn push(&mut self, value: T) -> bool
pub fn push(&mut self, value: T) -> bool
Adds an element at the end of the queue. If the queue is full it returns false, otherwise true.
Sourcepub fn push_with_overflow(&mut self, value: T) -> Option<T>
pub fn push_with_overflow(&mut self, value: T) -> Option<T>
Adds an element at the end of the queue. If the queue is full it returns the oldest element,
otherwise None.
Source§impl<T: Copy + Debug, const CAPACITY: usize> FixedSizeQueue<T, CAPACITY>
impl<T: Copy + Debug, const CAPACITY: usize> FixedSizeQueue<T, CAPACITY>
Sourcepub unsafe fn get_unchecked(&self, index: usize) -> T
pub unsafe fn get_unchecked(&self, index: usize) -> T
Returns a copy of the element stored at index. The index is starting by 0 for the first
element until FixedSizeQueue::len().
§Safety
- The index must be not out of bounds
Sourcepub fn get(&self, index: usize) -> T
pub fn get(&self, index: usize) -> T
Returns a copy of the element stored at index. The index is starting by 0 for the first
element until FixedSizeQueue::len().
Trait Implementations§
Source§impl<T, const CAPACITY: usize> Default for FixedSizeQueue<T, CAPACITY>
impl<T, const CAPACITY: usize> Default for FixedSizeQueue<T, CAPACITY>
Source§impl<T, const CAPACITY: usize> PlacementDefault for FixedSizeQueue<T, CAPACITY>
impl<T, const CAPACITY: usize> PlacementDefault for FixedSizeQueue<T, CAPACITY>
Source§unsafe fn placement_default(ptr: *mut Self)
unsafe fn placement_default(ptr: *mut Self)
Default::default(). Read more