binary-tree-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 (30) hide show
  1. package/README.md +1 -1
  2. package/dist/cjs/index.cjs +42 -43
  3. package/dist/cjs/index.cjs.map +1 -1
  4. package/dist/cjs-legacy/index.cjs +42 -43
  5. package/dist/cjs-legacy/index.cjs.map +1 -1
  6. package/dist/esm/index.mjs +42 -43
  7. package/dist/esm/index.mjs.map +1 -1
  8. package/dist/esm-legacy/index.mjs +42 -43
  9. package/dist/esm-legacy/index.mjs.map +1 -1
  10. package/dist/types/data-structures/binary-tree/avl-tree-counter.d.ts +1 -1
  11. package/dist/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +2 -2
  12. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +10 -10
  13. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +22 -23
  14. package/dist/types/data-structures/binary-tree/bst.d.ts +11 -11
  15. package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +1 -1
  16. package/dist/types/data-structures/binary-tree/tree-counter.d.ts +1 -1
  17. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +2 -2
  18. package/dist/umd/binary-tree-typed.js +42 -43
  19. package/dist/umd/binary-tree-typed.js.map +1 -1
  20. package/dist/umd/binary-tree-typed.min.js +2 -2
  21. package/dist/umd/binary-tree-typed.min.js.map +1 -1
  22. package/package.json +2 -2
  23. package/src/data-structures/binary-tree/avl-tree-counter.ts +6 -6
  24. package/src/data-structures/binary-tree/avl-tree-multi-map.ts +13 -13
  25. package/src/data-structures/binary-tree/avl-tree.ts +15 -15
  26. package/src/data-structures/binary-tree/binary-tree.ts +53 -55
  27. package/src/data-structures/binary-tree/bst.ts +21 -22
  28. package/src/data-structures/binary-tree/red-black-tree.ts +3 -3
  29. package/src/data-structures/binary-tree/tree-counter.ts +4 -4
  30. package/src/data-structures/binary-tree/tree-multi-map.ts +13 -13
@@ -147,7 +147,7 @@ export declare class AVLTreeCounter<K = any, V = any, R = any> extends AVLTree<K
147
147
  * @param [count] - How much to increase the node's count (default 1).
148
148
  * @returns True if inserted/updated; false if ignored.
149
149
  */
150
- add(keyNodeOrEntry: K | AVLTreeCounterNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, value?: V, count?: number): boolean;
150
+ set(keyNodeOrEntry: K | AVLTreeCounterNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, value?: V, count?: number): boolean;
151
151
  /**
152
152
  * Delete a node (or decrement its count) and rebalance if needed.
153
153
  * @remarks Time O(log N), Space O(1)
@@ -132,8 +132,8 @@ export declare class AVLTreeMultiMap<K = any, V = any, R = any> extends AVLTree<
132
132
  * @returns True if it's a AVLTreeMultiMapNode, false otherwise.
133
133
  */
134
134
  isNode(keyNodeOrEntry: K | AVLTreeMultiMapNode<K, V> | [K | null | undefined, V[] | undefined] | null | undefined): keyNodeOrEntry is AVLTreeMultiMapNode<K, V>;
