data-structure-typed 1.43.0 → 1.43.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 (71) hide show
  1. package/.eslintrc.js +3 -1
  2. package/CHANGELOG.md +1 -1
  3. package/README.md +28 -12
  4. package/benchmark/report.html +33 -24
  5. package/benchmark/report.json +224 -125
  6. package/dist/cjs/src/data-structures/binary-tree/avl-tree.js.map +1 -1
  7. package/dist/cjs/src/data-structures/binary-tree/binary-tree.d.ts +8 -8
  8. package/dist/cjs/src/data-structures/binary-tree/binary-tree.js +62 -62
  9. package/dist/cjs/src/data-structures/binary-tree/binary-tree.js.map +1 -1
  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 +4 -4
  12. package/dist/cjs/src/data-structures/binary-tree/rb-tree.js +1 -1
  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-multimap.d.ts +24 -24
  15. package/dist/cjs/src/data-structures/binary-tree/tree-multimap.js +50 -50
  16. package/dist/cjs/src/data-structures/binary-tree/tree-multimap.js.map +1 -1
  17. package/dist/cjs/src/data-structures/graph/abstract-graph.d.ts +37 -37
  18. package/dist/cjs/src/data-structures/graph/abstract-graph.js +37 -37
  19. package/dist/cjs/src/data-structures/graph/abstract-graph.js.map +1 -1
  20. package/dist/cjs/src/data-structures/graph/directed-graph.js.map +1 -1
  21. package/dist/cjs/src/data-structures/graph/map-graph.js.map +1 -1
  22. package/dist/cjs/src/data-structures/graph/undirected-graph.js.map +1 -1
  23. package/dist/cjs/src/data-structures/heap/heap.js.map +1 -1
  24. package/dist/cjs/src/interfaces/binary-tree.d.ts +1 -1
  25. package/dist/mjs/src/data-structures/binary-tree/binary-tree.d.ts +8 -8
  26. package/dist/mjs/src/data-structures/binary-tree/binary-tree.js +62 -62
  27. package/dist/mjs/src/data-structures/binary-tree/rb-tree.d.ts +4 -4
  28. package/dist/mjs/src/data-structures/binary-tree/rb-tree.js +1 -1
  29. package/dist/mjs/src/data-structures/binary-tree/tree-multimap.d.ts +24 -24
  30. package/dist/mjs/src/data-structures/binary-tree/tree-multimap.js +50 -50
  31. package/dist/mjs/src/data-structures/graph/abstract-graph.d.ts +37 -37
  32. package/dist/mjs/src/data-structures/graph/abstract-graph.js +37 -37
  33. package/dist/mjs/src/interfaces/binary-tree.d.ts +1 -1
  34. package/dist/umd/data-structure-typed.js +10497 -0
  35. package/dist/umd/data-structure-typed.min.js +1 -1
  36. package/dist/umd/data-structure-typed.min.js.map +1 -1
  37. package/package.json +3 -2
  38. package/src/data-structures/binary-tree/avl-tree.ts +2 -3
  39. package/src/data-structures/binary-tree/binary-tree.ts +85 -92
  40. package/src/data-structures/binary-tree/bst.ts +14 -22
  41. package/src/data-structures/binary-tree/rb-tree.ts +11 -20
  42. package/src/data-structures/binary-tree/tree-multimap.ts +56 -58
  43. package/src/data-structures/graph/abstract-graph.ts +6 -22
  44. package/src/data-structures/graph/directed-graph.ts +3 -9
  45. package/src/data-structures/graph/map-graph.ts +6 -6
  46. package/src/data-structures/graph/undirected-graph.ts +1 -2
  47. package/src/data-structures/heap/heap.ts +1 -6
  48. package/src/data-structures/trie/trie.ts +1 -1
  49. package/src/interfaces/binary-tree.ts +1 -1
  50. package/src/types/utils/validate-type.ts +2 -16
  51. package/test/config.ts +2 -1
  52. package/test/integration/index.html +77 -12
  53. package/test/performance/data-structures/binary-tree/rb-tree.test.ts +17 -5
  54. package/test/performance/data-structures/hash/hash-map.test.ts +48 -0
  55. package/test/performance/data-structures/linked-list/doubly-linked-list.test.ts +16 -5
  56. package/test/performance/data-structures/priority-queue/max-priority-queue.test.ts +1 -3
  57. package/test/performance/data-structures/priority-queue/priority-queue.test.ts +35 -0
  58. package/test/performance/data-structures/queue/deque.test.ts +20 -11
  59. package/test/performance/data-structures/queue/queue.test.ts +20 -10
  60. package/test/performance/data-structures/stack/stack.test.ts +49 -0
  61. package/test/performance/reportor.ts +4 -5
  62. package/test/unit/data-structures/binary-tree/avl-tree.test.ts +0 -1
  63. package/test/unit/data-structures/binary-tree/binary-tree.test.ts +83 -61
  64. package/test/unit/data-structures/binary-tree/bst.test.ts +2 -6
  65. package/test/unit/data-structures/binary-tree/rb-tree.test.ts +34 -25
  66. package/test/unit/data-structures/graph/abstract-graph.test.ts +6 -6
  67. package/test/unit/data-structures/graph/directed-graph.test.ts +8 -28
  68. package/test/unit/data-structures/heap/heap.test.ts +1 -8
  69. package/test/unit/data-structures/priority-queue/priority-queue.test.ts +34 -12
  70. package/test/utils/json2html.ts +2 -6
  71. package/tsup.config.js +19 -1
