Typed API (TypeDoc) / IStack
Interface: IStack<E>
Defined in: stack.ts:13
Extends
ICollection<E>
Extended by
Type Parameters
E
E
Value type.
Properties
comparator
comparator:
Comparator<E>
Defined in: index.ts:142
Comparator used for equality/sort checks.
Inherited from
size
size:
number
Defined in: index.ts:146
Current element count.
Inherited from
Methods
add()
add(
element):void
Defined in: index.ts:153
Append an element.
Parameters
element
E
Returns
void
Remarks
Complexity: Amortized O(1) unless stated otherwise.
Inherited from
addAll()
addAll(
collection):void
Defined in: index.ts:160
Append every element from another collection.
Parameters
collection
ICollection<E>
Returns
void
Remarks
Complexity: O(n + m) where m is collection.size.
Inherited from
clear()
clear():
void
Defined in: index.ts:178
Remove all entries.
Returns
void
Remarks
Complexity: O(n)
Inherited from
contains()
contains(
element):boolean
Defined in: index.ts:192
Test membership using the comparator when available.
Parameters
element
E
Returns
boolean
Remarks
Complexity: O(n) worst case
Inherited from
isEmpty()
isEmpty():
boolean
Defined in: index.ts:185
Check for emptiness.
Returns
boolean
true when size === 0.
Inherited from
pop()
pop():
E
Defined in: stack.ts:29
Pop and return the top value.
Returns
E
Removed value.
Throws
When empty.
Remarks
Complexity: O(1)
push()
push(
e):void
Defined in: stack.ts:20
Push a value on top.
Parameters
e
E
Value to push.
Returns
void
Remarks
Complexity: O(1)
remove()
remove(
e,isIndex?):number|E
Defined in: index.ts:171
Remove by value or index.
Parameters
e
Element or index.
number | E
isIndex?
boolean
When true, treat e as index.
Returns
number | E
Removed element or index of removal.
Throws
If neither argument nor existing comparator are set.
Remarks
Complexity: O(n) worst case.
Inherited from
reverseIterator()
reverseIterator():
Generator<E>
Defined in: index.ts:129
Iterates elements from the most recently added to the earliest.
Returns
Generator<E>
Inherited from
sort()
sort(
cmp?):void
Defined in: sort/index.ts:18
Sort the structure using the provided comparator.
Parameters
cmp?
Comparator<E>
Optional comparator; falls back to the internal one.
Returns
void
Inherited from
top()
top():
E
Defined in: stack.ts:37
Peek the top value without removing it.
Returns
E
Top value.
Throws
When empty.