135
- add(keyNodeOrEntry: K | AVLTreeMultiMapNode<K, V> | [K | null | undefined, V[] | undefined] | null | undefined): boolean;
136
- add(key: K, value: V): boolean;
135
+ set(keyNodeOrEntry: K | AVLTreeMultiMapNode<K, V> | [K | null | undefined, V[] | undefined] | null | undefined): boolean;
136
+ set(key: K, value: V): boolean;
137
137
  /**
138
138
  * Delete a single value from the bucket at a given key. Removes the key if the bucket becomes empty.
139
139
  * @remarks Time O(log N), Space O(1)
@@ -112,7 +112,7 @@ export declare class AVLTreeNode<K = any, V = any> {
112
112
  }
113
113
  /**
114
114
  * Represents a self-balancing AVL (Adelson-Velsky and Landis) Tree.
115
- * This tree extends BST and performs rotations on add/delete to maintain balance.
115
+ * This tree extends BST and performs rotations on set/delete to maintain balance.
116
116
  *
117
117
  * @template K - The type of the key.
118
118
  * @template V - The type of the value.
@@ -145,7 +145,7 @@ export declare class AVLTreeNode<K = any, V = any> {
145
145
  * console.log(tree.size); // 5;
146
146
  *
147
147
  * // Add a new element
148
- * tree.add(3);
148
+ * tree.set(3);
149
149
  * console.log(tree.size); // 6;
150
150
  * console.log([...tree.keys()]); // [1, 2, 3, 5, 8, 9];
151
151
  * @example
@@ -208,7 +208,7 @@ export declare class AVLTreeNode<K = any, V = any> {
208
208
  * console.log(universityTree.isAVLBalanced()); // true;
209
209
  *
210
210
  * // Add more universities
211
- * universityTree.add(6, { name: 'Oxford', rank: 6, students: 2000 });
211
+ * universityTree.set(6, { name: 'Oxford', rank: 6, students: 2000 });
212
212
  * console.log(universityTree.isAVLBalanced()); // true;
213
213
  *
214
214
  * // Delete and verify balance is maintained
@@ -288,9 +288,9 @@ export declare class AVLTreeNode<K = any, V = any> {
288
288
  export declare class AVLTree<K = any, V = any, R = any> extends BST<K, V, R> implements IBinaryTree<K, V, R> {
289
289
  /**
290
290
  * Creates an instance of AVLTree.
291
- * @remarks Time O(N log N) (from `addMany` with balanced add). Space O(N).
291
+ * @remarks Time O(N log N) (from `setMany` with balanced set). Space O(N).
292
292
  *
293
- * @param [keysNodesEntriesOrRaws=[]] - An iterable of items to add.
293
+ * @param [keysNodesEntriesOrRaws=[]] - An iterable of items to set.
294
294
  * @param [options] - Configuration options for the AVL tree.
295
295
  */
296
296
  constructor(keysNodesEntriesOrRaws?: Iterable<K | AVLTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined | R>, options?: AVLTreeOptions<K, V, R>);
@@ -312,14 +312,14 @@ export declare class AVLTree<K = any, V = any, R = any> extends BST<K, V, R> imp
312
312
  */
313
313
  isNode(keyNodeOrEntry: K | AVLTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined): keyNodeOrEntry is AVLTreeNode<K, V>;
314
314
  /**
315
- * Adds a new node to the AVL tree and balances the tree path.
316
- * @remarks Time O(log N) (O(H) for BST add + O(H) for `_balancePath`). Space O(H) for path/recursion.
315
+ * Sets a new node to the AVL tree and balances the tree path.
316
+ * @remarks Time O(log N) (O(H) for BST set + O(H) for `_balancePath`). Space O(H) for path/recursion.
317
317
  *
318
- * @param keyNodeOrEntry - The key, node, or entry to add.
318
+ * @param keyNodeOrEntry - The key, node, or entry to set.
319
319
  * @param [value] - The value, if providing just a key.
320
320
  * @returns True if the addition was successful, false otherwise.
321
321
  */
