red-black-tree-typed 1.53.7 → 1.54.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 (114) hide show
  1. package/README.md +52 -0
  2. package/dist/common/index.js +5 -0
  3. package/dist/data-structures/base/iterable-entry-base.js +4 -4
  4. package/dist/data-structures/binary-tree/avl-tree-counter.d.ts +213 -0
  5. package/dist/data-structures/binary-tree/avl-tree-counter.js +407 -0
  6. package/dist/data-structures/binary-tree/avl-tree-multi-map.d.ts +71 -170
  7. package/dist/data-structures/binary-tree/avl-tree-multi-map.js +133 -328
  8. package/dist/data-structures/binary-tree/avl-tree.d.ts +103 -69
  9. package/dist/data-structures/binary-tree/avl-tree.js +130 -70
  10. package/dist/data-structures/binary-tree/binary-indexed-tree.d.ts +3 -0
  11. package/dist/data-structures/binary-tree/binary-indexed-tree.js +3 -0
  12. package/dist/data-structures/binary-tree/binary-tree.d.ts +268 -202
  13. package/dist/data-structures/binary-tree/binary-tree.js +311 -263
  14. package/dist/data-structures/binary-tree/bst.d.ts +193 -139
  15. package/dist/data-structures/binary-tree/bst.js +248 -164
  16. package/dist/data-structures/binary-tree/index.d.ts +3 -1
  17. package/dist/data-structures/binary-tree/index.js +3 -1
  18. package/dist/data-structures/binary-tree/red-black-tree.d.ts +286 -0
  19. package/dist/data-structures/binary-tree/{rb-tree.js → red-black-tree.js} +176 -107
  20. package/dist/data-structures/binary-tree/tree-counter.d.ts +212 -0
  21. package/dist/data-structures/binary-tree/tree-counter.js +444 -0
  22. package/dist/data-structures/binary-tree/tree-multi-map.d.ts +78 -170
  23. package/dist/data-structures/binary-tree/tree-multi-map.js +145 -367
  24. package/dist/data-structures/graph/abstract-graph.js +2 -2
  25. package/dist/data-structures/graph/directed-graph.d.ts +3 -0
  26. package/dist/data-structures/graph/directed-graph.js +3 -0
  27. package/dist/data-structures/graph/map-graph.d.ts +3 -0
  28. package/dist/data-structures/graph/map-graph.js +3 -0
  29. package/dist/data-structures/graph/undirected-graph.d.ts +3 -0
  30. package/dist/data-structures/graph/undirected-graph.js +3 -0
  31. package/dist/data-structures/hash/hash-map.d.ts +31 -1
  32. package/dist/data-structures/hash/hash-map.js +35 -5
  33. package/dist/data-structures/heap/heap.d.ts +20 -3
  34. package/dist/data-structures/heap/heap.js +31 -11
  35. package/dist/data-structures/linked-list/doubly-linked-list.d.ts +46 -11
  36. package/dist/data-structures/linked-list/doubly-linked-list.js +68 -21
  37. package/dist/data-structures/linked-list/singly-linked-list.d.ts +47 -11
  38. package/dist/data-structures/linked-list/singly-linked-list.js +73 -26
  39. package/dist/data-structures/linked-list/skip-linked-list.d.ts +3 -0
  40. package/dist/data-structures/linked-list/skip-linked-list.js +3 -0
  41. package/dist/data-structures/matrix/matrix.d.ts +3 -0
  42. package/dist/data-structures/matrix/matrix.js +3 -0
  43. package/dist/data-structures/matrix/navigator.d.ts +3 -0
  44. package/dist/data-structures/matrix/navigator.js +3 -0
  45. package/dist/data-structures/priority-queue/max-priority-queue.d.ts +3 -0
  46. package/dist/data-structures/priority-queue/max-priority-queue.js +3 -0
  47. package/dist/data-structures/priority-queue/min-priority-queue.d.ts +3 -0
  48. package/dist/data-structures/priority-queue/min-priority-queue.js +3 -0
  49. package/dist/data-structures/queue/deque.d.ts +37 -8
  50. package/dist/data-structures/queue/deque.js +73 -29
  51. package/dist/data-structures/queue/queue.d.ts +41 -1
  52. package/dist/data-structures/queue/queue.js +51 -9
  53. package/dist/data-structures/stack/stack.d.ts +27 -10
  54. package/dist/data-structures/stack/stack.js +39 -20
  55. package/dist/data-structures/trie/trie.d.ts +8 -7
  56. package/dist/data-structures/trie/trie.js +8 -7
  57. package/dist/interfaces/binary-tree.d.ts +8 -8
  58. package/dist/types/data-structures/base/base.d.ts +1 -1
  59. package/dist/types/data-structures/binary-tree/avl-tree-counter.d.ts +2 -0
  60. package/dist/types/data-structures/binary-tree/avl-tree-counter.js +2 -0
  61. package/dist/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +1 -4
  62. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +0 -3
  63. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +0 -3
  64. package/dist/types/data-structures/binary-tree/bst.d.ts +4 -4
  65. package/dist/types/data-structures/binary-tree/index.d.ts +2 -0
  66. package/dist/types/data-structures/binary-tree/index.js +2 -0
  67. package/dist/types/data-structures/binary-tree/rb-tree.d.ts +2 -5
  68. package/dist/types/data-structures/binary-tree/tree-counter.d.ts +2 -0
  69. package/dist/types/data-structures/binary-tree/tree-counter.js +2 -0
  70. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +2 -5
  71. package/package.json +2 -2
  72. package/src/common/index.ts +7 -1
  73. package/src/data-structures/base/iterable-entry-base.ts +4 -4
  74. package/src/data-structures/binary-tree/avl-tree-counter.ts +463 -0
  75. package/src/data-structures/binary-tree/avl-tree-multi-map.ts +151 -370
  76. package/src/data-structures/binary-tree/avl-tree.ts +162 -105
  77. package/src/data-structures/binary-tree/binary-indexed-tree.ts +3 -0
  78. package/src/data-structures/binary-tree/binary-tree.ts +488 -416
  79. package/src/data-structures/binary-tree/bst.ts +326 -251
  80. package/src/data-structures/binary-tree/index.ts +3 -1
  81. package/src/data-structures/binary-tree/{rb-tree.ts → red-black-tree.ts} +219 -145
  82. package/src/data-structures/binary-tree/tree-counter.ts +504 -0
  83. package/src/data-structures/binary-tree/tree-multi-map.ts +159 -401
  84. package/src/data-structures/graph/abstract-graph.ts +2 -2
  85. package/src/data-structures/graph/directed-graph.ts +3 -0
  86. package/src/data-structures/graph/map-graph.ts +3 -0
  87. package/src/data-structures/graph/undirected-graph.ts +3 -0
  88. package/src/data-structures/hash/hash-map.ts +37 -7
  89. package/src/data-structures/heap/heap.ts +33 -10
  90. package/src/data-structures/linked-list/doubly-linked-list.ts +75 -21
  91. package/src/data-structures/linked-list/singly-linked-list.ts +80 -27
  92. package/src/data-structures/linked-list/skip-linked-list.ts +3 -0
  93. package/src/data-structures/matrix/matrix.ts +3 -0
  94. package/src/data-structures/matrix/navigator.ts +3 -0
  95. package/src/data-structures/priority-queue/max-priority-queue.ts +3 -0
  96. package/src/data-structures/priority-queue/min-priority-queue.ts +3 -0
  97. package/src/data-structures/queue/deque.ts +72 -28
  98. package/src/data-structures/queue/queue.ts +50 -7
  99. package/src/data-structures/stack/stack.ts +39 -20
  100. package/src/data-structures/trie/trie.ts +8 -7
  101. package/src/index.ts +2 -2
  102. package/src/interfaces/binary-tree.ts +10 -21
  103. package/src/types/data-structures/base/base.ts +1 -1
  104. package/src/types/data-structures/binary-tree/avl-tree-counter.ts +3 -0
  105. package/src/types/data-structures/binary-tree/avl-tree-multi-map.ts +1 -6
  106. package/src/types/data-structures/binary-tree/avl-tree.ts +0 -5
  107. package/src/types/data-structures/binary-tree/binary-tree.ts +0 -5
  108. package/src/types/data-structures/binary-tree/bst.ts +6 -6
  109. package/src/types/data-structures/binary-tree/index.ts +3 -1
  110. package/src/types/data-structures/binary-tree/red-black-tree.ts +5 -0
  111. package/src/types/data-structures/binary-tree/tree-counter.ts +3 -0
  112. package/src/types/data-structures/binary-tree/tree-multi-map.ts +2 -7
  113. package/dist/data-structures/binary-tree/rb-tree.d.ts +0 -209
  114. package/src/types/data-structures/binary-tree/rb-tree.ts +0 -10
