+ /**
+ * The number of filled prioritized buckets.
+ */
+ public get buckets (): number {
+ return this.bucketSize === Infinity
+ ? 1
+ : Math.trunc(this.nodeArray.length / this.bucketSize)
+ }
+
+ /**
+ * Constructs a priority queue.
+ *
+ * @param bucketSize - Prioritized bucket size. @defaultValue Infinity
+ */
+ public constructor (bucketSize = Infinity) {
+ if (bucketSize !== Infinity && !Number.isSafeInteger(bucketSize)) {
+ throw new TypeError('bucketSize must be an integer')
+ }
+ if (bucketSize < 1) {
+ throw new RangeError('bucketSize must be greater than or equal to 1')
+ }
+ this.bucketSize = bucketSize