Options
All
  • Public
  • Public/Protected
  • All
Menu

LIFO(Last In First Out) data structure.

const stack = new Stack();
stack.push(123);
console.log(stack.pop()); // 123

Type parameters

  • T

Hierarchy

  • Stack

Index

Constructors

Properties

Methods

Constructors

constructor

Properties

Protected _values

_values: T[]

Methods

peek

  • peek(): T
  • Returns top value of the stack. Throws an error if the stack is empty.

    Returns T

pop

  • pop(): T
  • Returns top value of the stack and remove it. Throws an error if the stack is empty.

    Returns T

push

  • push(value: T): void

Generated using TypeDoc