linked-list-typed 1.52.0 → 1.52.1

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 (37) hide show
  1. package/dist/data-structures/binary-tree/avl-tree-multi-map.d.ts +11 -11
  2. package/dist/data-structures/binary-tree/avl-tree-multi-map.js +6 -6
  3. package/dist/data-structures/binary-tree/avl-tree.d.ts +11 -11
  4. package/dist/data-structures/binary-tree/avl-tree.js +6 -6
  5. package/dist/data-structures/binary-tree/binary-tree.d.ts +97 -97
  6. package/dist/data-structures/binary-tree/binary-tree.js +50 -50
  7. package/dist/data-structures/binary-tree/bst.d.ts +35 -35
  8. package/dist/data-structures/binary-tree/bst.js +15 -15
  9. package/dist/data-structures/binary-tree/rb-tree.d.ts +8 -8
  10. package/dist/data-structures/binary-tree/rb-tree.js +6 -6
  11. package/dist/data-structures/binary-tree/tree-multi-map.d.ts +10 -10
  12. package/dist/data-structures/binary-tree/tree-multi-map.js +5 -5
  13. package/dist/data-structures/graph/directed-graph.js +2 -1
  14. package/dist/data-structures/queue/deque.d.ts +7 -0
  15. package/dist/data-structures/queue/deque.js +16 -1
  16. package/dist/data-structures/queue/queue.d.ts +0 -1
  17. package/dist/data-structures/queue/queue.js +0 -1
  18. package/dist/interfaces/binary-tree.d.ts +3 -3
  19. package/dist/types/common.d.ts +1 -22
  20. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +18 -1
  21. package/dist/types/data-structures/binary-tree/bst.d.ts +3 -0
  22. package/dist/types/data-structures/queue/deque.d.ts +1 -0
  23. package/package.json +2 -2
  24. package/src/data-structures/binary-tree/avl-tree-multi-map.ts +12 -12
  25. package/src/data-structures/binary-tree/avl-tree.ts +11 -11
  26. package/src/data-structures/binary-tree/binary-tree.ts +151 -147
  27. package/src/data-structures/binary-tree/bst.ts +44 -41
  28. package/src/data-structures/binary-tree/rb-tree.ts +10 -10
  29. package/src/data-structures/binary-tree/tree-multi-map.ts +10 -10
  30. package/src/data-structures/graph/directed-graph.ts +2 -1
  31. package/src/data-structures/queue/deque.ts +15 -1
  32. package/src/data-structures/queue/queue.ts +0 -1
  33. package/src/interfaces/binary-tree.ts +3 -3
  34. package/src/types/common.ts +2 -24
  35. package/src/types/data-structures/binary-tree/binary-tree.ts +21 -1
  36. package/src/types/data-structures/binary-tree/bst.ts +7 -0
  37. package/src/types/data-structures/queue/deque.ts +4 -1
@@ -5,7 +5,7 @@
5
5
  * @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
6
6
  * @license MIT License
7
7
  */
8
- import type { AVLTreeMultiMapNested, AVLTreeMultiMapNodeNested, AVLTreeMultiMapOptions, BinaryTreeDeleteResult, BSTNKeyOrNode, BTNCallback, IterationType, KeyOrNodeOrEntry } from '../../types';
8
+ import type { AVLTreeMultiMapNested, AVLTreeMultiMapNodeNested, AVLTreeMultiMapOptions, BinaryTreeDeleteResult, BSTNKeyOrNode, BTNCallback, BTNKeyOrNodeOrEntry, IterationType } from '../../types';
9
9
  import { BTNEntry } from '../../types';
10
10
  import { IBinaryTree } from '../../interfaces';
11
11
  import { AVLTree, AVLTreeNode } from './avl-tree';
@@ -46,7 +46,7 @@ export declare class AVLTreeMultiMap<K = any, V = any, R = BTNEntry<K, V>, NODE
46
46
  * behavior of the AVLTreeMultiMap. It can include properties such as `compareKeys` and
47
47
  * `compareValues` functions to define custom comparison logic for keys and values, respectively.
48
48
  */
49
- constructor(keysOrNodesOrEntriesOrRawElements?: Iterable<R | KeyOrNodeOrEntry<K, V, NODE>>, options?: AVLTreeMultiMapOptions<K, V, R>);
49
+ constructor(keysOrNodesOrEntriesOrRawElements?: Iterable<R | BTNKeyOrNodeOrEntry<K, V, NODE>>, options?: AVLTreeMultiMapOptions<K, V, R>);
50
50
  protected _count: number;
