tree-set-typed 2.4.3 → 2.4.4

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.
@@ -1026,8 +1026,9 @@ var redBlackTreeTyped = (() => {
1026
1026
  const cur = node;
1027
1027
  node = node.next;
1028
1028
  if (predicate(cur.key, cur.value, i++, this)) {
1029
- if (isWeakKey(cur.key)) {
1030
- this._objMap.delete(cur.key);
1029
+ const keyToCheck = cur.key;
1030
+ if (isWeakKey(keyToCheck)) {
1031
+ this._objMap.delete(keyToCheck);
1031
1032
  } else {
1032
1033
  const hash = this._hashFn(cur.key);
1033
1034
  delete this._noObjMap[hash];
@@ -1540,7 +1541,7 @@ var redBlackTreeTyped = (() => {
1540
1541
  */
1541
1542
  constructor(elements = [], options) {
1542
1543
  super(options);
1543
- __publicField(this, "_equals", Object.is);
1544
+ __publicField(this, "_equals", /* @__PURE__ */ __name((a, b) => Object.is(a, b), "_equals"));
1544
1545
  __publicField(this, "_head");
1545
1546
  __publicField(this, "_tail");
1546
1547
  __publicField(this, "_length", 0);
@@ -1628,6 +1629,7 @@ var redBlackTreeTyped = (() => {
1628
1629
  * @returns Removed element or undefined.
1629
1630
  */
1630
1631
  pop() {
1632
+ var _a;
1631
1633
  if (!this.head) return void 0;
1632
1634
  if (this.head === this.tail) {
1633
1635
  const value2 = this.head.value;
@@ -1637,8 +1639,8 @@ var redBlackTreeTyped = (() => {
1637
1639
  return value2;
1638
1640
  }
1639
1641
  let current = this.head;
1640
- while (current.next !== this.tail) current = current.next;
1641
- const value = this.tail.value;
1642
+ while (current.next && current.next !== this.tail) current = current.next;
1643
+ const value = (_a = this.tail) == null ? void 0 : _a.value;
1642
1644
  current.next = void 0;
1643
1645
  this._tail = current;
1644
1646
  this._length--;
@@ -1726,8 +1728,8 @@ var redBlackTreeTyped = (() => {
1726
1728
  at(index) {
1727
1729
  if (index < 0 || index >= this._length) return void 0;
1728
1730
  let current = this.head;
1729
- for (let i = 0; i < index; i++) current = current.next;
1730
- return current.value;
1731
+ for (let i = 0; i < index && current; i++) current = current.next;
1732
+ return current == null ? void 0 : current.value;
1731
1733
  }
1732
1734
  /**
1733
1735
  * Type guard: check whether the input is a SinglyLinkedListNode.
@@ -1747,7 +1749,7 @@ var redBlackTreeTyped = (() => {
1747
1749
  getNodeAt(index) {
1748
1750
  if (index < 0 || index >= this._length) return void 0;
1749
1751
  let current = this.head;
1750
- for (let i = 0; i < index; i++) current = current.next;
1752
+ for (let i = 0; i < index && current; i++) current = current.next;
1751
1753
  return current;
1752
1754
  }
1753
1755
  /**
@@ -2261,7 +2263,7 @@ var redBlackTreeTyped = (() => {
2261
2263
  */
2262
2264
  constructor(elements = [], options) {
2263
2265
  super(options);
2264
- __publicField(this, "_equals", Object.is);
2266
+ __publicField(this, "_equals", /* @__PURE__ */ __name((a, b) => Object.is(a, b), "_equals"));
2265
2267
  __publicField(this, "_head");
2266
2268
  __publicField(this, "_tail");
2267
2269
  __publicField(this, "_length", 0);
@@ -2449,8 +2451,8 @@ var redBlackTreeTyped = (() => {
2449
2451
  at(index) {
2450
2452
  if (index < 0 || index >= this._length) return void 0;
2451
2453
  let current = this.head;
2452
- for (let i = 0; i < index; i++) current = current.next;
2453
- return current.value;
2454
+ for (let i = 0; i < index && current; i++) current = current.next;
2455
+ return current == null ? void 0 : current.value;
2454
2456
  }
2455
2457
  /**
2456
2458
  * Get the node reference at a given index.
@@ -2461,7 +2463,7 @@ var redBlackTreeTyped = (() => {
2461
2463
  getNodeAt(index) {
2462
2464
  if (index < 0 || index >= this._length) return void 0;
2463
2465
  let current = this.head;
2464
- for (let i = 0; i < index; i++) current = current.next;
2466
+ for (let i = 0; i < index && current; i++) current = current.next;
2465
2467
  return current;
2466
2468
  }
2467
2469
  /**
@@ -2967,7 +2969,7 @@ var redBlackTreeTyped = (() => {
2967
2969
  */
2968
2970
  constructor(elements = [], options) {
2969
2971
  super(options);
2970
- __publicField(this, "_equals", Object.is);
2972
+ __publicField(this, "_equals", /* @__PURE__ */ __name((a, b) => Object.is(a, b), "_equals"));
2971
2973
  __publicField(this, "_elements", []);
2972
2974
  this.pushMany(elements);
2973
2975
  }
@@ -3596,7 +3598,7 @@ var redBlackTreeTyped = (() => {
3596
3598
  */
3597
3599
  constructor(elements = [], options) {
3598
3600
  super(options);
3599
- __publicField(this, "_equals", Object.is);
3601
+ __publicField(this, "_equals", /* @__PURE__ */ __name((a, b) => Object.is(a, b), "_equals"));
3600
3602
  __publicField(this, "_bucketSize", 1 << 12);
3601
3603
  __publicField(this, "_bucketFirst", 0);
3602
3604
  __publicField(this, "_firstInBucket", 0);
@@ -4665,11 +4667,6 @@ var redBlackTreeTyped = (() => {
4665
4667
  }
4666
4668
  return out;
4667
4669
  }
4668
- /**
4669
- * Get the comparator used to order elements.
4670
- * @remarks Time O(1), Space O(1)
4671
- * @returns Comparator function.
4672
- */
4673
4670
  /**
4674
4671
  * Get the comparator used to order elements.
4675
4672
  * @remarks Time O(1), Space O(1)
@@ -4718,8 +4715,7 @@ var redBlackTreeTyped = (() => {
4718
4715
  */
4719
4716
  _createInstance(options) {
4720
4717
  const Ctor = this.constructor;
4721
- const next = new Ctor([], { comparator: this.comparator, toElementFn: this.toElementFn, ...options != null ? options : {} });
4722
- return next;
4718
+ return new Ctor([], { comparator: this.comparator, toElementFn: this.toElementFn, ...options != null ? options : {} });
4723
4719
  }
4724
4720
  /**
4725
4721
  * (Protected) Create a like-kind instance seeded by elements.
@@ -5756,8 +5752,8 @@ var redBlackTreeTyped = (() => {
5756
5752
  const Ctor = this.constructor;
5757
5753
  const instance = new Ctor();
5758
5754
  const graph = _options == null ? void 0 : _options.graph;
5759
- if (graph) instance._options = { ...instance._options, ...graph };
5760
- else instance._options = { ...instance._options, ...this._options };
5755
+ if (graph) instance["_options"] = { ...instance["_options"], ...graph };
5756
+ else instance["_options"] = { ...instance["_options"], ...this._options };
5761
5757
  return instance;
5762
5758
  }
5763
5759
  /**
@@ -5790,12 +5786,10 @@ var redBlackTreeTyped = (() => {
5790
5786
  const [va, vb] = ends;
5791
5787
  const ka = va.key;
5792
5788
  const kb = vb.key;
5793
- const hasA = g.hasVertex ? g.hasVertex(ka) : false;
5794
- const hasB = g.hasVertex ? g.hasVertex(kb) : false;
5789
+ const hasA = typeof g.hasVertex === "function" ? g.hasVertex(ka) : false;
5790
+ const hasB = typeof g.hasVertex === "function" ? g.hasVertex(kb) : false;
5795
5791
  if (hasA && hasB) {
5796
- const w = e.weight;
5797
- const val = e.value;
5798
- const newEdge = g.createEdge(ka, kb, w, val);
5792
+ const newEdge = g.createEdge(ka, kb, e.weight, e.value);
5799
5793
  g._addEdge(newEdge);
5800
5794
  }
5801
5795
  }
@@ -6960,7 +6954,7 @@ var redBlackTreeTyped = (() => {
6960
6954
  __publicField(this, "_size", 0);
6961
6955
  __publicField(this, "_NIL", new BinaryTreeNode(NaN));
6962
6956
  __publicField(this, "_toEntryFn");
6963
- __publicField(this, "_DEFAULT_NODE_CALLBACK", /* @__PURE__ */ __name((node) => node ? node.key : void 0, "_DEFAULT_NODE_CALLBACK"));
6957
+ __publicField(this, "_DEFAULT_NODE_CALLBACK", /* @__PURE__ */ __name((node) => node == null ? void 0 : node.key, "_DEFAULT_NODE_CALLBACK"));
6964
6958
  if (options) {
6965
6959
  const { iterationType, toEntryFn, isMapMode, isDuplicate } = options;
6966
6960
  if (iterationType) this.iterationType = iterationType;
@@ -13142,7 +13136,7 @@ var redBlackTreeTyped = (() => {
13142
13136
  * @remarks Time O(1), Space O(1)
13143
13137
  */
13144
13138
  get comparator() {
13145
- return __privateGet(this, _core4)._comparator;
13139
+ return __privateGet(this, _core4).comparator;
13146
13140
  }
13147
13141
  // ━━━ clear ━━━
13148
13142
  /**
@@ -13279,7 +13273,7 @@ var redBlackTreeTyped = (() => {
13279
13273
  filter(predicate) {
13280
13274
  const result = new _TreeMultiSet2([], {
13281
13275
  comparator: __privateGet(this, _isDefaultComparator4) ? void 0 : this.comparator,
13282
- isMapMode: __privateGet(this, _core4)._isMapMode
13276
+ isMapMode: __privateGet(this, _core4).isMapMode
13283
13277
  });
13284
13278
  for (const [k, c] of this.entries()) {
13285
13279
  if (predicate(k, c)) {
@@ -13319,7 +13313,7 @@ var redBlackTreeTyped = (() => {
13319
13313
  map(mapper, options) {
13320
13314
  const result = new _TreeMultiSet2([], {
13321
13315
  comparator: options == null ? void 0 : options.comparator,
13322
- isMapMode: __privateGet(this, _core4)._isMapMode
13316
+ isMapMode: __privateGet(this, _core4).isMapMode
13323
13317
  });
13324
13318
  for (const [k, c] of this.entries()) {
13325
13319
  const [newKey, newCount] = mapper(k, c);
@@ -13339,7 +13333,7 @@ var redBlackTreeTyped = (() => {
13339
13333
  clone() {
13340
13334
  const result = new _TreeMultiSet2([], {
13341
13335
  comparator: __privateGet(this, _isDefaultComparator4) ? void 0 : this.comparator,
13342
- isMapMode: __privateGet(this, _core4)._isMapMode
13336
+ isMapMode: __privateGet(this, _core4).isMapMode
13343
13337
  });
13344
13338
  for (const [k, c] of this.entries()) {
13345
13339
  result.add(k, c);
@@ -14370,12 +14364,11 @@ var redBlackTreeTyped = (() => {
14370
14364
  */
14371
14365
  _createInstance(options) {
14372
14366
  const Ctor = this.constructor;
14373
- const next = new Ctor([], {
14367
+ return new Ctor([], {
14374
14368
  toElementFn: this.toElementFn,
14375
14369
  caseSensitive: this.caseSensitive,
14376
14370
  ...options != null ? options : {}
14377
14371
  });
14378
- return next;
14379
14372
  }
14380
14373
  /**
14381
14374
  * (Protected) Create a like-kind trie and seed it from an iterable.