data-structure-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.
Files changed (44) hide show
  1. package/.github/workflows/release.yml +27 -0
  2. package/CHANGELOG.md +3 -1
  3. package/README.md +46 -50
  4. package/dist/cjs/index.cjs +27 -35
  5. package/dist/cjs-legacy/index.cjs +28 -35
  6. package/dist/esm/index.mjs +27 -35
  7. package/dist/esm-legacy/index.mjs +28 -35
  8. package/dist/types/data-structures/base/iterable-element-base.d.ts +1 -1
  9. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +5 -5
  10. package/dist/types/data-structures/binary-tree/bst.d.ts +1 -1
  11. package/dist/types/data-structures/graph/directed-graph.d.ts +2 -2
  12. package/dist/types/data-structures/graph/undirected-graph.d.ts +2 -2
  13. package/dist/types/data-structures/hash/hash-map.d.ts +2 -2
  14. package/dist/types/data-structures/heap/heap.d.ts +3 -7
  15. package/dist/types/types/data-structures/binary-tree/avl-tree.d.ts +1 -1
  16. package/dist/types/types/data-structures/binary-tree/red-black-tree.d.ts +1 -1
  17. package/dist/types/types/data-structures/linked-list/doubly-linked-list.d.ts +1 -1
  18. package/dist/types/types/data-structures/linked-list/singly-linked-list.d.ts +1 -1
  19. package/dist/types/types/data-structures/priority-queue/priority-queue.d.ts +1 -1
  20. package/dist/types/types/data-structures/stack/stack.d.ts +1 -1
  21. package/dist/umd/data-structure-typed.js +28 -35
  22. package/dist/umd/data-structure-typed.min.js +4 -4
  23. package/package.json +2 -2
  24. package/src/data-structures/base/iterable-element-base.ts +2 -2
  25. package/src/data-structures/binary-tree/binary-tree.ts +8 -7
  26. package/src/data-structures/binary-tree/bst.ts +1 -1
  27. package/src/data-structures/binary-tree/tree-multi-set.ts +5 -5
  28. package/src/data-structures/graph/abstract-graph.ts +18 -18
  29. package/src/data-structures/graph/directed-graph.ts +4 -4
  30. package/src/data-structures/graph/map-graph.ts +1 -1
  31. package/src/data-structures/graph/undirected-graph.ts +4 -4
  32. package/src/data-structures/hash/hash-map.ts +6 -4
  33. package/src/data-structures/heap/heap.ts +17 -14
  34. package/src/data-structures/linked-list/doubly-linked-list.ts +4 -4
  35. package/src/data-structures/linked-list/singly-linked-list.ts +15 -9
  36. package/src/data-structures/queue/deque.ts +1 -1
  37. package/src/data-structures/stack/stack.ts +1 -1
  38. package/src/data-structures/trie/trie.ts +10 -5
  39. package/src/types/data-structures/binary-tree/avl-tree.ts +1 -1
  40. package/src/types/data-structures/binary-tree/red-black-tree.ts +1 -1
  41. package/src/types/data-structures/linked-list/doubly-linked-list.ts +1 -1
  42. package/src/types/data-structures/linked-list/singly-linked-list.ts +1 -1
  43. package/src/types/data-structures/priority-queue/priority-queue.ts +1 -1
  44. package/src/types/data-structures/stack/stack.ts +1 -1
