data-structure-typed 2.2.6 → 2.2.8

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 (72) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/CONTRIBUTING.md +47 -1
  3. package/README.md +19 -8
  4. package/README_CN.md +119 -275
  5. package/benchmark/report.html +1 -1
  6. package/benchmark/report.json +20 -324
  7. package/dist/cjs/index.cjs +109 -107
  8. package/dist/cjs/index.cjs.map +1 -1
  9. package/dist/cjs-legacy/index.cjs +109 -107
  10. package/dist/cjs-legacy/index.cjs.map +1 -1
  11. package/dist/esm/index.mjs +109 -107
  12. package/dist/esm/index.mjs.map +1 -1
  13. package/dist/esm-legacy/index.mjs +109 -107
  14. package/dist/esm-legacy/index.mjs.map +1 -1
  15. package/dist/leetcode/avl-tree-counter.mjs +2957 -0
  16. package/dist/leetcode/avl-tree-multi-map.mjs +2889 -0
  17. package/dist/leetcode/avl-tree.mjs +2720 -0
  18. package/dist/leetcode/binary-tree.mjs +1594 -0
  19. package/dist/leetcode/bst.mjs +2398 -0
  20. package/dist/leetcode/deque.mjs +683 -0
  21. package/dist/leetcode/directed-graph.mjs +1733 -0
  22. package/dist/leetcode/doubly-linked-list.mjs +709 -0
  23. package/dist/leetcode/hash-map.mjs +493 -0
  24. package/dist/leetcode/heap.mjs +542 -0
  25. package/dist/leetcode/max-heap.mjs +375 -0
  26. package/dist/leetcode/max-priority-queue.mjs +383 -0
  27. package/dist/leetcode/min-heap.mjs +363 -0
  28. package/dist/leetcode/min-priority-queue.mjs +371 -0
  29. package/dist/leetcode/priority-queue.mjs +363 -0
  30. package/dist/leetcode/queue.mjs +943 -0
  31. package/dist/leetcode/red-black-tree.mjs +2765 -0
  32. package/dist/leetcode/singly-linked-list.mjs +754 -0
  33. package/dist/leetcode/stack.mjs +217 -0
  34. package/dist/leetcode/tree-counter.mjs +3039 -0
  35. package/dist/leetcode/tree-multi-map.mjs +2913 -0
  36. package/dist/leetcode/trie.mjs +413 -0
  37. package/dist/leetcode/undirected-graph.mjs +1650 -0
  38. package/dist/types/data-structures/binary-tree/avl-tree-counter.d.ts +1 -1
  39. package/dist/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +2 -2
  40. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +10 -10
  41. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +22 -23
  42. package/dist/types/data-structures/binary-tree/bst.d.ts +11 -11
  43. package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +1 -1
  44. package/dist/types/data-structures/binary-tree/tree-counter.d.ts +1 -1
  45. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +2 -2
  46. package/dist/umd/data-structure-typed.js +105 -103
  47. package/dist/umd/data-structure-typed.js.map +1 -1
  48. package/dist/umd/data-structure-typed.min.js +2 -2
  49. package/dist/umd/data-structure-typed.min.js.map +1 -1
  50. package/package.json +48 -171
  51. package/src/data-structures/binary-tree/avl-tree-counter.ts +6 -6
  52. package/src/data-structures/binary-tree/avl-tree-multi-map.ts +13 -13
  53. package/src/data-structures/binary-tree/avl-tree.ts +15 -15
  54. package/src/data-structures/binary-tree/binary-tree.ts +53 -55
  55. package/src/data-structures/binary-tree/bst.ts +21 -22
  56. package/src/data-structures/binary-tree/red-black-tree.ts +3 -3
  57. package/src/data-structures/binary-tree/tree-counter.ts +4 -4
  58. package/src/data-structures/binary-tree/tree-multi-map.ts +13 -13
  59. package/test/performance/data-structures/binary-tree/red-black-tree.test.ts +1 -2
  60. package/test/unit/data-structures/binary-tree/avl-tree-counter.test.ts +30 -30
  61. package/test/unit/data-structures/binary-tree/avl-tree-multi-map.test.ts +46 -46
  62. package/test/unit/data-structures/binary-tree/avl-tree.test.ts +43 -43
  63. package/test/unit/data-structures/binary-tree/binary-tree.test.ts +151 -151
  64. package/test/unit/data-structures/binary-tree/bst.test.ts +99 -99
  65. package/test/unit/data-structures/binary-tree/overall.test.ts +20 -20
  66. package/test/unit/data-structures/binary-tree/red-black-tree.test.ts +141 -141
  67. package/test/unit/data-structures/binary-tree/tree-counter.test.ts +37 -37
  68. package/test/unit/data-structures/binary-tree/tree-multi-map.test.ts +145 -145
  69. package/tsup.config.js +50 -21
  70. package/tsup.leetcode.config.js +1 -1
  71. package/tsup.umd.config.js +29 -0
  72. package/tsup.node.config.js +0 -83
