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