binary-tree-typed 2.2.2 → 2.2.3

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 (46) hide show
  1. package/README.md +91 -7
  2. package/dist/cjs/index.cjs +22 -0
  3. package/dist/cjs/index.cjs.map +1 -1
  4. package/dist/cjs-legacy/index.cjs +22 -0
  5. package/dist/cjs-legacy/index.cjs.map +1 -1
  6. package/dist/esm/index.mjs +22 -0
  7. package/dist/esm/index.mjs.map +1 -1
  8. package/dist/esm-legacy/index.mjs +22 -0
  9. package/dist/esm-legacy/index.mjs.map +1 -1
  10. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +96 -2
  11. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +103 -7
  12. package/dist/types/data-structures/binary-tree/bst.d.ts +156 -13
  13. package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +84 -35
  14. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +2 -2
  15. package/dist/types/data-structures/graph/directed-graph.d.ts +126 -1
  16. package/dist/types/data-structures/graph/undirected-graph.d.ts +160 -1
  17. package/dist/types/data-structures/hash/hash-map.d.ts +110 -27
  18. package/dist/types/data-structures/heap/heap.d.ts +107 -58
  19. package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +72 -404
  20. package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +121 -5
  21. package/dist/types/data-structures/queue/deque.d.ts +95 -67
  22. package/dist/types/data-structures/queue/queue.d.ts +90 -34
  23. package/dist/types/data-structures/stack/stack.d.ts +58 -40
  24. package/dist/types/data-structures/trie/trie.d.ts +109 -47
  25. package/dist/types/interfaces/binary-tree.d.ts +1 -0
  26. package/dist/umd/binary-tree-typed.js +22 -0
  27. package/dist/umd/binary-tree-typed.js.map +1 -1
  28. package/dist/umd/binary-tree-typed.min.js +2 -2
  29. package/dist/umd/binary-tree-typed.min.js.map +1 -1
  30. package/package.json +2 -2
  31. package/src/data-structures/binary-tree/avl-tree.ts +96 -2
  32. package/src/data-structures/binary-tree/binary-tree.ts +117 -7
  33. package/src/data-structures/binary-tree/bst.ts +322 -13
  34. package/src/data-structures/binary-tree/red-black-tree.ts +84 -35
  35. package/src/data-structures/binary-tree/tree-multi-map.ts +2 -2
  36. package/src/data-structures/graph/directed-graph.ts +126 -1
  37. package/src/data-structures/graph/undirected-graph.ts +160 -1
  38. package/src/data-structures/hash/hash-map.ts +110 -27
  39. package/src/data-structures/heap/heap.ts +107 -58
  40. package/src/data-structures/linked-list/doubly-linked-list.ts +72 -404
  41. package/src/data-structures/linked-list/singly-linked-list.ts +121 -5
  42. package/src/data-structures/queue/deque.ts +95 -67
  43. package/src/data-structures/queue/queue.ts +90 -34
  44. package/src/data-structures/stack/stack.ts +58 -40
  45. package/src/data-structures/trie/trie.ts +109 -47
  46. package/src/interfaces/binary-tree.ts +2 -0
@@ -1466,6 +1466,17 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
1466
1466
  }
1467
1467
  return false;
1468
1468
  }
1469
+ /**
1470
+ * Adds or updates a new node to the tree.
1471
+ * @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).
1472
+ *
1473
+ * @param keyNodeOrEntry - The key, node, or entry to add or update.
1474
+ * @param [value] - The value, if providing just a key.
1475
+ * @returns True if the addition was successful, false otherwise.
1476
+ */
1477
+ set(keyNodeOrEntry, value) {
1478
+ return this.add(keyNodeOrEntry, value);
1479
+ }
1469
1480
  /**
1470
1481
  * Adds multiple items to the tree.
1471
1482
  * @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).
@@ -1493,6 +1504,17 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
1493
1504
  }
1494
1505
  return inserted;
1495
1506
  }
1507
+ /**
1508
+ * Adds or updates multiple items to the tree.
1509
+ * @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).
1510
+ *
1511
+ * @param keysNodesEntriesOrRaws - An iterable of items to add or update.
1512
+ * @param [values] - An optional parallel iterable of values.
1513
+ * @returns An array of booleans indicating the success of each individual `add` operation.
1514
+ */
1515
+ setMany(keysNodesEntriesOrRaws, values) {
1516
+ return this.addMany(keysNodesEntriesOrRaws, values);
1517
+ }
1496
1518
  /**
1497
1519
  * Merges another tree into this one by adding all its nodes.
1498
1520
  * @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`).