Stack

Stack

new Stack()

Create a FILO stack data structure.
Source:

Methods

clear()

Clear the contents of the stack.
Source:

hasNext() → {boolean}

Checks if the stack isn't empty.
Source:
Returns:
Whether or not the stack has another element. True if yes.
Type
boolean

isEmpty() → {boolean}

Checks if the stack is empty.
Source:
Returns:
Whether or not the stack is empty. True if yes.
Type
boolean

peek() → {object}

Get the front element of the stack without removing it from the stack.
Source:
Returns:
Front element from the stack.
Type
object

pop() → {object}

Get the front element of the stack and removes it from the stack.
Source:
Returns:
Front element from the stack.
Type
object

push(obj)

Push an object in to the stack.
Parameters:
Name Type Description
obj object Any object to be pushed into the stack.
Source:

size() → {number}

Get the number of objects in the stack.
Source:
Returns:
Number of elements in the stack.
Type
number