5 export const defaultQueueSize
= 2048
9 * @typeParam T - Type of fixed queue node data.
12 export interface FixedQueueNode
<T
> {
19 * @typeParam T - Type of fixed queue data.
22 export interface IFixedQueue
<T
> {
23 /** The fixed queue capacity. */
24 readonly capacity
: number
25 /** The fixed queue size. */
27 /** The fixed queue node array. */
28 nodeArray
: FixedQueueNode
<T
>[]
30 * Checks if the fixed queue is empty.
31 * @returns `true` if the fixed queue is empty, `false` otherwise.
35 * Checks if the fixed queue is full.
36 * @returns `true` if the fixed queue is full, `false` otherwise.
40 * Enqueue data into the fixed queue.
41 * @param data - Data to enqueue.
42 * @param priority - Priority of the data. Lower values have higher priority.
43 * @returns The new size of the fixed queue.
44 * @throws If the fixed queue is full.
46 enqueue
: (data
: T
, priority
?: number) => number
48 * Gets data from the fixed queue.
49 * @param index - The index of the data to get.
50 * @returns The data at the index or `undefined` if the fixed queue is empty or the index is out of bounds.
52 get
: (index
: number) => T
| undefined
54 * Dequeue data from the fixed queue.
55 * @returns The dequeued data or `undefined` if the fixed queue is empty.
57 dequeue
: () => T
| undefined
59 * Clears the fixed queue.
63 * Returns an iterator for the fixed queue.
64 * @returns An iterator for the fixed queue.
65 * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols
67 [Symbol
.iterator
]: () => Iterator
<T
>
71 * Default bucket size.
74 export const defaultBucketSize
= 2048
77 * Priority queue node.
78 * @typeParam T - Type of priority queue node data.
81 export interface PriorityQueueNode
<T
> extends IFixedQueue
<T
> {