@@ -0,0 +1,27 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - 'v*'
7
+
8
+ permissions:
9
+ contents: write
10
+
11
+ jobs:
12
+ release:
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - name: Checkout
16
+ uses: actions/checkout@v4
17
+ with:
18
+ fetch-depth: 0
19
+
20
+ - name: Create GitHub Release
21
+ uses: softprops/action-gh-release@v1
22
+ with:
23
+ generate_release_notes: true
24
+ draft: false
25
+ prerelease: ${{ contains(github.ref, '-alpha') || contains(github.ref, '-beta') || contains(github.ref, '-rc') }}
26
+ env:
27
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
package/CHANGELOG.md CHANGED
@@ -8,7 +8,9 @@ All notable changes to this project will be documented in this file.
8
8
  - [Semantic Versioning](https://semver.org/spec/v2.0.0.html)
9
9
  - [`auto-changelog`](https://github.com/CookPete/auto-changelog)
10
10
 
11
- ## [v2.4.3](https://github.com/zrwusa/data-structure-typed/compare/v2.2.3...main) (upcoming)
11
+ ## [v2.4.4](https://github.com/zrwusa/data-structure-typed/compare/v2.4.3...main) (upcoming)
12
+
13
+ ## [v2.4.3](https://github.com/zrwusa/data-structure-typed/compare/v2.2.3...v2.4.3) (3 March 2026)
12
14
 
13
15
  ## [v2.2.3](https://github.com/zrwusa/data-structure-typed/compare/v2.2.2...v2.2.3) (6 January 2026)
14
16
 
package/README.md CHANGED
@@ -4,6 +4,8 @@ English | [简体中文](./README_CN.md)
4
4
 
5
5
  A comprehensive TypeScript data structures library with production-ready implementations.
6
6
 
7
+ **We TypeScript/JavaScript devs want something like C++'s `STL`, Java's `java.util` Collections, or Python's `collections` — but with an API that feels as intuitive and ergonomic as JavaScript's native `Array`.** If that's what you're looking for, you're in the right place. This is a zero-dependency library, and you can also install individual data structure packages separately if you prefer a more modular setup.
8
+
7
9
  ![npm](https://img.shields.io/npm/dm/data-structure-typed)
8
10
  ![GitHub contributors](https://img.shields.io/github/contributors/zrwusa/data-structure-typed)
9
11
  ![GITHUB Star](https://img.shields.io/github/stars/zrwusa/data-structure-typed)
@@ -12,19 +14,55 @@ A comprehensive TypeScript data structures library with production-ready impleme
12
14
  ![NPM](https://img.shields.io/npm/l/data-structure-typed)
13
15
  ![npm](https://img.shields.io/npm/v/data-structure-typed)
14
16
 
15
- **📚 [Installation](#-installation) • [Quick Start](#-quick-start-30-seconds) • [Full Docs](#-documentation) • [API Reference](./docs/REFERENCE.md) • [Playground](#playground) [Examples](./docs/GUIDES.md)**
17
+ **📦 [Installation](#-installation) • 🎮 [Playground](#-playground) • ⚡ [Quick Start](#-quick-start-30-seconds) • 📖 [Docs](#-documentation) • 📋 [API](./docs/REFERENCE.md) • 💡 [Examples](./docs/GUIDES.md)**
16
18
 
17
19
  ---
18
20
 
19
21
  ## Table of Contents
20
22
 
21
- 1. [Who Should Use This?](#-who-should-use-this)
22
- 2. [Why Not Just Array or Map?](#-why-not-just-array-or-map)
23
- 3. [Key Features](#-key-features)
24
- 4. [Installation](#-installation)
25
- 5. [Quick Start](#-quick-start-30-seconds)
26
- 6. [Data Structures](#-data-structures-available)
27
- 7. [Documentation](#-documentation)
23
+ 1. [Installation](#-installation)
24
+ 2. [Playground](#-playground)
25
+ 3. [Quick Start](#-quick-start-30-seconds)
26
+ 4. [Who Should Use This?](#-who-should-use-this)
27
+ 5. [Why Not Just Array or Map?](#-why-not-just-array-or-map)
28
+ 6. [Key Features](#-key-features)
29
+ 7. [Data Structures](#-data-structures-available)
30
+ 8. [Documentation](#-documentation)
31
+
32
+ ---
33
+
34
+ ## 📦 Installation
35
+
36
+ ```bash
37
+ npm i data-structure-typed
38
+ ```
39
+
40
+ ```bash
41
+ yarn add data-structure-typed
42
+ ```
43
+
44
+ ```bash
45
+ pnpm add data-structure-typed
46
+ ```
47
+
48
+ ### Individual Packages
49
+
50
+ Use only what you need:
51
+
52
+ ```bash
53
+ npm i heap-typed deque-typed red-black-tree-typed
54
+ ```
55
+
56
+ ---
57
+
58
+ ## 🎮 Playground
59
+
60
+ Try it instantly:
61
+
62
+ - [Node.js TypeScript](https://stackblitz.com/edit/stackblitz-starters-e1vdy3zw?file=src%2Findex.ts)
63
+ - [Node.js JavaScript](https://stackblitz.com/edit/stackblitz-starters-oczhrfzn?file=src%2Findex.js)
64
+ - [React TypeScript](https://stackblitz.com/edit/vitejs-vite-7bva1zhd?file=src%2FApp.tsx)
65
+ - [NestJS](https://stackblitz.com/edit/nestjs-typescript-starter-q9n7okgc?file=src%2Fproduct%2Fservices%2Fproduct-price-index.service.ts)
28
66
 
29
67
  ---
30
68
 
@@ -144,30 +182,6 @@ const set = new Set(tree); // Set constructor
144
182
 
145
183
  ---
146
184
 
147
- ## 📥 Installation
148
-
149
- ```bash
150
- pnpm add data-structure-typed
151
- ```
152
-
153
- ```bash
154
- npm i data-structure-typed --save
155
- ```
156
-
157
- ```bash
158
- yarn add data-structure-typed
159
- ```
160
-
161
- ### Individual Packages
162
-
163
- Use only what you need:
164
-
165
- ```bash
166
- pnpm add heap-typed deque-typed red-black-tree-typed
167
- ```
168
-
169
- ---
170
-
171
185
  ## 💡 When Should I Consider This Library?
172
186
 
173
187
  ✅ **When you need:**
@@ -494,24 +508,6 @@ const tree = new RedBlackTree([5, 2, 8]);
494
508
  console.log([...tree]); // [2, 5, 8] - Automatically sorted!
495
509
  ```
496
510
 
497
- ## Playground
498
-
499
- 🏃🏻‍♀️ Try it instantly:
500
-
501
- - [Node.js TypeScript](https://stackblitz.com/edit/stackblitz-starters-e1vdy3zw?file=src%2Findex.ts)
502
- - [Node.js JavaScript](https://stackblitz.com/edit/stackblitz-starters-oczhrfzn?file=src%2Findex.js)
503
- - [React TypeScript](https://stackblitz.com/edit/vitejs-vite-7bva1zhd?file=src%2FApp.tsx)
504
- - [NestJS](https://stackblitz.com/edit/nestjs-typescript-starter-q9n7okgc?file=src%2Fproduct%2Fservices%2Fproduct-price-index.service.ts)
505
-
506
-
507
- ### Step 4: Learn More
508
-
509
- 👉 Check [CONCEPTS.md](./docs/CONCEPTS.md) for core concepts
510
- 👉 See [GUIDES.md](./docs/GUIDES.md) for production examples
511
- 👉 Read [REFERENCE.md](./docs/REFERENCE.md) for complete API
512
-
513
- ---
514
-
515
511
  ## 📊 Comparison Chart
516
512
 
517
513
  ```
@@ -1021,8 +1021,9 @@ var LinkedHashMap = class extends IterableEntryBase {
1021
1021
  const cur = node;
1022
1022
  node = node.next;
1023
1023
  if (predicate(cur.key, cur.value, i++, this)) {
1024
- if (isWeakKey(cur.key)) {
1025
- this._objMap.delete(cur.key);
1024
+ const keyToCheck = cur.key;
1025
+ if (isWeakKey(keyToCheck)) {
1026
+ this._objMap.delete(keyToCheck);
1026
1027
  } else {
1027
1028
  const hash = this._hashFn(cur.key);
1028
1029
  delete this._noObjMap[hash];
@@ -1536,7 +1537,7 @@ var SinglyLinkedList = class extends LinearLinkedBase {
1536
1537
  static {
1537
1538
  __name(this, "SinglyLinkedList");
1538
1539
  }
1539
- _equals = Object.is;
1540
+ _equals = /* @__PURE__ */ __name((a, b) => Object.is(a, b), "_equals");
1540
1541
  /**
1541
1542
  * Create a SinglyLinkedList and optionally bulk-insert elements.
1542
1543
  * @remarks Time O(N), Space O(N)
@@ -1640,8 +1641,8 @@ var SinglyLinkedList = class extends LinearLinkedBase {
1640
1641
  return value2;
1641
1642
  }
1642
1643
  let current = this.head;
1643
- while (current.next !== this.tail) current = current.next;
1644
- const value = this.tail.value;
1644
+ while (current.next && current.next !== this.tail) current = current.next;
1645
+ const value = this.tail?.value;
1645
1646
  current.next = void 0;
1646
1647
  this._tail = current;
1647
1648
  this._length--;
@@ -1729,8 +1730,8 @@ var SinglyLinkedList = class extends LinearLinkedBase {
1729
1730
  at(index) {
1730
1731
  if (index < 0 || index >= this._length) return void 0;
1731
1732
  let current = this.head;
1732
- for (let i = 0; i < index; i++) current = current.next;
1733
- return current.value;
1733
+ for (let i = 0; i < index && current; i++) current = current.next;
1734
+ return current?.value;
1734
1735
  }
1735
1736
  /**
1736
1737
  * Type guard: check whether the input is a SinglyLinkedListNode.
@@ -1750,7 +1751,7 @@ var SinglyLinkedList = class extends LinearLinkedBase {
1750
1751
  getNodeAt(index) {
1751
1752
  if (index < 0 || index >= this._length) return void 0;
1752
1753
  let current = this.head;
1753
- for (let i = 0; i < index; i++) current = current.next;
1754
+ for (let i = 0; i < index && current; i++) current = current.next;
1754
1755
  return current;
1755
1756
  }
1756
1757
  /**
@@ -2259,7 +2260,7 @@ var DoublyLinkedList = class extends LinearLinkedBase {
2259
2260
  static {
2260
2261
  __name(this, "DoublyLinkedList");
2261
2262
  }
2262
- _equals = Object.is;
2263
+ _equals = /* @__PURE__ */ __name((a, b) => Object.is(a, b), "_equals");
2263
2264
  /**
2264
2265
  * Create a DoublyLinkedList and optionally bulk-insert elements.
2265
2266
  * @remarks Time O(N), Space O(N)
@@ -2454,8 +2455,8 @@ var DoublyLinkedList = class extends LinearLinkedBase {
2454
2455
  at(index) {
2455
2456
  if (index < 0 || index >= this._length) return void 0;
2456
2457
  let current = this.head;
2457
- for (let i = 0; i < index; i++) current = current.next;
2458
- return current.value;
2458
+ for (let i = 0; i < index && current; i++) current = current.next;
2459
+ return current?.value;
2459
2460
  }
2460
2461
  /**
2461
2462
  * Get the node reference at a given index.
@@ -2466,7 +2467,7 @@ var DoublyLinkedList = class extends LinearLinkedBase {
2466
2467
  getNodeAt(index) {
2467
2468
  if (index < 0 || index >= this._length) return void 0;
2468
2469
  let current = this.head;
2469
- for (let i = 0; i < index; i++) current = current.next;
2470
+ for (let i = 0; i < index && current; i++) current = current.next;
2470
2471
  return current;
2471
2472
  }
2472
2473
  /**
@@ -2972,7 +2973,7 @@ var Stack = class extends IterableElementBase {
2972
2973
  static {
2973
2974
  __name(this, "Stack");
2974
2975
  }
2975
- _equals = Object.is;
2976
+ _equals = /* @__PURE__ */ __name((a, b) => Object.is(a, b), "_equals");
2976
2977
  /**
2977
2978
  * Create a Stack and optionally bulk-push elements.
2978
2979
  * @remarks Time O(N), Space O(N)
@@ -3608,7 +3609,7 @@ var Deque = class extends LinearBase {
3608
3609
  static {
3609
3610
  __name(this, "Deque");
3610
3611
  }
3611
- _equals = Object.is;
3612
+ _equals = /* @__PURE__ */ __name((a, b) => Object.is(a, b), "_equals");
3612
3613
  /**
3613
3614
  * Create a Deque and optionally bulk-insert elements.
3614
3615
  * @remarks Time O(N), Space O(N)
@@ -4689,11 +4690,6 @@ var Heap = class _Heap extends IterableElementBase {
4689
4690
  return 0;
4690
4691
  }, "_DEFAULT_COMPARATOR");
4691
4692
  _comparator = this._DEFAULT_COMPARATOR;
4692
- /**
4693
- * Get the comparator used to order elements.
4694
- * @remarks Time O(1), Space O(1)
4695
- * @returns Comparator function.
4696
- */
4697
4693
  /**
4698
4694
  * Get the comparator used to order elements.
4699
4695
  * @remarks Time O(1), Space O(1)
@@ -4742,8 +4738,7 @@ var Heap = class _Heap extends IterableElementBase {
4742
4738
  */
4743
4739
  _createInstance(options) {
4744
4740
  const Ctor = this.constructor;
4745
- const next = new Ctor([], { comparator: this.comparator, toElementFn: this.toElementFn, ...options ?? {} });
4746
- return next;
4741
+ return new Ctor([], { comparator: this.comparator, toElementFn: this.toElementFn, ...options ?? {} });
4747
4742
  }
4748
4743
  /**
4749
4744
  * (Protected) Create a like-kind instance seeded by elements.
@@ -5792,8 +5787,8 @@ var AbstractGraph = class extends IterableEntryBase {
5792
5787
  const Ctor = this.constructor;
5793
5788
  const instance = new Ctor();
5794
5789
  const graph = _options?.graph;
5795
- if (graph) instance._options = { ...instance._options, ...graph };
5796
- else instance._options = { ...instance._options, ...this._options };
5790
+ if (graph) instance["_options"] = { ...instance["_options"], ...graph };
5791
+ else instance["_options"] = { ...instance["_options"], ...this._options };
5797
5792
  return instance;
5798
5793
  }
5799
5794
  /**
@@ -5826,12 +5821,10 @@ var AbstractGraph = class extends IterableEntryBase {
5826
5821
  const [va, vb] = ends;
5827
5822
  const ka = va.key;
5828
5823
  const kb = vb.key;
5829
- const hasA = g.hasVertex ? g.hasVertex(ka) : false;
5830
- const hasB = g.hasVertex ? g.hasVertex(kb) : false;
5824
+ const hasA = typeof g.hasVertex === "function" ? g.hasVertex(ka) : false;
5825
+ const hasB = typeof g.hasVertex === "function" ? g.hasVertex(kb) : false;
5831
5826
  if (hasA && hasB) {
5832
- const w = e.weight;
5833
- const val = e.value;
5834
- const newEdge = g.createEdge(ka, kb, w, val);
5827
+ const newEdge = g.createEdge(ka, kb, e.weight, e.value);
5835
5828
  g._addEdge(newEdge);
5836
5829
  }
5837
5830
  }
@@ -8258,7 +8251,7 @@ var BinaryTree = class extends IterableEntryBase {
8258
8251
  * @param node - The node.
8259
8252
  * @returns The node's key or undefined.
8260
8253
  */
8261
- _DEFAULT_NODE_CALLBACK = /* @__PURE__ */ __name((node) => node ? node.key : void 0, "_DEFAULT_NODE_CALLBACK");
8254
+ _DEFAULT_NODE_CALLBACK = /* @__PURE__ */ __name((node) => node?.key, "_DEFAULT_NODE_CALLBACK");
8262
8255
  /**
8263
8256
  * (Protected) Snapshots the current tree's configuration options.
8264
8257
  * @remarks Time O(1)
@@ -13229,7 +13222,7 @@ var TreeMultiSet = class _TreeMultiSet {
13229
13222
  * @remarks Time O(1), Space O(1)
13230
13223
  */
13231
13224
  get comparator() {
13232
- return this.#core._comparator;
13225
+ return this.#core.comparator;
13233
13226
  }
13234
13227
  // ━━━ clear ━━━
13235
13228
  /**
@@ -13366,7 +13359,7 @@ var TreeMultiSet = class _TreeMultiSet {
13366
13359
  filter(predicate) {
13367
13360
  const result = new _TreeMultiSet([], {
13368
13361
  comparator: this.#isDefaultComparator ? void 0 : this.comparator,
13369
- isMapMode: this.#core._isMapMode
13362
+ isMapMode: this.#core.isMapMode
13370
13363
  });
13371
13364
  for (const [k, c] of this.entries()) {
13372
13365
  if (predicate(k, c)) {
@@ -13406,7 +13399,7 @@ var TreeMultiSet = class _TreeMultiSet {
13406
13399
  map(mapper, options) {
13407
13400
  const result = new _TreeMultiSet([], {
13408
13401
  comparator: options?.comparator,
13409
- isMapMode: this.#core._isMapMode
13402
+ isMapMode: this.#core.isMapMode
13410
13403
  });
13411
13404
  for (const [k, c] of this.entries()) {
13412
13405
  const [newKey, newCount] = mapper(k, c);
@@ -13426,7 +13419,7 @@ var TreeMultiSet = class _TreeMultiSet {
13426
13419
  clone() {
13427
13420
  const result = new _TreeMultiSet([], {
13428
13421
  comparator: this.#isDefaultComparator ? void 0 : this.comparator,
13429
- isMapMode: this.#core._isMapMode
13422
+ isMapMode: this.#core.isMapMode
13430
13423
  });
13431
13424
  for (const [k, c] of this.entries()) {
13432
13425
  result.add(k, c);
@@ -14478,12 +14471,11 @@ var Trie = class extends IterableElementBase {
14478
14471
  */
14479
14472
  _createInstance(options) {
14480
14473
  const Ctor = this.constructor;
14481
- const next = new Ctor([], {
14474
+ return new Ctor([], {
14482
14475
  toElementFn: this.toElementFn,
14483
14476
  caseSensitive: this.caseSensitive,
14484
14477
  ...options ?? {}
14485
14478
  });
14486
- return next;
14487
14479
  }
14488
14480
  /**
14489
14481
  * (Protected) Create a like-kind trie and seed it from an iterable.
@@ -1025,8 +1025,9 @@ var _LinkedHashMap = class _LinkedHashMap extends IterableEntryBase {
1025
1025
  const cur = node;
1026
1026
  node = node.next;
1027
1027
  if (predicate(cur.key, cur.value, i++, this)) {
1028
- if (isWeakKey(cur.key)) {
1029
- this._objMap.delete(cur.key);
1028
+ const keyToCheck = cur.key;
1029
+ if (isWeakKey(keyToCheck)) {
1030
+ this._objMap.delete(keyToCheck);
1030
1031
  } else {
1031
1032
  const hash = this._hashFn(cur.key);
1032
1033
  delete this._noObjMap[hash];
@@ -1544,7 +1545,7 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1544
1545
  */
1545
1546
  constructor(elements = [], options) {
1546
1547
  super(options);
1547
- __publicField(this, "_equals", Object.is);
1548
+ __publicField(this, "_equals", /* @__PURE__ */ __name((a, b) => Object.is(a, b), "_equals"));
1548
1549
  __publicField(this, "_head");
1549
1550
  __publicField(this, "_tail");
1550
1551
  __publicField(this, "_length", 0);
@@ -1632,6 +1633,7 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1632
1633
  * @returns Removed element or undefined.
1633
1634
  */
1634
1635
  pop() {
1636
+ var _a;
1635
1637
  if (!this.head) return void 0;
1636
1638
  if (this.head === this.tail) {
1637
1639
  const value2 = this.head.value;
@@ -1641,8 +1643,8 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1641
1643
  return value2;
1642
1644
  }
1643
1645
  let current = this.head;
1644
- while (current.next !== this.tail) current = current.next;
1645
- const value = this.tail.value;
1646
+ while (current.next && current.next !== this.tail) current = current.next;
1647
+ const value = (_a = this.tail) == null ? void 0 : _a.value;
1646
1648
  current.next = void 0;
1647
1649
  this._tail = current;
1648
1650
  this._length--;
@@ -1730,8 +1732,8 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1730
1732
  at(index) {
1731
1733
  if (index < 0 || index >= this._length) return void 0;
1732
1734
  let current = this.head;
1733
- for (let i = 0; i < index; i++) current = current.next;
1734
- return current.value;
1735
+ for (let i = 0; i < index && current; i++) current = current.next;
1736
+ return current == null ? void 0 : current.value;
1735
1737
  }
1736
1738
  /**
1737
1739
  * Type guard: check whether the input is a SinglyLinkedListNode.
@@ -1751,7 +1753,7 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
1751
1753
  getNodeAt(index) {
1752
1754
  if (index < 0 || index >= this._length) return void 0;
1753
1755
  let current = this.head;
1754
- for (let i = 0; i < index; i++) current = current.next;
1756
+ for (let i = 0; i < index && current; i++) current = current.next;
1755
1757
  return current;
1756
1758
  }
1757
1759
  /**
@@ -2267,7 +2269,7 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2267
2269
  */
2268
2270
  constructor(elements = [], options) {
2269
2271
  super(options);
2270
- __publicField(this, "_equals", Object.is);
2272
+ __publicField(this, "_equals", /* @__PURE__ */ __name((a, b) => Object.is(a, b), "_equals"));
2271
2273
  __publicField(this, "_head");
2272
2274
  __publicField(this, "_tail");
2273
2275
  __publicField(this, "_length", 0);
@@ -2455,8 +2457,8 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2455
2457
  at(index) {
2456
2458
  if (index < 0 || index >= this._length) return void 0;
2457
2459
  let current = this.head;
2458
- for (let i = 0; i < index; i++) current = current.next;
2459
- return current.value;
2460
+ for (let i = 0; i < index && current; i++) current = current.next;
2461
+ return current == null ? void 0 : current.value;
2460
2462
  }
2461
2463
  /**
2462
2464
  * Get the node reference at a given index.
@@ -2467,7 +2469,7 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
2467
2469
  getNodeAt(index) {
2468
2470
  if (index < 0 || index >= this._length) return void 0;
2469
2471
  let current = this.head;
2470
- for (let i = 0; i < index; i++) current = current.next;
2472
+ for (let i = 0; i < index && current; i++) current = current.next;
2471
2473
  return current;
2472
2474
  }
2473
2475
  /**
@@ -2979,7 +2981,7 @@ var _Stack = class _Stack extends IterableElementBase {
2979
2981
  */
2980
2982
  constructor(elements = [], options) {
2981
2983
  super(options);
2982
- __publicField(this, "_equals", Object.is);
2984
+ __publicField(this, "_equals", /* @__PURE__ */ __name((a, b) => Object.is(a, b), "_equals"));
2983
2985
  __publicField(this, "_elements", []);
2984
2986
  this.pushMany(elements);
2985
2987
  }
@@ -3614,7 +3616,7 @@ var _Deque = class _Deque extends LinearBase {
3614
3616
  */
3615
3617
  constructor(elements = [], options) {
3616
3618
  super(options);
3617
- __publicField(this, "_equals", Object.is);
3619
+ __publicField(this, "_equals", /* @__PURE__ */ __name((a, b) => Object.is(a, b), "_equals"));
3618
3620
  __publicField(this, "_bucketSize", 1 << 12);
3619
3621
  __publicField(this, "_bucketFirst", 0);
3620
3622
  __publicField(this, "_firstInBucket", 0);
@@ -4686,11 +4688,6 @@ var _Heap = class _Heap extends IterableElementBase {
4686
4688
  }
4687
4689
  return out;
4688
4690
  }
4689
- /**
4690
- * Get the comparator used to order elements.
4691
- * @remarks Time O(1), Space O(1)
4692
- * @returns Comparator function.
4693
- */
4694
4691
  /**
4695
4692
  * Get the comparator used to order elements.
4696
4693
  * @remarks Time O(1), Space O(1)
@@ -4739,8 +4736,7 @@ var _Heap = class _Heap extends IterableElementBase {
4739
4736
  */
4740
4737
  _createInstance(options) {
4741
4738
  const Ctor = this.constructor;
4742
- const next = new Ctor([], { comparator: this.comparator, toElementFn: this.toElementFn, ...options != null ? options : {} });
4743
- return next;
4739
+ return new Ctor([], { comparator: this.comparator, toElementFn: this.toElementFn, ...options != null ? options : {} });
4744
4740
  }
4745
4741
  /**
4746
4742
  * (Protected) Create a like-kind instance seeded by elements.
@@ -5786,8 +5782,8 @@ var _AbstractGraph = class _AbstractGraph extends IterableEntryBase {
5786
5782
  const Ctor = this.constructor;
5787
5783
  const instance = new Ctor();
5788
5784
  const graph = _options == null ? void 0 : _options.graph;
5789
- if (graph) instance._options = { ...instance._options, ...graph };
5790
- else instance._options = { ...instance._options, ...this._options };
5785
+ if (graph) instance["_options"] = { ...instance["_options"], ...graph };
5786
+ else instance["_options"] = { ...instance["_options"], ...this._options };
5791
5787
  return instance;
5792
5788
  }
5793
5789
  /**
@@ -5820,12 +5816,10 @@ var _AbstractGraph = class _AbstractGraph extends IterableEntryBase {
5820
5816
  const [va, vb] = ends;
5821
5817
  const ka = va.key;
5822
5818
  const kb = vb.key;
5823
- const hasA = g.hasVertex ? g.hasVertex(ka) : false;
5824
- const hasB = g.hasVertex ? g.hasVertex(kb) : false;
5819
+ const hasA = typeof g.hasVertex === "function" ? g.hasVertex(ka) : false;
5820
+ const hasB = typeof g.hasVertex === "function" ? g.hasVertex(kb) : false;
5825
5821
  if (hasA && hasB) {
5826
- const w = e.weight;
5827
- const val = e.value;
5828
- const newEdge = g.createEdge(ka, kb, w, val);
5822
+ const newEdge = g.createEdge(ka, kb, e.weight, e.value);
5829
5823
  g._addEdge(newEdge);
5830
5824
  }
5831
5825
  }
@@ -7017,7 +7011,7 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
7017
7011
  * @param node - The node.
7018
7012
  * @returns The node's key or undefined.
7019
7013
  */
7020
- __publicField(this, "_DEFAULT_NODE_CALLBACK", /* @__PURE__ */ __name((node) => node ? node.key : void 0, "_DEFAULT_NODE_CALLBACK"));
7014
+ __publicField(this, "_DEFAULT_NODE_CALLBACK", /* @__PURE__ */ __name((node) => node == null ? void 0 : node.key, "_DEFAULT_NODE_CALLBACK"));
7021
7015
  if (options) {
7022
7016
  const { iterationType, toEntryFn, isMapMode, isDuplicate } = options;
7023
7017
  if (iterationType) this.iterationType = iterationType;
@@ -13237,7 +13231,7 @@ var _TreeMultiSet = class _TreeMultiSet {
13237
13231
  * @remarks Time O(1), Space O(1)
13238
13232
  */
13239
13233
  get comparator() {
13240
- return __privateGet(this, _core4)._comparator;
13234
+ return __privateGet(this, _core4).comparator;
13241
13235
  }
13242
13236
  // ━━━ clear ━━━
13243
13237
  /**
@@ -13374,7 +13368,7 @@ var _TreeMultiSet = class _TreeMultiSet {
13374
13368
  filter(predicate) {
13375
13369
  const result = new _TreeMultiSet([], {
13376
13370
  comparator: __privateGet(this, _isDefaultComparator4) ? void 0 : this.comparator,
13377
- isMapMode: __privateGet(this, _core4)._isMapMode
13371
+ isMapMode: __privateGet(this, _core4).isMapMode
13378
13372
  });
13379
13373
  for (const [k, c] of this.entries()) {
13380
13374
  if (predicate(k, c)) {
@@ -13414,7 +13408,7 @@ var _TreeMultiSet = class _TreeMultiSet {
13414
13408
  map(mapper, options) {
13415
13409
  const result = new _TreeMultiSet([], {
13416
13410
  comparator: options == null ? void 0 : options.comparator,
13417
- isMapMode: __privateGet(this, _core4)._isMapMode
13411
+ isMapMode: __privateGet(this, _core4).isMapMode
13418
13412
  });
13419
13413
  for (const [k, c] of this.entries()) {
13420
13414
  const [newKey, newCount] = mapper(k, c);
@@ -13434,7 +13428,7 @@ var _TreeMultiSet = class _TreeMultiSet {
13434
13428
  clone() {
13435
13429
  const result = new _TreeMultiSet([], {
13436
13430
  comparator: __privateGet(this, _isDefaultComparator4) ? void 0 : this.comparator,
13437
- isMapMode: __privateGet(this, _core4)._isMapMode
13431
+ isMapMode: __privateGet(this, _core4).isMapMode
13438
13432
  });
13439
13433
  for (const [k, c] of this.entries()) {
13440
13434
  result.add(k, c);
@@ -14482,12 +14476,11 @@ var _Trie = class _Trie extends IterableElementBase {
14482
14476
  */
14483
14477
  _createInstance(options) {
14484
14478
  const Ctor = this.constructor;
14485
- const next = new Ctor([], {
14479
+ return new Ctor([], {
14486
14480
  toElementFn: this.toElementFn,
14487
14481
  caseSensitive: this.caseSensitive,
14488
14482
  ...options != null ? options : {}
14489
14483
  });
14490
- return next;
14491
14484
  }
14492
14485
  /**
14493
14486
  * (Protected) Create a like-kind trie and seed it from an iterable.