51
51
  /**
52
52
  * The function calculates the sum of the count property of all nodes in a tree using depth-first
@@ -89,17 +89,17 @@ export declare class AVLTreeMultiMap<K = any, V = any, R = BTNEntry<K, V>, NODE
89
89
  createTree(options?: AVLTreeMultiMapOptions<K, V, R>): TREE;
90
90
  /**
91
91
  * The function checks if the input is an instance of AVLTreeMultiMapNode.
92
- * @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter
93
- * `keyOrNodeOrEntryOrRawElement` can be of type `R` or `KeyOrNodeOrEntry<K, V, NODE>`.
92
+ * @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter
93
+ * `keyOrNodeOrEntryOrRawElement` can be of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`.
94
94
  * @returns a boolean value indicating whether the input parameter `keyOrNodeOrEntryOrRawElement` is
95
95
  * an instance of the `AVLTreeMultiMapNode` class.
96
96
  */
97
- isNode(keyOrNodeOrEntryOrRawElement: R | KeyOrNodeOrEntry<K, V, NODE>): keyOrNodeOrEntryOrRawElement is NODE;
97
+ isNode(keyOrNodeOrEntryOrRawElement: R | BTNKeyOrNodeOrEntry<K, V, NODE>): keyOrNodeOrEntryOrRawElement is NODE;
98
98
  /**
99
99
  * The function `keyValueOrEntryOrRawElementToNode` converts a key, value, entry, or raw element into
100
100
  * a node object.
101
- * @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The
102
- * `keyOrNodeOrEntryOrRawElement` parameter can be of type `R` or `KeyOrNodeOrEntry<K, V, NODE>`.
101
+ * @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The
102
+ * `keyOrNodeOrEntryOrRawElement` parameter can be of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`.
103
103
  * @param {V} [value] - The `value` parameter is an optional value that can be passed to the
104
104
  * `override` function. It represents the value associated with the key in the data structure. If no
105
105
  * value is provided, it will default to `undefined`.
@@ -107,7 +107,7 @@ export declare class AVLTreeMultiMap<K = any, V = any, R = BTNEntry<K, V>, NODE
107
107
  * times the key-value pair should be added to the data structure. If not provided, it defaults to 1.
108
108
  * @returns either a NODE object or undefined.
109
109
  */
110
- keyValueOrEntryOrRawElementToNode(keyOrNodeOrEntryOrRawElement: R | KeyOrNodeOrEntry<K, V, NODE>, value?: V, count?: number): NODE | undefined;
110
+ keyValueOrEntryOrRawElementToNode(keyOrNodeOrEntryOrRawElement: R | BTNKeyOrNodeOrEntry<K, V, NODE>, value?: V, count?: number): NODE | undefined;
111
111
  /**
112
112
  * Time Complexity: O(log n)
113
113
  * Space Complexity: O(1)
@@ -118,9 +118,9 @@ export declare class AVLTreeMultiMap<K = any, V = any, R = BTNEntry<K, V>, NODE
118
118
  *
119
119
  * The function overrides the add method of a TypeScript class to add a new node to a data structure
120
120
  * and update the count.
121
- * @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The
121
+ * @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The
122
122
  * `keyOrNodeOrEntryOrRawElement` parameter can accept a value of type `R`, which can be any type. It
123
- * can also accept a value of type `KeyOrNodeOrEntry<K, V, NODE>`, which represents a key, node,
123
+ * can also accept a value of type `BTNKeyOrNodeOrEntry<K, V, NODE>`, which represents a key, node,
124
124
  * entry, or raw element
125
125
  * @param {V} [value] - The `value` parameter represents the value associated with the key in the
126
126
  * data structure. It is an optional parameter, so it can be omitted if not needed.
@@ -129,7 +129,7 @@ export declare class AVLTreeMultiMap<K = any, V = any, R = BTNEntry<K, V>, NODE
129
129
  * be added once. However, you can specify a different value for `count` if you want to add
130
130
  * @returns a boolean value.
131
131
  */
132
- add(keyOrNodeOrEntryOrRawElement: R | KeyOrNodeOrEntry<K, V, NODE>, value?: V, count?: number): boolean;
132
+ add(keyOrNodeOrEntryOrRawElement: R | BTNKeyOrNodeOrEntry<K, V, NODE>, value?: V, count?: number): boolean;
133
133
  /**
134
134
  * Time Complexity: O(log n)
135
135
  * Space Complexity: O(1)
@@ -104,8 +104,8 @@ class AVLTreeMultiMap extends avl_tree_1.AVLTree {
104
104
  }
105
105
  /**
106
106
  * The function checks if the input is an instance of AVLTreeMultiMapNode.
107
- * @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter
108
- * `keyOrNodeOrEntryOrRawElement` can be of type `R` or `KeyOrNodeOrEntry<K, V, NODE>`.
107
+ * @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter
108
+ * `keyOrNodeOrEntryOrRawElement` can be of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`.
109
109
  * @returns a boolean value indicating whether the input parameter `keyOrNodeOrEntryOrRawElement` is
110
110
  * an instance of the `AVLTreeMultiMapNode` class.
111
111
  */
