pub struct Stack<T>{ /* private fields */ }
Expand description
Implements a stack with a fixed maximum size. The stack access pattern and size are oblivious. The stack is implemented as a linked list on top of NRORAM.
§Invariants
-
- The linked list of elements is in monotonic decreasing order of Ids.
Implementations§
Source§impl<T> Stack<T>
impl<T> Stack<T>
Sourcepub fn maybe_push(&mut self, real: bool, value: T)
pub fn maybe_push(&mut self, real: bool, value: T)
Pushes a new element on the stack if real
is true.
If real
is false, the element is not pushed and the stack size is not incremented.
Sourcepub fn maybe_pop(&mut self, real: bool, out: &mut T)
pub fn maybe_pop(&mut self, real: bool, out: &mut T)
Pops the top element from the stack if real
is true.
The popped element is returned in out
.
The stack size is decremented by 1 if real
is true.
If real
is false, the element is not popped, the stack size is not decremented, and out
is not modified.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Stack<T>
impl<T> !RefUnwindSafe for Stack<T>
impl<T> !Send for Stack<T>
impl<T> !Sync for Stack<T>
impl<T> Unpin for Stack<T>where
T: Unpin,
impl<T> !UnwindSafe for Stack<T>
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