fivem-ts

a library to speed up the development of Fivem scripts and frameworks


Project maintained by Purpose-Dev Hosted on GitHub Pages — Theme by mattgraham

fivem-ts - Documentation v0.7.5Docs


fivem-ts - Documentation v0.7.5 / Shared / Stack

Class: Stack<T>

A generic stack implementation with a maximum capacity.

Type Parameters

T

The type of elements in the stack.

Implements

Constructors

new Stack()

new Stack<T>(maxCapacity): Stack<T>

Parameters

maxCapacity: number

Returns

Stack<T>

Defined in

shared/ds/stack/Stack.ts:12

Methods

isEmpty()

isEmpty(): boolean

Checks if the collection is empty.

Returns

boolean

True if the collection has no elements, otherwise false.

Implementation of

IStack.isEmpty

Defined in

shared/ds/stack/Stack.ts:67


isFull()

isFull(): boolean

Determines whether the container or collection has reached its maximum capacity. Checks if the number of elements in the collection is equal to its predefined maximum capacity.

Returns

boolean

True if the number of elements equals the maximum capacity, otherwise false.

Implementation of

IStack.isFull

Defined in

shared/ds/stack/Stack.ts:77


peek()

peek(): T

Returns the top element of the stack without removing it. Throws an error if the stack is empty.

Returns

T

The top element of the stack.

Throws

If the stack is empty.

Implementation of

IStack.peek

Defined in

shared/ds/stack/Stack.ts:55


pop()

pop(): T

Removes the top element from the stack and returns it. If the stack is empty, an error is thrown.

Returns

T

The top element of the stack if available, otherwise undefined.

Throws

StackUnderflowError if the stack is empty.

Implementation of

IStack.pop

Defined in

shared/ds/stack/Stack.ts:41


push()

push(item): void

Adds an item to the top of the stack.

Parameters

item: T

The item to be added to the stack.

Returns

void

No return value.

Throws

If the stack is already at its maximum capacity.

Implementation of

IStack.push

Defined in

shared/ds/stack/Stack.ts:26


size()

size(): number

Retrieves the size of the collection.

Returns

number

The number of elements in the collection.

Implementation of

IStack.size

Defined in

shared/ds/stack/Stack.ts:85