docs: refine a code comment
[poolifier.git] / src / fixed-priority-queue.ts
diff --git a/src/fixed-priority-queue.ts b/src/fixed-priority-queue.ts
deleted file mode 100644 (file)
index 6c89928..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-import { AbstractFixedQueue } from './abstract-fixed-queue.js'
-import type { IFixedQueue } from './utility-types.js'
-
-/**
- * Fixed priority queue.
- * @typeParam T - Type of fixed priority queue data.
- * @internal
- */
-export class FixedPriorityQueue<T>
-  extends AbstractFixedQueue<T>
-  implements IFixedQueue<T> {
-  /** @inheritdoc */
-  public enqueue (data: T, priority?: number): number {
-    if (this.full()) {
-      throw new Error('Fixed priority queue is full')
-    }
-    priority = priority ?? 0
-    let inserted = false
-    let index = this.start
-    for (let i = 0; i < this.size; i++) {
-      if (this.nodeArray[index].priority > priority) {
-        this.nodeArray.splice(index, 0, { data, priority })
-        this.nodeArray.length = this.capacity
-        inserted = true
-        break
-      }
-      ++index
-      if (index === this.capacity) {
-        index = 0
-      }
-    }
-    if (!inserted) {
-      let index = this.start + this.size
-      if (index >= this.capacity) {
-        index -= this.capacity
-      }
-      this.nodeArray[index] = { data, priority }
-    }
-    return ++this.size
-  }
-}