data-structure-typed 1.42.3 → 1.42.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/dist/cjs/src/data-structures/binary-tree/avl-tree.d.ts +2 -2
  3. package/dist/cjs/src/data-structures/binary-tree/avl-tree.js +5 -3
  4. package/dist/cjs/src/data-structures/binary-tree/avl-tree.js.map +1 -1
  5. package/dist/cjs/src/data-structures/binary-tree/binary-tree.d.ts +56 -52
  6. package/dist/cjs/src/data-structures/binary-tree/binary-tree.js +115 -53
  7. package/dist/cjs/src/data-structures/binary-tree/binary-tree.js.map +1 -1
  8. package/dist/cjs/src/data-structures/binary-tree/bst.d.ts +42 -15
  9. package/dist/cjs/src/data-structures/binary-tree/bst.js +77 -21
  10. package/dist/cjs/src/data-structures/binary-tree/bst.js.map +1 -1
  11. package/dist/cjs/src/data-structures/binary-tree/rb-tree.d.ts +28 -51
  12. package/dist/cjs/src/data-structures/binary-tree/rb-tree.js +148 -180
  13. package/dist/cjs/src/data-structures/binary-tree/rb-tree.js.map +1 -1
  14. package/dist/cjs/src/data-structures/binary-tree/tree-multiset.d.ts +10 -10
  15. package/dist/cjs/src/data-structures/binary-tree/tree-multiset.js +20 -17
  16. package/dist/cjs/src/data-structures/binary-tree/tree-multiset.js.map +1 -1
  17. package/dist/cjs/src/types/data-structures/binary-tree/binary-tree.d.ts +1 -1
  18. package/dist/cjs/src/types/data-structures/binary-tree/rb-tree.d.ts +4 -0
  19. package/dist/cjs/src/types/data-structures/binary-tree/rb-tree.js +0 -5
  20. package/dist/cjs/src/types/data-structures/binary-tree/rb-tree.js.map +1 -1
  21. package/dist/mjs/src/data-structures/binary-tree/avl-tree.d.ts +2 -2
  22. package/dist/mjs/src/data-structures/binary-tree/avl-tree.js +5 -3
  23. package/dist/mjs/src/data-structures/binary-tree/binary-tree.d.ts +56 -52
  24. package/dist/mjs/src/data-structures/binary-tree/binary-tree.js +115 -53
  25. package/dist/mjs/src/data-structures/binary-tree/bst.d.ts +42 -15
  26. package/dist/mjs/src/data-structures/binary-tree/bst.js +79 -21
  27. package/dist/mjs/src/data-structures/binary-tree/rb-tree.d.ts +28 -51
  28. package/dist/mjs/src/data-structures/binary-tree/rb-tree.js +148 -184
  29. package/dist/mjs/src/data-structures/binary-tree/tree-multiset.d.ts +10 -10
  30. package/dist/mjs/src/data-structures/binary-tree/tree-multiset.js +19 -17
  31. package/dist/mjs/src/types/data-structures/binary-tree/binary-tree.d.ts +1 -1
  32. package/dist/mjs/src/types/data-structures/binary-tree/rb-tree.d.ts +4 -0
  33. package/dist/mjs/src/types/data-structures/binary-tree/rb-tree.js +0 -5
  34. package/dist/umd/data-structure-typed.min.js +1 -1
  35. package/dist/umd/data-structure-typed.min.js.map +1 -1
  36. package/package.json +1 -1
  37. package/src/data-structures/binary-tree/avl-tree.ts +5 -4
  38. package/src/data-structures/binary-tree/binary-tree.ts +201 -131
  39. package/src/data-structures/binary-tree/bst.ts +100 -34
  40. package/src/data-structures/binary-tree/rb-tree.ts +227 -236
  41. package/src/data-structures/binary-tree/tree-multiset.ts +24 -23
  42. package/src/types/data-structures/binary-tree/binary-tree.ts +1 -1
  43. package/src/types/data-structures/binary-tree/rb-tree.ts +5 -5
  44. package/test/unit/data-structures/binary-tree/avl-tree.test.ts +20 -1
  45. package/test/unit/data-structures/binary-tree/binary-tree.test.ts +12 -31
  46. package/test/unit/data-structures/binary-tree/bst.test.ts +3 -3
  47. package/test/unit/data-structures/binary-tree/rb-tree.test.ts +205 -159
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "data-structure-typed",
3
- "version": "1.42.3",
3
+ "version": "1.42.4",
4
4
  "description": "Data Structures of Javascript & TypeScript. Binary Tree, BST, Graph, Heap, Priority Queue, Linked List, Queue, Deque, Stack, AVL Tree, Tree Multiset, Trie, Directed Graph, Undirected Graph, Singly Linked List, Doubly Linked List, Max Heap, Max Priority Queue, Min Heap, Min Priority Queue.",
5
5
  "main": "dist/cjs/src/index.js",
6
6
  "module": "dist/mjs/src/index.js",
@@ -49,13 +49,14 @@ export class AVLTree<V = any, N extends AVLTreeNode<V, N> = AVLTreeNode<V, AVLTr
49
49
  /**
50
50
  * The function overrides the add method of a binary tree node and balances the tree after inserting
51
51
  * a new node.
52
- * @param {BTNKey | N | null} keyOrNode - The `keyOrNode` parameter can accept either a
52
+ * @param {BTNKey | N | undefined} keyOrNode - The `keyOrNode` parameter can accept either a
53
53
  * `BTNKey` or a `N` (which represents a node in the binary tree) or `null`.
54
54
  * @param [value] - The `value` parameter is the value that you want to assign to the new node that you
55
55
  * are adding to the binary search tree.
56
56
  * @returns The method is returning the inserted node (`N`), `null`, or `undefined`.
57
57
  */
58
- override add(keyOrNode: BTNKey | N | null, value?: V): N | null | undefined {
58
+ override add(keyOrNode: BTNKey | N | null | undefined, value?: V): N | undefined {
59
+ if (keyOrNode === null) return undefined;
59
60
  const inserted = super.add(keyOrNode, value);
60
61
  if (inserted) this._balancePath(inserted);
61
62
  return inserted;
@@ -226,7 +227,7 @@ export class AVLTree<V = any, N extends AVLTreeNode<V, N> = AVLTreeNode<V, AVLTr
226
227
  protected _balanceLR(A: N): void {
227
228
  const parentOfA = A.parent;
228
229
  const B = A.left;
229
- let C = null;
230
+ let C = undefined;
230
231
  if (B) {
231
232
  C = B.right;
232
233
  }
@@ -309,7 +310,7 @@ export class AVLTree<V = any, N extends AVLTreeNode<V, N> = AVLTreeNode<V, AVLTr
309
310
  protected _balanceRL(A: N): void {
310
311
  const parentOfA = A.parent;
311
312
  const B = A.right;
312
- let C = null;
313
+ let C = undefined;
313
314
  if (B) {
314
315
  C = B.left;
315
316
  }