1 import { AbstractFixedQueue
} from
'./abstract-fixed-queue.js'
2 import type { IFixedQueue
} from
'./utility-types.js'
6 * @typeParam T - Type of fixed queue data.
9 export class FixedQueue
<T
>
10 extends AbstractFixedQueue
<T
>
11 implements IFixedQueue
<T
> {
13 public enqueue (data
: T
, priority
?: number): number {
15 throw new Error('Fixed queue is full')
17 let index
= this.start
+ this.size
18 if (index
>= this.capacity
) {
19 index
-= this.capacity
21 this.nodeArray
[index
] = { data
, priority
: priority
?? 0 }
26 public get (index
: number): T
| undefined {
27 if (this.empty() || index
>= this.size
) {
31 if (index
>= this.capacity
) {
32 index
-= this.capacity
34 return this.nodeArray
[index
].data