@@ -115,8 +115,8 @@ class AVLTreeMultiMap extends avl_tree_1.AVLTree {
115
115
  /**
116
116
  * The function `keyValueOrEntryOrRawElementToNode` converts a key, value, entry, or raw element into
117
117
  * a node object.
118
- * @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The
119
- * `keyOrNodeOrEntryOrRawElement` parameter can be of type `R` or `KeyOrNodeOrEntry<K, V, NODE>`.
118
+ * @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The
119
+ * `keyOrNodeOrEntryOrRawElement` parameter can be of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`.
120
120
  * @param {V} [value] - The `value` parameter is an optional value that can be passed to the
121
121
  * `override` function. It represents the value associated with the key in the data structure. If no
122
122
  * value is provided, it will default to `undefined`.
@@ -155,9 +155,9 @@ class AVLTreeMultiMap extends avl_tree_1.AVLTree {
155
155
  *
156
156
  * The function overrides the add method of a TypeScript class to add a new node to a data structure
157
157
  * and update the count.
158
- * @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The
158
+ * @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The
159
159
  * `keyOrNodeOrEntryOrRawElement` parameter can accept a value of type `R`, which can be any type. It
160
- * can also accept a value of type `KeyOrNodeOrEntry<K, V, NODE>`, which represents a key, node,
160
+ * can also accept a value of type `BTNKeyOrNodeOrEntry<K, V, NODE>`, which represents a key, node,
161
161
  * entry, or raw element
162
162
  * @param {V} [value] - The `value` parameter represents the value associated with the key in the
163
163
  * data structure. It is an optional parameter, so it can be omitted if not needed.
@@ -6,7 +6,7 @@
6
6
  * @license MIT License
7
7
  */
8
8
  import { BST, BSTNode } from './bst';
9
- import type { AVLTreeNested, AVLTreeNodeNested, AVLTreeOptions, BinaryTreeDeleteResult, BSTNKeyOrNode, BTNCallback, KeyOrNodeOrEntry } from '../../types';
9
+ import type { AVLTreeNested, AVLTreeNodeNested, AVLTreeOptions, BinaryTreeDeleteResult, BSTNKeyOrNode, BTNCallback, BTNKeyOrNodeOrEntry } from '../../types';
10
10
  import { BTNEntry } from '../../types';
11
11
  import { IBinaryTree } from '../../interfaces';
12
12
  export declare class AVLTreeNode<K = any, V = any, NODE extends AVLTreeNode<K, V, NODE> = AVLTreeNodeNested<K, V>> extends BSTNode<K, V, NODE> {
@@ -53,7 +53,7 @@ export declare class AVLTree<K = any, V = any, R = BTNEntry<K, V>, NODE extends
53
53
  * keys), `allowDuplicates` (a boolean indicating whether duplicate keys are allowed), and
54
54
  * `nodeBuilder` (
55
55
  */
56
- constructor(keysOrNodesOrEntriesOrRawElements?: Iterable<R | KeyOrNodeOrEntry<K, V, NODE>>, options?: AVLTreeOptions<K, V, R>);
56
+ constructor(keysOrNodesOrEntriesOrRawElements?: Iterable<R | BTNKeyOrNodeOrEntry<K, V, NODE>>, options?: AVLTreeOptions<K, V, R>);
57
57
  /**
58
58
  * The function creates a new AVL tree node with the given key and value.
59
59
  * @param {K} key - The key parameter is of type K, which represents the key of the node being
@@ -74,12 +74,12 @@ export declare class AVLTree<K = any, V = any, R = BTNEntry<K, V>, NODE extends
74
74
  createTree(options?: AVLTreeOptions<K, V, R>): TREE;
75
75
  /**
76
76
  * The function checks if the input is an instance of AVLTreeNode.
77
- * @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter
78
- * `keyOrNodeOrEntryOrRawElement` can be of type `R` or `KeyOrNodeOrEntry<K, V, NODE>`.
77
+ * @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter
78
+ * `keyOrNodeOrEntryOrRawElement` can be of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`.
79
79
  * @returns a boolean value indicating whether the input parameter `keyOrNodeOrEntryOrRawElement` is
80
80
  * an instance of the `AVLTreeNode` class.
81
81
  */
82
- isNode(keyOrNodeOrEntryOrRawElement: R | KeyOrNodeOrEntry<K, V, NODE>): keyOrNodeOrEntryOrRawElement is NODE;
82
+ isNode(keyOrNodeOrEntryOrRawElement: R | BTNKeyOrNodeOrEntry<K, V, NODE>): keyOrNodeOrEntryOrRawElement is NODE;
83
83
  /**
84
84
  * Time Complexity: O(log n)
85
85
  * Space Complexity: O(1)
@@ -91,14 +91,14 @@ export declare class AVLTree<K = any, V = any, R = BTNEntry<K, V>, NODE extends
91
91
  *
92
92
  * The function overrides the add method of a class and inserts a key-value pair into a data
93
93
  * structure, then balances the path.
94
- * @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter
95
- * `keyOrNodeOrEntryOrRawElement` can accept values of type `R`, `KeyOrNodeOrEntry<K, V, NODE>`, or
94
+ * @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter
95
+ * `keyOrNodeOrEntryOrRawElement` can accept values of type `R`, `BTNKeyOrNodeOrEntry<K, V, NODE>`, or
96
96
  * `RawElement`.
97
97
  * @param {V} [value] - The `value` parameter is an optional value that you want to associate with
98
98
  * the key or node being added to the data structure.
99
99
  * @returns The method is returning a boolean value.
100
100
  */
101
- add(keyOrNodeOrEntryOrRawElement: R | KeyOrNodeOrEntry<K, V, NODE>, value?: V): boolean;
101
+ add(keyOrNodeOrEntryOrRawElement: R | BTNKeyOrNodeOrEntry<K, V, NODE>, value?: V): boolean;
102
102
  /**
103
103
  * Time Complexity: O(log n)
104
104
  * Space Complexity: O(1)
@@ -222,10 +222,10 @@ export declare class AVLTree<K = any, V = any, R = BTNEntry<K, V>, NODE extends
222
222
  *
223
223
  * The `_balancePath` function is used to update the heights of nodes and perform rotation operations
224
224
  * to restore balance in an AVL tree after inserting a node.
225
- * @param {R | KeyOrNodeOrEntry<K, V, NODE>} node - The `node` parameter can be of type `R` or
226
- * `KeyOrNodeOrEntry<K, V, NODE>`.
225
+ * @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} node - The `node` parameter can be of type `R` or
226
+ * `BTNKeyOrNodeOrEntry<K, V, NODE>`.
227
227
  */
228
- protected _balancePath(node: R | KeyOrNodeOrEntry<K, V, NODE>): void;
228
+ protected _balancePath(node: R | BTNKeyOrNodeOrEntry<K, V, NODE>): void;
229
229
  /**
230
230
  * Time Complexity: O(1)
231
231
  * Space Complexity: O(1)
@@ -89,8 +89,8 @@ class AVLTree extends bst_1.BST {
89
89
  }
90
90
  /**
91
91
  * The function checks if the input is an instance of AVLTreeNode.
92
- * @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter
93
- * `keyOrNodeOrEntryOrRawElement` can be of type `R` or `KeyOrNodeOrEntry<K, V, NODE>`.
92
+ * @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter
93
+ * `keyOrNodeOrEntryOrRawElement` can be of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`.
94
94
  * @returns a boolean value indicating whether the input parameter `keyOrNodeOrEntryOrRawElement` is
95
95
  * an instance of the `AVLTreeNode` class.
96
96
  */
@@ -108,8 +108,8 @@ class AVLTree extends bst_1.BST {
108
108
  *
109
109
  * The function overrides the add method of a class and inserts a key-value pair into a data
110
110
  * structure, then balances the path.
111
- * @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter
112
- * `keyOrNodeOrEntryOrRawElement` can accept values of type `R`, `KeyOrNodeOrEntry<K, V, NODE>`, or
111
+ * @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter
112
+ * `keyOrNodeOrEntryOrRawElement` can accept values of type `R`, `BTNKeyOrNodeOrEntry<K, V, NODE>`, or
113
113
  * `RawElement`.
114
114
  * @param {V} [value] - The `value` parameter is an optional value that you want to associate with
115
115
  * the key or node being added to the data structure.
@@ -439,8 +439,8 @@ class AVLTree extends bst_1.BST {
439
439
  *
440
440
  * The `_balancePath` function is used to update the heights of nodes and perform rotation operations
441
441
  * to restore balance in an AVL tree after inserting a node.
442
- * @param {R | KeyOrNodeOrEntry<K, V, NODE>} node - The `node` parameter can be of type `R` or
443
- * `KeyOrNodeOrEntry<K, V, NODE>`.
442
+ * @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} node - The `node` parameter can be of type `R` or
443
+ * `BTNKeyOrNodeOrEntry<K, V, NODE>`.
444
444
  */
445
445
  _balancePath(node) {
446
446
  node = this.ensureNode(node);