Skip to content

Typed API (TypeDoc)


Typed API (TypeDoc) / LinkedStack

Class: LinkedStack<E> ​

Defined in: stack.ts:206

Type Parameters ​

E ​

E

Implements ​

Constructors ​

Constructor ​

new LinkedStack<E>(elements?): LinkedStack<E>

Defined in: stack.ts:217

Parameters ​

elements? ​

Iterable<E, any, any>

Returns ​

LinkedStack<E>

Properties ​

comparator ​

comparator: Comparator<E>

Defined in: stack.ts:215

Comparator used for equality/sort checks.

Implementation of ​

IStack.comparator


size ​

size: number = 0

Defined in: stack.ts:211

Current element count.

Implementation of ​

IStack.size

Methods ​

[iterator]() ​

[iterator](): Iterator<E>

Defined in: stack.ts:293

Iterable

Returns ​

Iterator<E>

Implementation of ​

IStack.[iterator]


add() ​

add(e): void

Defined in: stack.ts:310

Append an element.

Parameters ​

e ​

E

Returns ​

void

Remarks ​

Complexity: Amortized O(1) unless stated otherwise.

Implementation of ​

IStack.add


addAll() ​

addAll(collection): void

Defined in: stack.ts:317

Append every element from another collection.

Parameters ​

collection ​

ICollection<E>

Returns ​

void

Remarks ​

Complexity: O(n + m) where m is collection.size.

Implementation of ​

IStack.addAll


clear() ​

clear(): void

Defined in: stack.ts:269

Remove all entries.

Returns ​

void

Remarks ​

Complexity: O(n)

Implementation of ​

IStack.clear


contains() ​

contains(e): boolean

Defined in: stack.ts:277

Test membership using the comparator when available.

Parameters ​

e ​

E

Returns ​

boolean

Remarks ​

Complexity: O(n) worst case

Implementation of ​

IStack.contains


isEmpty() ​

isEmpty(): boolean

Defined in: stack.ts:254

Check for emptiness.

Returns ​

boolean

true when size === 0.

Implementation of ​

IStack.isEmpty


pop() ​

pop(): E

Defined in: stack.ts:241

Pop and return the top value.

Returns ​

E

Removed value.

Remarks ​

Complexity: O(1)

Implementation of ​

IStack.pop


push() ​

push(e): void

Defined in: stack.ts:228

Push a value on top.

Parameters ​

e ​

E

Value to push.

Returns ​

void

Remarks ​

Complexity: O(1)

Implementation of ​

IStack.push


remove() ​

remove(target, isIndex): number | E

Defined in: stack.ts:343

Remove by value or index.

Parameters ​

target ​

Element or index.

number | E

isIndex ​

boolean = true

When true, treat e as index.

Returns ​

number | E

Removed element or index of removal.

Remarks ​

Complexity: O(n) worst case.

Implementation of ​

IStack.remove


reverseIterator() ​

reverseIterator(): Generator<E>

Defined in: stack.ts:370

Iterates elements from the most recently added to the earliest.

Returns ​

Generator<E>

Implementation of ​

IStack.reverseIterator


sort() ​

sort(cmp?): void

Defined in: stack.ts:384

Sort the structure using the provided comparator.

Parameters ​

cmp? ​

Comparator<E>

Optional comparator; falls back to the internal one.

Returns ​

void

Implementation of ​

IStack.sort


top() ​

top(): E

Defined in: stack.ts:261

Peek the top value without removing it.

Returns ​

E

Top value.

Implementation of ​

IStack.top

Built with VitePress – Released under the MIT License.