322
- add(keyNodeOrEntry: K | AVLTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, value?: V): boolean;
322
+ set(keyNodeOrEntry: K | AVLTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, value?: V): boolean;
323
323
  /**
324
324
  * Deletes a node from the AVL tree and re-balances the tree.
325
325
  * @remarks Time O(log N) (O(H) for BST delete + O(H) for `_balancePath`). Space O(H) for path/recursion.
@@ -339,7 +339,7 @@ export declare class AVLTree<K = any, V = any, R = any> extends BST<K, V, R> imp
339
339
  perfectlyBalance(iterationType?: IterationType): boolean;
340
340
  /**
341
341
  * Creates a new AVLTree by mapping each [key, value] pair.
342
- * @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.
342
+ * @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.
343
343
  *
344
344
  * @template MK - New key type.
345
345
  * @template MV - New value type.
@@ -113,7 +113,7 @@ export declare class BinaryTreeNode<K = any, V = any> {
113
113
  *
114
114
  * @remarks
115
115
  * This class implements a basic Binary Tree, not a Binary Search Tree.
116
- * The `add` operation inserts nodes level-by-level (BFS) into the first available slot.
116
+ * The `set` operation inserts nodes level-by-level (BFS) into the first available slot.
117
117
  *
118
118
  * @template K - The type of the key.
119
119
  * @template V - The type of the value.
@@ -145,7 +145,7 @@ export declare class BinaryTreeNode<K = any, V = any> {
145
145
  * console.log(tree.size); // 9;
146
146
  *
147
147
  * // Add new element
148
- * tree.add(10, 'ten');
148
+ * tree.set(10, 'ten');
149
149
  * console.log(tree.size); // 10;
150
150
  * @example
151
151
  * // BinaryTree get and has operations
@@ -269,9 +269,9 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
269
269
  iterationType: IterationType;
270
270
  /**
271
271
  * Creates an instance of BinaryTree.
272
- * @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.
272
+ * @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.
273
273
  *
274
- * @param [keysNodesEntriesOrRaws=[]] - An iterable of items to add.
274
+ * @param [keysNodesEntriesOrRaws=[]] - An iterable of items to set.
275
275
  * @param [options] - Configuration options for the tree.
276
276
  */
277
277
  constructor(keysNodesEntriesOrRaws?: Iterable<K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined | R>, options?: BinaryTreeOptions<K, V, R>);
@@ -434,49 +434,48 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
434
434
  * @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).
435
435
  *
436
436
  * @param keyNodeOrEntry - The key, node, or entry to add.
437
- * @param [value] - The value, if providing just a key.
438
437
  * @returns True if the addition was successful, false otherwise.
439
438
  */
440
- add(keyNodeOrEntry: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, value?: V): boolean;
439
+ add(keyNodeOrEntry: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined): boolean;
441
440
  /**
442
441
  * Adds or updates a new node to the tree.
443
- * @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).
442
+ * @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).
444
443
  *
445
- * @param keyNodeOrEntry - The key, node, or entry to add or update.
444
+ * @param keyNodeOrEntry - The key, node, or entry to set or update.
446
445
  * @param [value] - The value, if providing just a key.
447
446
  * @returns True if the addition was successful, false otherwise.
448
447
  */
449
448
  set(keyNodeOrEntry: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, value?: V): boolean;
450
449
  /**
451
450
  * Adds multiple items to the tree.
452
- * @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).
451
+ * @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).
453
452
  *
454
- * @param keysNodesEntriesOrRaws - An iterable of items to add.
453
+ * @param keysNodesEntriesOrRaws - An iterable of items to set.
455
454
  * @param [values] - An optional parallel iterable of values.
456
- * @returns An array of booleans indicating the success of each individual `add` operation.
455
+ * @returns An array of booleans indicating the success of each individual `set` operation.
457
456
  */
458
- addMany(keysNodesEntriesOrRaws: Iterable<K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined | R>, values?: Iterable<V | undefined>): boolean[];
457
+ addMany(keysNodesEntriesOrRaws: Iterable<K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined | R>): boolean[];
459
458
  /**
460
459
  * Adds or updates multiple items to the tree.
461
- * @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).
460
+ * @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).
462
461
  *
463
- * @param keysNodesEntriesOrRaws - An iterable of items to add or update.
462
+ * @param keysNodesEntriesOrRaws - An iterable of items to set or update.
464
463
  * @param [values] - An optional parallel iterable of values.
465
- * @returns An array of booleans indicating the success of each individual `add` operation.
464
+ * @returns An array of booleans indicating the success of each individual `set` operation.
466
465
  */
