npm.io
1.0.0 • Published 5 years ago

js-data-structure-library

Licence
ISC
Version
1.0.0
Deps
1
Size
11 kB
Vulns
0
Weekly
0

js-data-structure-library

Stack

methods

  • push: add an element to the end of this stack
  • pop: delete an element from the end of this stack
  • peek: return the front element of this stack
  • isEmpty: return this stack is empty or not
  • clear: clear all elements of this stack
  • size: return length of this stack
  • toString: to show elements of this stack
How to use?

you can use Stack like this:

const stack = new Stack<number>()
stack.push(1)
stack.push(2)
stack.pop()
stack.peek() // 1
stack.isEmpty() // false
stack.size() // 1
stack.clear()
stack.size() // 0

Keywords