queue-typed 2.1.2 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs +77 -73
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs-legacy/index.cjs +2499 -0
- package/dist/cjs-legacy/index.cjs.map +1 -0
- package/dist/esm/index.mjs +77 -73
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm-legacy/index.mjs +2493 -0
- package/dist/esm-legacy/index.mjs.map +1 -0
- package/dist/types/data-structures/binary-tree/avl-tree-counter.d.ts +57 -3
- package/dist/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +65 -3
- package/dist/types/data-structures/binary-tree/avl-tree.d.ts +58 -4
- package/dist/types/data-structures/binary-tree/bst.d.ts +57 -3
- package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +58 -4
- package/dist/types/data-structures/binary-tree/tree-counter.d.ts +57 -3
- package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +65 -3
- package/package.json +20 -2
- package/src/data-structures/binary-tree/avl-tree-counter.ts +102 -11
- package/src/data-structures/binary-tree/avl-tree-multi-map.ts +115 -11
- package/src/data-structures/binary-tree/avl-tree.ts +105 -14
- package/src/data-structures/binary-tree/bst.ts +102 -11
- package/src/data-structures/binary-tree/red-black-tree.ts +108 -18
- package/src/data-structures/binary-tree/tree-counter.ts +101 -10
- package/src/data-structures/binary-tree/tree-multi-map.ts +122 -11
- package/src/data-structures/graph/abstract-graph.ts +5 -5
- package/src/data-structures/graph/directed-graph.ts +5 -5
- package/src/data-structures/graph/undirected-graph.ts +5 -5
- package/tsup.node.config.js +40 -6
package/dist/esm/index.mjs
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
4
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
3
|
|
|
6
4
|
// src/data-structures/base/iterable-element-base.ts
|
|
7
|
-
var
|
|
5
|
+
var IterableElementBase = class {
|
|
6
|
+
static {
|
|
7
|
+
__name(this, "IterableElementBase");
|
|
8
|
+
}
|
|
8
9
|
/**
|
|
9
10
|
* Create a new iterable base.
|
|
10
11
|
*
|
|
@@ -15,19 +16,19 @@ var _IterableElementBase = class _IterableElementBase {
|
|
|
15
16
|
* Time O(1), Space O(1).
|
|
16
17
|
*/
|
|
17
18
|
constructor(options) {
|
|
18
|
-
/**
|
|
19
|
-
* The converter used to transform a raw element (`R`) into a public element (`E`).
|
|
20
|
-
*
|
|
21
|
-
* @remarks
|
|
22
|
-
* Time O(1), Space O(1).
|
|
23
|
-
*/
|
|
24
|
-
__publicField(this, "_toElementFn");
|
|
25
19
|
if (options) {
|
|
26
20
|
const { toElementFn } = options;
|
|
27
21
|
if (typeof toElementFn === "function") this._toElementFn = toElementFn;
|
|
28
22
|
else if (toElementFn) throw new TypeError("toElementFn must be a function type");
|
|
29
23
|
}
|
|
30
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* The converter used to transform a raw element (`R`) into a public element (`E`).
|
|
27
|
+
*
|
|
28
|
+
* @remarks
|
|
29
|
+
* Time O(1), Space O(1).
|
|
30
|
+
*/
|
|
31
|
+
_toElementFn;
|
|
31
32
|
/**
|
|
32
33
|
* Exposes the current `toElementFn`, if configured.
|
|
33
34
|
*
|
|
@@ -222,22 +223,22 @@ var _IterableElementBase = class _IterableElementBase {
|
|
|
222
223
|
console.log(this.toVisual());
|
|
223
224
|
}
|
|
224
225
|
};
|
|
225
|
-
__name(_IterableElementBase, "IterableElementBase");
|
|
226
|
-
var IterableElementBase = _IterableElementBase;
|
|
227
226
|
|
|
228
227
|
// src/data-structures/base/linear-base.ts
|
|
229
|
-
var
|
|
228
|
+
var LinkedListNode = class {
|
|
229
|
+
static {
|
|
230
|
+
__name(this, "LinkedListNode");
|
|
231
|
+
}
|
|
230
232
|
/**
|
|
231
233
|
* Initialize a node.
|
|
232
234
|
* @param value - Element value.
|
|
233
235
|
* @remarks Time O(1), Space O(1)
|
|
234
236
|
*/
|
|
235
237
|
constructor(value) {
|
|
236
|
-
__publicField(this, "_value");
|
|
237
|
-
__publicField(this, "_next");
|
|
238
238
|
this._value = value;
|
|
239
239
|
this._next = void 0;
|
|
240
240
|
}
|
|
241
|
+
_value;
|
|
241
242
|
/**
|
|
242
243
|
* Element payload getter.
|
|
243
244
|
* @returns Element value.
|
|
@@ -254,6 +255,7 @@ var _LinkedListNode = class _LinkedListNode {
|
|
|
254
255
|
set value(value) {
|
|
255
256
|
this._value = value;
|
|
256
257
|
}
|
|
258
|
+
_next;
|
|
257
259
|
/**
|
|
258
260
|
* Next node getter.
|
|
259
261
|
* @returns Next node or `undefined`.
|
|
@@ -271,9 +273,10 @@ var _LinkedListNode = class _LinkedListNode {
|
|
|
271
273
|
this._next = value;
|
|
272
274
|
}
|
|
273
275
|
};
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
276
|
+
var LinearBase = class _LinearBase extends IterableElementBase {
|
|
277
|
+
static {
|
|
278
|
+
__name(this, "LinearBase");
|
|
279
|
+
}
|
|
277
280
|
/**
|
|
278
281
|
* Construct a linear container with runtime options.
|
|
279
282
|
* @param options - `{ maxLen?, ... }` bounds/behavior options.
|
|
@@ -281,12 +284,12 @@ var _LinearBase = class _LinearBase extends IterableElementBase {
|
|
|
281
284
|
*/
|
|
282
285
|
constructor(options) {
|
|
283
286
|
super(options);
|
|
284
|
-
__publicField(this, "_maxLen", -1);
|
|
285
287
|
if (options) {
|
|
286
288
|
const { maxLen } = options;
|
|
287
289
|
if (typeof maxLen === "number" && maxLen > 0 && maxLen % 1 === 0) this._maxLen = maxLen;
|
|
288
290
|
}
|
|
289
291
|
}
|
|
292
|
+
_maxLen = -1;
|
|
290
293
|
/**
|
|
291
294
|
* Upper bound for length (if positive), or `-1` when unbounded.
|
|
292
295
|
* @returns Maximum allowed length.
|
|
@@ -419,7 +422,7 @@ var _LinearBase = class _LinearBase extends IterableElementBase {
|
|
|
419
422
|
return array;
|
|
420
423
|
}
|
|
421
424
|
reduceRight(callbackfn, initialValue) {
|
|
422
|
-
let accumulator = initialValue
|
|
425
|
+
let accumulator = initialValue ?? 0;
|
|
423
426
|
for (let i = this.length - 1; i >= 0; i--) {
|
|
424
427
|
accumulator = callbackfn(accumulator, this.at(i), i, this);
|
|
425
428
|
}
|
|
@@ -461,9 +464,10 @@ var _LinearBase = class _LinearBase extends IterableElementBase {
|
|
|
461
464
|
return this;
|
|
462
465
|
}
|
|
463
466
|
};
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
+
var LinearLinkedBase = class extends LinearBase {
|
|
468
|
+
static {
|
|
469
|
+
__name(this, "LinearLinkedBase");
|
|
470
|
+
}
|
|
467
471
|
constructor(options) {
|
|
468
472
|
super(options);
|
|
469
473
|
if (options) {
|
|
@@ -593,7 +597,7 @@ var _LinearLinkedBase = class _LinearLinkedBase extends LinearBase {
|
|
|
593
597
|
return removedList;
|
|
594
598
|
}
|
|
595
599
|
reduceRight(callbackfn, initialValue) {
|
|
596
|
-
let accumulator = initialValue
|
|
600
|
+
let accumulator = initialValue ?? 0;
|
|
597
601
|
let index = this.length - 1;
|
|
598
602
|
for (const item of this._getReverseIterator()) {
|
|
599
603
|
accumulator = callbackfn(accumulator, item, index--, this);
|
|
@@ -601,11 +605,12 @@ var _LinearLinkedBase = class _LinearLinkedBase extends LinearBase {
|
|
|
601
605
|
return accumulator;
|
|
602
606
|
}
|
|
603
607
|
};
|
|
604
|
-
__name(_LinearLinkedBase, "LinearLinkedBase");
|
|
605
|
-
var LinearLinkedBase = _LinearLinkedBase;
|
|
606
608
|
|
|
607
609
|
// src/data-structures/linked-list/singly-linked-list.ts
|
|
608
|
-
var
|
|
610
|
+
var SinglyLinkedListNode = class extends LinkedListNode {
|
|
611
|
+
static {
|
|
612
|
+
__name(this, "SinglyLinkedListNode");
|
|
613
|
+
}
|
|
609
614
|
/**
|
|
610
615
|
* Create a list node.
|
|
611
616
|
* @remarks Time O(1), Space O(1)
|
|
@@ -614,10 +619,10 @@ var _SinglyLinkedListNode = class _SinglyLinkedListNode extends LinkedListNode {
|
|
|
614
619
|
*/
|
|
615
620
|
constructor(value) {
|
|
616
621
|
super(value);
|
|
617
|
-
__publicField(this, "_next");
|
|
618
622
|
this._value = value;
|
|
619
623
|
this._next = void 0;
|
|
620
624
|
}
|
|
625
|
+
_next;
|
|
621
626
|
/**
|
|
622
627
|
* Get the next node.
|
|
623
628
|
* @remarks Time O(1), Space O(1)
|
|
@@ -636,9 +641,11 @@ var _SinglyLinkedListNode = class _SinglyLinkedListNode extends LinkedListNode {
|
|
|
636
641
|
this._next = value;
|
|
637
642
|
}
|
|
638
643
|
};
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
644
|
+
var SinglyLinkedList = class extends LinearLinkedBase {
|
|
645
|
+
static {
|
|
646
|
+
__name(this, "SinglyLinkedList");
|
|
647
|
+
}
|
|
648
|
+
_equals = Object.is;
|
|
642
649
|
/**
|
|
643
650
|
* Create a SinglyLinkedList and optionally bulk-insert elements.
|
|
644
651
|
* @remarks Time O(N), Space O(N)
|
|
@@ -648,12 +655,9 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
648
655
|
*/
|
|
649
656
|
constructor(elements = [], options) {
|
|
650
657
|
super(options);
|
|
651
|
-
__publicField(this, "_equals", Object.is);
|
|
652
|
-
__publicField(this, "_head");
|
|
653
|
-
__publicField(this, "_tail");
|
|
654
|
-
__publicField(this, "_length", 0);
|
|
655
658
|
this.pushMany(elements);
|
|
656
659
|
}
|
|
660
|
+
_head;
|
|
657
661
|
/**
|
|
658
662
|
* Get the head node.
|
|
659
663
|
* @remarks Time O(1), Space O(1)
|
|
@@ -662,6 +666,7 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
662
666
|
get head() {
|
|
663
667
|
return this._head;
|
|
664
668
|
}
|
|
669
|
+
_tail;
|
|
665
670
|
/**
|
|
666
671
|
* Get the tail node.
|
|
667
672
|
* @remarks Time O(1), Space O(1)
|
|
@@ -670,6 +675,7 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
670
675
|
get tail() {
|
|
671
676
|
return this._tail;
|
|
672
677
|
}
|
|
678
|
+
_length = 0;
|
|
673
679
|
/**
|
|
674
680
|
* Get the number of elements.
|
|
675
681
|
* @remarks Time O(1), Space O(1)
|
|
@@ -684,8 +690,7 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
684
690
|
* @returns First element or undefined.
|
|
685
691
|
*/
|
|
686
692
|
get first() {
|
|
687
|
-
|
|
688
|
-
return (_a = this.head) == null ? void 0 : _a.value;
|
|
693
|
+
return this.head?.value;
|
|
689
694
|
}
|
|
690
695
|
/**
|
|
691
696
|
* Get the last element value.
|
|
@@ -693,8 +698,7 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
693
698
|
* @returns Last element or undefined.
|
|
694
699
|
*/
|
|
695
700
|
get last() {
|
|
696
|
-
|
|
697
|
-
return (_a = this.tail) == null ? void 0 : _a.value;
|
|
701
|
+
return this.tail?.value;
|
|
698
702
|
}
|
|
699
703
|
/**
|
|
700
704
|
* Create a new list from an iterable of elements.
|
|
@@ -1173,7 +1177,7 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
1173
1177
|
* @returns A new SinglyLinkedList with mapped values.
|
|
1174
1178
|
*/
|
|
1175
1179
|
map(callback, options, thisArg) {
|
|
1176
|
-
const out = this._createLike([], { ...options
|
|
1180
|
+
const out = this._createLike([], { ...options ?? {}, maxLen: this._maxLen });
|
|
1177
1181
|
let index = 0;
|
|
1178
1182
|
for (const value of this) out.push(callback.call(thisArg, value, index++, this));
|
|
1179
1183
|
return out;
|
|
@@ -1298,8 +1302,6 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
1298
1302
|
return this._createLike([], options);
|
|
1299
1303
|
}
|
|
1300
1304
|
};
|
|
1301
|
-
__name(_SinglyLinkedList, "SinglyLinkedList");
|
|
1302
|
-
var SinglyLinkedList = _SinglyLinkedList;
|
|
1303
1305
|
function elementOrPredicate(input, equals) {
|
|
1304
1306
|
if (input instanceof SinglyLinkedListNode) return (node) => node === input;
|
|
1305
1307
|
if (typeof input === "function") return input;
|
|
@@ -1309,7 +1311,10 @@ function elementOrPredicate(input, equals) {
|
|
|
1309
1311
|
__name(elementOrPredicate, "elementOrPredicate");
|
|
1310
1312
|
|
|
1311
1313
|
// src/data-structures/queue/queue.ts
|
|
1312
|
-
var
|
|
1314
|
+
var Queue = class _Queue extends LinearBase {
|
|
1315
|
+
static {
|
|
1316
|
+
__name(this, "Queue");
|
|
1317
|
+
}
|
|
1313
1318
|
/**
|
|
1314
1319
|
* Create a Queue and optionally bulk-insert elements.
|
|
1315
1320
|
* @remarks Time O(N), Space O(N)
|
|
@@ -1319,15 +1324,13 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
1319
1324
|
*/
|
|
1320
1325
|
constructor(elements = [], options) {
|
|
1321
1326
|
super(options);
|
|
1322
|
-
__publicField(this, "_elements", []);
|
|
1323
|
-
__publicField(this, "_offset", 0);
|
|
1324
|
-
__publicField(this, "_autoCompactRatio", 0.5);
|
|
1325
1327
|
if (options) {
|
|
1326
1328
|
const { autoCompactRatio = 0.5 } = options;
|
|
1327
1329
|
this._autoCompactRatio = autoCompactRatio;
|
|
1328
1330
|
}
|
|
1329
1331
|
this.pushMany(elements);
|
|
1330
1332
|
}
|
|
1333
|
+
_elements = [];
|
|
1331
1334
|
/**
|
|
1332
1335
|
* Get the underlying array buffer.
|
|
1333
1336
|
* @remarks Time O(1), Space O(1)
|
|
@@ -1336,6 +1339,7 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
1336
1339
|
get elements() {
|
|
1337
1340
|
return this._elements;
|
|
1338
1341
|
}
|
|
1342
|
+
_offset = 0;
|
|
1339
1343
|
/**
|
|
1340
1344
|
* Get the current start offset into the array.
|
|
1341
1345
|
* @remarks Time O(1), Space O(1)
|
|
@@ -1344,6 +1348,7 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
1344
1348
|
get offset() {
|
|
1345
1349
|
return this._offset;
|
|
1346
1350
|
}
|
|
1351
|
+
_autoCompactRatio = 0.5;
|
|
1347
1352
|
/**
|
|
1348
1353
|
* Get the compaction threshold (offset/size).
|
|
1349
1354
|
* @remarks Time O(1), Space O(1)
|
|
@@ -1588,11 +1593,10 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
1588
1593
|
* @returns A new Queue with mapped elements.
|
|
1589
1594
|
*/
|
|
1590
1595
|
map(callback, options, thisArg) {
|
|
1591
|
-
var _a, _b;
|
|
1592
1596
|
const out = new this.constructor([], {
|
|
1593
|
-
toElementFn: options
|
|
1594
|
-
maxLen:
|
|
1595
|
-
autoCompactRatio:
|
|
1597
|
+
toElementFn: options?.toElementFn,
|
|
1598
|
+
maxLen: options?.maxLen ?? this._maxLen,
|
|
1599
|
+
autoCompactRatio: options?.autoCompactRatio ?? this._autoCompactRatio
|
|
1596
1600
|
});
|
|
1597
1601
|
let index = 0;
|
|
1598
1602
|
for (const v of this)
|
|
@@ -1607,14 +1611,13 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
1607
1611
|
* @returns A new queue with mapped elements (same element type).
|
|
1608
1612
|
*/
|
|
1609
1613
|
mapSame(callback, thisArg) {
|
|
1610
|
-
var _a;
|
|
1611
1614
|
const Ctor = this.constructor;
|
|
1612
1615
|
const out = new Ctor([], {
|
|
1613
1616
|
toElementFn: this.toElementFn,
|
|
1614
1617
|
maxLen: this._maxLen,
|
|
1615
1618
|
autoCompactRatio: this._autoCompactRatio
|
|
1616
1619
|
});
|
|
1617
|
-
|
|
1620
|
+
out._setAutoCompactRatio?.(this._autoCompactRatio);
|
|
1618
1621
|
let index = 0;
|
|
1619
1622
|
for (const v of this) {
|
|
1620
1623
|
const mv = thisArg === void 0 ? callback(v, index++, this) : callback.call(thisArg, v, index++, this);
|
|
@@ -1674,9 +1677,10 @@ var _Queue = class _Queue extends LinearBase {
|
|
|
1674
1677
|
return new Ctor(elements, options);
|
|
1675
1678
|
}
|
|
1676
1679
|
};
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
+
var LinkedListQueue = class extends SinglyLinkedList {
|
|
1681
|
+
static {
|
|
1682
|
+
__name(this, "LinkedListQueue");
|
|
1683
|
+
}
|
|
1680
1684
|
/**
|
|
1681
1685
|
* Deep clone this linked-list-based queue.
|
|
1682
1686
|
* @remarks Time O(N), Space O(N)
|
|
@@ -1688,8 +1692,6 @@ var _LinkedListQueue = class _LinkedListQueue extends SinglyLinkedList {
|
|
|
1688
1692
|
return out;
|
|
1689
1693
|
}
|
|
1690
1694
|
};
|
|
1691
|
-
__name(_LinkedListQueue, "LinkedListQueue");
|
|
1692
|
-
var LinkedListQueue = _LinkedListQueue;
|
|
1693
1695
|
|
|
1694
1696
|
// src/utils/utils.ts
|
|
1695
1697
|
var rangeCheck = /* @__PURE__ */ __name((index, min, max, message = "Index out of bounds.") => {
|
|
@@ -1730,7 +1732,11 @@ function isComparable(value, isForceObjectComparable = false) {
|
|
|
1730
1732
|
__name(isComparable, "isComparable");
|
|
1731
1733
|
|
|
1732
1734
|
// src/data-structures/queue/deque.ts
|
|
1733
|
-
var
|
|
1735
|
+
var Deque = class extends LinearBase {
|
|
1736
|
+
static {
|
|
1737
|
+
__name(this, "Deque");
|
|
1738
|
+
}
|
|
1739
|
+
_equals = Object.is;
|
|
1734
1740
|
/**
|
|
1735
1741
|
* Create a Deque and optionally bulk-insert elements.
|
|
1736
1742
|
* @remarks Time O(N), Space O(N)
|
|
@@ -1740,15 +1746,6 @@ var _Deque = class _Deque extends LinearBase {
|
|
|
1740
1746
|
*/
|
|
1741
1747
|
constructor(elements = [], options) {
|
|
1742
1748
|
super(options);
|
|
1743
|
-
__publicField(this, "_equals", Object.is);
|
|
1744
|
-
__publicField(this, "_bucketSize", 1 << 12);
|
|
1745
|
-
__publicField(this, "_bucketFirst", 0);
|
|
1746
|
-
__publicField(this, "_firstInBucket", 0);
|
|
1747
|
-
__publicField(this, "_bucketLast", 0);
|
|
1748
|
-
__publicField(this, "_lastInBucket", 0);
|
|
1749
|
-
__publicField(this, "_bucketCount", 0);
|
|
1750
|
-
__publicField(this, "_buckets", []);
|
|
1751
|
-
__publicField(this, "_length", 0);
|
|
1752
1749
|
if (options) {
|
|
1753
1750
|
const { bucketSize } = options;
|
|
1754
1751
|
if (typeof bucketSize === "number") this._bucketSize = bucketSize;
|
|
@@ -1768,6 +1765,7 @@ var _Deque = class _Deque extends LinearBase {
|
|
|
1768
1765
|
this._firstInBucket = this._lastInBucket = this._bucketSize - _size % this._bucketSize >> 1;
|
|
1769
1766
|
this.pushMany(elements);
|
|
1770
1767
|
}
|
|
1768
|
+
_bucketSize = 1 << 12;
|
|
1771
1769
|
/**
|
|
1772
1770
|
* Get the current bucket size.
|
|
1773
1771
|
* @remarks Time O(1), Space O(1)
|
|
@@ -1776,6 +1774,7 @@ var _Deque = class _Deque extends LinearBase {
|
|
|
1776
1774
|
get bucketSize() {
|
|
1777
1775
|
return this._bucketSize;
|
|
1778
1776
|
}
|
|
1777
|
+
_bucketFirst = 0;
|
|
1779
1778
|
/**
|
|
1780
1779
|
* Get the index of the first bucket in use.
|
|
1781
1780
|
* @remarks Time O(1), Space O(1)
|
|
@@ -1784,6 +1783,7 @@ var _Deque = class _Deque extends LinearBase {
|
|
|
1784
1783
|
get bucketFirst() {
|
|
1785
1784
|
return this._bucketFirst;
|
|
1786
1785
|
}
|
|
1786
|
+
_firstInBucket = 0;
|
|
1787
1787
|
/**
|
|
1788
1788
|
* Get the index inside the first bucket.
|
|
1789
1789
|
* @remarks Time O(1), Space O(1)
|
|
@@ -1792,6 +1792,7 @@ var _Deque = class _Deque extends LinearBase {
|
|
|
1792
1792
|
get firstInBucket() {
|
|
1793
1793
|
return this._firstInBucket;
|
|
1794
1794
|
}
|
|
1795
|
+
_bucketLast = 0;
|
|
1795
1796
|
/**
|
|
1796
1797
|
* Get the index of the last bucket in use.
|
|
1797
1798
|
* @remarks Time O(1), Space O(1)
|
|
@@ -1800,6 +1801,7 @@ var _Deque = class _Deque extends LinearBase {
|
|
|
1800
1801
|
get bucketLast() {
|
|
1801
1802
|
return this._bucketLast;
|
|
1802
1803
|
}
|
|
1804
|
+
_lastInBucket = 0;
|
|
1803
1805
|
/**
|
|
1804
1806
|
* Get the index inside the last bucket.
|
|
1805
1807
|
* @remarks Time O(1), Space O(1)
|
|
@@ -1808,6 +1810,7 @@ var _Deque = class _Deque extends LinearBase {
|
|
|
1808
1810
|
get lastInBucket() {
|
|
1809
1811
|
return this._lastInBucket;
|
|
1810
1812
|
}
|
|
1813
|
+
_bucketCount = 0;
|
|
1811
1814
|
/**
|
|
1812
1815
|
* Get the number of buckets allocated.
|
|
1813
1816
|
* @remarks Time O(1), Space O(1)
|
|
@@ -1816,6 +1819,7 @@ var _Deque = class _Deque extends LinearBase {
|
|
|
1816
1819
|
get bucketCount() {
|
|
1817
1820
|
return this._bucketCount;
|
|
1818
1821
|
}
|
|
1822
|
+
_buckets = [];
|
|
1819
1823
|
/**
|
|
1820
1824
|
* Get the internal buckets array.
|
|
1821
1825
|
* @remarks Time O(1), Space O(1)
|
|
@@ -1824,6 +1828,7 @@ var _Deque = class _Deque extends LinearBase {
|
|
|
1824
1828
|
get buckets() {
|
|
1825
1829
|
return this._buckets;
|
|
1826
1830
|
}
|
|
1831
|
+
_length = 0;
|
|
1827
1832
|
/**
|
|
1828
1833
|
* Get the number of elements in the deque.
|
|
1829
1834
|
* @remarks Time O(1), Space O(1)
|
|
@@ -2339,7 +2344,7 @@ var _Deque = class _Deque extends LinearBase {
|
|
|
2339
2344
|
*/
|
|
2340
2345
|
map(callback, options, thisArg) {
|
|
2341
2346
|
const out = this._createLike([], {
|
|
2342
|
-
...options
|
|
2347
|
+
...options ?? {},
|
|
2343
2348
|
bucketSize: this._bucketSize,
|
|
2344
2349
|
maxLen: this._maxLen
|
|
2345
2350
|
});
|
|
@@ -2453,8 +2458,6 @@ var _Deque = class _Deque extends LinearBase {
|
|
|
2453
2458
|
}
|
|
2454
2459
|
}
|
|
2455
2460
|
};
|
|
2456
|
-
__name(_Deque, "Deque");
|
|
2457
|
-
var Deque = _Deque;
|
|
2458
2461
|
|
|
2459
2462
|
// src/common/index.ts
|
|
2460
2463
|
var DFSOperation = /* @__PURE__ */ ((DFSOperation2) => {
|
|
@@ -2462,7 +2465,7 @@ var DFSOperation = /* @__PURE__ */ ((DFSOperation2) => {
|
|
|
2462
2465
|
DFSOperation2[DFSOperation2["PROCESS"] = 1] = "PROCESS";
|
|
2463
2466
|
return DFSOperation2;
|
|
2464
2467
|
})(DFSOperation || {});
|
|
2465
|
-
var
|
|
2468
|
+
var Range = class {
|
|
2466
2469
|
constructor(low, high, includeLow = true, includeHigh = true) {
|
|
2467
2470
|
this.low = low;
|
|
2468
2471
|
this.high = high;
|
|
@@ -2471,6 +2474,9 @@ var _Range = class _Range {
|
|
|
2471
2474
|
if (!(isComparable(low) && isComparable(high))) throw new RangeError("low or high is not comparable");
|
|
2472
2475
|
if (low > high) throw new RangeError("low must be less than or equal to high");
|
|
2473
2476
|
}
|
|
2477
|
+
static {
|
|
2478
|
+
__name(this, "Range");
|
|
2479
|
+
}
|
|
2474
2480
|
// Determine whether a key is within the range
|
|
2475
2481
|
isInRange(key, comparator) {
|
|
2476
2482
|
const lowCheck = this.includeLow ? comparator(key, this.low) >= 0 : comparator(key, this.low) > 0;
|
|
@@ -2478,8 +2484,6 @@ var _Range = class _Range {
|
|
|
2478
2484
|
return lowCheck && highCheck;
|
|
2479
2485
|
}
|
|
2480
2486
|
};
|
|
2481
|
-
__name(_Range, "Range");
|
|
2482
|
-
var Range = _Range;
|
|
2483
2487
|
/**
|
|
2484
2488
|
* data-structure-typed
|
|
2485
2489
|
*
|