doubly-linked-list-typed 2.1.2 → 2.2.1

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.
Files changed (33) hide show
  1. package/dist/cjs/index.cjs +50 -47
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/cjs-legacy/index.cjs +1299 -0
  4. package/dist/cjs-legacy/index.cjs.map +1 -0
  5. package/dist/esm/index.mjs +50 -47
  6. package/dist/esm/index.mjs.map +1 -1
  7. package/dist/esm-legacy/index.mjs +1294 -0
  8. package/dist/esm-legacy/index.mjs.map +1 -0
  9. package/dist/types/data-structures/binary-tree/avl-tree-counter.d.ts +57 -3
  10. package/dist/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +65 -3
  11. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +61 -5
  12. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +1 -0
  13. package/dist/types/data-structures/binary-tree/bst.d.ts +58 -3
  14. package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +59 -4
  15. package/dist/types/data-structures/binary-tree/tree-counter.d.ts +57 -3
  16. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +66 -3
  17. package/dist/types/types/data-structures/base/base.d.ts +1 -1
  18. package/package.json +20 -2
  19. package/src/data-structures/base/iterable-entry-base.ts +4 -4
  20. package/src/data-structures/binary-tree/avl-tree-counter.ts +103 -12
  21. package/src/data-structures/binary-tree/avl-tree-multi-map.ts +116 -12
  22. package/src/data-structures/binary-tree/avl-tree.ts +109 -16
  23. package/src/data-structures/binary-tree/binary-tree.ts +3 -2
  24. package/src/data-structures/binary-tree/bst.ts +104 -12
  25. package/src/data-structures/binary-tree/red-black-tree.ts +110 -19
  26. package/src/data-structures/binary-tree/tree-counter.ts +102 -11
  27. package/src/data-structures/binary-tree/tree-multi-map.ts +124 -12
  28. package/src/data-structures/graph/abstract-graph.ts +8 -8
  29. package/src/data-structures/graph/directed-graph.ts +5 -5
  30. package/src/data-structures/graph/undirected-graph.ts +5 -5
  31. package/src/data-structures/hash/hash-map.ts +4 -4
  32. package/src/types/data-structures/base/base.ts +1 -1
  33. package/tsup.node.config.js +40 -6
