deque-typed 1.52.0 → 1.52.2
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.
- package/dist/data-structures/binary-tree/avl-tree-multi-map.d.ts +11 -11
- package/dist/data-structures/binary-tree/avl-tree-multi-map.js +6 -6
- package/dist/data-structures/binary-tree/avl-tree.d.ts +11 -11
- package/dist/data-structures/binary-tree/avl-tree.js +6 -6
- package/dist/data-structures/binary-tree/binary-tree.d.ts +97 -97
- package/dist/data-structures/binary-tree/binary-tree.js +52 -52
- package/dist/data-structures/binary-tree/bst.d.ts +35 -35
- package/dist/data-structures/binary-tree/bst.js +17 -17
- package/dist/data-structures/binary-tree/rb-tree.d.ts +8 -8
- package/dist/data-structures/binary-tree/rb-tree.js +6 -6
- package/dist/data-structures/binary-tree/tree-multi-map.d.ts +10 -10
- package/dist/data-structures/binary-tree/tree-multi-map.js +5 -5
- package/dist/data-structures/graph/directed-graph.js +2 -1
- package/dist/data-structures/queue/deque.d.ts +7 -0
- package/dist/data-structures/queue/deque.js +16 -1
- package/dist/data-structures/queue/queue.d.ts +18 -1
- package/dist/data-structures/queue/queue.js +32 -7
- package/dist/interfaces/binary-tree.d.ts +3 -3
- package/dist/types/common.d.ts +1 -22
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +18 -1
- package/dist/types/data-structures/binary-tree/bst.d.ts +3 -0
- package/dist/types/data-structures/queue/deque.d.ts +1 -0
- package/dist/types/data-structures/queue/queue.d.ts +3 -1
- package/package.json +2 -2
- package/src/data-structures/base/iterable-element-base.ts +2 -2
- package/src/data-structures/base/iterable-entry-base.ts +4 -4
- package/src/data-structures/binary-tree/avl-tree-multi-map.ts +25 -24
- package/src/data-structures/binary-tree/avl-tree.ts +20 -19
- package/src/data-structures/binary-tree/binary-tree.ts +162 -157
- package/src/data-structures/binary-tree/bst.ts +54 -50
- package/src/data-structures/binary-tree/rb-tree.ts +18 -17
- package/src/data-structures/binary-tree/tree-multi-map.ts +18 -17
- package/src/data-structures/graph/abstract-graph.ts +15 -14
- package/src/data-structures/graph/directed-graph.ts +9 -7
- package/src/data-structures/graph/undirected-graph.ts +7 -6
- package/src/data-structures/hash/hash-map.ts +4 -4
- package/src/data-structures/heap/heap.ts +1 -1
- package/src/data-structures/linked-list/doubly-linked-list.ts +1 -1
- package/src/data-structures/linked-list/singly-linked-list.ts +1 -1
- package/src/data-structures/queue/deque.ts +18 -4
- package/src/data-structures/queue/queue.ts +38 -8
- package/src/data-structures/stack/stack.ts +1 -1
- package/src/data-structures/trie/trie.ts +1 -1
- package/src/interfaces/binary-tree.ts +3 -3
- package/src/types/common.ts +2 -24
- package/src/types/data-structures/binary-tree/binary-tree.ts +21 -1
- package/src/types/data-structures/binary-tree/bst.ts +7 -0
- package/src/types/data-structures/graph/abstract-graph.ts +8 -8
- package/src/types/data-structures/queue/deque.ts +4 -1
- package/src/types/data-structures/queue/queue.ts +3 -1
- package/src/types/utils/utils.ts +4 -4
|
@@ -19,7 +19,7 @@ class BSTNode extends binary_tree_1.BinaryTreeNode {
|
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
21
|
* The function sets the left child of a node and updates the parent reference of the child.
|
|
22
|
-
* @param {NODE
|
|
22
|
+
* @param {OptBSTN<NODE>} v - The parameter `v` is of type `OptBSTN<NODE>`. It can either be an
|
|
23
23
|
* instance of the `NODE` class or `undefined`.
|
|
24
24
|
*/
|
|
25
25
|
set left(v) {
|
|
@@ -38,7 +38,7 @@ class BSTNode extends binary_tree_1.BinaryTreeNode {
|
|
|
38
38
|
}
|
|
39
39
|
/**
|
|
40
40
|
* The function sets the right child of a node and updates the parent reference of the child.
|
|
41
|
-
* @param {NODE
|
|
41
|
+
* @param {OptBSTN<NODE>} v - The parameter `v` is of type `OptBSTN<NODE>`. It can either be a
|
|
42
42
|
* `NODE` object or `undefined`.
|
|
43
43
|
*/
|
|
44
44
|
set right(v) {
|
|
@@ -119,8 +119,8 @@ class BST extends binary_tree_1.BinaryTree {
|
|
|
119
119
|
}
|
|
120
120
|
/**
|
|
121
121
|
* The function overrides a method and converts a key, value pair or entry or raw element to a node.
|
|
122
|
-
* @param {R |
|
|
123
|
-
* type R or
|
|
122
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - A variable that can be of
|
|
123
|
+
* type R or BTNKeyOrNodeOrEntry<K, V, NODE>. It represents either a key, a node, an entry, or a raw
|
|
124
124
|
* element.
|
|
125
125
|
* @param {V} [value] - The `value` parameter is an optional value of type `V`. It represents the
|
|
126
126
|
* value associated with a key in a key-value pair.
|
|
@@ -136,7 +136,7 @@ class BST extends binary_tree_1.BinaryTree {
|
|
|
136
136
|
*
|
|
137
137
|
* The function ensures the existence of a node in a data structure and returns it, or undefined if
|
|
138
138
|
* it doesn't exist.
|
|
139
|
-
* @param {R |
|
|
139
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter
|
|
140
140
|
* `keyOrNodeOrEntryOrRawElement` can accept a value of type `R`, which represents the key, node,
|
|
141
141
|
* entry, or raw element that needs to be ensured in the tree.
|
|
142
142
|
* @param {IterationType} [iterationType=ITERATIVE] - The `iterationType` parameter is an optional
|
|
@@ -151,8 +151,8 @@ class BST extends binary_tree_1.BinaryTree {
|
|
|
151
151
|
}
|
|
152
152
|
/**
|
|
153
153
|
* The function checks if the input is an instance of the BSTNode class.
|
|
154
|
-
* @param {R |
|
|
155
|
-
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `
|
|
154
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter
|
|
155
|
+
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`.
|
|
156
156
|
* @returns a boolean value indicating whether the input parameter `keyOrNodeOrEntryOrRawElement` is
|
|
157
157
|
* an instance of the `BSTNode` class.
|
|
158
158
|
*/
|
|
@@ -164,8 +164,8 @@ class BST extends binary_tree_1.BinaryTree {
|
|
|
164
164
|
* Space Complexity: O(1)
|
|
165
165
|
*
|
|
166
166
|
* The `add` function in TypeScript adds a new node to a binary search tree based on the key value.
|
|
167
|
-
* @param {R |
|
|
168
|
-
* `keyOrNodeOrEntryOrRawElement` can accept a value of type `R` or `
|
|
167
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter
|
|
168
|
+
* `keyOrNodeOrEntryOrRawElement` can accept a value of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`.
|
|
169
169
|
* @param {V} [value] - The `value` parameter is an optional value that can be associated with the
|
|
170
170
|
* key in the binary search tree. If provided, it will be stored in the node along with the key.
|
|
171
171
|
* @returns a boolean value.
|
|
@@ -329,7 +329,7 @@ class BST extends binary_tree_1.BinaryTree {
|
|
|
329
329
|
* @param [onlyOne=false] - A boolean value indicating whether to return only the first matching node
|
|
330
330
|
* or all matching nodes. If set to true, only the first matching node will be returned. If set to
|
|
331
331
|
* false, all matching nodes will be returned. The default value is false.
|
|
332
|
-
* @param {R |
|
|
332
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is the starting
|
|
333
333
|
* point for the search in the binary tree. It can be either a node object, a key-value pair, or an
|
|
334
334
|
* entry object. If it is not provided, the `root` of the binary tree is used as the starting point.
|
|
335
335
|
* @param {IterationType} iterationType - The `iterationType` parameter determines the type of
|
|
@@ -462,7 +462,7 @@ class BST extends binary_tree_1.BinaryTree {
|
|
|
462
462
|
* @param {DFSOrderPattern} [pattern=IN] - The "pattern" parameter in the code snippet refers to the
|
|
463
463
|
* order in which the Depth-First Search (DFS) algorithm visits the nodes in a tree or graph. It can
|
|
464
464
|
* take one of the following values:
|
|
465
|
-
* @param {R |
|
|
465
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is the starting
|
|
466
466
|
* point for the depth-first search traversal. It can be either a root node, a key-value pair, or a
|
|
467
467
|
* node entry. If not specified, the default value is the root of the tree.
|
|
468
468
|
* @param {IterationType} [iterationType=ITERATIVE] - The `iterationType` parameter specifies the
|
|
@@ -486,7 +486,7 @@ class BST extends binary_tree_1.BinaryTree {
|
|
|
486
486
|
* @param {C} callback - The `callback` parameter is a function that will be called for each node
|
|
487
487
|
* visited during the breadth-first search. It should take a single argument, which is the current
|
|
488
488
|
* node being visited, and it can return a value of any type.
|
|
489
|
-
* @param {R |
|
|
489
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is the starting
|
|
490
490
|
* point for the breadth-first search. It can be either a root node, a key-value pair, or an entry
|
|
491
491
|
* object. If no value is provided, the default value is the root of the tree.
|
|
492
492
|
* @param {IterationType} iterationType - The `iterationType` parameter is used to specify the type
|
|
@@ -510,7 +510,7 @@ class BST extends binary_tree_1.BinaryTree {
|
|
|
510
510
|
* @param {C} callback - The `callback` parameter is a generic type `C` that extends
|
|
511
511
|
* `BTNCallback<NODE>`. It represents a callback function that will be called for each node in the
|
|
512
512
|
* tree during the iteration process.
|
|
513
|
-
* @param {R |
|
|
513
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} beginRoot - The `beginRoot` parameter is the starting
|
|
514
514
|
* point for listing the levels of the binary tree. It can be either a root node of the tree, a
|
|
515
515
|
* key-value pair representing a node in the tree, or a key representing a node in the tree. If no
|
|
516
516
|
* value is provided, the root of
|
|
@@ -538,7 +538,7 @@ class BST extends binary_tree_1.BinaryTree {
|
|
|
538
538
|
* @param {CP} lesserOrGreater - The `lesserOrGreater` parameter is used to determine whether to
|
|
539
539
|
* traverse nodes that are lesser, greater, or both than the `targetNode`. It accepts the values -1,
|
|
540
540
|
* 0, or 1, where:
|
|
541
|
-
* @param {R |
|
|
541
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} targetNode - The `targetNode` parameter is the node in
|
|
542
542
|
* the binary tree that you want to start traversing from. It can be specified either by providing
|
|
543
543
|
* the key of the node, the node itself, or an entry containing the key and value of the node. If no
|
|
544
544
|
* `targetNode` is provided,
|
|
@@ -683,8 +683,8 @@ class BST extends binary_tree_1.BinaryTree {
|
|
|
683
683
|
if (!node.right || last === node.right) {
|
|
684
684
|
node = stack.pop();
|
|
685
685
|
if (node) {
|
|
686
|
-
const left = node.left ? (_a = depths.get(node.left)) !== null && _a !== void 0 ? _a : -1 : -1;
|
|
687
|
-
const right = node.right ? (_b = depths.get(node.right)) !== null && _b !== void 0 ? _b : -1 : -1;
|
|
686
|
+
const left = node.left ? ((_a = depths.get(node.left)) !== null && _a !== void 0 ? _a : -1) : -1;
|
|
687
|
+
const right = node.right ? ((_b = depths.get(node.right)) !== null && _b !== void 0 ? _b : -1) : -1;
|
|
688
688
|
if (Math.abs(left - right) > 1)
|
|
689
689
|
return false;
|
|
690
690
|
depths.set(node, 1 + Math.max(left, right));
|
|
@@ -713,7 +713,7 @@ class BST extends binary_tree_1.BinaryTree {
|
|
|
713
713
|
/**
|
|
714
714
|
* The function sets the root of a tree-like structure and updates the parent property of the new
|
|
715
715
|
* root.
|
|
716
|
-
* @param {NODE
|
|
716
|
+
* @param {OptBSTN<NODE>} v - v is a parameter of type NODE or undefined.
|
|
717
717
|
*/
|
|
718
718
|
_setRoot(v) {
|
|
719
719
|
if (v) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BinaryTreeDeleteResult, BTNCallback,
|
|
1
|
+
import type { BinaryTreeDeleteResult, BTNCallback, BTNKeyOrNodeOrEntry, CRUD, RBTNColor, RBTreeOptions, RedBlackTreeNested, RedBlackTreeNodeNested } from '../../types';
|
|
2
2
|
import { BTNEntry } from '../../types';
|
|
3
3
|
import { BST, BSTNode } from './bst';
|
|
4
4
|
import { IBinaryTree } from '../../interfaces';
|
|
@@ -38,7 +38,7 @@ export declare class RedBlackTree<K = any, V = any, R = BTNEntry<K, V>, NODE ext
|
|
|
38
38
|
* configuring the behavior of the Red-Black Tree. The specific properties and their meanings would
|
|
39
39
|
* depend on the implementation
|
|
40
40
|
*/
|
|
41
|
-
constructor(keysOrNodesOrEntriesOrRawElements?: Iterable<R |
|
|
41
|
+
constructor(keysOrNodesOrEntriesOrRawElements?: Iterable<R | BTNKeyOrNodeOrEntry<K, V, NODE>>, options?: RBTreeOptions<K, V, R>);
|
|
42
42
|
protected _root: NODE | undefined;
|
|
43
43
|
/**
|
|
44
44
|
* The function returns the root node of a tree or undefined if there is no root.
|
|
@@ -76,12 +76,12 @@ export declare class RedBlackTree<K = any, V = any, R = BTNEntry<K, V>, NODE ext
|
|
|
76
76
|
* Space Complexity: O(1)
|
|
77
77
|
*
|
|
78
78
|
* The function checks if the input is an instance of the RedBlackTreeNode class.
|
|
79
|
-
* @param {R |
|
|
80
|
-
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `
|
|
79
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter
|
|
80
|
+
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`.
|
|
81
81
|
* @returns a boolean value indicating whether the input parameter `keyOrNodeOrEntryOrRawElement` is
|
|
82
82
|
* an instance of the `RedBlackTreeNode` class.
|
|
83
83
|
*/
|
|
84
|
-
isNode(keyOrNodeOrEntryOrRawElement: R |
|
|
84
|
+
isNode(keyOrNodeOrEntryOrRawElement: R | BTNKeyOrNodeOrEntry<K, V, NODE>): keyOrNodeOrEntryOrRawElement is NODE;
|
|
85
85
|
/**
|
|
86
86
|
* Time Complexity: O(1)
|
|
87
87
|
* Space Complexity: O(1)
|
|
@@ -104,8 +104,8 @@ export declare class RedBlackTree<K = any, V = any, R = BTNEntry<K, V>, NODE ext
|
|
|
104
104
|
*
|
|
105
105
|
* The function adds a new node to a binary search tree and returns true if the node was successfully
|
|
106
106
|
* added.
|
|
107
|
-
* @param {R |
|
|
108
|
-
* `keyOrNodeOrEntryOrRawElement` can accept a value of type `R` or `
|
|
107
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter
|
|
108
|
+
* `keyOrNodeOrEntryOrRawElement` can accept a value of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`.
|
|
109
109
|
* @param {V} [value] - The `value` parameter is an optional value that you want to associate with
|
|
110
110
|
* the key in the data structure. It represents the value that you want to add or update in the data
|
|
111
111
|
* structure.
|
|
@@ -113,7 +113,7 @@ export declare class RedBlackTree<K = any, V = any, R = BTNEntry<K, V>, NODE ext
|
|
|
113
113
|
* the method returns true. If the node already exists and its value is updated, the method also
|
|
114
114
|
* returns true. If the node cannot be added or updated, the method returns false.
|
|
115
115
|
*/
|
|
116
|
-
add(keyOrNodeOrEntryOrRawElement: R |
|
|
116
|
+
add(keyOrNodeOrEntryOrRawElement: R | BTNKeyOrNodeOrEntry<K, V, NODE>, value?: V): boolean;
|
|
117
117
|
/**
|
|
118
118
|
* Time Complexity: O(log n)
|
|
119
119
|
* Space Complexity: O(1)
|
|
@@ -94,8 +94,8 @@ class RedBlackTree extends bst_1.BST {
|
|
|
94
94
|
* Space Complexity: O(1)
|
|
95
95
|
*
|
|
96
96
|
* The function checks if the input is an instance of the RedBlackTreeNode class.
|
|
97
|
-
* @param {R |
|
|
98
|
-
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `
|
|
97
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter
|
|
98
|
+
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`.
|
|
99
99
|
* @returns a boolean value indicating whether the input parameter `keyOrNodeOrEntryOrRawElement` is
|
|
100
100
|
* an instance of the `RedBlackTreeNode` class.
|
|
101
101
|
*/
|
|
@@ -113,11 +113,11 @@ class RedBlackTree extends bst_1.BST {
|
|
|
113
113
|
// *
|
|
114
114
|
// * The function `keyValueOrEntryOrRawElementToNode` takes a key, value, or entry and returns a node if it is
|
|
115
115
|
// * valid, otherwise it returns undefined.
|
|
116
|
-
// * @param {
|
|
116
|
+
// * @param {BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The key, value, or entry to convert.
|
|
117
117
|
// * @param {V} [value] - The value associated with the key (if `keyOrNodeOrEntryOrRawElement` is a key).
|
|
118
118
|
// * @returns {NODE | undefined} - The corresponding Red-Black Tree node, or `undefined` if conversion fails.
|
|
119
119
|
// */
|
|
120
|
-
// override keyValueOrEntryOrRawElementToNode(keyOrNodeOrEntryOrRawElement: R |
|
|
120
|
+
// override keyValueOrEntryOrRawElementToNode(keyOrNodeOrEntryOrRawElement: R | BTNKeyOrNodeOrEntry<K, V, NODE>, value?: V): NODE | undefined {
|
|
121
121
|
//
|
|
122
122
|
// if (keyOrNodeOrEntryOrRawElement === null || keyOrNodeOrEntryOrRawElement === undefined) return;
|
|
123
123
|
// if (this.isNode(keyOrNodeOrEntryOrRawElement)) return keyOrNodeOrEntryOrRawElement;
|
|
@@ -162,8 +162,8 @@ class RedBlackTree extends bst_1.BST {
|
|
|
162
162
|
*
|
|
163
163
|
* The function adds a new node to a binary search tree and returns true if the node was successfully
|
|
164
164
|
* added.
|
|
165
|
-
* @param {R |
|
|
166
|
-
* `keyOrNodeOrEntryOrRawElement` can accept a value of type `R` or `
|
|
165
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter
|
|
166
|
+
* `keyOrNodeOrEntryOrRawElement` can accept a value of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`.
|
|
167
167
|
* @param {V} [value] - The `value` parameter is an optional value that you want to associate with
|
|
168
168
|
* the key in the data structure. It represents the value that you want to add or update in the data
|
|
169
169
|
* structure.
|
|
@@ -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 { BinaryTreeDeleteResult, BSTNKeyOrNode, BTNCallback,
|
|
8
|
+
import type { BinaryTreeDeleteResult, BSTNKeyOrNode, BTNCallback, BTNKeyOrNodeOrEntry, IterationType, RBTNColor, TreeMultiMapNested, TreeMultiMapNodeNested, TreeMultiMapOptions } from '../../types';
|
|
9
9
|
import { BTNEntry } from '../../types';
|
|
10
10
|
import { IBinaryTree } from '../../interfaces';
|
|
11
11
|
import { RedBlackTree, RedBlackTreeNode } from './rb-tree';
|
|
@@ -46,7 +46,7 @@ export declare class TreeMultiMap<K = any, V = any, R = BTNEntry<K, V>, NODE ext
|
|
|
46
46
|
* behavior of the `TreeMultiMap` constructor. It can include properties such as `compareKeys` and
|
|
47
47
|
* `compareValues`, which are functions used to compare keys and values respectively.
|
|
48
48
|
*/
|
|
49
|
-
constructor(keysOrNodesOrEntriesOrRawElements?: Iterable<
|
|
49
|
+
constructor(keysOrNodesOrEntriesOrRawElements?: Iterable<BTNKeyOrNodeOrEntry<K, V, NODE>>, options?: TreeMultiMapOptions<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 structure.
|
|
@@ -92,8 +92,8 @@ export declare class TreeMultiMap<K = any, V = any, R = BTNEntry<K, V>, NODE ext
|
|
|
92
92
|
/**
|
|
93
93
|
* The function `keyValueOrEntryOrRawElementToNode` takes in a key, value, and count and returns a
|
|
94
94
|
* node based on the input.
|
|
95
|
-
* @param {R |
|
|
96
|
-
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `
|
|
95
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter
|
|
96
|
+
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`.
|
|
97
97
|
* @param {V} [value] - The `value` parameter is an optional value that represents the value
|
|
98
98
|
* associated with the key in the node. It is used when creating a new node or updating the value of
|
|
99
99
|
* an existing node.
|
|
@@ -101,15 +101,15 @@ export declare class TreeMultiMap<K = any, V = any, R = BTNEntry<K, V>, NODE ext
|
|
|
101
101
|
* times the key-value pair should be added to the data structure. If not provided, it defaults to 1.
|
|
102
102
|
* @returns either a NODE object or undefined.
|
|
103
103
|
*/
|
|
104
|
-
keyValueOrEntryOrRawElementToNode(keyOrNodeOrEntryOrRawElement: R |
|
|
104
|
+
keyValueOrEntryOrRawElementToNode(keyOrNodeOrEntryOrRawElement: R | BTNKeyOrNodeOrEntry<K, V, NODE>, value?: V, count?: number): NODE | undefined;
|
|
105
105
|
/**
|
|
106
106
|
* The function checks if the input is an instance of the TreeMultiMapNode class.
|
|
107
|
-
* @param {R |
|
|
108
|
-
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `
|
|
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 `TreeMultiMapNode` class.
|
|
111
111
|
*/
|
|
112
|
-
isNode(keyOrNodeOrEntryOrRawElement: R |
|
|
112
|
+
isNode(keyOrNodeOrEntryOrRawElement: R | BTNKeyOrNodeOrEntry<K, V, NODE>): keyOrNodeOrEntryOrRawElement is NODE;
|
|
113
113
|
/**
|
|
114
114
|
* Time Complexity: O(log n)
|
|
115
115
|
* Space Complexity: O(1)
|
|
@@ -120,7 +120,7 @@ export declare class TreeMultiMap<K = any, V = any, R = BTNEntry<K, V>, NODE ext
|
|
|
120
120
|
*
|
|
121
121
|
* The function overrides the add method of a class and adds a new node to a data structure, updating
|
|
122
122
|
* the count and returning a boolean indicating success.
|
|
123
|
-
* @param {R |
|
|
123
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The
|
|
124
124
|
* `keyOrNodeOrEntryOrRawElement` parameter can accept one of the following types:
|
|
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.
|
|
@@ -130,7 +130,7 @@ export declare class TreeMultiMap<K = any, V = any, R = BTNEntry<K, V>, NODE ext
|
|
|
130
130
|
* @returns The method is returning a boolean value. It returns true if the addition of the new node
|
|
131
131
|
* was successful, and false otherwise.
|
|
132
132
|
*/
|
|
133
|
-
add(keyOrNodeOrEntryOrRawElement: R |
|
|
133
|
+
add(keyOrNodeOrEntryOrRawElement: R | BTNKeyOrNodeOrEntry<K, V, NODE>, value?: V, count?: number): boolean;
|
|
134
134
|
/**
|
|
135
135
|
* Time Complexity: O(log n)
|
|
136
136
|
* Space Complexity: O(1)
|
|
@@ -108,8 +108,8 @@ class TreeMultiMap extends rb_tree_1.RedBlackTree {
|
|
|
108
108
|
/**
|
|
109
109
|
* The function `keyValueOrEntryOrRawElementToNode` takes in a key, value, and count and returns a
|
|
110
110
|
* node based on the input.
|
|
111
|
-
* @param {R |
|
|
112
|
-
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `
|
|
111
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter
|
|
112
|
+
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`.
|
|
113
113
|
* @param {V} [value] - The `value` parameter is an optional value that represents the value
|
|
114
114
|
* associated with the key in the node. It is used when creating a new node or updating the value of
|
|
115
115
|
* an existing node.
|
|
@@ -140,8 +140,8 @@ class TreeMultiMap extends rb_tree_1.RedBlackTree {
|
|
|
140
140
|
}
|
|
141
141
|
/**
|
|
142
142
|
* The function checks if the input is an instance of the TreeMultiMapNode class.
|
|
143
|
-
* @param {R |
|
|
144
|
-
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `
|
|
143
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter
|
|
144
|
+
* `keyOrNodeOrEntryOrRawElement` can be of type `R` or `BTNKeyOrNodeOrEntry<K, V, NODE>`.
|
|
145
145
|
* @returns a boolean value indicating whether the input parameter `keyOrNodeOrEntryOrRawElement` is
|
|
146
146
|
* an instance of the `TreeMultiMapNode` class.
|
|
147
147
|
*/
|
|
@@ -158,7 +158,7 @@ class TreeMultiMap extends rb_tree_1.RedBlackTree {
|
|
|
158
158
|
*
|
|
159
159
|
* The function overrides the add method of a class and adds a new node to a data structure, updating
|
|
160
160
|
* the count and returning a boolean indicating success.
|
|
161
|
-
* @param {R |
|
|
161
|
+
* @param {R | BTNKeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The
|
|
162
162
|
* `keyOrNodeOrEntryOrRawElement` parameter can accept one of the following types:
|
|
163
163
|
* @param {V} [value] - The `value` parameter represents the value associated with the key in the
|
|
164
164
|
* data structure. It is an optional parameter, so it can be omitted if not needed.
|
|
@@ -220,7 +220,8 @@ class DirectedGraph extends abstract_graph_1.AbstractGraph {
|
|
|
220
220
|
if (vertex) {
|
|
221
221
|
const neighbors = this.getNeighbors(vertex);
|
|
222
222
|
for (const neighbor of neighbors) {
|
|
223
|
-
this._inEdgeMap.delete(neighbor);
|
|
223
|
+
// this._inEdgeMap.delete(neighbor);
|
|
224
|
+
this.deleteEdgeSrcToDest(vertex, neighbor);
|
|
224
225
|
}
|
|
225
226
|
this._outEdgeMap.delete(vertex);
|
|
226
227
|
this._inEdgeMap.delete(vertex);
|
|
@@ -34,6 +34,13 @@ export declare class Deque<E = any, R = any> extends IterableElementBase<E, R, D
|
|
|
34
34
|
* @return The size of the bucket
|
|
35
35
|
*/
|
|
36
36
|
get bucketSize(): number;
|
|
37
|
+
protected _maxLen: number;
|
|
38
|
+
/**
|
|
39
|
+
* The maxLen function returns the max length of the deque.
|
|
40
|
+
*
|
|
41
|
+
* @return The max length of the deque
|
|
42
|
+
*/
|
|
43
|
+
get maxLen(): number;
|
|
37
44
|
protected _bucketFirst: number;
|
|
38
45
|
/**
|
|
39
46
|
* The function returns the value of the protected variable `_bucketFirst`.
|
|
@@ -25,6 +25,7 @@ class Deque extends base_1.IterableElementBase {
|
|
|
25
25
|
constructor(elements = [], options) {
|
|
26
26
|
super(options);
|
|
27
27
|
this._bucketSize = 1 << 12;
|
|
28
|
+
this._maxLen = -1;
|
|
28
29
|
this._bucketFirst = 0;
|
|
29
30
|
this._firstInBucket = 0;
|
|
30
31
|
this._bucketLast = 0;
|
|
@@ -33,9 +34,11 @@ class Deque extends base_1.IterableElementBase {
|
|
|
33
34
|
this._buckets = [];
|
|
34
35
|
this._size = 0;
|
|
35
36
|
if (options) {
|
|
36
|
-
const { bucketSize } = options;
|
|
37
|
+
const { bucketSize, maxLen } = options;
|
|
37
38
|
if (typeof bucketSize === 'number')
|
|
38
39
|
this._bucketSize = bucketSize;
|
|
40
|
+
if (typeof maxLen === 'number' && maxLen > 0 && maxLen % 1 === 0)
|
|
41
|
+
this._maxLen = maxLen;
|
|
39
42
|
}
|
|
40
43
|
let _size;
|
|
41
44
|
if ('length' in elements) {
|
|
@@ -74,6 +77,14 @@ class Deque extends base_1.IterableElementBase {
|
|
|
74
77
|
get bucketSize() {
|
|
75
78
|
return this._bucketSize;
|
|
76
79
|
}
|
|
80
|
+
/**
|
|
81
|
+
* The maxLen function returns the max length of the deque.
|
|
82
|
+
*
|
|
83
|
+
* @return The max length of the deque
|
|
84
|
+
*/
|
|
85
|
+
get maxLen() {
|
|
86
|
+
return this._maxLen;
|
|
87
|
+
}
|
|
77
88
|
/**
|
|
78
89
|
* The function returns the value of the protected variable `_bucketFirst`.
|
|
79
90
|
* @returns The value of the `_bucketFirst` property.
|
|
@@ -175,6 +186,8 @@ class Deque extends base_1.IterableElementBase {
|
|
|
175
186
|
}
|
|
176
187
|
this._size += 1;
|
|
177
188
|
this._buckets[this._bucketLast][this._lastInBucket] = element;
|
|
189
|
+
if (this._maxLen > 0 && this._size > this._maxLen)
|
|
190
|
+
this.shift();
|
|
178
191
|
return true;
|
|
179
192
|
}
|
|
180
193
|
/**
|
|
@@ -241,6 +254,8 @@ class Deque extends base_1.IterableElementBase {
|
|
|
241
254
|
}
|
|
242
255
|
this._size += 1;
|
|
243
256
|
this._buckets[this._bucketFirst][this._firstInBucket] = element;
|
|
257
|
+
if (this._maxLen > 0 && this._size > this._maxLen)
|
|
258
|
+
this.pop();
|
|
244
259
|
return true;
|
|
245
260
|
}
|
|
246
261
|
/**
|
|
@@ -60,6 +60,18 @@ export declare class Queue<E = any, R = any> extends IterableElementBase<E, R, Q
|
|
|
60
60
|
* array is empty, it returns `undefined`.
|
|
61
61
|
*/
|
|
62
62
|
get last(): E | undefined;
|
|
63
|
+
_autoCompactRatio: number;
|
|
64
|
+
/**
|
|
65
|
+
* This function returns the value of the autoCompactRatio property.
|
|
66
|
+
* @returns The `autoCompactRatio` property of the object, which is a number.
|
|
67
|
+
*/
|
|
68
|
+
get autoCompactRatio(): number;
|
|
69
|
+
/**
|
|
70
|
+
* The above function sets the autoCompactRatio property to a specified number in TypeScript.
|
|
71
|
+
* @param {number} v - The parameter `v` represents the value that will be assigned to the
|
|
72
|
+
* `_autoCompactRatio` property.
|
|
73
|
+
*/
|
|
74
|
+
set autoCompactRatio(v: number);
|
|
63
75
|
/**
|
|
64
76
|
* Time Complexity: O(n)
|
|
65
77
|
* Space Complexity: O(n)
|
|
@@ -70,7 +82,6 @@ export declare class Queue<E = any, R = any> extends IterableElementBase<E, R, Q
|
|
|
70
82
|
*
|
|
71
83
|
* The function "fromArray" creates a new Queue object from an array of elements.Creates a queue from an existing array.
|
|
72
84
|
* @public
|
|
73
|
-
* @static
|
|
74
85
|
* @param {E[]} elements - The "elements" parameter is an array of elements of type E.
|
|
75
86
|
* @returns The method is returning a new instance of the Queue class, initialized with the elements from the input
|
|
76
87
|
* array.
|
|
@@ -160,6 +171,12 @@ export declare class Queue<E = any, R = any> extends IterableElementBase<E, R, Q
|
|
|
160
171
|
* The clear function resets the elements array and offset to their initial values.
|
|
161
172
|
*/
|
|
162
173
|
clear(): void;
|
|
174
|
+
/**
|
|
175
|
+
* The `compact` function in TypeScript slices the elements array based on the offset and resets the
|
|
176
|
+
* offset to zero.
|
|
177
|
+
* @returns The `compact()` method is returning a boolean value of `true`.
|
|
178
|
+
*/
|
|
179
|
+
compact(): boolean;
|
|
163
180
|
/**
|
|
164
181
|
* Time Complexity: O(n)
|
|
165
182
|
* Space Complexity: O(n)
|
|
@@ -17,6 +17,11 @@ class Queue extends base_1.IterableElementBase {
|
|
|
17
17
|
super(options);
|
|
18
18
|
this._elements = [];
|
|
19
19
|
this._offset = 0;
|
|
20
|
+
this._autoCompactRatio = 0.5;
|
|
21
|
+
if (options) {
|
|
22
|
+
const { autoCompactRatio = 0.5 } = options;
|
|
23
|
+
this._autoCompactRatio = autoCompactRatio;
|
|
24
|
+
}
|
|
20
25
|
if (elements) {
|
|
21
26
|
for (const el of elements) {
|
|
22
27
|
if (this.toElementFn)
|
|
@@ -77,6 +82,21 @@ class Queue extends base_1.IterableElementBase {
|
|
|
77
82
|
get last() {
|
|
78
83
|
return this.size > 0 ? this.elements[this.elements.length - 1] : undefined;
|
|
79
84
|
}
|
|
85
|
+
/**
|
|
86
|
+
* This function returns the value of the autoCompactRatio property.
|
|
87
|
+
* @returns The `autoCompactRatio` property of the object, which is a number.
|
|
88
|
+
*/
|
|
89
|
+
get autoCompactRatio() {
|
|
90
|
+
return this._autoCompactRatio;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* The above function sets the autoCompactRatio property to a specified number in TypeScript.
|
|
94
|
+
* @param {number} v - The parameter `v` represents the value that will be assigned to the
|
|
95
|
+
* `_autoCompactRatio` property.
|
|
96
|
+
*/
|
|
97
|
+
set autoCompactRatio(v) {
|
|
98
|
+
this._autoCompactRatio = v;
|
|
99
|
+
}
|
|
80
100
|
/**
|
|
81
101
|
* Time Complexity: O(n)
|
|
82
102
|
* Space Complexity: O(n)
|
|
@@ -87,7 +107,6 @@ class Queue extends base_1.IterableElementBase {
|
|
|
87
107
|
*
|
|
88
108
|
* The function "fromArray" creates a new Queue object from an array of elements.Creates a queue from an existing array.
|
|
89
109
|
* @public
|
|
90
|
-
* @static
|
|
91
110
|
* @param {E[]} elements - The "elements" parameter is an array of elements of type E.
|
|
92
111
|
* @returns The method is returning a new instance of the Queue class, initialized with the elements from the input
|
|
93
112
|
* array.
|
|
@@ -128,12 +147,8 @@ class Queue extends base_1.IterableElementBase {
|
|
|
128
147
|
return undefined;
|
|
129
148
|
const first = this.first;
|
|
130
149
|
this._offset += 1;
|
|
131
|
-
if (this.offset
|
|
132
|
-
|
|
133
|
-
// only delete dequeued elements when reaching half size
|
|
134
|
-
// to decrease latency of shifting elements.
|
|
135
|
-
this._elements = this.elements.slice(this.offset);
|
|
136
|
-
this._offset = 0;
|
|
150
|
+
if (this.offset / this.elements.length > this.autoCompactRatio)
|
|
151
|
+
this.compact();
|
|
137
152
|
return first;
|
|
138
153
|
}
|
|
139
154
|
/**
|
|
@@ -209,6 +224,16 @@ class Queue extends base_1.IterableElementBase {
|
|
|
209
224
|
this._elements = [];
|
|
210
225
|
this._offset = 0;
|
|
211
226
|
}
|
|
227
|
+
/**
|
|
228
|
+
* The `compact` function in TypeScript slices the elements array based on the offset and resets the
|
|
229
|
+
* offset to zero.
|
|
230
|
+
* @returns The `compact()` method is returning a boolean value of `true`.
|
|
231
|
+
*/
|
|
232
|
+
compact() {
|
|
233
|
+
this._elements = this.elements.slice(this.offset);
|
|
234
|
+
this._offset = 0;
|
|
235
|
+
return true;
|
|
236
|
+
}
|
|
212
237
|
/**
|
|
213
238
|
* Time Complexity: O(n)
|
|
214
239
|
* Space Complexity: O(n)
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { BinaryTree, BinaryTreeNode } from '../data-structures';
|
|
2
|
-
import type { BinaryTreeDeleteResult, BinaryTreeNested, BinaryTreeNodeNested, BinaryTreeOptions, BTNCallback,
|
|
2
|
+
import type { BinaryTreeDeleteResult, BinaryTreeNested, BinaryTreeNodeNested, BinaryTreeOptions, BTNCallback, BTNKeyOrNodeOrEntry } from '../types';
|
|
3
3
|
export interface IBinaryTree<K = any, V = any, R = [K, V], NODE extends BinaryTreeNode<K, V, NODE> = BinaryTreeNodeNested<K, V>, TREE extends BinaryTree<K, V, R, NODE, TREE> = BinaryTreeNested<K, V, R, NODE>> {
|
|
4
4
|
createNode(key: K, value?: NODE['value']): NODE;
|
|
5
5
|
createTree(options?: Partial<BinaryTreeOptions<K, V, R>>): TREE;
|
|
6
|
-
add(keyOrNodeOrEntryOrRawElement:
|
|
7
|
-
addMany(nodes: Iterable<
|
|
6
|
+
add(keyOrNodeOrEntryOrRawElement: BTNKeyOrNodeOrEntry<K, V, NODE>, value?: V, count?: number): boolean;
|
|
7
|
+
addMany(nodes: Iterable<BTNKeyOrNodeOrEntry<K, V, NODE>>, values?: Iterable<V | undefined>): boolean[];
|
|
8
8
|
delete<C extends BTNCallback<NODE>>(identifier: ReturnType<C> | null, callback: C): BinaryTreeDeleteResult<NODE>[];
|
|
9
9
|
}
|
package/dist/types/common.d.ts
CHANGED
|
@@ -1,36 +1,15 @@
|
|
|
1
1
|
export type CP = 1 | -1 | 0;
|
|
2
|
-
/**
|
|
3
|
-
* Enum representing different loop types.
|
|
4
|
-
*
|
|
5
|
-
* - `iterative`: Indicates the iterative loop type (with loops that use iterations).
|
|
6
|
-
* - `recursive`: Indicates the recursive loop type (with loops that call themselves).
|
|
7
|
-
*/
|
|
8
2
|
export type IterationType = 'ITERATIVE' | 'RECURSIVE';
|
|
9
3
|
export type FamilyPosition = 'ROOT' | 'LEFT' | 'RIGHT' | 'ROOT_LEFT' | 'ROOT_RIGHT' | 'ISOLATED' | 'MAL_NODE';
|
|
10
4
|
export type Comparator<K> = (a: K, b: K) => number;
|
|
11
5
|
export type DFSOrderPattern = 'PRE' | 'IN' | 'POST';
|
|
12
6
|
export type NodeDisplayLayout = [string[], number, number, number];
|
|
13
|
-
export type BTNCallback<N, D = any> = (node: N) => D;
|
|
14
7
|
export interface IterableWithSize<T> extends Iterable<T> {
|
|
15
8
|
size: number | ((...args: any[]) => number);
|
|
16
9
|
}
|
|
17
10
|
export interface IterableWithLength<T> extends Iterable<T> {
|
|
18
11
|
length: number | ((...args: any[]) => number);
|
|
19
12
|
}
|
|
13
|
+
export type OptValue<V> = V | undefined;
|
|
20
14
|
export type IterableWithSizeOrLength<T> = IterableWithSize<T> | IterableWithLength<T>;
|
|
21
|
-
export type BinaryTreePrintOptions = {
|
|
22
|
-
isShowUndefined?: boolean;
|
|
23
|
-
isShowNull?: boolean;
|
|
24
|
-
isShowRedBlackNIL?: boolean;
|
|
25
|
-
};
|
|
26
|
-
export type BTNEntry<K, V> = [K | null | undefined, V | undefined];
|
|
27
|
-
export type BTNKeyOrNode<K, N> = K | null | undefined | N;
|
|
28
|
-
export type KeyOrNodeOrEntry<K, V, N> = BTNEntry<K, V> | BTNKeyOrNode<K, N>;
|
|
29
|
-
export type BTNodePureKeyOrNode<K, N> = K | N;
|
|
30
|
-
export type BTNPureKeyOrNodeOrEntry<K, V, N> = [K, V | undefined] | BTNodePureKeyOrNode<K, N>;
|
|
31
|
-
export type BSTNKeyOrNode<K, N> = K | undefined | N;
|
|
32
|
-
export type BinaryTreeDeleteResult<N> = {
|
|
33
|
-
deleted: N | null | undefined;
|
|
34
|
-
needBalanced: N | null | undefined;
|
|
35
|
-
};
|
|
36
15
|
export type CRUD = 'CREATED' | 'READ' | 'UPDATED' | 'DELETED';
|
|
@@ -1,8 +1,25 @@
|
|
|
1
1
|
import { BinaryTree, BinaryTreeNode } from '../../../data-structures';
|
|
2
|
-
import {
|
|
2
|
+
import { IterationType, OptValue } from '../../common';
|
|
3
3
|
export type BinaryTreeNodeNested<K, V> = BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
|
|
4
4
|
export type BinaryTreeNested<K, V, R, NODE extends BinaryTreeNode<K, V, NODE>> = BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, BinaryTree<K, V, R, NODE, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
|
|
5
5
|
export type BinaryTreeOptions<K, V, R> = {
|
|
6
6
|
iterationType?: IterationType;
|
|
7
7
|
toEntryFn?: (rawElement: R) => BTNEntry<K, V>;
|
|
8
8
|
};
|
|
9
|
+
export type BinaryTreePrintOptions = {
|
|
10
|
+
isShowUndefined?: boolean;
|
|
11
|
+
isShowNull?: boolean;
|
|
12
|
+
isShowRedBlackNIL?: boolean;
|
|
13
|
+
};
|
|
14
|
+
export type OptBTNOrNull<NODE> = NODE | null | undefined;
|
|
15
|
+
export type OptBTNKeyOrNull<K> = K | null | undefined;
|
|
16
|
+
export type BTNEntry<K, V> = [OptBTNKeyOrNull<K>, OptValue<V>];
|
|
17
|
+
export type BTNKeyOrNode<K, NODE> = OptBTNKeyOrNull<K> | NODE;
|
|
18
|
+
export type BTNKeyOrNodeOrEntry<K, V, NODE> = BTNEntry<K, V> | BTNKeyOrNode<K, NODE>;
|
|
19
|
+
export type BTNPureKeyOrNode<K, NODE> = K | NODE;
|
|
20
|
+
export type BTNPureKeyOrNodeOrEntry<K, V, NODE> = [K, OptValue<V>] | BTNPureKeyOrNode<K, NODE>;
|
|
21
|
+
export type BinaryTreeDeleteResult<NODE> = {
|
|
22
|
+
deleted: OptBTNOrNull<NODE>;
|
|
23
|
+
needBalanced: OptBTNOrNull<NODE>;
|
|
24
|
+
};
|
|
25
|
+
export type BTNCallback<NODE, D = any> = (node: NODE) => D;
|
|
@@ -6,3 +6,6 @@ export type BSTNested<K, V, R, NODE extends BSTNode<K, V, NODE>> = BST<K, V, R,
|
|
|
6
6
|
export type BSTOptions<K, V, R> = BinaryTreeOptions<K, V, R> & {
|
|
7
7
|
comparator?: Comparator<K>;
|
|
8
8
|
};
|
|
9
|
+
export type OptBSTNKey<K> = K | undefined;
|
|
10
|
+
export type OptBSTN<NODE> = NODE | undefined;
|
|
11
|
+
export type BSTNKeyOrNode<K, NODE> = OptBSTNKey<K> | NODE;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "deque-typed",
|
|
3
|
-
"version": "1.52.
|
|
3
|
+
"version": "1.52.2",
|
|
4
4
|
"description": "Deque. Javascript & Typescript Data Structure.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -119,6 +119,6 @@
|
|
|
119
119
|
"typescript": "^4.9.5"
|
|
120
120
|
},
|
|
121
121
|
"dependencies": {
|
|
122
|
-
"data-structure-typed": "^1.52.
|
|
122
|
+
"data-structure-typed": "^1.52.2"
|
|
123
123
|
}
|
|
124
124
|
}
|