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 / PriorityQueue

Class: PriorityQueue<T>

PriorityQueue is a data structure that manages elements in a way that the element with the highest priority is always dequeued first. Elements are stored with an associated priority, and the element with the lowest numerical priority value is considered the highest priority.

Type Parameters

T

The type of elements held in the PriorityQueue.

Implements

Constructors

new PriorityQueue()

new PriorityQueue<T>(): PriorityQueue<T>

Returns

PriorityQueue<T>

Methods

dequeue()

dequeue(): T

Removes and returns the first element from the queue. If the queue is empty, it returns undefined.

Returns

T

The first element in the queue or undefined if the queue is empty.

Implementation of

IPriorityQueue.dequeue

Defined in

shared/ds/queue/PriorityQueue.ts:44


enqueue()

enqueue(item, priority): void

Adds an item to the queue with a specified priority.

Parameters

item: T

The item to be added to the queue.

priority: number

The priority of the item.

Returns

void

Implementation of

IPriorityQueue.enqueue

Defined in

shared/ds/queue/PriorityQueue.ts:21


isEmpty()

isEmpty(): boolean

Checks if the collection is empty.

Returns

boolean

True if the collection is empty, false otherwise.

Implementation of

IPriorityQueue.isEmpty

Defined in

shared/ds/queue/PriorityQueue.ts:62


peek()

peek(): T

Returns the first element in the collection without removing it.

Returns

T

The value of the first element, or undefined if the collection is empty.

Implementation of

IPriorityQueue.peek

Defined in

shared/ds/queue/PriorityQueue.ts:53


size()

size(): number

Gets the number of elements.

Returns

number

The number of elements.

Implementation of

IPriorityQueue.size

Defined in

shared/ds/queue/PriorityQueue.ts:71