467
466
  setMany(keysNodesEntriesOrRaws: Iterable<K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined | R>, values?: Iterable<V | undefined>): boolean[];
468
467
  /**
469
- * Merges another tree into this one by adding all its nodes.
470
- * @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`).
468
+ * Merges another tree into this one by seting all its nodes.
469
+ * @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`).
471
470
  *
472
471
  * @param anotherTree - The tree to merge.
473
472
  */
474
473
  merge(anotherTree: BinaryTree<K, V, R>): void;
475
474
  /**
476
475
  * Clears the tree and refills it with new items.
477
- * @remarks Time O(N) (for `clear`) + O(N * M) (for `addMany`) = O(N * M). Space O(M) (from `addMany`).
476
+ * @remarks Time O(N) (for `clear`) + O(N * M) (for `setMany`) = O(N * M). Space O(M) (from `setMany`).
478
477
  *
479
- * @param keysNodesEntriesOrRaws - An iterable of items to add.
478
+ * @param keysNodesEntriesOrRaws - An iterable of items to set.
480
479
  * @param [values] - An optional parallel iterable of values.
481
480
  */
482
481
  refill(keysNodesEntriesOrRaws: Iterable<K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined | R>, values?: Iterable<V | undefined>): void;
@@ -624,14 +623,14 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
624
623
  morris<C extends NodeCallback<BinaryTreeNode<K, V>>>(callback?: C, pattern?: DFSOrderPattern, startNode?: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined): ReturnType<C>[];
625
624
  /**
626
625
  * Clones the tree.
627
- * @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.
626
+ * @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.
628
627
  *
629
628
  * @returns A new, cloned instance of the tree.
630
629
  */
631
630
  clone(): this;
632
631
  /**
633
632
  * Creates a new tree containing only the entries that satisfy the predicate.
634
- * @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.
633
+ * @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.
635
634
  *
636
635
  * @param predicate - A function to test each [key, value] pair.
637
636
  * @param [thisArg] - `this` context for the predicate.
@@ -722,8 +721,8 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
722
721
  */
723
722
  protected _keyValueNodeOrEntryToNodeAndValue(keyNodeOrEntry: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, value?: V): [BinaryTreeNode<K, V> | null | undefined, V | undefined];
724
723
  /**
725
- * (Protected) Helper for cloning. Performs a BFS and adds all nodes to the new tree.
726
- * @remarks Time O(N * M) (O(N) BFS + O(M) `add` for each node).
724
+ * (Protected) Helper for cloning. Performs a BFS and sets all nodes to the new tree.
725
+ * @remarks Time O(N * M) (O(N) BFS + O(M) `set` for each node).
727
726
  *
728
727
  * @param cloned - The new, empty tree instance to populate.
729
728
  */
