Stack
Stack containers for simple FILO data structures.
Constructor Summary
Public Constructor | ||
public |
Constructs a Stack instance. |
Member Summary
Public Members | ||
public get |
Getter for size, allows access as a property |
|
public |
stack: * |
Method Summary
Public Methods | ||
public |
clear() Clear the stack. |
|
public |
Helper function to loop through all items in the stack. |
|
public |
Check if the stack contains the specified item. |
|
public |
peek(): * Get the item at the top of the stack. |
|
public |
pop(): * Get and remove the item at the top of the stack. |
|
public |
push(item: *) Add item to the top of the stack. |
Public Constructors
Public Members
public stack: * source
Public Methods
public forEach(callback: function(item: *): boolean) source
Helper function to loop through all items in the stack.
public has(item: *): boolean source
Check if the stack contains the specified item.
Params:
Name | Type | Attribute | Description |
item | * | Item to check. |
Throw:
Throws an error if checking null or undefined. |
public peek(): * source
Get the item at the top of the stack.
Return:
* (nullable: true) | Item at the top of the stack, or null if the stack is empty. |
public pop(): * source
Get and remove the item at the top of the stack.
Return:
* (nullable: true) | Item at the top of the stack, or null if the stack is empty. |