test: add priority queue test suite
[poolifier.git] / src / priority-queue.ts
index 55a97169f757beb0f53c51843d6a8a87f6392612..168e6c3455ca9fe82a864ad93fb61e3e894397a5 100644 (file)
@@ -7,20 +7,28 @@ interface PriorityQueueNode<T> {
 }
 
 /**
- * Priority queue.
+ * k-priority queue.
  *
  * @typeParam T - Type of priority queue data.
  * @internal
  */
 export class PriorityQueue<T> {
   private nodeArray!: Array<PriorityQueueNode<T>>
+  /** Prioritized bucket size. */
+  private readonly k: number
   /** The size of the priority queue. */
   public size!: number
   /** The maximum size of the priority queue. */
   public maxSize!: number
 
-  public constructor () {
+  /**
+   * Constructs a k-priority queue.
+   *
+   * @param k - Prioritized bucket size.
+   */
+  public constructor (k = Infinity) {
     this.clear()
+    this.k = k
   }
 
   /**