Constructor takes an optional capacity
parameter. If set,
the Stack won't accept new elements after the lengths reache
the capacity, until an element is removed.
The maximum queue length before overflow.
The maximum elements the structure can contain.
It can be set via the constructor or setCapacity
.
Default value is -1
(no limit).
The current amount of elements.
Returns the stack's top element without popping it.
Removes the first element and returns its value or undefined
if it
failed (empty stack).
The value of the removed element or undefined
if it failed.
Adds an element to the front of the stack and returns its length. If the length already reached the (optional) capacity, push is not performed and returns -1.
The value associed to the pushed element.
The length of the current Queue after insertion,
or -1
if it failed.
Generated using TypeDoc
Stack implementation based on a linked list. Its elements are managed by two methods
push
andpop
. It implements the CappedStructure interface to handle overflow of acapacity
is set.