Skip to main content

Stack

A last-in, first-out (LIFO) data structure.

Interactive Visualization

Loading visualization…

Usage

src/sample/stack.ts
import { Stack } from 'athro';

const stack = new Stack<number>();
stack.push(3);
stack.push(7);
stack.pop();

Available Methods

MethodsDescriptionSyntax
pushAdd item to the stackstack.push(value)
popRemove item from the stackstack.pop()
topGet the item at the topstack.top()
isEmptyCheck if the stack is emptystack.isEmpty()
getSizeGet size of the stackstack.getSize()