directed-graph-typed 1.48.0 → 1.49.0

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 (89) hide show
  1. package/dist/data-structures/base/index.d.ts +1 -0
  2. package/dist/data-structures/base/index.js +17 -0
  3. package/dist/data-structures/base/iterable-base.d.ts +232 -0
  4. package/dist/data-structures/base/iterable-base.js +312 -0
  5. package/dist/data-structures/binary-tree/avl-tree.d.ts +28 -19
  6. package/dist/data-structures/binary-tree/avl-tree.js +22 -11
  7. package/dist/data-structures/binary-tree/binary-tree.d.ts +158 -152
  8. package/dist/data-structures/binary-tree/binary-tree.js +241 -215
  9. package/dist/data-structures/binary-tree/bst.d.ts +64 -48
  10. package/dist/data-structures/binary-tree/bst.js +94 -65
  11. package/dist/data-structures/binary-tree/rb-tree.d.ts +39 -39
  12. package/dist/data-structures/binary-tree/rb-tree.js +42 -49
  13. package/dist/data-structures/binary-tree/tree-multimap.d.ts +60 -34
  14. package/dist/data-structures/binary-tree/tree-multimap.js +59 -27
  15. package/dist/data-structures/graph/abstract-graph.d.ts +92 -53
  16. package/dist/data-structures/graph/abstract-graph.js +130 -103
  17. package/dist/data-structures/graph/directed-graph.d.ts +70 -52
  18. package/dist/data-structures/graph/directed-graph.js +111 -65
  19. package/dist/data-structures/graph/map-graph.d.ts +5 -5
  20. package/dist/data-structures/graph/map-graph.js +8 -8
  21. package/dist/data-structures/graph/undirected-graph.d.ts +51 -32
  22. package/dist/data-structures/graph/undirected-graph.js +117 -54
  23. package/dist/data-structures/hash/hash-map.d.ts +160 -44
  24. package/dist/data-structures/hash/hash-map.js +314 -82
  25. package/dist/data-structures/heap/heap.d.ts +50 -7
  26. package/dist/data-structures/heap/heap.js +60 -30
  27. package/dist/data-structures/index.d.ts +1 -0
  28. package/dist/data-structures/index.js +1 -0
  29. package/dist/data-structures/linked-list/doubly-linked-list.d.ts +42 -55
  30. package/dist/data-structures/linked-list/doubly-linked-list.js +50 -77
  31. package/dist/data-structures/linked-list/singly-linked-list.d.ts +36 -55
  32. package/dist/data-structures/linked-list/singly-linked-list.js +44 -77
  33. package/dist/data-structures/queue/deque.d.ts +35 -167
  34. package/dist/data-structures/queue/deque.js +43 -249
  35. package/dist/data-structures/queue/queue.d.ts +49 -48
  36. package/dist/data-structures/queue/queue.js +69 -82
  37. package/dist/data-structures/stack/stack.d.ts +43 -10
  38. package/dist/data-structures/stack/stack.js +50 -31
  39. package/dist/data-structures/trie/trie.d.ts +41 -6
  40. package/dist/data-structures/trie/trie.js +53 -32
  41. package/dist/interfaces/binary-tree.d.ts +6 -6
  42. package/dist/types/common.d.ts +11 -8
  43. package/dist/types/common.js +6 -1
  44. package/dist/types/data-structures/base/base.d.ts +5 -0
  45. package/dist/types/data-structures/base/base.js +2 -0
  46. package/dist/types/data-structures/base/index.d.ts +1 -0
  47. package/dist/types/data-structures/base/index.js +17 -0
  48. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +3 -3
  49. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +4 -4
  50. package/dist/types/data-structures/binary-tree/bst.d.ts +6 -6
  51. package/dist/types/data-structures/binary-tree/rb-tree.d.ts +3 -3
  52. package/dist/types/data-structures/binary-tree/tree-multimap.d.ts +3 -3
  53. package/dist/types/data-structures/hash/hash-map.d.ts +4 -0
  54. package/dist/types/data-structures/index.d.ts +1 -0
  55. package/dist/types/data-structures/index.js +1 -0
  56. package/package.json +2 -2
  57. package/src/data-structures/base/index.ts +1 -0
  58. package/src/data-structures/base/iterable-base.ts +329 -0
  59. package/src/data-structures/binary-tree/avl-tree.ts +37 -25
  60. package/src/data-structures/binary-tree/binary-tree.ts +336 -296
  61. package/src/data-structures/binary-tree/bst.ts +135 -89
  62. package/src/data-structures/binary-tree/rb-tree.ts +60 -69
  63. package/src/data-structures/binary-tree/tree-multimap.ts +86 -49
  64. package/src/data-structures/graph/abstract-graph.ts +136 -104
  65. package/src/data-structures/graph/directed-graph.ts +114 -65
  66. package/src/data-structures/graph/map-graph.ts +8 -8
  67. package/src/data-structures/graph/undirected-graph.ts +124 -56
  68. package/src/data-structures/hash/hash-map.ts +335 -84
  69. package/src/data-structures/heap/heap.ts +63 -36
  70. package/src/data-structures/index.ts +1 -0
  71. package/src/data-structures/linked-list/doubly-linked-list.ts +54 -83
  72. package/src/data-structures/linked-list/singly-linked-list.ts +49 -84
  73. package/src/data-structures/queue/deque.ts +43 -275
  74. package/src/data-structures/queue/queue.ts +71 -86
  75. package/src/data-structures/stack/stack.ts +53 -34
  76. package/src/data-structures/trie/trie.ts +58 -35
  77. package/src/interfaces/binary-tree.ts +5 -6
  78. package/src/types/common.ts +11 -8
  79. package/src/types/data-structures/base/base.ts +6 -0
  80. package/src/types/data-structures/base/index.ts +1 -0
  81. package/src/types/data-structures/binary-tree/avl-tree.ts +3 -3
  82. package/src/types/data-structures/binary-tree/binary-tree.ts +6 -5
  83. package/src/types/data-structures/binary-tree/bst.ts +6 -6
  84. package/src/types/data-structures/binary-tree/rb-tree.ts +3 -3
  85. package/src/types/data-structures/binary-tree/tree-multimap.ts +3 -3
  86. package/src/types/data-structures/hash/hash-map.ts +2 -0
  87. package/src/types/data-structures/heap/heap.ts +1 -1
  88. package/src/types/data-structures/index.ts +1 -0
  89. package/src/types/data-structures/priority-queue/priority-queue.ts +1 -1