@@ -5,194 +5,102 @@
5
5
  * @copyright Copyright (c) 2022 Pablo Zeng <zrwusa@gmail.com>
6
6
  * @license MIT License
7
7
  */
8
- import type { BinaryTreeDeleteResult, BSTNOptKeyOrNode, BTNRep, IterationType, RBTNColor, TreeMultiMapNested, TreeMultiMapNodeNested, TreeMultiMapOptions } from '../../types';
8
+ import type { BTNRep, OptNodeOrNull, TreeMultiMapOptions } from '../../types';
9
+ import { RedBlackTree, RedBlackTreeNode } from './red-black-tree';
9
10
  import { IBinaryTree } from '../../interfaces';
10
- import { RedBlackTree, RedBlackTreeNode } from './rb-tree';
11
- export declare class TreeMultiMapNode<K = any, V = any, NODE extends TreeMultiMapNode<K, V, NODE> = TreeMultiMapNodeNested<K, V>> extends RedBlackTreeNode<K, V, NODE> {
12
- /**
13
- * The constructor function initializes a Red-Black Tree node with a key, value, count, and color.
14
- * @param {K} key - The key parameter represents the key of the node in the Red-Black Tree. It is
15
- * used to identify and locate the node within the tree.
16
- * @param {V} [value] - The `value` parameter is an optional parameter that represents the value
17
- * associated with the key in the Red-Black Tree node. It is not required and can be omitted when
18
- * creating a new node.
19
- * @param [count=1] - The `count` parameter represents the number of occurrences of a particular key
20
- * in the Red-Black Tree. It is an optional parameter with a default value of 1.
21
- * @param {RBTNColor} [color=BLACK] - The `color` parameter is used to specify the color of the node
22
- * in a Red-Black Tree. It is optional and has a default value of `'BLACK'`.
23
- */
24
- constructor(key: K, value?: V, count?: number, color?: RBTNColor);
25
- protected _count: number;
26
- /**
27
- * The function returns the value of the private variable _count.
28
- * @returns The count property of the object, which is of type number.
29
- */
30
- get count(): number;
31
- /**
32
- * The above function sets the value of the count property.
33
- * @param {number} value - The value parameter is of type number, which means it can accept any
34
- * numeric value.
35
- */
36
- set count(value: number);
11
+ export declare class TreeMultiMapNode<K = any, V = any> extends RedBlackTreeNode<K, V[]> {
12
+ /**
13
+ * This TypeScript constructor initializes an object with a key of type K and an array of values of
14
+ * type V.
15
+ * @param {K} key - The `key` parameter is typically used to store a unique identifier or key for the
16
+ * data being stored in the data structure. It helps in quickly accessing or retrieving the
17
+ * associated value in the data structure.
18
+ * @param {V[]} value - The `value` parameter in the constructor represents an array of values of
19
+ * type `V`.
20
+ */
21
+ constructor(key: K, value: V[]);
22
+ parent?: TreeMultiMapNode<K, V>;
23
+ _left?: OptNodeOrNull<TreeMultiMapNode<K, V>>;
24
+ get left(): OptNodeOrNull<TreeMultiMapNode<K, V>>;
25
+ set left(v: OptNodeOrNull<TreeMultiMapNode<K, V>>);
26
+ _right?: OptNodeOrNull<TreeMultiMapNode<K, V>>;
27
+ get right(): OptNodeOrNull<TreeMultiMapNode<K, V>>;
28
+ set right(v: OptNodeOrNull<TreeMultiMapNode<K, V>>);
37
29
  }
38
- export declare class TreeMultiMap<K = any, V = any, R = object, NODE extends TreeMultiMapNode<K, V, NODE> = TreeMultiMapNode<K, V, TreeMultiMapNodeNested<K, V>>, TREE extends TreeMultiMap<K, V, R, NODE, TREE> = TreeMultiMap<K, V, R, NODE, TreeMultiMapNested<K, V, R, NODE>>> extends RedBlackTree<K, V, R, NODE, TREE> implements IBinaryTree<K, V, R, NODE, TREE> {
39
- /**
40
- * The constructor function initializes a TreeMultiMap object with optional initial data.
41
- * @param keysNodesEntriesOrRaws - The parameter `keysNodesEntriesOrRaws` is an
42
- * iterable that can contain keys, nodes, entries, or raw elements. It is used to initialize the
43
- * TreeMultiMap with initial data.
44
- * @param [options] - The `options` parameter is an optional object that can be used to customize the
45
- * behavior of the `TreeMultiMap` constructor. It can include properties such as `compareKeys` and
46
- * `compareValues`, which are functions used to compare keys and values respectively.
47
- */
48
- constructor(keysNodesEntriesOrRaws?: Iterable<BTNRep<K, V, NODE>>, options?: TreeMultiMapOptions<K, V, R>);
49
- protected _count: number;
50
- /**
51
- * The function calculates the sum of the count property of all nodes in a tree structure.
52
- * @returns the sum of the count property of all nodes in the tree.
53
- */
54
- get count(): number;
55
- /**
56
- * Time Complexity: O(n)
57
- * Space Complexity: O(1)
58
- *
59
- * The function calculates the sum of the count property of all nodes in a tree using depth-first
60
- * search.
61
- * @returns the sum of the count property of all nodes in the tree.
62
- */
63
- getComputedCount(): number;
64
- /**
65
- * The function creates a new TreeMultiMapNode with the specified key, value, color, and count.
66
- * @param {K} key - The key parameter represents the key of the node being created. It is of type K,
67
- * which is a generic type representing the type of keys in the tree.
68
- * @param {V} [value] - The `value` parameter is an optional parameter that represents the value
69
- * associated with the key in the node. It is of type `V`, which can be any data type.
70
- * @param {RBTNColor} [color=BLACK] - The color parameter is used to specify the color of the node in
71
- * a Red-Black Tree. It can have two possible values: 'RED' or 'BLACK'. The default value is 'BLACK'.
72
- * @param {number} [count] - The `count` parameter represents the number of occurrences of a key in
73
- * the tree. It is an optional parameter and is used to keep track of the number of values associated
74
- * with a key in the tree.
75
- * @returns A new instance of the TreeMultiMapNode class, casted as NODE.
76
- */
77
- createNode(key: K, value?: V, color?: RBTNColor, count?: number): NODE;
78
- /**
79
- * The function creates a new instance of a TreeMultiMap with the specified options and returns it.
80
- * @param [options] - The `options` parameter is an optional object that contains additional
81
- * configuration options for creating the `TreeMultiMap`. It is of type `TreeMultiMapOptions<K, V,
82
- * R>`.
83
- * @returns a new instance of the `TreeMultiMap` class, with the provided options merged with the
84
- * existing `iterationType` property. The returned value is casted as `TREE`.
85
- */
86
- createTree(options?: TreeMultiMapOptions<K, V, R>): TREE;
87
- /**
88
- * The function `keyValueNodeEntryRawToNodeAndValue` takes in a key, value, and count and returns a
89
- * node based on the input.
90
- * @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - The parameter
91
- * `keyNodeEntryOrRaw` can be of type `R` or `BTNRep<K, V, NODE>`.
92
- * @param {V} [value] - The `value` parameter is an optional value that represents the value
93
- * associated with the key in the node. It is used when creating a new node or updating the value of
94
- * an existing node.
95
- * @param [count=1] - The `count` parameter is an optional parameter that specifies the number of
96
- * times the key-value pair should be added to the data structure. If not provided, it defaults to 1.
97
- * @returns either a NODE object or undefined.
98
- */
99
- keyValueNodeEntryRawToNodeAndValue(keyNodeEntryOrRaw: BTNRep<K, V, NODE> | R, value?: V, count?: number): [NODE | undefined, V | undefined];
100
- /**
101
- * The function checks if the input is an instance of the TreeMultiMapNode class.
102
- * @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - The parameter
103
- * `keyNodeEntryOrRaw` can be of type `R` or `BTNRep<K, V, NODE>`.
104
- * @returns a boolean value indicating whether the input parameter `keyNodeEntryOrRaw` is
105
- * an instance of the `TreeMultiMapNode` class.
106
- */
107
- isNode(keyNodeEntryOrRaw: BTNRep<K, V, NODE> | R): keyNodeEntryOrRaw is NODE;
30
+ /**
31
+ *
32
+ * @example
33
+ * // Find elements in a range
34
+ * const tmm = new TreeMultiMap<number>([10, 5, 15, 3, 7, 12, 18]);
35
+ * console.log(tmm.search(new Range(5, 10))); // [5, 10, 7]
36
+ * console.log(tmm.search(new Range(4, 12))); // [5, 10, 12, 7]
37
+ * console.log(tmm.search(new Range(15, 20))); // [15, 18]
38
+ */
39
+ export declare class TreeMultiMap<K = any, V = any, R = object, MK = any, MV = any, MR = object> extends RedBlackTree<K, V[], R, MK, MV[], MR> implements IBinaryTree<K, V[], R, MK, MV, MR> {
108
40
  /**
109
- * Time Complexity: O(log n)
110
- * Space Complexity: O(1)
111
- *
112
- * The function overrides the add method of a class and adds a new node to a data structure, updating
113
- * the count and returning a boolean indicating success.
114
- * @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - The
115
- * `keyNodeEntryOrRaw` parameter can accept one of the following types:
116
- * @param {V} [value] - The `value` parameter represents the value associated with the key in the
117
- * data structure. It is an optional parameter, so it can be omitted if not needed.
118
- * @param [count=1] - The `count` parameter represents the number of times the key-value pair should
119
- * be added to the data structure. By default, it is set to 1, meaning that if no value is provided
120
- * for `count`, the key-value pair will be added once.
121
- * @returns The method is returning a boolean value. It returns true if the addition of the new node
122
- * was successful, and false otherwise.
41
+ * The constructor initializes an TreeMultiMap with the provided keys, nodes, entries, or raw data
42
+ * and options.
43
+ * @param keysNodesEntriesOrRaws - The `keysNodesEntriesOrRaws` parameter in the constructor is an
44
+ * iterable that can contain either key-value pairs represented as `BTNRep<K, V[],
45
+ * TreeMultiMapNode<K, V>>` or raw data represented as `R`. This parameter is used to initialize
46
+ * the RedBlackTreeMulti
47
+ * @param [options] - The `options` parameter in the constructor is of type
48
+ * `TreeMultiMapOptions<K, V[], R>`. It is an optional parameter that allows you to specify
49
+ * additional options for configuring the TreeMultiMap instance.
123
50
  */
124
- add(keyNodeEntryOrRaw: BTNRep<K, V, NODE> | R, value?: V, count?: number): boolean;
51
+ constructor(keysNodesEntriesOrRaws?: Iterable<BTNRep<K, V[], TreeMultiMapNode<K, V>> | R>, options?: TreeMultiMapOptions<K, V[], R>);
125
52
  /**
126
- * Time Complexity: O(log n)
53
+ * Time Complexity: O(1)
127
54
  * Space Complexity: O(1)
128
55
  *
129
- * The function `delete` in TypeScript overrides the deletion operation in a binary tree data
130
- * structure, handling cases where nodes have children and maintaining balance in the tree.
131
- * @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - The `predicate`
132
- * parameter in the `delete` method is used to specify the condition or key based on which a node
133
- * should be deleted from the binary tree. It can be a key, a node, or an entry.
134
- * @param [ignoreCount=false] - The `ignoreCount` parameter in the `override delete` method is a
135
- * boolean flag that determines whether to ignore the count of nodes when performing deletion. If
136
- * `ignoreCount` is set to `true`, the method will delete the node regardless of its count. If
137
- * `ignoreCount` is `false
138
- * @returns The `override delete` method returns an array of `BinaryTreeDeleteResult<NODE>` objects.
56
+ * The `createTree` function in TypeScript overrides the default implementation to create a new
57
+ * TreeMultiMap with specified options.
58
+ * @param [options] - The `options` parameter in the `createTree` method is of type
59
+ * `TreeMultiMapOptions<K, V[], R>`. This parameter allows you to pass additional configuration
60
+ * options when creating a new `TreeMultiMap` instance. It includes properties such as
61
+ * `iterationType`, `specifyComparable
62
+ * @returns A new instance of `TreeMultiMap` is being returned, with an empty array as the initial
63
+ * data and the provided options merged with the existing properties of the current object.
139
64
  */
140
- delete(keyNodeEntryOrRaw: BTNRep<K, V, NODE> | R, ignoreCount?: boolean): BinaryTreeDeleteResult<NODE>[];
65
+ createTree(options?: TreeMultiMapOptions<K, V[], R>): TreeMultiMap<K, V, R, MK, MV, MR>;
141
66
  /**
142
67
  * Time Complexity: O(1)
143
68
  * Space Complexity: O(1)
144
69
  *
145
- * The "clear" function overrides the parent class's "clear" function and also resets the count to
146
- * zero.
70
+ * The function `createNode` overrides the method to create a new `TreeMultiMapNode` with a specified
71
+ * key and an empty array of values.
72
+ * @param {K} key - The `key` parameter in the `createNode` method represents the key of the node
73
+ * that will be created in the TreeMultiMap data structure.
74
+ * @returns A new instance of `TreeMultiMapNode<K, V>` is being returned, with the specified key and
75
+ * an empty array as its value.
147
76
  */
148
- clear(): void;
77
+ createNode(key: K): TreeMultiMapNode<K, V>;
78
+ add(node: BTNRep<K, V[], TreeMultiMapNode<K, V>>): boolean;
79
+ add(key: K, value: V): boolean;
149
80
  /**
150
- * Time Complexity: O(n log n)
81
+ * Time Complexity: O(log n)
151
82
  * Space Complexity: O(log n)
152
83
  *
153
- * The `perfectlyBalance` function takes a sorted array of nodes and builds a balanced binary search
154
- * tree using either a recursive or iterative approach.
155
- * @param {IterationType} iterationType - The `iterationType` parameter is an optional parameter that
156
- * specifies the type of iteration to use when building the balanced binary search tree. It has a
157
- * default value of `this.iterationType`, which means it will use the iteration type specified by the
158
- * `iterationType` property of the current object.
159
- * @returns The function `perfectlyBalance` returns a boolean value. It returns `true` if the
160
- * balancing operation is successful, and `false` if there are no nodes to balance.
161
- */
162
- perfectlyBalance(iterationType?: IterationType): boolean;
163
- /**
164
- * Time complexity: O(n)
165
- * Space complexity: O(n)
166
- *
167
- * The function overrides the clone method to create a deep copy of a tree object.
168
- * @returns The `clone()` method is returning a cloned instance of the `TREE` object.
169
- */
170
- clone(): TREE;
84
+ * The function `deleteValue` removes a specific value from a key in a TreeMultiMap data structure
85
+ * and deletes the entire node if no values are left for that key.
86
+ * @param {BTNRep<K, V[], TreeMultiMapNode<K, V>> | K} keyNodeOrEntry - The `keyNodeOrEntry`
87
+ * parameter in the `deleteValue` function can be either a `BTNRep` object containing a key and an
88
+ * array of values, or just a key itself.
89
+ * @param {V} value - The `value` parameter in the `deleteValue` function represents the specific
90
+ * value that you want to remove from the multi-map data structure associated with a particular key.
91
+ * The function checks if the value exists in the array of values associated with the key, and if
92
+ * found, removes it from the array.
93
+ * @returns The `deleteValue` function returns a boolean value - `true` if the specified `value` was
94
+ * successfully deleted from the values associated with the `keyNodeOrEntry`, and `false` otherwise.
95
+ */
96
+ deleteValue(keyNodeOrEntry: BTNRep<K, V[], TreeMultiMapNode<K, V>> | K, value: V): boolean;
171
97
  /**
172
- * Time Complexity: O(1)
173
- * Space Complexity: O(1)
174
- *
175
- * The `_swapProperties` function swaps the properties (key, value, count, color) between two nodes
176
- * in a binary search tree.
177
- * @param {R | BSTNOptKeyOrNode<K, NODE>} srcNode - The `srcNode` parameter represents the source node
178
- * that will be swapped with the `destNode`. It can be either an instance of the `R` class or an
179
- * instance of the `BSTNOptKeyOrNode<K, NODE>` class.
180
- * @param {R | BSTNOptKeyOrNode<K, NODE>} destNode - The `destNode` parameter represents the destination
181
- * node where the properties will be swapped with the source node.
182
- * @returns The method is returning the `destNode` after swapping its properties with the `srcNode`.
183
- * If either `srcNode` or `destNode` is undefined, it returns undefined.
184
- */
185
- protected _swapProperties(srcNode: R | BSTNOptKeyOrNode<K, NODE>, destNode: R | BSTNOptKeyOrNode<K, NODE>): NODE | undefined;
186
- /**
187
- * Time Complexity: O(1)
188
- * Space Complexity: O(1)
98
+ * Time Complexity: O(n)
99
+ * Space Complexity: O(n)
189
100
  *
190
- * The function replaces an old node with a new node and updates the count property of the new node.
191
- * @param {NODE} oldNode - The `oldNode` parameter is the node that you want to replace in the data
101
+ * The function `clone` overrides the default cloning behavior to create a deep copy of a tree
192
102
  * structure.
193
- * @param {NODE} newNode - The `newNode` parameter is an instance of the `NODE` class.
194
- * @returns The method is returning the result of calling the `_replaceNode` method from the
195
- * superclass, which is of type `NODE`.
103
+ * @returns The `cloned` object is being returned.
196
104
  */
197
- protected _replaceNode(oldNode: NODE, newNode: NODE): NODE;
105
+ clone(): TreeMultiMap<K, V, R, MK, MV, MR>;
198
106
  }