@@ -1 +1 @@
1
- {"version":3,"file":"heap.js","sourceRoot":"","sources":["../../../../../src/data-structures/heap/heap.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAIH,MAAa,IAAI;IACf,YAAY,OAAiD;QAQnD,WAAM,GAAQ,EAAE,CAAC;QAPzB,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC;QACtC,IAAI,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;YAC7C,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;YAC5B,IAAI,CAAC,GAAG,EAAE,CAAC;SACZ;IACH,CAAC;IAID,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAID,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAED;;OAEG;IACH,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;IAC3B,CAAC;IAED;;;OAGG;IACH,IAAI,IAAI;;QACN,OAAO,MAAA,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,mCAAI,SAAS,CAAC;IAChD,CAAC;IAED;;;;OAIG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1,5 @@
1
1
  import { BinaryTreeNode } from '../data-structures';
2
- import { BiTreeDeleteResult, BinaryTreeNodeNested, BTNCallback, BTNKey } from '../types';
2
+ import { BinaryTreeNodeNested, BiTreeDeleteResult, BTNCallback, BTNKey } from '../types';
3
3
  export interface IBinaryTree<V = any, N extends BinaryTreeNode<V, N> = BinaryTreeNodeNested<V>> {
4
4
  createNode(key: BTNKey, value?: N['value']): N;
5
5
  add(keyOrNode: BTNKey | N | null, value?: N['value']): N | null | undefined;
@@ -381,7 +381,7 @@ export declare class BinaryTree<V = any, N extends BinaryTreeNode<V, N> = Binary
381
381
  * @param {any} node - The parameter `node` is of type `any`, which means it can be any data type.
382
382
  * @returns a boolean value.
383
383
  */
384
- isNodeOrNull(node: any): node is (N | null);
384
+ isNodeOrNull(node: any): node is N | null;
385
385
  /**
386
386
  * The function "isNodeKey" checks if a potential key is a number.
387
387
  * @param {any} potentialKey - The potentialKey parameter is of type any, which means it can be any
@@ -439,6 +439,13 @@ export declare class BinaryTree<V = any, N extends BinaryTreeNode<V, N> = Binary
439
439
  * binary tree nodes in a specific order.
440
440
  */
441
441
  [Symbol.iterator](node?: N | null | undefined): Generator<BTNKey, void, undefined>;
442
+ /**
443
+ * The `print` function is used to display a binary tree structure in a visually appealing way.
444
+ * @param {N | null | undefined} root - The `root` parameter is of type `BTNKey | N | null |
445
+ * undefined`. It represents the root node of a binary tree. The root node can have one of the
446
+ * following types:
447
+ */
448
+ print(beginRoot?: BTNKey | N | null | undefined): void;
442
449
  protected _defaultOneParamCallback: (node: N) => number;
443
450
  /**
444
451
  * Swap the data of two nodes in the binary tree.
@@ -466,11 +473,4 @@ export declare class BinaryTree<V = any, N extends BinaryTreeNode<V, N> = Binary
466
473
  * type `N` or `null`.
467
474
  */
468
475
  protected _setRoot(v: N | null | undefined): void;
469
- /**
470
- * The `print` function is used to display a binary tree structure in a visually appealing way.
471
- * @param {N | null | undefined} root - The `root` parameter is of type `BTNKey | N | null |
472
- * undefined`. It represents the root node of a binary tree. The root node can have one of the
473
- * following types:
474
- */
475
- print(beginRoot?: BTNKey | N | null | undefined): void;
476
476
  }
@@ -1457,6 +1457,68 @@ class BinaryTree {
1457
1457
  }
1458
1458
  }
1459
1459
  }
