35f9025e121bb861729df62a0064a3aa0176387c
1 // Copyright Jerome Benoit. 2021-2023. All Rights Reserved.
6 export class Queue
<T
> {
7 private items
: Record
<number, T
>
11 public constructor () {
17 public get
size (): number {
18 return this.tail
- this.head
21 public enqueue (item
: T
): number {
22 this.items
[this.tail
] = item
27 public dequeue (): T
| undefined {
28 if (this.size
<= 0) return undefined
29 const item
= this.items
[this.head
]
30 // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
31 delete this.items
[this.head
]
33 if (this.head
=== this.tail
) {