@@ -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 _IterableElementBase = class _IterableElementBase {
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 _LinkedListNode = class _LinkedListNode {
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
- __name(_LinkedListNode, "LinkedListNode");
277
- var LinkedListNode = _LinkedListNode;
278
- var _LinearBase = class _LinearBase extends IterableElementBase {
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 != null ? initialValue : 0;
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
- __name(_LinearBase, "LinearBase");
467
- var LinearBase = _LinearBase;
468
- var _LinearLinkedBase = class _LinearLinkedBase extends LinearBase {
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 != null ? initialValue : 0;
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/doubly-linked-list.ts
610
- var _DoublyLinkedListNode = class _DoublyLinkedListNode extends LinkedListNode {
612
+ var DoublyLinkedListNode = class extends LinkedListNode {
613
+ static {
614
+ __name(this, "DoublyLinkedListNode");
615
+ }
611
616
  /**
612
617
  * Create a node.
613
618
  * @remarks Time O(1), Space O(1)
@@ -616,12 +621,11 @@ var _DoublyLinkedListNode = class _DoublyLinkedListNode extends LinkedListNode {
616
621
  */
617
622
  constructor(value) {
618
623
  super(value);
619
- __publicField(this, "_next");
620
- __publicField(this, "_prev");
621
624
  this._value = value;
622
625
  this._next = void 0;
623
626
  this._prev = void 0;
624
627
  }
628
+ _next;
625
629
  /**
626
630
  * Get the next node link.
627
631
  * @remarks Time O(1), Space O(1)
@@ -639,6 +643,7 @@ var _DoublyLinkedListNode = class _DoublyLinkedListNode extends LinkedListNode {
639
643
  set next(value) {
640
644
  this._next = value;
641
645
  }
646
+ _prev;
642
647
  /**
643
648
  * Get the previous node link.
644
649
  * @remarks Time O(1), Space O(1)
@@ -657,9 +662,11 @@ var _DoublyLinkedListNode = class _DoublyLinkedListNode extends LinkedListNode {
657
662
  this._prev = value;
658
663
  }
659
664
  };
660
- __name(_DoublyLinkedListNode, "DoublyLinkedListNode");
661
- var DoublyLinkedListNode = _DoublyLinkedListNode;
662
- var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
665
+ var DoublyLinkedList = class extends LinearLinkedBase {
666
+ static {
667
+ __name(this, "DoublyLinkedList");
668
+ }
669
+ _equals = Object.is;
663
670
  /**
664
671
  * Create a DoublyLinkedList and optionally bulk-insert elements.
665
672
  * @remarks Time O(N), Space O(N)
@@ -669,18 +676,15 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
669
676
  */
670
677
  constructor(elements = [], options) {
671
678
  super(options);
672
- __publicField(this, "_equals", Object.is);
673
- __publicField(this, "_head");
674
- __publicField(this, "_tail");
675
- __publicField(this, "_length", 0);
676
679
  this._head = void 0;
677
680
  this._tail = void 0;
678
681
  this._length = 0;
679
- if ((options == null ? void 0 : options.maxLen) && Number.isInteger(options.maxLen) && options.maxLen > 0) {
682
+ if (options?.maxLen && Number.isInteger(options.maxLen) && options.maxLen > 0) {
680
683
  this._maxLen = options.maxLen;
681
684
  }
682
685
  this.pushMany(elements);
683
686
  }
687
+ _head;
684
688
  /**
685
689
  * Get the head node.
686
690
  * @remarks Time O(1), Space O(1)
@@ -689,6 +693,7 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
689
693
  get head() {
690
694
  return this._head;
691
695
  }
696
+ _tail;
692
697
  /**
693
698
  * Get the tail node.
694
699
  * @remarks Time O(1), Space O(1)
@@ -697,6 +702,7 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
697
702
  get tail() {
698
703
  return this._tail;
699
704
  }
705
+ _length = 0;
700
706
  /**
701
707
  * Get the number of elements.
702
708
  * @remarks Time O(1), Space O(1)
@@ -711,8 +717,7 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
711
717
  * @returns First element or undefined.
712
718
  */
713
719
  get first() {
714
- var _a;
715
- return (_a = this.head) == null ? void 0 : _a.value;
720
+ return this.head?.value;
716
721
  }
717
722
  /**
718
723
  * Get the last element value.
@@ -720,8 +725,7 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
720
725
  * @returns Last element or undefined.
721
726
  */
722
727
  get last() {
723
- var _a;
724
- return (_a = this.tail) == null ? void 0 : _a.value;
728
+ return this.tail?.value;
725
729
  }
726
730
  /**
727
731
  * Create a new list from an array of elements.
@@ -1136,7 +1140,7 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
1136
1140
  * @returns A new DoublyLinkedList with mapped values.
1137
1141
  */
1138
1142
  map(callback, options, thisArg) {
1139
- const out = this._createLike([], { ...options != null ? options : {}, maxLen: this._maxLen });
1143
+ const out = this._createLike([], { ...options ?? {}, maxLen: this._maxLen });
1140
1144
  let index = 0;
1141
1145
  for (const v of this) out.push(callback.call(thisArg, v, index++, this));
1142
1146
  return out;
@@ -1222,8 +1226,6 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
1222
1226
  }
1223
1227
  }
1224
1228
  };
1225
- __name(_DoublyLinkedList, "DoublyLinkedList");
1226
- var DoublyLinkedList = _DoublyLinkedList;
1227
1229
 
1228
1230
  // src/utils/utils.ts
1229
1231
  function isPrimitiveComparable(value) {
@@ -1265,7 +1267,7 @@ var DFSOperation = /* @__PURE__ */ ((DFSOperation2) => {
1265
1267
  DFSOperation2[DFSOperation2["PROCESS"] = 1] = "PROCESS";
1266
1268
  return DFSOperation2;
1267
1269
  })(DFSOperation || {});
1268
- var _Range = class _Range {
1270
+ var Range = class {
1269
1271
  constructor(low, high, includeLow = true, includeHigh = true) {
1270
1272
  this.low = low;
1271
1273
  this.high = high;
@@ -1274,6 +1276,9 @@ var _Range = class _Range {
1274
1276
  if (!(isComparable(low) && isComparable(high))) throw new RangeError("low or high is not comparable");
1275
1277
  if (low > high) throw new RangeError("low must be less than or equal to high");
1276
1278
  }
1279
+ static {
1280
+ __name(this, "Range");
1281
+ }
1277
1282
  // Determine whether a key is within the range
1278
1283
  isInRange(key, comparator) {
1279
1284
  const lowCheck = this.includeLow ? comparator(key, this.low) >= 0 : comparator(key, this.low) > 0;
@@ -1281,8 +1286,6 @@ var _Range = class _Range {
1281
1286
  return lowCheck && highCheck;
1282
1287
  }
1283
1288
  };
1284
- __name(_Range, "Range");
1285
- var Range = _Range;
1286
1289
  /**
1287
1290
  * data-structure-typed
1288
1291
  *