+ /**
+ * The number of filled prioritized buckets.
+ */
+ public get buckets (): number {
+ return this.bucketSize === Number.POSITIVE_INFINITY
+ ? 1
+ : Math.trunc(this.nodeArray.length / this.bucketSize)
+ }
+
+ /**
+ * Constructs a priority queue.
+ *
+ * @param bucketSize - Prioritized bucket size. @defaultValue Number.POSITIVE_INFINITY
+ */
+ public constructor (bucketSize = Number.POSITIVE_INFINITY) {
+ if (
+ bucketSize !== Number.POSITIVE_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