1460
+ /**
1461
+ * The `print` function is used to display a binary tree structure in a visually appealing way.
1462
+ * @param {N | null | undefined} root - The `root` parameter is of type `BTNKey | N | null |
1463
+ * undefined`. It represents the root node of a binary tree. The root node can have one of the
1464
+ * following types:
1465
+ */
1466
+ print(beginRoot = this.root) {
1467
+ beginRoot = this.ensureNotKey(beginRoot);
1468
+ if (!beginRoot)
1469
+ return;
1470
+ const display = (root) => {
1471
+ const [lines, , ,] = _displayAux(root);
1472
+ for (const line of lines) {
1473
+ console.log(line);
1474
+ }
1475
+ };
1476
+ const _displayAux = (node) => {
1477
+ if (!this.isRealNode(node)) {
1478
+ return [[], 0, 0, 0];
1479
+ }
1480
+ if (this.isRealNode(node) && !this.isRealNode(node.right) && !this.isRealNode(node.left)) {
1481
+ const line = `${node.key}`;
1482
+ const width = line.length;
1483
+ const height = 1;
1484
+ const middle = Math.floor(width / 2);
1485
+ return [[line], width, height, middle];
1486
+ }
1487
+ if (this.isRealNode(node) && !this.isRealNode(node.right)) {
1488
+ const [lines, n, p, x] = _displayAux(node.left);
1489
+ const s = `${node.key}`;
1490
+ const u = s.length;
1491
+ const first_line = ' '.repeat(x + 1) + '_'.repeat(n - x - 1) + s;
1492
+ const second_line = ' '.repeat(x) + '/' + ' '.repeat(n - x - 1 + u);
1493
+ const shifted_lines = lines.map(line => line + ' '.repeat(u));
1494
+ return [[first_line, second_line, ...shifted_lines], n + u, p + 2, n + Math.floor(u / 2)];
1495
+ }
1496
+ if (this.isRealNode(node) && !this.isRealNode(node.left)) {
1497
+ const [lines, n, p, u] = _displayAux(node.right);
1498
+ const s = `${node.key}`;
1499
+ const x = s.length;
1500
+ const first_line = s + '_'.repeat(x) + ' '.repeat(n - x);
1501
+ const second_line = ' '.repeat(u + x) + '\\' + ' '.repeat(n - x - 1);
1502
+ const shifted_lines = lines.map(line => ' '.repeat(u) + line);
1503
+ return [[first_line, second_line, ...shifted_lines], n + x, p + 2, Math.floor(u / 2)];
1504
+ }
1505
+ const [left, n, p, x] = _displayAux(node.left);
1506
+ const [right, m, q, y] = _displayAux(node.right);
1507
+ const s = `${node.key}`;
1508
+ const u = s.length;
1509
+ const first_line = ' '.repeat(x + 1) + '_'.repeat(n - x - 1) + s + '_'.repeat(y) + ' '.repeat(m - y);
1510
+ const second_line = ' '.repeat(x) + '/' + ' '.repeat(n - x - 1 + u + y) + '\\' + ' '.repeat(m - y - 1);
1511
+ if (p < q) {
1512
+ left.push(...new Array(q - p).fill(' '.repeat(n)));
1513
+ }
1514
+ else if (q < p) {
1515
+ right.push(...new Array(p - q).fill(' '.repeat(m)));
1516
+ }
1517
+ const zipped_lines = left.map((a, i) => a + ' '.repeat(u) + right[i]);
1518
+ return [[first_line, second_line, ...zipped_lines], n + m + u, Math.max(p, q) + 2, n + Math.floor(u / 2)];
1519
+ };
1520
+ display(beginRoot);
1521
+ }
1460
1522
  _defaultOneParamCallback = (node) => node.key;
1461
1523
  /**
1462
1524
  * Swap the data of two nodes in the binary tree.
@@ -1531,67 +1593,5 @@ class BinaryTree {
1531
1593
  }
1532
1594
  this._root = v;
1533
1595
  }
1534
- /**
1535
- * The `print` function is used to display a binary tree structure in a visually appealing way.
1536
- * @param {N | null | undefined} root - The `root` parameter is of type `BTNKey | N | null |
1537
- * undefined`. It represents the root node of a binary tree. The root node can have one of the
1538
- * following types:
1539
- */
1540
- print(beginRoot = this.root) {
1541
- beginRoot = this.ensureNotKey(beginRoot);
1542
- if (!beginRoot)
1543
- return;
1544
- const display = (root) => {
1545
- const [lines, , ,] = _displayAux(root);
1546
- for (const line of lines) {
1547
- console.log(line);
1548
- }
1549
- };
1550
- const _displayAux = (node) => {
1551
- if (!this.isRealNode(node)) {
1552
- return [[], 0, 0, 0];
1553
- }
1554
- if (this.isRealNode(node) && !this.isRealNode(node.right) && !this.isRealNode(node.left)) {
1555
- const line = `${node.key}`;
1556
- const width = line.length;
1557
- const height = 1;
1558
- const middle = Math.floor(width / 2);
1559
- return [[line], width, height, middle];
1560
- }
1561
- if (this.isRealNode(node) && !this.isRealNode(node.right)) {
1562
- const [lines, n, p, x] = _displayAux(node.left);
1563
- const s = `${node.key}`;
1564
- const u = s.length;
1565
- const first_line = ' '.repeat(x + 1) + '_'.repeat(n - x - 1) + s;
1566
- const second_line = ' '.repeat(x) + '/' + ' '.repeat(n - x - 1 + u);
1567
- const shifted_lines = lines.map(line => line + ' '.repeat(u));
1568
- return [[first_line, second_line, ...shifted_lines], n + u, p + 2, n + Math.floor(u / 2)];
1569
- }
1570
- if (this.isRealNode(node) && !this.isRealNode(node.left)) {
1571
- const [lines, n, p, u] = _displayAux(node.right);
1572
- const s = `${node.key}`;
1573
- const x = s.length;
1574
- const first_line = s + '_'.repeat(x) + ' '.repeat(n - x);
1575
- const second_line = ' '.repeat(u + x) + '\\' + ' '.repeat(n - x - 1);
1576
- const shifted_lines = lines.map(line => ' '.repeat(u) + line);
1577
- return [[first_line, second_line, ...shifted_lines], n + x, p + 2, Math.floor(u / 2)];
1578
- }
1579
- const [left, n, p, x] = _displayAux(node.left);
1580
- const [right, m, q, y] = _displayAux(node.right);
1581
- const s = `${node.key}`;
1582
- const u = s.length;
1583
- const first_line = ' '.repeat(x + 1) + '_'.repeat(n - x - 1) + s + '_'.repeat(y) + ' '.repeat(m - y);
1584
- const second_line = ' '.repeat(x) + '/' + ' '.repeat(n - x - 1 + u + y) + '\\' + ' '.repeat(m - y - 1);
1585
- if (p < q) {
1586
- left.push(...new Array(q - p).fill(' '.repeat(n)));
1587
- }
1588
- else if (q < p) {
1589
- right.push(...new Array(p - q).fill(' '.repeat(m)));
1590
- }
1591
- const zipped_lines = left.map((a, i) => a + ' '.repeat(u) + right[i]);
1592
- return [[first_line, second_line, ...zipped_lines], n + m + u, Math.max(p, q) + 2, n + Math.floor(u / 2)];
1593
- };
1594
- display(beginRoot);
1595
- }
1596
1596
  }
