pub struct ShortQueue<T, const N: usize>{ /* private fields */ }
Expand description
Implements a queue with a fixed maximum size. The queue access pattern and size are oblivious.
There are two trivial efficient ways to implement this for short queues:
- Use oblivious compaction:
- Push: n (2 + log n)
- Pop: n
- Iter: n
- Use timestamps:
- Push: n
- Pop: n
- Iter: n (1 + log^2 n)
This implementation uses timestamps (2.), as we only need push and pop for the unsorted map.
§Invariants
highest_timestamp
is the timestamp of the most recently added elementlowest_timestamp
is the timestamp of the oldest element added, or just non-zero if the queue is emptysize
is the number ofelements
with non-zero timestamps- an element in
elements
is valid if its timestamp is non-zero, in which case the timestamp is unique and in the range[lowest_timestamp, highest_timestamp]
Implementations§
Source§impl<T, const N: usize> ShortQueue<T, N>
impl<T, const N: usize> ShortQueue<T, N>
Trait Implementations§
Source§impl<T, const N: usize> Debug for ShortQueue<T, N>
impl<T, const N: usize> Debug for ShortQueue<T, N>
Source§impl<T, const N: usize> Default for ShortQueue<T, N>
impl<T, const N: usize> Default for ShortQueue<T, N>
Auto Trait Implementations§
impl<T, const N: usize> Freeze for ShortQueue<T, N>where
T: Freeze,
impl<T, const N: usize> RefUnwindSafe for ShortQueue<T, N>where
T: RefUnwindSafe,
impl<T, const N: usize> Send for ShortQueue<T, N>where
T: Send,
impl<T, const N: usize> Sync for ShortQueue<T, N>where
T: Sync,
impl<T, const N: usize> Unpin for ShortQueue<T, N>where
T: Unpin,
impl<T, const N: usize> UnwindSafe for ShortQueue<T, N>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more