@@ -277,6 +277,7 @@ var dataStructureTyped = (() => {
277
277
  * @remarks Time O(n), Space O(n)
278
278
  */
279
279
  print() {
280
+ console.log(this.toVisual());
280
281
  }
281
282
  };
282
283
 
@@ -496,6 +497,7 @@ var dataStructureTyped = (() => {
496
497
  * Time O(n) due to materialization, Space O(n) for the intermediate representation.
497
498
  */
498
499
  print() {
500
+ console.log(this.toVisual());
499
501
  }
500
502
  };
501
503
 
@@ -6987,9 +6989,9 @@ var dataStructureTyped = (() => {
6987
6989
  var BinaryTree = class extends IterableEntryBase {
6988
6990
  /**
6989
6991
  * Creates an instance of BinaryTree.
6990
- * @remarks Time O(N * M), where N is the number of items in `keysNodesEntriesOrRaws` and M is the tree size at insertion time (due to O(M) `add` operation). Space O(N) for storing the nodes.
6992
+ * @remarks Time O(N * M), where N is the number of items in `keysNodesEntriesOrRaws` and M is the tree size at insertion time (due to O(M) `set` operation). Space O(N) for storing the nodes.
6991
6993
  *
6992
- * @param [keysNodesEntriesOrRaws=[]] - An iterable of items to add.
6994
+ * @param [keysNodesEntriesOrRaws=[]] - An iterable of items to set.
6993
6995
  * @param [options] - Configuration options for the tree.
6994
6996
  */
6995
6997
  constructor(keysNodesEntriesOrRaws = [], options) {
@@ -7018,7 +7020,7 @@ var dataStructureTyped = (() => {
7018
7020
  if (typeof toEntryFn === "function") this._toEntryFn = toEntryFn;
7019
7021
  else if (toEntryFn) throw TypeError("toEntryFn must be a function type");
7020
7022
  }
7021
- if (keysNodesEntriesOrRaws) this.addMany(keysNodesEntriesOrRaws);
7023
+ if (keysNodesEntriesOrRaws) this.setMany(keysNodesEntriesOrRaws);
7022
7024
  }
7023
7025
  /**
7024
7026
  * Gets whether the tree is in Map mode.
@@ -7225,10 +7227,20 @@ var dataStructureTyped = (() => {
7225
7227
  * @remarks Time O(log N), For BST, Red-Black Tree, and AVL Tree subclasses, the worst-case time is O(log N). This implementation adds the node at the first available position in a level-order (BFS) traversal. This is NOT a Binary Search Tree insertion. Time O(N), where N is the number of nodes. It must traverse level-by-level to find an empty slot. Space O(N) in the worst case for the BFS queue (e.g., a full last level).
7226
7228
  *
7227
7229
  * @param keyNodeOrEntry - The key, node, or entry to add.
7230
+ * @returns True if the addition was successful, false otherwise.
7231
+ */
7232
+ add(keyNodeOrEntry) {
7233
+ return this.set(keyNodeOrEntry);
7234
+ }
7235
+ /**
7236
+ * Adds or updates a new node to the tree.
7237
+ * @remarks Time O(log N), For BST, Red-Black Tree, and AVL Tree subclasses, the worst-case time is O(log N). This implementation sets the node at the first available position in a level-order (BFS) traversal. This is NOT a Binary Search Tree insertion. Time O(N), where N is the number of nodes. It must traverse level-by-level to find an empty slot. Space O(N) in the worst case for the BFS queue (e.g., a full last level).
7238
+ *
7239
+ * @param keyNodeOrEntry - The key, node, or entry to set or update.
7228
7240
  * @param [value] - The value, if providing just a key.
7229
7241
  * @returns True if the addition was successful, false otherwise.
7230
7242
  */
7231
- add(keyNodeOrEntry, value) {
7243
+ set(keyNodeOrEntry, value) {
7232
7244
  const [newNode, newValue] = this._keyValueNodeOrEntryToNodeAndValue(keyNodeOrEntry, value);
7233
7245
  if (newNode === void 0) return false;
7234
7246
  if (!this._root) {
@@ -7272,25 +7284,25 @@ var dataStructureTyped = (() => {
7272
7284
  return false;
7273
7285
  }
7274
7286
  /**
7275
- * Adds or updates a new node to the tree.
7276
- * @remarks Time O(log N), For BST, Red-Black Tree, and AVL Tree subclasses, the worst-case time is O(log N). This implementation adds the node at the first available position in a level-order (BFS) traversal. This is NOT a Binary Search Tree insertion. Time O(N), where N is the number of nodes. It must traverse level-by-level to find an empty slot. Space O(N) in the worst case for the BFS queue (e.g., a full last level).
7287
+ * Adds multiple items to the tree.
7288
+ * @remarks Time O(N * M), where N is the number of items to set and M is the size of the tree at insertion (due to O(M) `set` operation). Space O(M) (from `set`) + O(N) (for the `inserted` array).
7277
7289
  *
7278
- * @param keyNodeOrEntry - The key, node, or entry to add or update.
7279
- * @param [value] - The value, if providing just a key.
7280
- * @returns True if the addition was successful, false otherwise.
7290
+ * @param keysNodesEntriesOrRaws - An iterable of items to set.
7291
+ * @param [values] - An optional parallel iterable of values.
7292
+ * @returns An array of booleans indicating the success of each individual `set` operation.
7281
7293
  */
7282
- set(keyNodeOrEntry, value) {
7283
- return this.add(keyNodeOrEntry, value);
7294
+ addMany(keysNodesEntriesOrRaws) {
7295
+ return this.setMany(keysNodesEntriesOrRaws);
7284
7296
  }
7285
7297
  /**
7286
- * Adds multiple items to the tree.
7287
- * @remarks Time O(N * M), where N is the number of items to add and M is the size of the tree at insertion (due to O(M) `add` operation). Space O(M) (from `add`) + O(N) (for the `inserted` array).
7298
+ * Adds or updates multiple items to the tree.
7299
+ * @remarks Time O(N * M), where N is the number of items to set and M is the size of the tree at insertion (due to O(M) `set` operation). Space O(M) (from `set`) + O(N) (for the `inserted` array).
7288
7300
  *
7289
- * @param keysNodesEntriesOrRaws - An iterable of items to add.
7301
+ * @param keysNodesEntriesOrRaws - An iterable of items to set or update.
7290
7302
  * @param [values] - An optional parallel iterable of values.
7291
- * @returns An array of booleans indicating the success of each individual `add` operation.
7303
+ * @returns An array of booleans indicating the success of each individual `set` operation.
7292
7304
  */
7293
- addMany(keysNodesEntriesOrRaws, values) {
7305
+ setMany(keysNodesEntriesOrRaws, values) {
7294
7306
  const inserted = [];
7295
7307
  let valuesIterator;
7296
7308
  if (values) {
@@ -7305,40 +7317,29 @@ var dataStructureTyped = (() => {
7305
7317
  }
7306
7318
  }
7307
7319
  if (this.isRaw(keyNodeEntryOrRaw)) keyNodeEntryOrRaw = this._toEntryFn(keyNodeEntryOrRaw);
7308
- inserted.push(this.add(keyNodeEntryOrRaw, value));
7320
+ inserted.push(this.set(keyNodeEntryOrRaw, value));
7309
7321
  }
7310
7322
  return inserted;
7311
7323
  }
7312
7324
  /**
7313
- * Adds or updates multiple items to the tree.
7314
- * @remarks Time O(N * M), where N is the number of items to add and M is the size of the tree at insertion (due to O(M) `add` operation). Space O(M) (from `add`) + O(N) (for the `inserted` array).
7315
- *
7316
- * @param keysNodesEntriesOrRaws - An iterable of items to add or update.
7317
- * @param [values] - An optional parallel iterable of values.
7318
- * @returns An array of booleans indicating the success of each individual `add` operation.
7319
- */
7320
- setMany(keysNodesEntriesOrRaws, values) {
7321
- return this.addMany(keysNodesEntriesOrRaws, values);
7322
- }
7323
- /**
7324
- * Merges another tree into this one by adding all its nodes.
7325
- * @remarks Time O(N * M), same as `addMany`, where N is the size of `anotherTree` and M is the size of this tree. Space O(M) (from `add`).
7325
+ * Merges another tree into this one by seting all its nodes.
7326
+ * @remarks Time O(N * M), same as `setMany`, where N is the size of `anotherTree` and M is the size of this tree. Space O(M) (from `set`).
7326
7327
  *
7327
7328
  * @param anotherTree - The tree to merge.
7328
7329
  */
7329
7330
  merge(anotherTree) {
7330
- this.addMany(anotherTree, []);
7331
+ this.setMany(anotherTree, []);
7331
7332
  }
7332
7333
  /**
7333
7334
  * Clears the tree and refills it with new items.
7334
- * @remarks Time O(N) (for `clear`) + O(N * M) (for `addMany`) = O(N * M). Space O(M) (from `addMany`).
7335
+ * @remarks Time O(N) (for `clear`) + O(N * M) (for `setMany`) = O(N * M). Space O(M) (from `setMany`).
7335
7336
  *
7336
- * @param keysNodesEntriesOrRaws - An iterable of items to add.
7337
+ * @param keysNodesEntriesOrRaws - An iterable of items to set.
7337
7338
  * @param [values] - An optional parallel iterable of values.
7338
7339
  */
7339
7340
  refill(keysNodesEntriesOrRaws, values) {
7340
7341
  this.clear();
7341
- this.addMany(keysNodesEntriesOrRaws, values);
7342
+ this.setMany(keysNodesEntriesOrRaws, values);
7342
7343
  }
7343
7344
  /**
7344
7345
  * Deletes a node from the tree.
@@ -8004,7 +8005,7 @@ var dataStructureTyped = (() => {
8004
8005
  }
8005
8006
  /**
8006
8007
  * Clones the tree.
8007
- * @remarks Time O(N * M), where N is the number of nodes and M is the tree size during insertion (due to `bfs` + `add`, and `add` is O(M)). Space O(N) for the new tree and the BFS queue.
8008
+ * @remarks Time O(N * M), where N is the number of nodes and M is the tree size during insertion (due to `bfs` + `set`, and `set` is O(M)). Space O(N) for the new tree and the BFS queue.
8008
8009
  *
8009
8010
  * @returns A new, cloned instance of the tree.
8010
8011
  */
@@ -8015,7 +8016,7 @@ var dataStructureTyped = (() => {
8015
8016
  }
8016
8017
  /**
8017
8018
  * Creates a new tree containing only the entries that satisfy the predicate.
8018
- * @remarks Time O(N * M), where N is nodes in this tree, and M is size of the new tree during insertion (O(N) iteration + O(M) `add` for each item). Space O(N) for the new tree.
8019
+ * @remarks Time O(N * M), where N is nodes in this tree, and M is size of the new tree during insertion (O(N) iteration + O(M) `set` for each item). Space O(N) for the new tree.
8019
8020
  *
8020
8021
  * @param predicate - A function to test each [key, value] pair.
8021
8022
  * @param [thisArg] - `this` context for the predicate.
@@ -8024,7 +8025,7 @@ var dataStructureTyped = (() => {
8024
8025
  filter(predicate, thisArg) {
8025
8026
  const out = this._createInstance();
8026
8027
  let i = 0;
8027
- for (const [k, v] of this) if (predicate.call(thisArg, v, k, i++, this)) out.add([k, v]);
8028
+ for (const [k, v] of this) if (predicate.call(thisArg, v, k, i++, this)) out.set([k, v]);
8028
8029
  return out;
8029
8030
  }
8030
8031
  /**
@@ -8042,7 +8043,7 @@ var dataStructureTyped = (() => {
8042
8043
  map(cb, options, thisArg) {
8043
8044
  const out = this._createLike([], options);
8044
8045
  let i = 0;
8045
- for (const [k, v] of this) out.add(cb.call(thisArg, v, k, i++, this));
8046
+ for (const [k, v] of this) out.set(cb.call(thisArg, v, k, i++, this));
8046
8047
  return out;
8047
8048
  }
8048
8049
  /**
@@ -8083,6 +8084,7 @@ var dataStructureTyped = (() => {
8083
8084
  * @param [startNode=this._root] - The node to start printing from.
8084
8085
  */
8085
8086
  print(options, startNode = this._root) {
8087
+ console.log(this.toVisual(startNode, options));
8086
8088
  }
8087
8089
  /**
8088
8090
  * (Protected) Core DFS implementation.
@@ -8287,18 +8289,18 @@ var dataStructureTyped = (() => {
8287
8289
  return [this.createNode(keyNodeOrEntry, value), value];
8288
8290
  }
8289
8291
  /**
8290
- * (Protected) Helper for cloning. Performs a BFS and adds all nodes to the new tree.
8291
- * @remarks Time O(N * M) (O(N) BFS + O(M) `add` for each node).
8292
+ * (Protected) Helper for cloning. Performs a BFS and sets all nodes to the new tree.
8293
+ * @remarks Time O(N * M) (O(N) BFS + O(M) `set` for each node).
8292
8294
  *
8293
8295
  * @param cloned - The new, empty tree instance to populate.
8294
8296
  */
8295
8297
  _clone(cloned) {
8296
8298
  this.bfs(
8297
8299
  (node) => {
8298
- if (node === null) cloned.add(null);
8300
+ if (node === null) cloned.set(null);
8299
8301
  else {
8300
- if (this._isMapMode) cloned.add([node.key, this._store.get(node.key)]);
8301
- else cloned.add([node.key, node.value]);
8302
+ if (this._isMapMode) cloned.set([node.key, this._store.get(node.key)]);
8303
+ else cloned.set([node.key, node.value]);
8302
8304
  }
8303
8305
  },
8304
8306
  this._root,
@@ -8625,7 +8627,7 @@ var dataStructureTyped = (() => {
8625
8627
  * Creates an instance of BST.
8626
8628
  * @remarks Time O(N log N) or O(N^2) depending on `isBalanceAdd` in `addMany` and input order. Space O(N).
8627
8629
  *
8628
- * @param [keysNodesEntriesOrRaws=[]] - An iterable of items to add.
8630
+ * @param [keysNodesEntriesOrRaws=[]] - An iterable of items to set.
8629
8631
  * @param [options] - Configuration options for the BST, including comparator.
8630
8632
  */
8631
8633
  constructor(keysNodesEntriesOrRaws = [], options) {
@@ -8646,7 +8648,7 @@ var dataStructureTyped = (() => {
8646
8648
  } else {
8647
8649
  this._comparator = this._createDefaultComparator();
8648
8650
  }
8649
- if (keysNodesEntriesOrRaws) this.addMany(keysNodesEntriesOrRaws);
8651
+ if (keysNodesEntriesOrRaws) this.setMany(keysNodesEntriesOrRaws);
8650
8652
  }
8651
8653
  /**
8652
8654
  * Gets the root node of the tree.
@@ -8857,11 +8859,11 @@ var dataStructureTyped = (() => {
8857
8859
  * Adds a new node to the BST based on key comparison.
8858
8860
  * @remarks Time O(log N), where H is tree height. O(N) worst-case (unbalanced tree), O(log N) average. Space O(1).
8859
8861
  *
8860
- * @param keyNodeOrEntry - The key, node, or entry to add.
8862
+ * @param keyNodeOrEntry - The key, node, or entry to set.
8861
8863
  * @param [value] - The value, if providing just a key.
8862
8864
  * @returns True if the addition was successful, false otherwise.
8863
8865
  */
8864
- add(keyNodeOrEntry, value) {
8866
+ set(keyNodeOrEntry, value) {
8865
8867
  const [newNode, newValue] = this._keyValueNodeOrEntryToNodeAndValue(keyNodeOrEntry, value);
8866
8868
  if (newNode === void 0) return false;
8867
8869
  if (this._root === void 0) {
@@ -8898,24 +8900,24 @@ var dataStructureTyped = (() => {
8898
8900
  }
8899
8901
  /**
8900
8902
  * Adds multiple items to the tree.
8901
- * @remarks If `isBalanceAdd` is true, sorts the input and builds a balanced tree. Time O(N log N) (due to sort and balanced add).
8903
+ * @remarks If `isBalanceAdd` is true, sorts the input and builds a balanced tree. Time O(N log N) (due to sort and balanced set).
8902
8904
  * If false, adds items one by one. Time O(N * H), which is O(N^2) worst-case.
8903
8905
  * Space O(N) for sorting and recursion/iteration stack.
8904
8906
  *
8905
- * @param keysNodesEntriesOrRaws - An iterable of items to add.
8907
+ * @param keysNodesEntriesOrRaws - An iterable of items to set.
8906
8908
  * @param [values] - An optional parallel iterable of values.
8907
8909
  * @param [isBalanceAdd=true] - If true, builds a balanced tree from the items.
8908
- * @param [iterationType=this.iterationType] - The traversal method for balanced add (recursive or iterative).
8909
- * @returns An array of booleans indicating the success of each individual `add` operation.
8910
+ * @param [iterationType=this.iterationType] - The traversal method for balanced set (recursive or iterative).
8911
+ * @returns An array of booleans indicating the success of each individual `set` operation.
8910
8912
  */
8911
- addMany(keysNodesEntriesOrRaws, values, isBalanceAdd = true, iterationType = this.iterationType) {
8913
+ setMany(keysNodesEntriesOrRaws, values, isBalanceAdd = true, iterationType = this.iterationType) {
8912
8914
  const inserted = [];
8913
8915
  const valuesIterator = values == null ? void 0 : values[Symbol.iterator]();
8914
8916
  if (!isBalanceAdd) {
8915
8917
  for (let kve of keysNodesEntriesOrRaws) {
8916
8918
  const val = valuesIterator == null ? void 0 : valuesIterator.next().value;
8917
8919
  if (this.isRaw(kve)) kve = this._toEntryFn(kve);
8918
- inserted.push(this.add(kve, val));
8920
+ inserted.push(this.set(kve, val));
8919
8921
  }
8920
8922
  return inserted;
8921
8923
  }
@@ -8943,9 +8945,9 @@ var dataStructureTyped = (() => {
8943
8945
  const { key, value, orgIndex } = arr[mid];
8944
8946
  if (this.isRaw(key)) {
8945
8947
  const entry = this._toEntryFn(key);
8946
- inserted[orgIndex] = this.add(entry);
8948
+ inserted[orgIndex] = this.set(entry);
8947
8949
  } else {
8948
- inserted[orgIndex] = this.add(key, value);
8950
+ inserted[orgIndex] = this.set(key, value);
8949
8951
  }
8950
8952
  _dfs(arr.slice(0, mid));
8951
8953
  _dfs(arr.slice(mid + 1));
@@ -8962,9 +8964,9 @@ var dataStructureTyped = (() => {
8962
8964
  const { key, value, orgIndex } = sorted[m];
8963
8965
  if (this.isRaw(key)) {
8964
8966
  const entry = this._toEntryFn(key);
8965
- inserted[orgIndex] = this.add(entry);
8967
+ inserted[orgIndex] = this.set(entry);
8966
8968
  } else {
8967
- inserted[orgIndex] = this.add(key, value);
8969
+ inserted[orgIndex] = this.set(key, value);
8968
8970
  }
8969
8971
  stack.push([m + 1, r]);
8970
8972
  stack.push([l, m - 1]);
@@ -9239,7 +9241,7 @@ var dataStructureTyped = (() => {
9239
9241
  const out = this._createLike([], options);
9240
9242
  let index = 0;
9241
9243
  for (const [key, value] of this) {
9242
- out.add(callback.call(thisArg, value, key, index++, this));
9244
+ out.set(callback.call(thisArg, value, key, index++, this));
9243
9245
  }
9244
9246
  return out;
9245
9247
  }
@@ -10415,14 +10417,14 @@ var dataStructureTyped = (() => {
10415
10417
  var AVLTree = class extends BST {
10416
10418
  /**
10417
10419
  * Creates an instance of AVLTree.
10418
- * @remarks Time O(N log N) (from `addMany` with balanced add). Space O(N).
10420
+ * @remarks Time O(N log N) (from `setMany` with balanced set). Space O(N).
10419
10421
  *
10420
- * @param [keysNodesEntriesOrRaws=[]] - An iterable of items to add.
10422
+ * @param [keysNodesEntriesOrRaws=[]] - An iterable of items to set.
10421
10423
  * @param [options] - Configuration options for the AVL tree.
10422
10424
  */
10423
10425
  constructor(keysNodesEntriesOrRaws = [], options) {
10424
10426
  super([], options);
10425
- if (keysNodesEntriesOrRaws) super.addMany(keysNodesEntriesOrRaws);
10427
+ if (keysNodesEntriesOrRaws) super.setMany(keysNodesEntriesOrRaws);
10426
10428
  }
10427
10429
  /**
10428
10430
  * (Protected) Creates a new AVL tree node.
@@ -10446,16 +10448,16 @@ var dataStructureTyped = (() => {
10446
10448
  return keyNodeOrEntry instanceof AVLTreeNode;
10447
10449
  }
10448
10450
  /**
10449
- * Adds a new node to the AVL tree and balances the tree path.
10450
- * @remarks Time O(log N) (O(H) for BST add + O(H) for `_balancePath`). Space O(H) for path/recursion.
10451
+ * Sets a new node to the AVL tree and balances the tree path.
10452
+ * @remarks Time O(log N) (O(H) for BST set + O(H) for `_balancePath`). Space O(H) for path/recursion.
10451
10453
  *
10452
- * @param keyNodeOrEntry - The key, node, or entry to add.
10454
+ * @param keyNodeOrEntry - The key, node, or entry to set.
10453
10455
  * @param [value] - The value, if providing just a key.
10454
10456
  * @returns True if the addition was successful, false otherwise.
10455
10457
  */
10456
- add(keyNodeOrEntry, value) {
10458
+ set(keyNodeOrEntry, value) {
10457
10459
  if (keyNodeOrEntry === null) return false;
10458
- const inserted = super.add(keyNodeOrEntry, value);
10460
+ const inserted = super.set(keyNodeOrEntry, value);
10459
10461
  if (inserted) this._balancePath(keyNodeOrEntry);
10460
10462
  return inserted;
10461
10463
  }
@@ -10507,7 +10509,7 @@ var dataStructureTyped = (() => {
10507
10509
  }
10508
10510
  /**
10509
10511
  * Creates a new AVLTree by mapping each [key, value] pair.
10510
- * @remarks Time O(N log N) (O(N) iteration + O(log M) `add` for each item into the new tree). Space O(N) for the new tree.
10512
+ * @remarks Time O(N log N) (O(N) iteration + O(log M) `set` for each item into the new tree). Space O(N) for the new tree.
10511
10513
  *
10512
10514
  * @template MK - New key type.
10513
10515
  * @template MV - New value type.
@@ -10521,7 +10523,7 @@ var dataStructureTyped = (() => {
10521
10523
  const out = this._createLike([], options);
10522
10524
  let index = 0;
10523
10525
  for (const [key, value] of this) {
10524
- out.add(callback.call(thisArg, value, key, index++, this));
10526
+ out.set(callback.call(thisArg, value, key, index++, this));
10525
10527
  }
10526
10528
  return out;
10527
10529
  }
@@ -10942,7 +10944,7 @@ var dataStructureTyped = (() => {
10942
10944
  __publicField(this, "_root");
10943
10945
  this._root = this.NIL;
10944
10946
  if (keysNodesEntriesOrRaws) {
10945
- this.addMany(keysNodesEntriesOrRaws);
10947
+ this.setMany(keysNodesEntriesOrRaws);
10946
10948
  }
10947
10949
  }
10948
10950
  /**
@@ -10989,7 +10991,7 @@ var dataStructureTyped = (() => {
10989
10991
  * @param [value]- See parameter type for details.
10990
10992
  * @returns True if inserted or updated; false if ignored.
10991
10993
  */
10992
- add(keyNodeOrEntry, value) {
10994
+ set(keyNodeOrEntry, value) {
10993
10995
  const [newNode, newValue] = this._keyValueNodeOrEntryToNodeAndValue(keyNodeOrEntry, value);
10994
10996
  if (!this.isRealNode(newNode)) return false;
10995
10997
  const insertStatus = this._insert(newNode);
@@ -11083,7 +11085,7 @@ var dataStructureTyped = (() => {
11083
11085
  const out = this._createLike([], options);
11084
11086
  let index = 0;
11085
11087
  for (const [key, value] of this) {
11086
- out.add(callback.call(thisArg, value, key, index++, this));
11088
+ out.set(callback.call(thisArg, value, key, index++, this));
11087
11089
  }
11088
11090
  return out;
11089
11091
  }
@@ -11468,7 +11470,7 @@ var dataStructureTyped = (() => {
11468
11470
  constructor(keysNodesEntriesOrRaws = [], options) {
11469
11471
  super([], { ...options, isMapMode: true });
11470
11472
  if (keysNodesEntriesOrRaws) {
11471
- this.addMany(keysNodesEntriesOrRaws);
11473
+ this.setMany(keysNodesEntriesOrRaws);
11472
11474
  }
11473
11475
  }
11474
11476
  createNode(key, value = []) {
@@ -11488,14 +11490,14 @@ var dataStructureTyped = (() => {
11488
11490
  * Insert a value or a list of values into the multimap. If the key exists, values are appended.
11489
11491
  * @remarks Time O(log N + M), Space O(1)
11490
11492
  * @param keyNodeOrEntry - Key, node, or [key, values] entry.
11491
- * @param [value] - Single value to add when a bare key is provided.
11493
+ * @param [value] - Single value to set when a bare key is provided.
11492
11494
  * @returns True if inserted or appended; false if ignored.
11493
11495
  */
11494
- add(keyNodeOrEntry, value) {
11495
- if (this.isRealNode(keyNodeOrEntry)) return super.add(keyNodeOrEntry);
11496
+ set(keyNodeOrEntry, value) {
11497
+ if (this.isRealNode(keyNodeOrEntry)) return super.set(keyNodeOrEntry);
11496
11498
  const _commonAdd = (key, values) => {
11497
11499
  if (key === void 0 || key === null) return false;
11498
- const _addToValues = () => {
11500
+ const _setToValues = () => {
11499
11501
  const existingValues = this.get(key);
11500
11502
  if (existingValues !== void 0 && values !== void 0) {
11501
11503
  for (const value2 of values) existingValues.push(value2);
@@ -11503,12 +11505,12 @@ var dataStructureTyped = (() => {
11503
11505
  }
11504
11506
  return false;
11505
11507
  };
11506
- const _addByNode = () => {
11508
+ const _setByNode = () => {
11507
11509
  const existingNode = this.getNode(key);
11508
11510
  if (this.isRealNode(existingNode)) {
11509
11511
  const existingValues = this.get(existingNode);
11510
11512
  if (existingValues === void 0) {
11511
- super.add(key, values);
11513
+ super.set(key, values);
11512
11514
  return true;
11513
11515
  }
11514
11516
  if (values !== void 0) {
@@ -11518,13 +11520,13 @@ var dataStructureTyped = (() => {
11518
11520
  return false;
11519
11521
  }
11520
11522
  } else {
11521
- return super.add(key, values);
11523
+ return super.set(key, values);
11522
11524
  }
11523
11525
  };
11524
11526
  if (this._isMapMode) {
11525
- return _addByNode() || _addToValues();
11527
+ return _setByNode() || _setToValues();
11526
11528
  }
11527
- return _addToValues() || _addByNode();
11529
+ return _setToValues() || _setByNode();
11528
11530
  };
11529
11531
  if (this.isEntry(keyNodeOrEntry)) {
11530
11532
  const [key, values] = keyNodeOrEntry;
@@ -11592,7 +11594,7 @@ var dataStructureTyped = (() => {
11592
11594
  map(callback, options, thisArg) {
11593
11595
  const out = this._createLike([], options);
11594
11596
  let i = 0;
11595
- for (const [k, v] of this) out.add(callback.call(thisArg, v, k, i++, this));
11597
+ for (const [k, v] of this) out.set(callback.call(thisArg, v, k, i++, this));
11596
11598
  return out;
11597
11599
  }
11598
11600
  /**
@@ -11771,7 +11773,7 @@ var dataStructureTyped = (() => {
11771
11773
  constructor(keysNodesEntriesOrRaws = [], options) {
11772
11774
  super([], { ...options });
11773
11775
  if (keysNodesEntriesOrRaws) {
11774
- this.addMany(keysNodesEntriesOrRaws);
11776
+ this.setMany(keysNodesEntriesOrRaws);
11775
11777
  }
11776
11778
  }
11777
11779
  createNode(key, value = []) {
@@ -11791,14 +11793,14 @@ var dataStructureTyped = (() => {
11791
11793
  * Insert a value or a list of values into the multimap. If the key exists, values are appended.
11792
11794
  * @remarks Time O(log N + M), Space O(1)
11793
11795
  * @param keyNodeOrEntry - Key, node, or [key, values] entry.
11794
- * @param [value] - Single value to add when a bare key is provided.
11796
+ * @param [value] - Single value to set when a bare key is provided.
11795
11797
  * @returns True if inserted or appended; false if ignored.
11796
11798
  */
11797
- add(keyNodeOrEntry, value) {
11798
- if (this.isRealNode(keyNodeOrEntry)) return super.add(keyNodeOrEntry);
11799
+ set(keyNodeOrEntry, value) {
11800
+ if (this.isRealNode(keyNodeOrEntry)) return super.set(keyNodeOrEntry);
11799
11801
  const _commonAdd = (key, values) => {
11800
11802
  if (key === void 0 || key === null) return false;
11801
- const _addToValues = () => {
11803
+ const _setToValues = () => {
11802
11804
  const existingValues = this.get(key);
11803
11805
  if (existingValues !== void 0 && values !== void 0) {
11804
11806
  for (const value2 of values) existingValues.push(value2);
@@ -11806,12 +11808,12 @@ var dataStructureTyped = (() => {
11806
11808
  }
11807
11809
  return false;
11808
11810
  };
11809
- const _addByNode = () => {
11811
+ const _setByNode = () => {
11810
11812
  const existingNode = this.getNode(key);
11811
11813
  if (this.isRealNode(existingNode)) {
11812
11814
  const existingValues = this.get(existingNode);
11813
11815
  if (existingValues === void 0) {
11814
- super.add(key, values);
11816
+ super.set(key, values);
11815
11817
  return true;
11816
11818
  }
11817
11819
  if (values !== void 0) {
@@ -11821,13 +11823,13 @@ var dataStructureTyped = (() => {
11821
11823
  return false;
11822
11824
  }
11823
11825
  } else {
11824
- return super.add(key, values);
11826
+ return super.set(key, values);
11825
11827
  }
11826
11828
  };
11827
11829
  if (this._isMapMode) {
11828
- return _addByNode() || _addToValues();
11830
+ return _setByNode() || _setToValues();
11829
11831
  }
11830
- return _addToValues() || _addByNode();
11832
+ return _setToValues() || _setByNode();
11831
11833
  };
11832
11834
  if (this.isEntry(keyNodeOrEntry)) {
11833
11835
  const [key, values] = keyNodeOrEntry;
@@ -11867,7 +11869,7 @@ var dataStructureTyped = (() => {
11867
11869
  map(callback, options, thisArg) {
11868
11870
  const out = this._createLike([], options);
11869
11871
  let i = 0;
11870
- for (const [k, v] of this) out.add(callback.call(thisArg, v, k, i++, this));
11872
+ for (const [k, v] of this) out.set(callback.call(thisArg, v, k, i++, this));
11871
11873
  return out;
11872
11874
  }
11873
11875
  /**
@@ -12049,7 +12051,7 @@ var dataStructureTyped = (() => {
12049
12051
  constructor(keysNodesEntriesOrRaws = [], options) {
12050
12052
  super([], options);
12051
12053
  __publicField(this, "_count", 0);
12052
- if (keysNodesEntriesOrRaws) this.addMany(keysNodesEntriesOrRaws);
12054
+ if (keysNodesEntriesOrRaws) this.setMany(keysNodesEntriesOrRaws);
12053
12055
  }
12054
12056
  /**
12055
12057
  * Get the total aggregate count across all nodes.
@@ -12088,10 +12090,10 @@ var dataStructureTyped = (() => {
12088
12090
  * @param [count] - How much to increase the node's count (default 1).
12089
12091
  * @returns True if inserted/updated; false if ignored.
12090
12092
  */
12091
- add(keyNodeOrEntry, value, count = 1) {
12093
+ set(keyNodeOrEntry, value, count = 1) {
12092
12094
  const [newNode, newValue] = this._keyValueNodeOrEntryToNodeAndValue(keyNodeOrEntry, value, count);
12093
12095
  const orgCount = (newNode == null ? void 0 : newNode.count) || 0;
12094
- const isSuccessAdded = super.add(newNode, newValue);
12096
+ const isSuccessAdded = super.set(newNode, newValue);
12095
12097
  if (isSuccessAdded) {
12096
12098
  this._count += orgCount;
12097
12099
  return true;
@@ -12244,7 +12246,7 @@ var dataStructureTyped = (() => {
12244
12246
  const out = this._createLike([], options);
12245
12247
  let index = 0;
12246
12248
  for (const [key, value] of this) {
12247
- out.add(callback.call(thisArg, value, key, index++, this));
12249
+ out.set(callback.call(thisArg, value, key, index++, this));
12248
12250
  }
12249
12251
  return out;
12250
12252
  }
@@ -12495,7 +12497,7 @@ var dataStructureTyped = (() => {
12495
12497
  constructor(keysNodesEntriesOrRaws = [], options) {
12496
12498
  super([], options);
12497
12499
  __publicField(this, "_count", 0);
12498
- if (keysNodesEntriesOrRaws) this.addMany(keysNodesEntriesOrRaws);
12500
+ if (keysNodesEntriesOrRaws) this.setMany(keysNodesEntriesOrRaws);
12499
12501
  }
12500
12502
  get count() {
12501
12503
  return this._count;
@@ -12529,11 +12531,11 @@ var dataStructureTyped = (() => {
12529
12531
  * @param [count] - How much to increase the node's count (default 1).
12530
12532
  * @returns True if inserted/updated; false if ignored.
12531
12533
  */
12532
- add(keyNodeOrEntry, value, count = 1) {
12534
+ set(keyNodeOrEntry, value, count = 1) {
12533
12535
  const [newNode, newValue] = this._keyValueNodeOrEntryToNodeAndValue(keyNodeOrEntry, value, count);
12534
12536
  if (newNode === void 0) return false;
12535
12537
  const orgNodeCount = (newNode == null ? void 0 : newNode.count) || 0;
12536
- const inserted = super.add(newNode, newValue);
12538
+ const inserted = super.set(newNode, newValue);
12537
12539
  if (inserted) {
12538
12540
  this._count += orgNodeCount;
12539
12541
  }
@@ -12642,9 +12644,9 @@ var dataStructureTyped = (() => {
12642
12644
  clone() {
12643
12645
  const out = this._createInstance();
12644
12646
  if (this._isMapMode) {
12645
- this.bfs((node) => out.add(node.key, void 0, node.count));
12647
+ this.bfs((node) => out.set(node.key, void 0, node.count));
12646
12648
  } else {
12647
- this.bfs((node) => out.add(node.key, node.value, node.count));
12649
+ this.bfs((node) => out.set(node.key, node.value, node.count));
12648
12650
  }
12649
12651
  if (this._isMapMode) out._store = this._store;
12650
12652
  return out;
@@ -12664,7 +12666,7 @@ var dataStructureTyped = (() => {
12664
12666
  const out = this._createLike([], options);
12665
12667
  let index = 0;
12666
12668
  for (const [key, value] of this) {
12667
- out.add(callback.call(thisArg, value, key, index++, this));
12669
+ out.set(callback.call(thisArg, value, key, index++, this));
12668
12670
  }
12669
12671
  return out;
12670
12672
  }