Keyboard shortcuts

Press or to navigate between chapters

Press ? to show this help

Press Esc to hide this help

StackTrait

Fully qualified path: alexandria_data_structures::stack::StackTrait

pub trait StackTrait<S, T>

Trait functions

new

Creates a new Stack instance.

Fully qualified path: alexandria_data_structures::stack::StackTrait::new

fn new() -> S

push

Pushes a new value onto the stack.

Arguments

  • self - The stack to push the value onto
  • value - The value to push onto the stack

Fully qualified path: alexandria_data_structures::stack::StackTrait::push

fn push(ref self: S, value: T)

pop

Removes the last item from the stack and returns it, or None if the stack is empty.

Arguments

  • self - The stack to pop the item from

Fully qualified path: alexandria_data_structures::stack::StackTrait::pop

fn pop(ref self: S) -> Option<T>

peek

Returns the last item from the stack without removing it, or None if the stack is empty.

Arguments

  • self - The stack to peek at

Fully qualified path: alexandria_data_structures::stack::StackTrait::peek

fn peek(ref self: S) -> Option<T>

len

Returns the number of items in the stack.

Arguments

  • self - The stack to get the length of

Fully qualified path: alexandria_data_structures::stack::StackTrait::len

fn len(self: @S) -> u32

is_empty

Returns true if the stack is empty.

Arguments

  • self - The stack to check if it is empty

Fully qualified path: alexandria_data_structures::stack::StackTrait::is_empty

fn is_empty(self: @S) -> bool