min-heap-typed 1.50.2 → 1.50.4
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/base/iterable-base.d.ts +6 -0
- package/dist/data-structures/binary-tree/{tree-multimap.d.ts → avl-tree-multi-map.d.ts} +43 -10
- package/dist/data-structures/binary-tree/{tree-multimap.js → avl-tree-multi-map.js} +49 -11
- package/dist/data-structures/binary-tree/avl-tree.d.ts +29 -1
- package/dist/data-structures/binary-tree/avl-tree.js +33 -1
- package/dist/data-structures/binary-tree/binary-indexed-tree.d.ts +22 -0
- package/dist/data-structures/binary-tree/binary-indexed-tree.js +22 -0
- package/dist/data-structures/binary-tree/binary-tree.d.ts +1 -1
- package/dist/data-structures/binary-tree/binary-tree.js +1 -1
- package/dist/data-structures/binary-tree/bst.d.ts +46 -13
- package/dist/data-structures/binary-tree/bst.js +51 -20
- package/dist/data-structures/binary-tree/index.d.ts +2 -1
- package/dist/data-structures/binary-tree/index.js +2 -1
- package/dist/data-structures/binary-tree/rb-tree.d.ts +54 -2
- package/dist/data-structures/binary-tree/rb-tree.js +90 -24
- package/dist/data-structures/binary-tree/segment-tree.d.ts +99 -6
- package/dist/data-structures/binary-tree/segment-tree.js +127 -10
- package/dist/data-structures/binary-tree/tree-multi-map.d.ts +200 -0
- package/dist/data-structures/binary-tree/tree-multi-map.js +399 -0
- package/dist/data-structures/graph/abstract-graph.d.ts +0 -78
- package/dist/data-structures/graph/abstract-graph.js +0 -189
- package/dist/data-structures/graph/directed-graph.d.ts +59 -0
- package/dist/data-structures/graph/directed-graph.js +105 -0
- package/dist/data-structures/graph/undirected-graph.d.ts +60 -7
- package/dist/data-structures/graph/undirected-graph.js +126 -18
- package/dist/data-structures/hash/hash-map.d.ts +143 -23
- package/dist/data-structures/hash/hash-map.js +196 -62
- package/dist/data-structures/heap/heap.d.ts +29 -19
- package/dist/data-structures/heap/heap.js +29 -20
- package/dist/data-structures/linked-list/doubly-linked-list.d.ts +71 -25
- package/dist/data-structures/linked-list/doubly-linked-list.js +83 -25
- package/dist/data-structures/linked-list/singly-linked-list.d.ts +26 -3
- package/dist/data-structures/linked-list/singly-linked-list.js +34 -3
- package/dist/data-structures/linked-list/skip-linked-list.d.ts +2 -2
- package/dist/data-structures/linked-list/skip-linked-list.js +2 -2
- package/dist/data-structures/matrix/matrix.d.ts +1 -1
- package/dist/data-structures/matrix/matrix.js +1 -1
- package/dist/data-structures/priority-queue/max-priority-queue.d.ts +10 -0
- package/dist/data-structures/priority-queue/max-priority-queue.js +10 -0
- package/dist/data-structures/priority-queue/min-priority-queue.d.ts +11 -0
- package/dist/data-structures/priority-queue/min-priority-queue.js +11 -0
- package/dist/data-structures/priority-queue/priority-queue.d.ts +8 -0
- package/dist/data-structures/priority-queue/priority-queue.js +8 -0
- package/dist/data-structures/queue/deque.d.ts +95 -21
- package/dist/data-structures/queue/deque.js +100 -16
- package/dist/data-structures/queue/queue.d.ts +65 -45
- package/dist/data-structures/queue/queue.js +65 -45
- package/dist/data-structures/stack/stack.d.ts +36 -22
- package/dist/data-structures/stack/stack.js +36 -22
- package/dist/data-structures/tree/tree.d.ts +57 -3
- package/dist/data-structures/tree/tree.js +77 -11
- package/dist/data-structures/trie/trie.d.ts +100 -36
- package/dist/data-structures/trie/trie.js +115 -36
- package/dist/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +5 -0
- package/dist/types/data-structures/binary-tree/index.d.ts +2 -1
- package/dist/types/data-structures/binary-tree/index.js +2 -1
- package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +5 -0
- package/dist/types/data-structures/binary-tree/tree-multi-map.js +2 -0
- package/package.json +2 -2
- package/src/data-structures/base/iterable-base.ts +12 -0
- package/src/data-structures/binary-tree/{tree-multimap.ts → avl-tree-multi-map.ts} +59 -20
- package/src/data-structures/binary-tree/avl-tree.ts +37 -3
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +22 -0
- package/src/data-structures/binary-tree/binary-tree.ts +1 -1
- package/src/data-structures/binary-tree/bst.ts +51 -19
- package/src/data-structures/binary-tree/index.ts +2 -1
- package/src/data-structures/binary-tree/rb-tree.ts +99 -28
- package/src/data-structures/binary-tree/segment-tree.ts +145 -11
- package/src/data-structures/binary-tree/tree-multi-map.ts +463 -0
- package/src/data-structures/graph/abstract-graph.ts +0 -211
- package/src/data-structures/graph/directed-graph.ts +122 -0
- package/src/data-structures/graph/undirected-graph.ts +143 -19
- package/src/data-structures/hash/hash-map.ts +228 -76
- package/src/data-structures/heap/heap.ts +31 -20
- package/src/data-structures/linked-list/doubly-linked-list.ts +96 -29
- package/src/data-structures/linked-list/singly-linked-list.ts +42 -6
- package/src/data-structures/linked-list/skip-linked-list.ts +2 -2
- package/src/data-structures/matrix/matrix.ts +1 -1
- package/src/data-structures/priority-queue/max-priority-queue.ts +10 -0
- package/src/data-structures/priority-queue/min-priority-queue.ts +11 -0
- package/src/data-structures/priority-queue/priority-queue.ts +8 -0
- package/src/data-structures/queue/deque.ts +118 -22
- package/src/data-structures/queue/queue.ts +68 -45
- package/src/data-structures/stack/stack.ts +39 -23
- package/src/data-structures/tree/tree.ts +89 -15
- package/src/data-structures/trie/trie.ts +131 -40
- package/src/types/data-structures/binary-tree/avl-tree-multi-map.ts +8 -0
- package/src/types/data-structures/binary-tree/index.ts +2 -1
- package/src/types/data-structures/binary-tree/tree-multi-map.ts +8 -0
- package/dist/types/data-structures/binary-tree/tree-multimap.d.ts +0 -5
- package/src/types/data-structures/binary-tree/tree-multimap.ts +0 -8
- /package/dist/types/data-structures/binary-tree/{tree-multimap.js → avl-tree-multi-map.js} +0 -0
|
@@ -9,17 +9,118 @@
|
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.SegmentTree = exports.SegmentTreeNode = void 0;
|
|
11
11
|
class SegmentTreeNode {
|
|
12
|
+
/**
|
|
13
|
+
* The constructor initializes the properties of a SegmentTreeNode object.
|
|
14
|
+
* @param {number} start - The `start` parameter represents the starting index of the segment covered
|
|
15
|
+
* by this node in a segment tree.
|
|
16
|
+
* @param {number} end - The `end` parameter represents the end index of the segment covered by this
|
|
17
|
+
* node in a segment tree.
|
|
18
|
+
* @param {number} sum - The `sum` parameter represents the sum of the values in the range covered by
|
|
19
|
+
* the segment tree node.
|
|
20
|
+
* @param {SegmentTreeNodeVal | undefined} [value] - The `value` parameter is an optional parameter
|
|
21
|
+
* of type `SegmentTreeNodeVal`. It represents the value associated with the segment tree node.
|
|
22
|
+
*/
|
|
12
23
|
constructor(start, end, sum, value) {
|
|
13
|
-
this.
|
|
14
|
-
this.
|
|
15
|
-
this.
|
|
16
|
-
this.
|
|
17
|
-
this.
|
|
18
|
-
this.
|
|
19
|
-
this.
|
|
20
|
-
this.
|
|
21
|
-
this.
|
|
22
|
-
this.
|
|
24
|
+
this._start = 0;
|
|
25
|
+
this._end = 0;
|
|
26
|
+
this._value = undefined;
|
|
27
|
+
this._sum = 0;
|
|
28
|
+
this._left = undefined;
|
|
29
|
+
this._right = undefined;
|
|
30
|
+
this._start = start;
|
|
31
|
+
this._end = end;
|
|
32
|
+
this._sum = sum;
|
|
33
|
+
this._value = value || undefined;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The function returns the value of the protected variable _start.
|
|
37
|
+
* @returns The start value, which is of type number.
|
|
38
|
+
*/
|
|
39
|
+
get start() {
|
|
40
|
+
return this._start;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* The above function sets the value of the "start" property.
|
|
44
|
+
* @param {number} value - The value parameter is of type number.
|
|
45
|
+
*/
|
|
46
|
+
set start(value) {
|
|
47
|
+
this._start = value;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* The function returns the value of the protected variable `_end`.
|
|
51
|
+
* @returns The value of the protected property `_end`.
|
|
52
|
+
*/
|
|
53
|
+
get end() {
|
|
54
|
+
return this._end;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* The above function sets the value of the "end" property.
|
|
58
|
+
* @param {number} value - The value parameter is a number that represents the new value for the end
|
|
59
|
+
* property.
|
|
60
|
+
*/
|
|
61
|
+
set end(value) {
|
|
62
|
+
this._end = value;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* The function returns the value of a segment tree node.
|
|
66
|
+
* @returns The value being returned is either a `SegmentTreeNodeVal` object or `undefined`.
|
|
67
|
+
*/
|
|
68
|
+
get value() {
|
|
69
|
+
return this._value;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* The function sets the value of a segment tree node.
|
|
73
|
+
* @param {SegmentTreeNodeVal | undefined} value - The `value` parameter is of type
|
|
74
|
+
* `SegmentTreeNodeVal` or `undefined`.
|
|
75
|
+
*/
|
|
76
|
+
set value(value) {
|
|
77
|
+
this._value = value;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* The function returns the value of the sum property.
|
|
81
|
+
* @returns The method is returning the value of the variable `_sum`.
|
|
82
|
+
*/
|
|
83
|
+
get sum() {
|
|
84
|
+
return this._sum;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* The above function sets the value of the sum property.
|
|
88
|
+
* @param {number} value - The parameter "value" is of type "number".
|
|
89
|
+
*/
|
|
90
|
+
set sum(value) {
|
|
91
|
+
this._sum = value;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* The function returns the left child of a segment tree node.
|
|
95
|
+
* @returns The `left` property of the `SegmentTreeNode` object is being returned. It is of type
|
|
96
|
+
* `SegmentTreeNode` or `undefined`.
|
|
97
|
+
*/
|
|
98
|
+
get left() {
|
|
99
|
+
return this._left;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* The function sets the value of the left property of a SegmentTreeNode object.
|
|
103
|
+
* @param {SegmentTreeNode | undefined} value - The value parameter is of type SegmentTreeNode or
|
|
104
|
+
* undefined.
|
|
105
|
+
*/
|
|
106
|
+
set left(value) {
|
|
107
|
+
this._left = value;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* The function returns the right child of a segment tree node.
|
|
111
|
+
* @returns The `getRight()` method is returning a value of type `SegmentTreeNode` or `undefined`.
|
|
112
|
+
*/
|
|
113
|
+
get right() {
|
|
114
|
+
return this._right;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* The function sets the right child of a segment tree node.
|
|
118
|
+
* @param {SegmentTreeNode | undefined} value - The `value` parameter is of type `SegmentTreeNode |
|
|
119
|
+
* undefined`. This means that it can accept either a `SegmentTreeNode` object or `undefined` as its
|
|
120
|
+
* value.
|
|
121
|
+
*/
|
|
122
|
+
set right(value) {
|
|
123
|
+
this._right = value;
|
|
23
124
|
}
|
|
24
125
|
}
|
|
25
126
|
exports.SegmentTreeNode = SegmentTreeNode;
|
|
@@ -49,15 +150,31 @@ class SegmentTree {
|
|
|
49
150
|
this._values = [];
|
|
50
151
|
}
|
|
51
152
|
}
|
|
153
|
+
/**
|
|
154
|
+
* The function returns an array of numbers.
|
|
155
|
+
* @returns An array of numbers is being returned.
|
|
156
|
+
*/
|
|
52
157
|
get values() {
|
|
53
158
|
return this._values;
|
|
54
159
|
}
|
|
160
|
+
/**
|
|
161
|
+
* The function returns the value of the protected variable _start.
|
|
162
|
+
* @returns The start value, which is of type number.
|
|
163
|
+
*/
|
|
55
164
|
get start() {
|
|
56
165
|
return this._start;
|
|
57
166
|
}
|
|
167
|
+
/**
|
|
168
|
+
* The function returns the value of the protected variable `_end`.
|
|
169
|
+
* @returns The value of the protected property `_end`.
|
|
170
|
+
*/
|
|
58
171
|
get end() {
|
|
59
172
|
return this._end;
|
|
60
173
|
}
|
|
174
|
+
/**
|
|
175
|
+
* The function returns the root node of a segment tree.
|
|
176
|
+
* @returns The `root` property of the class `SegmentTreeNode` or `undefined` if it is not defined.
|
|
177
|
+
*/
|
|
61
178
|
get root() {
|
|
62
179
|
return this._root;
|
|
63
180
|
}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* data-structure-typed
|
|
3
|
+
*
|
|
4
|
+
* @author Tyler Zeng
|
|
5
|
+
* @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
|
|
6
|
+
* @license MIT License
|
|
7
|
+
*/
|
|
8
|
+
import type { BinaryTreeDeleteResult, BSTNKeyOrNode, BTNCallback, KeyOrNodeOrEntry, TreeMultiMapNested, TreeMultiMapNodeNested, TreeMultiMapOptions } from '../../types';
|
|
9
|
+
import { IterationType } from '../../types';
|
|
10
|
+
import { IBinaryTree } from '../../interfaces';
|
|
11
|
+
import { RedBlackTree, RedBlackTreeNode } from './rb-tree';
|
|
12
|
+
export declare class TreeMultiMapNode<K = any, V = any, NODE extends TreeMultiMapNode<K, V, NODE> = TreeMultiMapNodeNested<K, V>> extends RedBlackTreeNode<K, V, NODE> {
|
|
13
|
+
/**
|
|
14
|
+
* The constructor function initializes an instance of a class with a key, value, and count.
|
|
15
|
+
* @param {K} key - The key parameter is of type K, which represents the type of the key for the
|
|
16
|
+
* constructor. It is required and must be provided when creating an instance of the class.
|
|
17
|
+
* @param {V} [value] - The `value` parameter is an optional parameter of type `V`. It represents the
|
|
18
|
+
* value associated with the key in the constructor. If no value is provided, it will be `undefined`.
|
|
19
|
+
* @param [count=1] - The "count" parameter is an optional parameter that specifies the number of
|
|
20
|
+
* times the key-value pair should be repeated. If no value is provided for "count", it defaults to
|
|
21
|
+
* 1.
|
|
22
|
+
*/
|
|
23
|
+
constructor(key: K, value?: V, count?: number);
|
|
24
|
+
protected _count: number;
|
|
25
|
+
/**
|
|
26
|
+
* The function returns the value of the private variable _count.
|
|
27
|
+
* @returns The count property of the object, which is of type number.
|
|
28
|
+
*/
|
|
29
|
+
get count(): number;
|
|
30
|
+
/**
|
|
31
|
+
* The above function sets the value of the count property.
|
|
32
|
+
* @param {number} value - The value parameter is of type number, which means it can accept any
|
|
33
|
+
* numeric value.
|
|
34
|
+
*/
|
|
35
|
+
set count(value: number);
|
|
36
|
+
}
|
|
37
|
+
export declare class TreeMultiMap<K = any, V = any, NODE extends TreeMultiMapNode<K, V, NODE> = TreeMultiMapNode<K, V, TreeMultiMapNodeNested<K, V>>, TREE extends TreeMultiMap<K, V, NODE, TREE> = TreeMultiMap<K, V, NODE, TreeMultiMapNested<K, V, NODE>>> extends RedBlackTree<K, V, NODE, TREE> implements IBinaryTree<K, V, NODE, TREE> {
|
|
38
|
+
/**
|
|
39
|
+
* The constructor function initializes a new instance of the TreeMultiMap class with optional
|
|
40
|
+
* initial keys, nodes, or entries.
|
|
41
|
+
* @param keysOrNodesOrEntries - The `keysOrNodesOrEntries` parameter is an iterable object that can
|
|
42
|
+
* contain keys, nodes, or entries. It is used to initialize the TreeMultiMap with the provided keys,
|
|
43
|
+
* nodes, or entries.
|
|
44
|
+
* @param [options] - The `options` parameter is an optional object that can be passed to the
|
|
45
|
+
* constructor. It allows you to customize the behavior of the `TreeMultiMap` instance.
|
|
46
|
+
*/
|
|
47
|
+
constructor(keysOrNodesOrEntries?: Iterable<KeyOrNodeOrEntry<K, V, NODE>>, options?: TreeMultiMapOptions<K>);
|
|
48
|
+
protected _count: number;
|
|
49
|
+
/**
|
|
50
|
+
* The function calculates the sum of the count property of all nodes in a tree structure.
|
|
51
|
+
* @returns the sum of the count property of all nodes in the tree.
|
|
52
|
+
*/
|
|
53
|
+
get count(): number;
|
|
54
|
+
/**
|
|
55
|
+
* The function creates a new TreeMultiMapNode object with the specified key, value, and count.
|
|
56
|
+
* @param {K} key - The key parameter represents the key of the node being created. It is of type K,
|
|
57
|
+
* which is a generic type that can be replaced with any specific type when using the function.
|
|
58
|
+
* @param {V} [value] - The `value` parameter is an optional parameter that represents the value
|
|
59
|
+
* associated with the key in the node. It is of type `V`, which can be any data type.
|
|
60
|
+
* @param {number} [count] - The `count` parameter represents the number of occurrences of a
|
|
61
|
+
* key-value pair in the TreeMultiMap. It is an optional parameter, so if it is not provided, it will
|
|
62
|
+
* default to 1.
|
|
63
|
+
* @returns a new instance of the TreeMultiMapNode class, casted as NODE.
|
|
64
|
+
*/
|
|
65
|
+
createNode(key: K, value?: V, count?: number): NODE;
|
|
66
|
+
/**
|
|
67
|
+
* The function creates a new instance of a TreeMultiMap with the specified options and returns it.
|
|
68
|
+
* @param [options] - The `options` parameter is an optional object that contains additional
|
|
69
|
+
* configuration options for creating the `TreeMultiMap`. It can include properties such as
|
|
70
|
+
* `keyComparator`, `valueComparator`, `allowDuplicates`, etc.
|
|
71
|
+
* @returns a new instance of the `TreeMultiMap` class, with the provided options merged with the
|
|
72
|
+
* existing `iterationType` option. The returned value is casted as `TREE`.
|
|
73
|
+
*/
|
|
74
|
+
createTree(options?: TreeMultiMapOptions<K>): TREE;
|
|
75
|
+
/**
|
|
76
|
+
* The function `keyValueOrEntryToNode` takes a key, value, and count and returns a node if the input
|
|
77
|
+
* is valid.
|
|
78
|
+
* @param keyOrNodeOrEntry - The parameter `keyOrNodeOrEntry` can be of type `KeyOrNodeOrEntry<K, V,
|
|
79
|
+
* NODE>`. It can accept three types of values:
|
|
80
|
+
* @param {V} [value] - The `value` parameter is an optional value of type `V`. It represents the
|
|
81
|
+
* value associated with a key in a key-value pair.
|
|
82
|
+
* @param [count=1] - The count parameter is an optional parameter that specifies the number of times
|
|
83
|
+
* the key-value pair should be added to the node. If not provided, it defaults to 1.
|
|
84
|
+
* @returns a NODE object or undefined.
|
|
85
|
+
*/
|
|
86
|
+
keyValueOrEntryToNode(keyOrNodeOrEntry: KeyOrNodeOrEntry<K, V, NODE>, value?: V, count?: number): NODE | undefined;
|
|
87
|
+
/**
|
|
88
|
+
* The function "isNode" checks if a given key, node, or entry is an instance of the TreeMultiMapNode
|
|
89
|
+
* class.
|
|
90
|
+
* @param keyOrNodeOrEntry - The parameter `keyOrNodeOrEntry` can be of type `KeyOrNodeOrEntry<K, V,
|
|
91
|
+
* NODE>`.
|
|
92
|
+
* @returns a boolean value indicating whether the input parameter `keyOrNodeOrEntry` is an instance
|
|
93
|
+
* of the `TreeMultiMapNode` class.
|
|
94
|
+
*/
|
|
95
|
+
isNode(keyOrNodeOrEntry: KeyOrNodeOrEntry<K, V, NODE>): keyOrNodeOrEntry is NODE;
|
|
96
|
+
/**
|
|
97
|
+
* Time Complexity: O(log n)
|
|
98
|
+
* Space Complexity: O(1)
|
|
99
|
+
*/
|
|
100
|
+
/**
|
|
101
|
+
* Time Complexity: O(log n)
|
|
102
|
+
* Space Complexity: O(1)
|
|
103
|
+
*
|
|
104
|
+
* The function overrides the add method in TypeScript and adds a new node to the data structure.
|
|
105
|
+
* @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter can accept three types of values:
|
|
106
|
+
* @param {V} [value] - The `value` parameter represents the value associated with the key in the
|
|
107
|
+
* data structure.
|
|
108
|
+
* @param [count=1] - The `count` parameter represents the number of times the key-value pair should
|
|
109
|
+
* be added to the data structure. By default, it is set to 1, meaning that the key-value pair will
|
|
110
|
+
* be added once. However, you can specify a different value for `count` if you want to add
|
|
111
|
+
* @returns a boolean value.
|
|
112
|
+
*/
|
|
113
|
+
add(keyOrNodeOrEntry: KeyOrNodeOrEntry<K, V, NODE>, value?: V, count?: number): boolean;
|
|
114
|
+
/**
|
|
115
|
+
* Time Complexity: O(log n)
|
|
116
|
+
* Space Complexity: O(1)
|
|
117
|
+
*/
|
|
118
|
+
/**
|
|
119
|
+
* Time Complexity: O(log n)
|
|
120
|
+
* Space Complexity: O(1)
|
|
121
|
+
*
|
|
122
|
+
* The `delete` function in a TypeScript class is used to delete nodes from a binary tree based on a
|
|
123
|
+
* given identifier, and it returns an array of results containing information about the deleted
|
|
124
|
+
* nodes.
|
|
125
|
+
* @param {ReturnType<C> | null | undefined} identifier - The identifier parameter is the value used
|
|
126
|
+
* to identify the node to be deleted. It can be of any type that is returned by the callback
|
|
127
|
+
* function. It can also be null or undefined if no node needs to be deleted.
|
|
128
|
+
* @param {C} callback - The `callback` parameter is a function that takes a node of type `NODE` as
|
|
129
|
+
* input and returns a value of type `ReturnType<C>`. It is used to determine if a node matches the
|
|
130
|
+
* identifier for deletion. If no callback is provided, the `_defaultOneParamCallback` function is
|
|
131
|
+
* used
|
|
132
|
+
* @param [ignoreCount=false] - A boolean value indicating whether to ignore the count of the target
|
|
133
|
+
* node when performing deletion. If set to true, the count of the target node will not be considered
|
|
134
|
+
* and the node will be deleted regardless of its count. If set to false (default), the count of the
|
|
135
|
+
* target node will be decremented
|
|
136
|
+
* @returns an array of BinaryTreeDeleteResult<NODE> objects.
|
|
137
|
+
*/
|
|
138
|
+
delete<C extends BTNCallback<NODE>>(identifier: ReturnType<C> | null | undefined, callback?: C, ignoreCount?: boolean): BinaryTreeDeleteResult<NODE>[];
|
|
139
|
+
/**
|
|
140
|
+
* Time Complexity: O(1)
|
|
141
|
+
* Space Complexity: O(1)
|
|
142
|
+
*/
|
|
143
|
+
/**
|
|
144
|
+
* Time Complexity: O(1)
|
|
145
|
+
* Space Complexity: O(1)
|
|
146
|
+
*
|
|
147
|
+
* The "clear" function overrides the parent class's "clear" function and also resets the count to
|
|
148
|
+
* zero.
|
|
149
|
+
*/
|
|
150
|
+
clear(): void;
|
|
151
|
+
/**
|
|
152
|
+
* Time Complexity: O(n log n)
|
|
153
|
+
* Space Complexity: O(log n)
|
|
154
|
+
*/
|
|
155
|
+
/**
|
|
156
|
+
* Time Complexity: O(n log n)
|
|
157
|
+
* Space Complexity: O(log n)
|
|
158
|
+
*
|
|
159
|
+
* The `perfectlyBalance` function takes a sorted array of nodes and builds a balanced binary search
|
|
160
|
+
* tree using either a recursive or iterative approach.
|
|
161
|
+
* @param iterationType - The `iterationType` parameter is an optional parameter that specifies the
|
|
162
|
+
* type of iteration to use when building the balanced binary search tree. It can have two possible
|
|
163
|
+
* values:
|
|
164
|
+
* @returns a boolean value.
|
|
165
|
+
*/
|
|
166
|
+
perfectlyBalance(iterationType?: IterationType): boolean;
|
|
167
|
+
/**
|
|
168
|
+
* Time complexity: O(n)
|
|
169
|
+
* Space complexity: O(n)
|
|
170
|
+
*/
|
|
171
|
+
/**
|
|
172
|
+
* Time complexity: O(n)
|
|
173
|
+
* Space complexity: O(n)
|
|
174
|
+
*
|
|
175
|
+
* The function overrides the clone method to create a deep copy of a tree object.
|
|
176
|
+
* @returns The `clone()` method is returning a cloned instance of the `TREE` object.
|
|
177
|
+
*/
|
|
178
|
+
clone(): TREE;
|
|
179
|
+
/**
|
|
180
|
+
* The function swaps the properties of two nodes in a binary search tree.
|
|
181
|
+
* @param srcNode - The source node that needs to be swapped with the destination node. It can be
|
|
182
|
+
* either a key or a node object.
|
|
183
|
+
* @param destNode - The `destNode` parameter is the node in the binary search tree where the
|
|
184
|
+
* properties will be swapped with the `srcNode`.
|
|
185
|
+
* @returns The method is returning the `destNode` after swapping its properties with the `srcNode`.
|
|
186
|
+
* If both `srcNode` and `destNode` are valid nodes, the method swaps their `key`, `value`, `count`,
|
|
187
|
+
* and `color` properties. If the swapping is successful, the method returns the modified `destNode`.
|
|
188
|
+
* If either `srcNode` or `destNode` is
|
|
189
|
+
*/
|
|
190
|
+
protected _swapProperties(srcNode: BSTNKeyOrNode<K, NODE>, destNode: BSTNKeyOrNode<K, NODE>): NODE | undefined;
|
|
191
|
+
/**
|
|
192
|
+
* The function replaces an old node with a new node and updates the count property of the new node.
|
|
193
|
+
* @param {NODE} oldNode - The `oldNode` parameter is of type `NODE` and represents the node that
|
|
194
|
+
* needs to be replaced in the data structure.
|
|
195
|
+
* @param {NODE} newNode - The `newNode` parameter is an object of type `NODE`.
|
|
196
|
+
* @returns The method is returning the result of calling the `_replaceNode` method from the
|
|
197
|
+
* superclass, after updating the `count` property of the `newNode` object.
|
|
198
|
+
*/
|
|
199
|
+
protected _replaceNode(oldNode: NODE, newNode: NODE): NODE;
|
|
200
|
+
}
|