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