@@ -145,8 +145,8 @@ export declare class BSTNode<K = any, V = any> {
145
145
  * console.log(bst.size); // 16;
146
146
  *
147
147
  * // Add new elements
148
- * bst.add(17);
149
- * bst.add(0);
148
+ * bst.set(17);
149
+ * bst.set(0);
150
150
  * console.log(bst.size); // 18;
151
151
  *
152
152
  * // Verify keys are searchable
@@ -192,7 +192,7 @@ export declare class BSTNode<K = any, V = any> {
192
192
  *
193
193
  * // Merge datasets into a single BinarySearchTree
194
194
  * const merged = new BST<number, string>(dataset1);
195
- * merged.addMany(dataset2);
195
+ * merged.setMany(dataset2);
196
196
  * merged.merge(dataset3);
197
197
  *
198
198
  * // Verify merged dataset is in sorted order
@@ -276,7 +276,7 @@ export declare class BST<K = any, V = any, R = any> extends BinaryTree<K, V, R>
276
276
  * Creates an instance of BST.
277
277
  * @remarks Time O(N log N) or O(N^2) depending on `isBalanceAdd` in `addMany` and input order. Space O(N).
278
278
  *
279
- * @param [keysNodesEntriesOrRaws=[]] - An iterable of items to add.
279
+ * @param [keysNodesEntriesOrRaws=[]] - An iterable of items to set.
280
280
  * @param [options] - Configuration options for the BST, including comparator.
281
281
  */
282
282
  constructor(keysNodesEntriesOrRaws?: Iterable<K | BSTNode | [K | null | undefined, V | undefined] | null | undefined | R>, options?: BSTOptions<K, V, R>);
@@ -359,24 +359,24 @@ export declare class BST<K = any, V = any, R = any> extends BinaryTree<K, V, R>
359
359
  * Adds a new node to the BST based on key comparison.
360
360
  * @remarks Time O(log N), where H is tree height. O(N) worst-case (unbalanced tree), O(log N) average. Space O(1).
361
361
  *
362
- * @param keyNodeOrEntry - The key, node, or entry to add.
362
+ * @param keyNodeOrEntry - The key, node, or entry to set.
363
363
  * @param [value] - The value, if providing just a key.
364
364
  * @returns True if the addition was successful, false otherwise.
365
365
  */
366
- add(keyNodeOrEntry: K | BSTNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, value?: V): boolean;
366
+ set(keyNodeOrEntry: K | BSTNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, value?: V): boolean;
367
367
  /**
368
368
  * Adds multiple items to the tree.
369
- * @remarks If `isBalanceAdd` is true, sorts the input and builds a balanced tree. Time O(N log N) (due to sort and balanced add).
369
+ * @remarks If `isBalanceAdd` is true, sorts the input and builds a balanced tree. Time O(N log N) (due to sort and balanced set).
370
370
  * If false, adds items one by one. Time O(N * H), which is O(N^2) worst-case.
371
371
  * Space O(N) for sorting and recursion/iteration stack.
372
372
  *
373
- * @param keysNodesEntriesOrRaws - An iterable of items to add.
373
+ * @param keysNodesEntriesOrRaws - An iterable of items to set.
374
374
  * @param [values] - An optional parallel iterable of values.
375
375
  * @param [isBalanceAdd=true] - If true, builds a balanced tree from the items.
376
- * @param [iterationType=this.iterationType] - The traversal method for balanced add (recursive or iterative).
377
- * @returns An array of booleans indicating the success of each individual `add` operation.
376
+ * @param [iterationType=this.iterationType] - The traversal method for balanced set (recursive or iterative).
377
+ * @returns An array of booleans indicating the success of each individual `set` operation.
378
378
  */
379
- addMany(keysNodesEntriesOrRaws: Iterable<R | BTNRep<K, V, BSTNode<K, V>>>, values?: Iterable<V | undefined>, isBalanceAdd?: boolean, iterationType?: IterationType): boolean[];
379
+ setMany(keysNodesEntriesOrRaws: Iterable<R | BTNRep<K, V, BSTNode<K, V>>>, values?: Iterable<V | undefined>, isBalanceAdd?: boolean, iterationType?: IterationType): boolean[];
380
380
  /**
381
381
  * Returns the first key with a value >= target.
382
382
  * Equivalent to Java TreeMap.ceiling.
@@ -242,7 +242,7 @@ export declare class RedBlackTree<K = any, V = any, R = any> extends BST<K, V, R
242
242
  * @param [value]- See parameter type for details.
243
243
  * @returns True if inserted or updated; false if ignored.
244
244
  */
245
- add(keyNodeOrEntry: K | RedBlackTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, value?: V): boolean;
245
+ set(keyNodeOrEntry: K | RedBlackTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, value?: V): boolean;
246
246
  /**
247
247
  * Delete a node by key/node/entry and rebalance as needed.
248
248
  * @remarks Time O(log n), Space O(1)
@@ -154,7 +154,7 @@ export declare class TreeCounter<K = any, V = any, R = any> extends RedBlackTree
154
154
  * @param [count] - How much to increase the node's count (default 1).
155
155
  * @returns True if inserted/updated; false if ignored.
156
156
  */
157
- add(keyNodeOrEntry: K | TreeCounterNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, value?: V, count?: number): boolean;
157
+ set(keyNodeOrEntry: K | TreeCounterNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, value?: V, count?: number): boolean;
158
158
  /**
159
159
  * Delete a node (or decrement its count) and rebalance if needed.
160
160
  * @remarks Time O(log N), Space O(1)
@@ -297,8 +297,8 @@ export declare class TreeMultiMap<K = any, V = any, R = any> extends RedBlackTre
297
297
  * @returns True if it's a TreeMultiMapNode, false otherwise.
298
298
  */
299
299
  isNode(keyNodeOrEntry: K | TreeMultiMapNode<K, V> | [K | null | undefined, V[] | undefined] | null | undefined): keyNodeOrEntry is TreeMultiMapNode<K, V>;
300
- add(keyNodeOrEntry: K | TreeMultiMapNode<K, V> | [K | null | undefined, V[] | undefined] | null | undefined): boolean;
301
- add(key: K, value: V): boolean;
300
+ set(keyNodeOrEntry: K | TreeMultiMapNode<K, V> | [K | null | undefined, V[] | undefined] | null | undefined): boolean;
301
+ set(key: K, value: V): boolean;
302
302
  /**
303
303
  * Delete a single value from the bucket at a given key. Removes the key if the bucket becomes empty.
304
304
  * @remarks Time O(log N), Space O(1)
@@ -1195,9 +1195,9 @@ var binaryTreeTyped = (() => {
1195
1195
  var BinaryTree = class extends IterableEntryBase {
1196
1196
  /**
1197
1197
  * Creates an instance of BinaryTree.
1198
- * @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.
1198
+ * @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.
1199
1199
  *
1200
- * @param [keysNodesEntriesOrRaws=[]] - An iterable of items to add.
1200
+ * @param [keysNodesEntriesOrRaws=[]] - An iterable of items to set.
1201
1201
  * @param [options] - Configuration options for the tree.
1202
1202
  */
1203
1203
  constructor(keysNodesEntriesOrRaws = [], options) {
@@ -1226,7 +1226,7 @@ var binaryTreeTyped = (() => {
1226
1226
  if (typeof toEntryFn === "function") this._toEntryFn = toEntryFn;
1227
1227
  else if (toEntryFn) throw TypeError("toEntryFn must be a function type");
1228
1228
  }
1229
- if (keysNodesEntriesOrRaws) this.addMany(keysNodesEntriesOrRaws);
1229
+ if (keysNodesEntriesOrRaws) this.setMany(keysNodesEntriesOrRaws);
1230
1230
  }
1231
1231
  /**
1232
1232
  * Gets whether the tree is in Map mode.
@@ -1433,10 +1433,20 @@ var binaryTreeTyped = (() => {
1433
1433
  * @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).
1434
1434
  *
1435
1435
  * @param keyNodeOrEntry - The key, node, or entry to add.
1436
+ * @returns True if the addition was successful, false otherwise.
1437
+ */
1438
+ add(keyNodeOrEntry) {
1439
+ return this.set(keyNodeOrEntry);
1440
+ }
1441
+ /**
1442
+ * Adds or updates a new node to the tree.
1443
+ * @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).
1444
+ *
1445
+ * @param keyNodeOrEntry - The key, node, or entry to set or update.
1436
1446
  * @param [value] - The value, if providing just a key.
1437
1447
  * @returns True if the addition was successful, false otherwise.
1438
1448
  */
1439
- add(keyNodeOrEntry, value) {
1449
+ set(keyNodeOrEntry, value) {
1440
1450
  const [newNode, newValue] = this._keyValueNodeOrEntryToNodeAndValue(keyNodeOrEntry, value);
1441
1451
  if (newNode === void 0) return false;
1442
1452
  if (!this._root) {
@@ -1480,25 +1490,25 @@ var binaryTreeTyped = (() => {
1480
1490
  return false;
1481
1491
  }
1482
1492
  /**
1483
- * Adds or updates a new node to the tree.
1484
- * @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).
1493
+ * Adds multiple items to the tree.
1494
+ * @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).
1485
1495
  *
1486
- * @param keyNodeOrEntry - The key, node, or entry to add or update.
1487
- * @param [value] - The value, if providing just a key.
1488
- * @returns True if the addition was successful, false otherwise.
1496
+ * @param keysNodesEntriesOrRaws - An iterable of items to set.
1497
+ * @param [values] - An optional parallel iterable of values.
1498
+ * @returns An array of booleans indicating the success of each individual `set` operation.
1489
1499
  */
1490
- set(keyNodeOrEntry, value) {
1491
- return this.add(keyNodeOrEntry, value);
1500
+ addMany(keysNodesEntriesOrRaws) {
1501
+ return this.setMany(keysNodesEntriesOrRaws);
1492
1502
  }
1493
1503
  /**
1494
- * Adds multiple items to the tree.
1495
- * @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).
1504
+ * Adds or updates multiple items to the tree.
1505
+ * @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).
1496
1506
  *
1497
- * @param keysNodesEntriesOrRaws - An iterable of items to add.
1507
+ * @param keysNodesEntriesOrRaws - An iterable of items to set or update.
1498
1508
  * @param [values] - An optional parallel iterable of values.
1499
- * @returns An array of booleans indicating the success of each individual `add` operation.
1509
+ * @returns An array of booleans indicating the success of each individual `set` operation.
1500
1510
  */
1501
- addMany(keysNodesEntriesOrRaws, values) {
1511
+ setMany(keysNodesEntriesOrRaws, values) {
1502
1512
  const inserted = [];
1503
1513
  let valuesIterator;
1504
1514
  if (values) {
@@ -1513,40 +1523,29 @@ var binaryTreeTyped = (() => {
1513
1523
  }
1514
1524
  }
1515
1525
  if (this.isRaw(keyNodeEntryOrRaw)) keyNodeEntryOrRaw = this._toEntryFn(keyNodeEntryOrRaw);
1516
- inserted.push(this.add(keyNodeEntryOrRaw, value));
1526
+ inserted.push(this.set(keyNodeEntryOrRaw, value));
1517
1527
  }
1518
1528
  return inserted;
1519
1529
  }
1520
1530
  /**
1521
- * Adds or updates multiple items to the tree.
1522
- * @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).
1523
- *
1524
- * @param keysNodesEntriesOrRaws - An iterable of items to add or update.
1525
- * @param [values] - An optional parallel iterable of values.
1526
- * @returns An array of booleans indicating the success of each individual `add` operation.
1527
- */
1528
- setMany(keysNodesEntriesOrRaws, values) {
1529
- return this.addMany(keysNodesEntriesOrRaws, values);
1530
- }
1531
- /**
1532
- * Merges another tree into this one by adding all its nodes.
1533
- * @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`).
1531
+ * Merges another tree into this one by seting all its nodes.
1532
+ * @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`).
1534
1533
  *
1535
1534
  * @param anotherTree - The tree to merge.
1536
1535
  */
1537
1536
  merge(anotherTree) {
1538
- this.addMany(anotherTree, []);
1537
+ this.setMany(anotherTree, []);
1539
1538
  }
1540
1539
  /**
1541
1540
  * Clears the tree and refills it with new items.
1542
- * @remarks Time O(N) (for `clear`) + O(N * M) (for `addMany`) = O(N * M). Space O(M) (from `addMany`).
1541
+ * @remarks Time O(N) (for `clear`) + O(N * M) (for `setMany`) = O(N * M). Space O(M) (from `setMany`).
1543
1542
  *
1544
- * @param keysNodesEntriesOrRaws - An iterable of items to add.
1543
+ * @param keysNodesEntriesOrRaws - An iterable of items to set.
1545
1544
  * @param [values] - An optional parallel iterable of values.
1546
1545
  */
1547
1546
  refill(keysNodesEntriesOrRaws, values) {
1548
1547
  this.clear();
1549
- this.addMany(keysNodesEntriesOrRaws, values);
1548
+ this.setMany(keysNodesEntriesOrRaws, values);
1550
1549
  }
1551
1550
  /**
1552
1551
  * Deletes a node from the tree.
@@ -2212,7 +2211,7 @@ var binaryTreeTyped = (() => {
2212
2211
  }
2213
2212
  /**
2214
2213
  * Clones the tree.
2215
- * @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.
2214
+ * @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.
2216
2215
  *
2217
2216
  * @returns A new, cloned instance of the tree.
2218
2217
  */
@@ -2223,7 +2222,7 @@ var binaryTreeTyped = (() => {
2223
2222
  }
2224
2223
  /**
2225
2224
  * Creates a new tree containing only the entries that satisfy the predicate.
2226
- * @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.
2225
+ * @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.
2227
2226
  *
2228
2227
  * @param predicate - A function to test each [key, value] pair.
2229
2228
  * @param [thisArg] - `this` context for the predicate.
@@ -2232,7 +2231,7 @@ var binaryTreeTyped = (() => {
2232
2231
  filter(predicate, thisArg) {
2233
2232
  const out = this._createInstance();
2234
2233
  let i = 0;
2235
- for (const [k, v] of this) if (predicate.call(thisArg, v, k, i++, this)) out.add([k, v]);
2234
+ for (const [k, v] of this) if (predicate.call(thisArg, v, k, i++, this)) out.set([k, v]);
2236
2235
  return out;
2237
2236
  }
2238
2237
  /**
@@ -2250,7 +2249,7 @@ var binaryTreeTyped = (() => {
2250
2249
  map(cb, options, thisArg) {
2251
2250
  const out = this._createLike([], options);
2252
2251
  let i = 0;
2253
- for (const [k, v] of this) out.add(cb.call(thisArg, v, k, i++, this));
2252
+ for (const [k, v] of this) out.set(cb.call(thisArg, v, k, i++, this));
2254
2253
  return out;
2255
2254
  }
2256
2255
  /**
@@ -2496,18 +2495,18 @@ var binaryTreeTyped = (() => {
2496
2495
  return [this.createNode(keyNodeOrEntry, value), value];
2497
2496
  }
2498
2497
  /**
2499
- * (Protected) Helper for cloning. Performs a BFS and adds all nodes to the new tree.
2500
- * @remarks Time O(N * M) (O(N) BFS + O(M) `add` for each node).
2498
+ * (Protected) Helper for cloning. Performs a BFS and sets all nodes to the new tree.
2499
+ * @remarks Time O(N * M) (O(N) BFS + O(M) `set` for each node).
2501
2500
  *
2502
2501
  * @param cloned - The new, empty tree instance to populate.
2503
2502
  */
2504
2503
  _clone(cloned) {
2505
2504
  this.bfs(
2506
2505
  (node) => {
2507
- if (node === null) cloned.add(null);
2506
+ if (node === null) cloned.set(null);
2508
2507
  else {
2509
- if (this._isMapMode) cloned.add([node.key, this._store.get(node.key)]);
2510
- else cloned.add([node.key, node.value]);
2508
+ if (this._isMapMode) cloned.set([node.key, this._store.get(node.key)]);
2509
+ else cloned.set([node.key, node.value]);
2511
2510
  }
2512
2511
  },
2513
2512
  this._root,