1597
1597
  exports.BinaryTree = BinaryTree;
@@ -5,9 +5,9 @@
5
5
  * @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
6
6
  * @license MIT License
7
7
  */
8
- import { BiTreeDeleteResult, BTNCallback, BTNKey, IterationType, RBTNColor, RedBlackTreeNodeNested, RBTreeOptions } from '../../types';
9
- import { BST, BSTNode } from "./bst";
10
- import { IBinaryTree } from "../../interfaces";
8
+ import { BiTreeDeleteResult, BTNCallback, BTNKey, IterationType, RBTNColor, RBTreeOptions, RedBlackTreeNodeNested } from '../../types';
9
+ import { BST, BSTNode } from './bst';
10
+ import { IBinaryTree } from '../../interfaces';
11
11
  export declare class RedBlackTreeNode<V = any, N extends RedBlackTreeNode<V, N> = RedBlackTreeNodeNested<V>> extends BSTNode<V, N> {
12
12
  color: RBTNColor;
13
13
  constructor(key: BTNKey, value?: V, color?: RBTNColor);
@@ -20,6 +20,7 @@ export declare class RedBlackTreeNode<V = any, N extends RedBlackTreeNode<V, N>
20
20
  * 5. Black balance: Every path from any node to each of its leaf nodes contains the same number of black nodes.
21
21
  */
22
22
  export declare class RedBlackTree<V = any, N extends RedBlackTreeNode<V, N> = RedBlackTreeNode<V, RedBlackTreeNodeNested<V>>> extends BST<V, N> implements IBinaryTree<V, N> {
23
+ NIL: N;
23
24
  /**
24
25
  * The constructor function initializes a Red-Black Tree with an optional set of options.
25
26
  * @param {RBTreeOptions} [options] - The `options` parameter is an optional object that can be
@@ -30,7 +31,6 @@ export declare class RedBlackTree<V = any, N extends RedBlackTreeNode<V, N> = Re
30
31
  get root(): N;
31
32
  protected _size: number;
32
33
  get size(): number;
33
- NIL: N;
34
34
  /**
35
35
  * Time Complexity: O(log n) on average (where n is the number of nodes in the tree)
36
36
  * Space Complexity: O(1)
@@ -27,6 +27,7 @@ exports.RedBlackTreeNode = RedBlackTreeNode;
27
27
  * 5. Black balance: Every path from any node to each of its leaf nodes contains the same number of black nodes.
28
28
  */
29
29
  class RedBlackTree extends bst_1.BST {
30
+ NIL = new RedBlackTreeNode(NaN);
30
31
  /**
31
32
  * The constructor function initializes a Red-Black Tree with an optional set of options.
32
33
  * @param {RBTreeOptions} [options] - The `options` parameter is an optional object that can be
@@ -44,7 +45,6 @@ class RedBlackTree extends bst_1.BST {
44
45
  get size() {
45
46
  return this._size;
46
47
  }
47
- NIL = new RedBlackTreeNode(NaN);
48
48
  /**
49
49
  * Time Complexity: O(log n) on average (where n is the number of nodes in the tree)
50
50
  * Space Complexity: O(1)
@@ -69,26 +69,6 @@ export declare class TreeMultimap<V = any, N extends TreeMultimapNode<V, N> = Tr
69
69
  * Time Complexity: O(1) - constant time, as it performs basic pointer assignments.
70
70
  * Space Complexity: O(1) - constant space, as it only uses a constant amount of memory.
71
71
  */
72
- /**
73
- * Time Complexity: O(1) - constant time, as it performs basic pointer assignments.
74
- * Space Complexity: O(1) - constant space, as it only uses a constant amount of memory.
75
- *
76
- * The function adds a new node to a binary tree, either as the left child or the right child of a
77
- * given parent node.
78
- * @param {N | undefined} newNode - The `newNode` parameter represents the node that needs to be
79
- * added to the binary tree. It can be of type `N` (which represents a node in the binary tree) or
80
- * `undefined` if there is no node to add.
81
- * @param {BTNKey | N | undefined} parent - The `parent` parameter represents the parent node to
82
- * which the new node will be added as a child. It can be either a node object (`N`) or a key value
83
- * (`BTNKey`).
84
- * @returns The method `_addTo` returns either the `parent.left` or `parent.right` node that was
85
- * added, or `undefined` if no node was added.
86
- */
87
- protected _addTo(newNode: N | undefined, parent: BTNKey | N | undefined): N | undefined;
88
- /**
89
- * Time Complexity: O(k log n) - logarithmic time for each insertion, where "n" is the number of nodes in the tree, and "k" is the number of keys to be inserted. This is because the method iterates through the keys and calls the add method for each.
90
- * Space Complexity: O(1) - constant space, as it doesn't use additional data structures that scale with input size.
91
- */
92
72
  /**
93
73
  * Time Complexity: O(k log n) - logarithmic time for each insertion, where "n" is the number of nodes in the tree, and "k" is the number of keys to be inserted. This is because the method iterates through the keys and calls the add method for each.
94
74
  * Space Complexity: O(1) - constant space, as it doesn't use additional data structures that scale with input size.
@@ -104,8 +84,8 @@ export declare class TreeMultimap<V = any, N extends TreeMultimapNode<V, N> = Tr
104
84
  */
105
85
  addMany(keysOrNodes: (BTNKey | N | undefined)[], data?: V[]): (N | undefined)[];
106
86
  /**
107
- * Time Complexity: O(n log n) - logarithmic time for each insertion, where "n" is the number of nodes in the tree. This is because the method calls the add method for each node.
108
- * Space Complexity: O(n) - linear space, as it creates an array to store the sorted nodes.
87
+ * Time Complexity: O(k log n) - logarithmic time for each insertion, where "n" is the number of nodes in the tree, and "k" is the number of keys to be inserted. This is because the method iterates through the keys and calls the add method for each.
88
+ * Space Complexity: O(1) - constant space, as it doesn't use additional data structures that scale with input size.
109
89
  */
110
90
  /**
111
91
  * Time Complexity: O(n log n) - logarithmic time for each insertion, where "n" is the number of nodes in the tree. This is because the method calls the add method for each node.
@@ -120,8 +100,8 @@ export declare class TreeMultimap<V = any, N extends TreeMultimapNode<V, N> = Tr
120
100
  */
121
101
  perfectlyBalance(iterationType?: IterationType): boolean;
122
102
  /**
123
- * Time Complexity: O(log n) - logarithmic time, where "n" is the number of nodes in the tree. The delete method of the superclass (AVLTree) has logarithmic time complexity.
124
- * Space Complexity: O(1) - constant space, as it doesn't use additional data structures that scale with input size.
103
+ * Time Complexity: O(n log n) - logarithmic time for each insertion, where "n" is the number of nodes in the tree. This is because the method calls the add method for each node.
104
+ * Space Complexity: O(n) - linear space, as it creates an array to store the sorted nodes.
125
105
  */
126
106
  /**
127
107
  * Time Complexity: O(log n) - logarithmic time, where "n" is the number of nodes in the tree. The delete method of the superclass (AVLTree) has logarithmic time complexity.
@@ -143,10 +123,30 @@ export declare class TreeMultimap<V = any, N extends TreeMultimapNode<V, N> = Tr
143
123
  * @returns an array of `BiTreeDeleteResult<N>`.
144
124
  */
145
125
  delete<C extends BTNCallback<N>>(identifier: ReturnType<C>, callback?: C, ignoreCount?: boolean): BiTreeDeleteResult<N>[];
126
+ /**
127
+ * Time Complexity: O(log n) - logarithmic time, where "n" is the number of nodes in the tree. The delete method of the superclass (AVLTree) has logarithmic time complexity.
128
+ * Space Complexity: O(1) - constant space, as it doesn't use additional data structures that scale with input size.
129
+ */
146
130
  /**
147
131
  * The clear() function clears the contents of a data structure and sets the count to zero.
148
132
  */
149
133
  clear(): void;
134
+ /**
135
+ * Time Complexity: O(1) - constant time, as it performs basic pointer assignments.
136
+ * Space Complexity: O(1) - constant space, as it only uses a constant amount of memory.
137
+ *
138
+ * The function adds a new node to a binary tree, either as the left child or the right child of a
139
+ * given parent node.
140
+ * @param {N | undefined} newNode - The `newNode` parameter represents the node that needs to be
141
+ * added to the binary tree. It can be of type `N` (which represents a node in the binary tree) or
142
+ * `undefined` if there is no node to add.
143
+ * @param {BTNKey | N | undefined} parent - The `parent` parameter represents the parent node to
144
+ * which the new node will be added as a child. It can be either a node object (`N`) or a key value
145
+ * (`BTNKey`).
146
+ * @returns The method `_addTo` returns either the `parent.left` or `parent.right` node that was
147
+ * added, or `undefined` if no node was added.
148
+ */
149
+ protected _addTo(newNode: N | undefined, parent: BTNKey | N | undefined): N | undefined;
150
150
  /**
151
151
  * The `_swap` function swaps the key, value, count, and height properties between two nodes.
152
152
  * @param {BTNKey | N | undefined} srcNode - The `srcNode` parameter represents the source node from
@@ -151,52 +151,6 @@ class TreeMultimap extends avl_tree_1.AVLTree {
151
151
  * Time Complexity: O(1) - constant time, as it performs basic pointer assignments.
152
152
  * Space Complexity: O(1) - constant space, as it only uses a constant amount of memory.
153
153
  */
154
- /**
155
- * Time Complexity: O(1) - constant time, as it performs basic pointer assignments.
156
- * Space Complexity: O(1) - constant space, as it only uses a constant amount of memory.
157
- *
158
- * The function adds a new node to a binary tree, either as the left child or the right child of a
159
- * given parent node.
160
- * @param {N | undefined} newNode - The `newNode` parameter represents the node that needs to be
161
- * added to the binary tree. It can be of type `N` (which represents a node in the binary tree) or
162
- * `undefined` if there is no node to add.
163
- * @param {BTNKey | N | undefined} parent - The `parent` parameter represents the parent node to
164
- * which the new node will be added as a child. It can be either a node object (`N`) or a key value
165
- * (`BTNKey`).
166
- * @returns The method `_addTo` returns either the `parent.left` or `parent.right` node that was
167
- * added, or `undefined` if no node was added.
168
- */
169
- _addTo(newNode, parent) {
170
- parent = this.ensureNotKey(parent);
171
- if (parent) {
172
- if (parent.left === undefined) {
173
- parent.left = newNode;
174
- if (newNode !== undefined) {
175
- this._size = this.size + 1;
176
- this._count += newNode.count;
177
- }
178
- return parent.left;
179
- }
180
- else if (parent.right === undefined) {
181
- parent.right = newNode;
182
- if (newNode !== undefined) {
183
- this._size = this.size + 1;
184
- this._count += newNode.count;
185
- }
186
- return parent.right;
187
- }
188
- else {
189
- return;
190
- }
191
- }
192
- else {
193
- return;
194
- }
195
- }
196
- /**
197
- * Time Complexity: O(k log n) - logarithmic time for each insertion, where "n" is the number of nodes in the tree, and "k" is the number of keys to be inserted. This is because the method iterates through the keys and calls the add method for each.
198
- * Space Complexity: O(1) - constant space, as it doesn't use additional data structures that scale with input size.
199
- */
200
154
  /**
201
155
  * Time Complexity: O(k log n) - logarithmic time for each insertion, where "n" is the number of nodes in the tree, and "k" is the number of keys to be inserted. This is because the method iterates through the keys and calls the add method for each.
202
156
  * Space Complexity: O(1) - constant space, as it doesn't use additional data structures that scale with input size.
@@ -227,8 +181,8 @@ class TreeMultimap extends avl_tree_1.AVLTree {
227
181
  return inserted;
228
182
  }
229
183
  /**
230
- * Time Complexity: O(n log n) - logarithmic time for each insertion, where "n" is the number of nodes in the tree. This is because the method calls the add method for each node.
231
- * Space Complexity: O(n) - linear space, as it creates an array to store the sorted nodes.
184
+ * Time Complexity: O(k log n) - logarithmic time for each insertion, where "n" is the number of nodes in the tree, and "k" is the number of keys to be inserted. This is because the method iterates through the keys and calls the add method for each.
185
+ * Space Complexity: O(1) - constant space, as it doesn't use additional data structures that scale with input size.
232
186
  */
233
187
  /**
234
188
  * Time Complexity: O(n log n) - logarithmic time for each insertion, where "n" is the number of nodes in the tree. This is because the method calls the add method for each node.
@@ -278,8 +232,8 @@ class TreeMultimap extends avl_tree_1.AVLTree {
278
232
  }
279
233
  }
280
234
  /**
281
- * Time Complexity: O(log n) - logarithmic time, where "n" is the number of nodes in the tree. The delete method of the superclass (AVLTree) has logarithmic time complexity.
282
- * Space Complexity: O(1) - constant space, as it doesn't use additional data structures that scale with input size.
235
+ * Time Complexity: O(n log n) - logarithmic time for each insertion, where "n" is the number of nodes in the tree. This is because the method calls the add method for each node.
236
+ * Space Complexity: O(n) - linear space, as it creates an array to store the sorted nodes.
283
237
  */
284
238
  /**
285
239
  * Time Complexity: O(log n) - logarithmic time, where "n" is the number of nodes in the tree. The delete method of the superclass (AVLTree) has logarithmic time complexity.
@@ -357,6 +311,10 @@ class TreeMultimap extends avl_tree_1.AVLTree {
357
311
  }
358
312
  return deletedResult;
359
313
  }
314
+ /**
315
+ * Time Complexity: O(log n) - logarithmic time, where "n" is the number of nodes in the tree. The delete method of the superclass (AVLTree) has logarithmic time complexity.
316
+ * Space Complexity: O(1) - constant space, as it doesn't use additional data structures that scale with input size.
317
+ */
360
318
  /**
361
319
  * The clear() function clears the contents of a data structure and sets the count to zero.
362
320
  */
@@ -364,6 +322,48 @@ class TreeMultimap extends avl_tree_1.AVLTree {
364
322
  super.clear();
365
323
  this._count = 0;
366
324
  }
325
+ /**
326
+ * Time Complexity: O(1) - constant time, as it performs basic pointer assignments.
327
+ * Space Complexity: O(1) - constant space, as it only uses a constant amount of memory.
328
+ *
329
+ * The function adds a new node to a binary tree, either as the left child or the right child of a
330
+ * given parent node.
331
+ * @param {N | undefined} newNode - The `newNode` parameter represents the node that needs to be
332
+ * added to the binary tree. It can be of type `N` (which represents a node in the binary tree) or
333
+ * `undefined` if there is no node to add.
334
+ * @param {BTNKey | N | undefined} parent - The `parent` parameter represents the parent node to
335
+ * which the new node will be added as a child. It can be either a node object (`N`) or a key value
336
+ * (`BTNKey`).
337
+ * @returns The method `_addTo` returns either the `parent.left` or `parent.right` node that was
338
+ * added, or `undefined` if no node was added.
339
+ */
340
+ _addTo(newNode, parent) {
341
+ parent = this.ensureNotKey(parent);
342
+ if (parent) {
343
+ if (parent.left === undefined) {
344
+ parent.left = newNode;
345
+ if (newNode !== undefined) {
346
+ this._size = this.size + 1;
347
+ this._count += newNode.count;
348
+ }
349
+ return parent.left;
350
+ }
351
+ else if (parent.right === undefined) {
352
+ parent.right = newNode;
353
+ if (newNode !== undefined) {
354
+ this._size = this.size + 1;
355
+ this._count += newNode.count;
356
+ }
357
+ return parent.right;
358
+ }
359
+ else {
360
+ return;
361
+ }
362
+ }
363
+ else {
364
+ return;
365
+ }
366
+ }
367
367
  /**
368
368
  * The `_swap` function swaps the key, value, count, and height properties between two nodes.
369
369
  * @param {BTNKey | N | undefined} srcNode - The `srcNode` parameter represents the source node from
@@ -235,24 +235,24 @@ export declare abstract class AbstractGraph<V = any, E = any, VO extends Abstrac
235
235
  * Space Complexity: O(V + E) - Depends on the implementation (Dijkstra's algorithm).
236
236
  */
237
237
  /**
238
- * Time Complexity: O(V^2 + E) - Quadratic time in the worst case (no heap optimization).
239
- * Space Complexity: O(V + E) - Depends on the implementation (Dijkstra's algorithm).
240
- *
241
- * The function `dijkstraWithoutHeap` implements Dijkstra's algorithm to find the shortest path between two vertices in
242
- * a graph without using a heap data structure.
243
- * @param {VO | VertexKey} src - The source vertex from which to start the Dijkstra's algorithm. It can be either a
244
- * vertex object or a vertex ID.
245
- * @param {VO | VertexKey | null} [dest] - The `dest` parameter in the `dijkstraWithoutHeap` function is an optional
246
- * parameter that specifies the destination vertex for the Dijkstra algorithm. It can be either a vertex object or its
247
- * identifier. If no destination is provided, the value is set to `null`.
248
- * @param {boolean} [getMinDist] - The `getMinDist` parameter is a boolean flag that determines whether the minimum
249
- * distance from the source vertex to the destination vertex should be calculated and returned in the result. If
250
- * `getMinDist` is set to `true`, the `minDist` property in the result will contain the minimum distance
251
- * @param {boolean} [genPaths] - The `genPaths` parameter is a boolean flag that determines whether or not to generate
252
- * paths in the Dijkstra algorithm. If `genPaths` is set to `true`, the algorithm will calculate and return the
253
- * shortest paths from the source vertex to all other vertices in the graph. If `genPaths
254
- * @returns The function `dijkstraWithoutHeap` returns an object of type `DijkstraResult<VO>`.
255
- */
238
+ * Time Complexity: O(V^2 + E) - Quadratic time in the worst case (no heap optimization).
239
+ * Space Complexity: O(V + E) - Depends on the implementation (Dijkstra's algorithm).
240
+ *
241
+ * The function `dijkstraWithoutHeap` implements Dijkstra's algorithm to find the shortest path between two vertices in
242
+ * a graph without using a heap data structure.
243
+ * @param {VO | VertexKey} src - The source vertex from which to start the Dijkstra's algorithm. It can be either a
244
+ * vertex object or a vertex ID.
245
+ * @param {VO | VertexKey | null} [dest] - The `dest` parameter in the `dijkstraWithoutHeap` function is an optional
246
+ * parameter that specifies the destination vertex for the Dijkstra algorithm. It can be either a vertex object or its
247
+ * identifier. If no destination is provided, the value is set to `null`.
248
+ * @param {boolean} [getMinDist] - The `getMinDist` parameter is a boolean flag that determines whether the minimum
249
+ * distance from the source vertex to the destination vertex should be calculated and returned in the result. If
250
+ * `getMinDist` is set to `true`, the `minDist` property in the result will contain the minimum distance
251
+ * @param {boolean} [genPaths] - The `genPaths` parameter is a boolean flag that determines whether or not to generate
252
+ * paths in the Dijkstra algorithm. If `genPaths` is set to `true`, the algorithm will calculate and return the
253
+ * shortest paths from the source vertex to all other vertices in the graph. If `genPaths
254
+ * @returns The function `dijkstraWithoutHeap` returns an object of type `DijkstraResult<VO>`.
255
+ */
256
256
  dijkstraWithoutHeap(src: VO | VertexKey, dest?: VO | VertexKey | null, getMinDist?: boolean, genPaths?: boolean): DijkstraResult<VO>;
257
257
  /**
258
258
  * Dijkstra algorithm time: O(logVE) space: O(VO + EO)
@@ -268,25 +268,25 @@ export declare abstract class AbstractGraph<V = any, E = any, VO extends Abstrac
268
268
  * Space Complexity: O(V + E) - Depends on the implementation (using a binary heap).
269
269
  */
270
270
  /**
271
- * Time Complexity: O((V + E) * log(V)) - Depends on the implementation (using a binary heap).
272
- * Space Complexity: O(V + E) - Depends on the implementation (using a binary heap).
273
- *
274
- * Dijkstra's algorithm is used to find the shortest paths from a source node to all other nodes in a graph. Its basic idea is to repeatedly choose the node closest to the source node and update the distances of other nodes using this node as an intermediary. Dijkstra's algorithm requires that the edge weights in the graph are non-negative.
275
- * The `dijkstra` function implements Dijkstra's algorithm to find the shortest path between a source vertex and an
276
- * optional destination vertex, and optionally returns the minimum distance, the paths, and other information.
277
- * @param {VO | VertexKey} src - The `src` parameter represents the source vertex from which the Dijkstra algorithm will
278
- * start. It can be either a vertex object or a vertex ID.
279
- * @param {VO | VertexKey | null} [dest] - The `dest` parameter is the destination vertex or vertex ID. It specifies the
280
- * vertex to which the shortest path is calculated from the source vertex. If no destination is provided, the algorithm
281
- * will calculate the shortest paths to all other vertices from the source vertex.
282
- * @param {boolean} [getMinDist] - The `getMinDist` parameter is a boolean flag that determines whether the minimum
283
- * distance from the source vertex to the destination vertex should be calculated and returned in the result. If
284
- * `getMinDist` is set to `true`, the `minDist` property in the result will contain the minimum distance
285
- * @param {boolean} [genPaths] - The `genPaths` parameter is a boolean flag that determines whether or not to generate
286
- * paths in the Dijkstra algorithm. If `genPaths` is set to `true`, the algorithm will calculate and return the
287
- * shortest paths from the source vertex to all other vertices in the graph. If `genPaths
288
- * @returns The function `dijkstra` returns an object of type `DijkstraResult<VO>`.
289
- */
271
+ * Time Complexity: O((V + E) * log(V)) - Depends on the implementation (using a binary heap).
272
+ * Space Complexity: O(V + E) - Depends on the implementation (using a binary heap).
273
+ *
274
+ * Dijkstra's algorithm is used to find the shortest paths from a source node to all other nodes in a graph. Its basic idea is to repeatedly choose the node closest to the source node and update the distances of other nodes using this node as an intermediary. Dijkstra's algorithm requires that the edge weights in the graph are non-negative.
275
+ * The `dijkstra` function implements Dijkstra's algorithm to find the shortest path between a source vertex and an
276
+ * optional destination vertex, and optionally returns the minimum distance, the paths, and other information.
277
+ * @param {VO | VertexKey} src - The `src` parameter represents the source vertex from which the Dijkstra algorithm will
278
+ * start. It can be either a vertex object or a vertex ID.
279
+ * @param {VO | VertexKey | null} [dest] - The `dest` parameter is the destination vertex or vertex ID. It specifies the
280
+ * vertex to which the shortest path is calculated from the source vertex. If no destination is provided, the algorithm
281
+ * will calculate the shortest paths to all other vertices from the source vertex.
282
+ * @param {boolean} [getMinDist] - The `getMinDist` parameter is a boolean flag that determines whether the minimum
283
+ * distance from the source vertex to the destination vertex should be calculated and returned in the result. If
284
+ * `getMinDist` is set to `true`, the `minDist` property in the result will contain the minimum distance
285
+ * @param {boolean} [genPaths] - The `genPaths` parameter is a boolean flag that determines whether or not to generate
286
+ * paths in the Dijkstra algorithm. If `genPaths` is set to `true`, the algorithm will calculate and return the
287
+ * shortest paths from the source vertex to all other vertices in the graph. If `genPaths
288
+ * @returns The function `dijkstra` returns an object of type `DijkstraResult<VO>`.
289
+ */
290
290
  dijkstra(src: VO | VertexKey, dest?: VO | VertexKey | null, getMinDist?: boolean, genPaths?: boolean): DijkstraResult<VO>;
291
291
  /**
292
292
  * Time Complexity: O(V * E) - Quadratic time in the worst case (Bellman-Ford algorithm).