@@ -29,7 +29,7 @@ exports.AVLTreeNode = AVLTreeNode;
29
29
  class AVLTree extends bst_1.BST {
30
30
  /**
31
31
  * The constructor function initializes an AVLTree object with optional elements and options.
32
- * @param [elements] - The `elements` parameter is an optional iterable of `BTNodeExemplar<V, N>`
32
+ * @param [elements] - The `elements` parameter is an optional iterable of `BTNodeExemplar<K, V, N>`
33
33
  * objects. It represents a collection of elements that will be added to the AVL tree during
34
34
  * initialization.
35
35
  * @param [options] - The `options` parameter is an optional object that allows you to customize the
@@ -43,7 +43,7 @@ class AVLTree extends bst_1.BST {
43
43
  }
44
44
  /**
45
45
  * The function creates a new AVL tree node with the specified key and value.
46
- * @param {BTNKey} key - The key parameter is the key value that will be associated with
46
+ * @param {K} key - The key parameter is the key value that will be associated with
47
47
  * the new node. It is used to determine the position of the node in the binary search tree.
48
48
  * @param [value] - The parameter `value` is an optional value that can be assigned to the node. It is of
49
49
  * type `V`, which means it can be any value that is assignable to the `value` property of the
@@ -61,16 +61,25 @@ class AVLTree extends bst_1.BST {
61
61
  * @returns a new AVLTree object.
62
62
  */
63
63
  createTree(options) {
64
- return new AVLTree([], Object.assign({ iterationType: this.iterationType, comparator: this.comparator }, options));
64
+ return new AVLTree([], Object.assign({ iterationType: this.iterationType, variant: this.variant }, options));
65
65
  }
66
66
  /**
67
67
  * The function checks if an exemplar is an instance of AVLTreeNode.
68
- * @param exemplar - The `exemplar` parameter is of type `BTNodeExemplar<V, N>`.
68
+ * @param exemplar - The `exemplar` parameter is of type `BTNodeExemplar<K, V, N>`.
69
69
  * @returns a boolean value indicating whether the exemplar is an instance of the AVLTreeNode class.
70
70
  */
71
71
  isNode(exemplar) {
72
72
  return exemplar instanceof AVLTreeNode;
73
73
  }
74
+ /**
75
+ * The function "isNotNodeInstance" checks if a potential key is a K.
76
+ * @param {any} potentialKey - The potentialKey parameter is of type any, which means it can be any
77
+ * data type.
78
+ * @returns a boolean value indicating whether the potentialKey is of type number or not.
79
+ */
80
+ isNotNodeInstance(potentialKey) {
81
+ return !(potentialKey instanceof AVLTreeNode);
82
+ }
74
83
  /**
75
84
  * Time Complexity: O(log n) - logarithmic time, where "n" is the number of nodes in the tree. The add method of the superclass (BST) has logarithmic time complexity.
76
85
  * Space Complexity: O(1) - constant space, as it doesn't use additional data structures that scale with input size.
@@ -81,14 +90,16 @@ class AVLTree extends bst_1.BST {
81
90
  *
82
91
  * The function overrides the add method of a binary tree node and balances the tree after inserting
83
92
  * a new node.
84
- * @param keyOrNodeOrEntry - The parameter `keyOrNodeOrEntry` can be either a key, a node, or an
93
+ * @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter can be either a key, a node, or an
85
94
  * entry.
86
- * @returns The method is returning either the inserted node or `undefined`.
95
+ * @param {V} [value] - The `value` parameter represents the value associated with the key that is
96
+ * being added to the binary tree.
97
+ * @returns The method is returning either the inserted node or undefined.
87
98
  */
88
- add(keyOrNodeOrEntry) {
99
+ add(keyOrNodeOrEntry, value) {
89
100
  if (keyOrNodeOrEntry === null)
90
101
  return undefined;
91
- const inserted = super.add(keyOrNodeOrEntry);
102
+ const inserted = super.add(keyOrNodeOrEntry, value);
92
103
  if (inserted)
93
104
  this._balancePath(inserted);
94
105
  return inserted;
@@ -126,9 +137,9 @@ class AVLTree extends bst_1.BST {
126
137
  /**
127
138
  * The `_swapProperties` function swaps the key, value, and height properties between two nodes in a binary
128
139
  * tree.
129
- * @param {BTNKey | N | undefined} srcNode - The `srcNode` parameter represents the source node that
130
- * needs to be swapped with the destination node. It can be of type `BTNKey`, `N`, or `undefined`.
131
- * @param {BTNKey | N | undefined} destNode - The `destNode` parameter represents the destination
140
+ * @param {K | N | undefined} srcNode - The `srcNode` parameter represents the source node that
141
+ * needs to be swapped with the destination node. It can be of type `K`, `N`, or `undefined`.
142
+ * @param {K | N | undefined} destNode - The `destNode` parameter represents the destination
132
143
  * node where the values from the source node will be swapped to.
133
144
  * @returns either the `destNode` object if both `srcNode` and `destNode` are defined, or `undefined`
134
145
  * if either `srcNode` or `destNode` is undefined.