data-structure-typed 1.51.8 → 1.52.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (216) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/README.md +13 -13
  3. package/benchmark/report.html +13 -13
  4. package/benchmark/report.json +152 -152
  5. package/dist/cjs/data-structures/base/index.d.ts +2 -1
  6. package/dist/cjs/data-structures/base/index.js +2 -1
  7. package/dist/cjs/data-structures/base/index.js.map +1 -1
  8. package/dist/cjs/data-structures/base/iterable-element-base.d.ts +171 -0
  9. package/dist/cjs/data-structures/base/iterable-element-base.js +226 -0
  10. package/dist/cjs/data-structures/base/iterable-element-base.js.map +1 -0
  11. package/dist/cjs/data-structures/base/{iterable-base.d.ts → iterable-entry-base.d.ts} +4 -147
  12. package/dist/cjs/data-structures/base/{iterable-base.js → iterable-entry-base.js} +13 -190
  13. package/dist/cjs/data-structures/base/iterable-entry-base.js.map +1 -0
  14. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.d.ts +106 -68
  15. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js +119 -87
  16. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js.map +1 -1
  17. package/dist/cjs/data-structures/binary-tree/avl-tree.d.ts +82 -62
  18. package/dist/cjs/data-structures/binary-tree/avl-tree.js +78 -59
  19. package/dist/cjs/data-structures/binary-tree/avl-tree.js.map +1 -1
  20. package/dist/cjs/data-structures/binary-tree/binary-tree.d.ts +318 -226
  21. package/dist/cjs/data-structures/binary-tree/binary-tree.js +475 -363
  22. package/dist/cjs/data-structures/binary-tree/binary-tree.js.map +1 -1
  23. package/dist/cjs/data-structures/binary-tree/bst.d.ts +192 -202
  24. package/dist/cjs/data-structures/binary-tree/bst.js +207 -249
  25. package/dist/cjs/data-structures/binary-tree/bst.js.map +1 -1
  26. package/dist/cjs/data-structures/binary-tree/rb-tree.d.ts +73 -74
  27. package/dist/cjs/data-structures/binary-tree/rb-tree.js +107 -98
  28. package/dist/cjs/data-structures/binary-tree/rb-tree.js.map +1 -1
  29. package/dist/cjs/data-structures/binary-tree/tree-multi-map.d.ts +92 -75
  30. package/dist/cjs/data-structures/binary-tree/tree-multi-map.js +105 -93
  31. package/dist/cjs/data-structures/binary-tree/tree-multi-map.js.map +1 -1
  32. package/dist/cjs/data-structures/graph/abstract-graph.d.ts +10 -15
  33. package/dist/cjs/data-structures/graph/abstract-graph.js +10 -15
  34. package/dist/cjs/data-structures/graph/abstract-graph.js.map +1 -1
  35. package/dist/cjs/data-structures/hash/hash-map.d.ts +33 -40
  36. package/dist/cjs/data-structures/hash/hash-map.js +40 -55
  37. package/dist/cjs/data-structures/hash/hash-map.js.map +1 -1
  38. package/dist/cjs/data-structures/heap/heap.d.ts +43 -114
  39. package/dist/cjs/data-structures/heap/heap.js +59 -127
  40. package/dist/cjs/data-structures/heap/heap.js.map +1 -1
  41. package/dist/cjs/data-structures/heap/max-heap.d.ts +50 -4
  42. package/dist/cjs/data-structures/heap/max-heap.js +76 -10
  43. package/dist/cjs/data-structures/heap/max-heap.js.map +1 -1
  44. package/dist/cjs/data-structures/heap/min-heap.d.ts +51 -5
  45. package/dist/cjs/data-structures/heap/min-heap.js +68 -11
  46. package/dist/cjs/data-structures/heap/min-heap.js.map +1 -1
  47. package/dist/cjs/data-structures/linked-list/doubly-linked-list.d.ts +22 -28
  48. package/dist/cjs/data-structures/linked-list/doubly-linked-list.js +26 -28
  49. package/dist/cjs/data-structures/linked-list/doubly-linked-list.js.map +1 -1
  50. package/dist/cjs/data-structures/linked-list/singly-linked-list.d.ts +22 -25
  51. package/dist/cjs/data-structures/linked-list/singly-linked-list.js +29 -26
  52. package/dist/cjs/data-structures/linked-list/singly-linked-list.js.map +1 -1
  53. package/dist/cjs/data-structures/priority-queue/max-priority-queue.d.ts +50 -4
  54. package/dist/cjs/data-structures/priority-queue/max-priority-queue.js +79 -10
  55. package/dist/cjs/data-structures/priority-queue/max-priority-queue.js.map +1 -1
  56. package/dist/cjs/data-structures/priority-queue/min-priority-queue.d.ts +51 -5
  57. package/dist/cjs/data-structures/priority-queue/min-priority-queue.js +71 -11
  58. package/dist/cjs/data-structures/priority-queue/min-priority-queue.js.map +1 -1
  59. package/dist/cjs/data-structures/priority-queue/priority-queue.d.ts +50 -4
  60. package/dist/cjs/data-structures/priority-queue/priority-queue.js +70 -1
  61. package/dist/cjs/data-structures/priority-queue/priority-queue.js.map +1 -1
  62. package/dist/cjs/data-structures/queue/deque.d.ts +21 -20
  63. package/dist/cjs/data-structures/queue/deque.js +29 -23
  64. package/dist/cjs/data-structures/queue/deque.js.map +1 -1
  65. package/dist/cjs/data-structures/queue/queue.d.ts +8 -28
  66. package/dist/cjs/data-structures/queue/queue.js +15 -31
  67. package/dist/cjs/data-structures/queue/queue.js.map +1 -1
  68. package/dist/cjs/data-structures/stack/stack.d.ts +17 -22
  69. package/dist/cjs/data-structures/stack/stack.js +25 -24
  70. package/dist/cjs/data-structures/stack/stack.js.map +1 -1
  71. package/dist/cjs/data-structures/trie/trie.d.ts +19 -14
  72. package/dist/cjs/data-structures/trie/trie.js +27 -16
  73. package/dist/cjs/data-structures/trie/trie.js.map +1 -1
  74. package/dist/cjs/interfaces/binary-tree.d.ts +7 -7
  75. package/dist/cjs/types/common.d.ts +1 -2
  76. package/dist/cjs/types/data-structures/base/base.d.ts +5 -2
  77. package/dist/cjs/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +3 -4
  78. package/dist/cjs/types/data-structures/binary-tree/avl-tree.d.ts +3 -4
  79. package/dist/cjs/types/data-structures/binary-tree/binary-tree.d.ts +5 -5
  80. package/dist/cjs/types/data-structures/binary-tree/bst.d.ts +4 -5
  81. package/dist/cjs/types/data-structures/binary-tree/rb-tree.d.ts +3 -4
  82. package/dist/cjs/types/data-structures/binary-tree/tree-multi-map.d.ts +3 -4
  83. package/dist/cjs/types/data-structures/heap/heap.d.ts +3 -2
  84. package/dist/cjs/types/data-structures/linked-list/doubly-linked-list.d.ts +2 -1
  85. package/dist/cjs/types/data-structures/linked-list/singly-linked-list.d.ts +2 -1
  86. package/dist/cjs/types/data-structures/priority-queue/priority-queue.d.ts +1 -1
  87. package/dist/cjs/types/data-structures/queue/deque.d.ts +3 -2
  88. package/dist/cjs/types/data-structures/queue/queue.d.ts +2 -1
  89. package/dist/cjs/types/data-structures/stack/stack.d.ts +2 -1
  90. package/dist/cjs/types/data-structures/trie/trie.d.ts +3 -2
  91. package/dist/cjs/utils/utils.js +3 -5
  92. package/dist/cjs/utils/utils.js.map +1 -1
  93. package/dist/mjs/data-structures/base/index.d.ts +2 -1
  94. package/dist/mjs/data-structures/base/index.js +2 -1
  95. package/dist/mjs/data-structures/base/iterable-element-base.d.ts +171 -0
  96. package/dist/mjs/data-structures/base/iterable-element-base.js +222 -0
  97. package/dist/mjs/data-structures/base/{iterable-base.d.ts → iterable-entry-base.d.ts} +4 -147
  98. package/dist/mjs/data-structures/base/{iterable-base.js → iterable-entry-base.js} +10 -186
  99. package/dist/mjs/data-structures/binary-tree/avl-tree-multi-map.d.ts +106 -68
  100. package/dist/mjs/data-structures/binary-tree/avl-tree-multi-map.js +119 -87
  101. package/dist/mjs/data-structures/binary-tree/avl-tree.d.ts +82 -62
  102. package/dist/mjs/data-structures/binary-tree/avl-tree.js +78 -59
  103. package/dist/mjs/data-structures/binary-tree/binary-tree.d.ts +318 -226
  104. package/dist/mjs/data-structures/binary-tree/binary-tree.js +476 -364
  105. package/dist/mjs/data-structures/binary-tree/bst.d.ts +192 -202
  106. package/dist/mjs/data-structures/binary-tree/bst.js +211 -255
  107. package/dist/mjs/data-structures/binary-tree/rb-tree.d.ts +73 -74
  108. package/dist/mjs/data-structures/binary-tree/rb-tree.js +107 -98
  109. package/dist/mjs/data-structures/binary-tree/tree-multi-map.d.ts +92 -75
  110. package/dist/mjs/data-structures/binary-tree/tree-multi-map.js +105 -93
  111. package/dist/mjs/data-structures/graph/abstract-graph.d.ts +10 -15
  112. package/dist/mjs/data-structures/graph/abstract-graph.js +10 -15
  113. package/dist/mjs/data-structures/hash/hash-map.d.ts +33 -40
  114. package/dist/mjs/data-structures/hash/hash-map.js +41 -55
  115. package/dist/mjs/data-structures/heap/heap.d.ts +43 -114
  116. package/dist/mjs/data-structures/heap/heap.js +60 -128
  117. package/dist/mjs/data-structures/heap/max-heap.d.ts +50 -4
  118. package/dist/mjs/data-structures/heap/max-heap.js +79 -10
  119. package/dist/mjs/data-structures/heap/min-heap.d.ts +51 -5
  120. package/dist/mjs/data-structures/heap/min-heap.js +68 -11
  121. package/dist/mjs/data-structures/linked-list/doubly-linked-list.d.ts +22 -28
  122. package/dist/mjs/data-structures/linked-list/doubly-linked-list.js +26 -28
  123. package/dist/mjs/data-structures/linked-list/singly-linked-list.d.ts +22 -25
  124. package/dist/mjs/data-structures/linked-list/singly-linked-list.js +29 -26
  125. package/dist/mjs/data-structures/priority-queue/max-priority-queue.d.ts +50 -4
  126. package/dist/mjs/data-structures/priority-queue/max-priority-queue.js +82 -10
  127. package/dist/mjs/data-structures/priority-queue/min-priority-queue.d.ts +51 -5
  128. package/dist/mjs/data-structures/priority-queue/min-priority-queue.js +71 -11
  129. package/dist/mjs/data-structures/priority-queue/priority-queue.d.ts +50 -4
  130. package/dist/mjs/data-structures/priority-queue/priority-queue.js +70 -1
  131. package/dist/mjs/data-structures/queue/deque.d.ts +21 -20
  132. package/dist/mjs/data-structures/queue/deque.js +29 -23
  133. package/dist/mjs/data-structures/queue/queue.d.ts +8 -28
  134. package/dist/mjs/data-structures/queue/queue.js +15 -31
  135. package/dist/mjs/data-structures/stack/stack.d.ts +17 -22
  136. package/dist/mjs/data-structures/stack/stack.js +25 -24
  137. package/dist/mjs/data-structures/trie/trie.d.ts +19 -14
  138. package/dist/mjs/data-structures/trie/trie.js +27 -16
  139. package/dist/mjs/interfaces/binary-tree.d.ts +7 -7
  140. package/dist/mjs/types/common.d.ts +1 -2
  141. package/dist/mjs/types/data-structures/base/base.d.ts +5 -2
  142. package/dist/mjs/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +3 -4
  143. package/dist/mjs/types/data-structures/binary-tree/avl-tree.d.ts +3 -4
  144. package/dist/mjs/types/data-structures/binary-tree/binary-tree.d.ts +5 -5
  145. package/dist/mjs/types/data-structures/binary-tree/bst.d.ts +4 -5
  146. package/dist/mjs/types/data-structures/binary-tree/rb-tree.d.ts +3 -4
  147. package/dist/mjs/types/data-structures/binary-tree/tree-multi-map.d.ts +3 -4
  148. package/dist/mjs/types/data-structures/heap/heap.d.ts +3 -2
  149. package/dist/mjs/types/data-structures/linked-list/doubly-linked-list.d.ts +2 -1
  150. package/dist/mjs/types/data-structures/linked-list/singly-linked-list.d.ts +2 -1
  151. package/dist/mjs/types/data-structures/priority-queue/priority-queue.d.ts +1 -1
  152. package/dist/mjs/types/data-structures/queue/deque.d.ts +3 -2
  153. package/dist/mjs/types/data-structures/queue/queue.d.ts +2 -1
  154. package/dist/mjs/types/data-structures/stack/stack.d.ts +2 -1
  155. package/dist/mjs/types/data-structures/trie/trie.d.ts +3 -2
  156. package/dist/mjs/utils/utils.js +3 -5
  157. package/dist/umd/data-structure-typed.js +1949 -1481
  158. package/dist/umd/data-structure-typed.min.js +2 -2
  159. package/dist/umd/data-structure-typed.min.js.map +1 -1
  160. package/package.json +6 -6
  161. package/src/data-structures/base/index.ts +2 -1
  162. package/src/data-structures/base/iterable-element-base.ts +250 -0
  163. package/src/data-structures/base/{iterable-base.ts → iterable-entry-base.ts} +22 -213
  164. package/src/data-structures/binary-tree/avl-tree-multi-map.ts +144 -95
  165. package/src/data-structures/binary-tree/avl-tree.ts +96 -69
  166. package/src/data-structures/binary-tree/binary-tree.ts +535 -403
  167. package/src/data-structures/binary-tree/bst.ts +247 -277
  168. package/src/data-structures/binary-tree/rb-tree.ts +123 -103
  169. package/src/data-structures/binary-tree/tree-multi-map.ts +127 -102
  170. package/src/data-structures/graph/abstract-graph.ts +10 -10
  171. package/src/data-structures/hash/hash-map.ts +46 -53
  172. package/src/data-structures/heap/heap.ts +71 -152
  173. package/src/data-structures/heap/max-heap.ts +88 -13
  174. package/src/data-structures/heap/min-heap.ts +78 -15
  175. package/src/data-structures/linked-list/doubly-linked-list.ts +32 -32
  176. package/src/data-structures/linked-list/singly-linked-list.ts +37 -29
  177. package/src/data-structures/priority-queue/max-priority-queue.ts +94 -13
  178. package/src/data-structures/priority-queue/min-priority-queue.ts +84 -15
  179. package/src/data-structures/priority-queue/priority-queue.ts +81 -4
  180. package/src/data-structures/queue/deque.ts +37 -26
  181. package/src/data-structures/queue/queue.ts +23 -36
  182. package/src/data-structures/stack/stack.ts +31 -26
  183. package/src/data-structures/trie/trie.ts +35 -20
  184. package/src/interfaces/binary-tree.ts +9 -9
  185. package/src/types/common.ts +1 -2
  186. package/src/types/data-structures/base/base.ts +14 -6
  187. package/src/types/data-structures/binary-tree/avl-tree-multi-map.ts +3 -4
  188. package/src/types/data-structures/binary-tree/avl-tree.ts +3 -4
  189. package/src/types/data-structures/binary-tree/binary-tree.ts +6 -6
  190. package/src/types/data-structures/binary-tree/bst.ts +4 -5
  191. package/src/types/data-structures/binary-tree/rb-tree.ts +3 -4
  192. package/src/types/data-structures/binary-tree/tree-multi-map.ts +3 -4
  193. package/src/types/data-structures/heap/heap.ts +4 -1
  194. package/src/types/data-structures/linked-list/doubly-linked-list.ts +3 -1
  195. package/src/types/data-structures/linked-list/singly-linked-list.ts +3 -1
  196. package/src/types/data-structures/priority-queue/priority-queue.ts +1 -1
  197. package/src/types/data-structures/queue/deque.ts +3 -1
  198. package/src/types/data-structures/queue/queue.ts +3 -1
  199. package/src/types/data-structures/stack/stack.ts +3 -1
  200. package/src/types/data-structures/trie/trie.ts +3 -1
  201. package/src/utils/utils.ts +3 -3
  202. package/test/integration/avl-tree.test.ts +2 -2
  203. package/test/integration/bst.test.ts +3 -3
  204. package/test/integration/index.html +25 -11
  205. package/test/unit/data-structures/binary-tree/avl-tree-multi-map.test.ts +68 -0
  206. package/test/unit/data-structures/binary-tree/binary-tree.test.ts +56 -0
  207. package/test/unit/data-structures/graph/directed-graph.test.ts +2 -2
  208. package/test/unit/data-structures/heap/heap.test.ts +80 -0
  209. package/test/unit/data-structures/heap/max-heap.test.ts +44 -1
  210. package/test/unit/data-structures/heap/min-heap.test.ts +18 -1
  211. package/test/unit/data-structures/priority-queue/max-priority-queue.test.ts +42 -0
  212. package/test/unit/data-structures/queue/deque.test.ts +30 -0
  213. package/test/unit/data-structures/queue/queue.test.ts +56 -0
  214. package/test/utils/big-o.ts +12 -6
  215. package/tsconfig-base.json +1 -0
  216. package/dist/cjs/data-structures/base/iterable-base.js.map +0 -1
@@ -5,10 +5,11 @@
5
5
  * @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
6
6
  * @license MIT License
7
7
  */
8
- import type { BinaryTreeDeleteResult, BSTNKeyOrNode, BTNCallback, Comparable, IterationType, KeyOrNodeOrEntry, RBTNColor, TreeMultiMapNested, TreeMultiMapNodeNested, TreeMultiMapOptions } from '../../types';
8
+ import type { BinaryTreeDeleteResult, BSTNKeyOrNode, BTNCallback, IterationType, KeyOrNodeOrEntry, RBTNColor, TreeMultiMapNested, TreeMultiMapNodeNested, TreeMultiMapOptions } from '../../types';
9
+ import { BTNEntry } from '../../types';
9
10
  import { IBinaryTree } from '../../interfaces';
10
11
  import { RedBlackTree, RedBlackTreeNode } from './rb-tree';
11
- export declare class TreeMultiMapNode<K extends Comparable, V = any, NODE extends TreeMultiMapNode<K, V, NODE> = TreeMultiMapNodeNested<K, V>> extends RedBlackTreeNode<K, V, NODE> {
12
+ export declare class TreeMultiMapNode<K = any, V = any, NODE extends TreeMultiMapNode<K, V, NODE> = TreeMultiMapNodeNested<K, V>> extends RedBlackTreeNode<K, V, NODE> {
12
13
  /**
13
14
  * The constructor function initializes a Red-Black Tree node with a key, value, count, and color.
14
15
  * @param {K} key - The key parameter represents the key of the node in the Red-Black Tree. It is
@@ -35,17 +36,17 @@ export declare class TreeMultiMapNode<K extends Comparable, V = any, NODE extend
35
36
  */
36
37
  set count(value: number);
37
38
  }
38
- export declare class TreeMultiMap<K extends Comparable, 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> {
39
+ export declare class TreeMultiMap<K = any, V = any, R = BTNEntry<K, V>, 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
  /**
40
- * The constructor function initializes a new instance of the TreeMultiMap class with optional
41
- * initial keys, nodes, or entries.
42
- * @param keysOrNodesOrEntries - The `keysOrNodesOrEntries` parameter is an iterable object that can
43
- * contain keys, nodes, or entries. It is used to initialize the TreeMultiMap with the provided keys,
44
- * nodes, or entries.
45
- * @param [options] - The `options` parameter is an optional object that can be passed to the
46
- * constructor. It allows you to customize the behavior of the `TreeMultiMap` instance.
41
+ * The constructor function initializes a TreeMultiMap object with optional initial data.
42
+ * @param keysOrNodesOrEntriesOrRawElements - The parameter `keysOrNodesOrEntriesOrRawElements` is an
43
+ * iterable that can contain keys, nodes, entries, or raw elements. It is used to initialize the
44
+ * TreeMultiMap with initial data.
45
+ * @param [options] - The `options` parameter is an optional object that can be used to customize the
46
+ * behavior of the `TreeMultiMap` constructor. It can include properties such as `compareKeys` and
47
+ * `compareValues`, which are functions used to compare keys and values respectively.
47
48
  */
48
- constructor(keysOrNodesOrEntries?: Iterable<KeyOrNodeOrEntry<K, V, NODE>>, options?: TreeMultiMapOptions<K>);
49
+ constructor(keysOrNodesOrEntriesOrRawElements?: Iterable<KeyOrNodeOrEntry<K, V, NODE>>, options?: TreeMultiMapOptions<K, V, R>);
49
50
  protected _count: number;
50
51
  /**
51
52
  * The function calculates the sum of the count property of all nodes in a tree structure.
@@ -68,48 +69,47 @@ export declare class TreeMultiMap<K extends Comparable, V = any, NODE extends Tr
68
69
  /**
69
70
  * The function creates a new TreeMultiMapNode with the specified key, value, color, and count.
70
71
  * @param {K} key - The key parameter represents the key of the node being created. It is of type K,
71
- * which is a generic type representing the key type of the node.
72
- * @param {V} [value] - The `value` parameter represents the value associated with the key in the
73
- * node. It is an optional parameter, which means it can be omitted when calling the `createNode`
74
- * function. If provided, it should be of type `V`.
72
+ * which is a generic type representing the type of keys in the tree.
73
+ * @param {V} [value] - The `value` parameter is an optional parameter that represents the value
74
+ * associated with the key in the node. It is of type `V`, which can be any data type.
75
75
  * @param {RBTNColor} [color=BLACK] - The color parameter is used to specify the color of the node in
76
76
  * a Red-Black Tree. It can have two possible values: 'RED' or 'BLACK'. The default value is 'BLACK'.
77
77
  * @param {number} [count] - The `count` parameter represents the number of occurrences of a key in
78
78
  * the tree. It is an optional parameter and is used to keep track of the number of values associated
79
79
  * with a key in the tree.
80
- * @returns A new instance of the TreeMultiMapNode class is being returned.
80
+ * @returns A new instance of the TreeMultiMapNode class, casted as NODE.
81
81
  */
82
82
  createNode(key: K, value?: V, color?: RBTNColor, count?: number): NODE;
83
83
  /**
84
84
  * The function creates a new instance of a TreeMultiMap with the specified options and returns it.
85
85
  * @param [options] - The `options` parameter is an optional object that contains additional
86
- * configuration options for creating the `TreeMultiMap`. It can include properties such as
87
- * `keyComparator`, `valueComparator`, `allowDuplicates`, etc.
86
+ * configuration options for creating the `TreeMultiMap`. It is of type `TreeMultiMapOptions<K, V,
87
+ * R>`.
88
88
  * @returns a new instance of the `TreeMultiMap` class, with the provided options merged with the
89
- * existing `iterationType` option. The returned value is casted as `TREE`.
89
+ * existing `iterationType` property. The returned value is casted as `TREE`.
90
90
  */
91
- createTree(options?: TreeMultiMapOptions<K>): TREE;
91
+ createTree(options?: TreeMultiMapOptions<K, V, R>): TREE;
92
92
  /**
93
- * The function `keyValueOrEntryToNode` takes a key, value, and count and returns a node if the input
94
- * is valid.
95
- * @param keyOrNodeOrEntry - The parameter `keyOrNodeOrEntry` can be of type `KeyOrNodeOrEntry<K, V,
96
- * NODE>`. It can accept three types of values:
97
- * @param {V} [value] - The `value` parameter is an optional value of type `V`. It represents the
98
- * value associated with a key in a key-value pair.
99
- * @param [count=1] - The count parameter is an optional parameter that specifies the number of times
100
- * the key-value pair should be added to the node. If not provided, it defaults to 1.
101
- * @returns a NODE object or undefined.
93
+ * The function `keyValueOrEntryOrRawElementToNode` takes in a key, value, and count and returns a
94
+ * node based on the input.
95
+ * @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter
96
+ * `keyOrNodeOrEntryOrRawElement` can be of type `R` or `KeyOrNodeOrEntry<K, V, NODE>`.
97
+ * @param {V} [value] - The `value` parameter is an optional value that represents the value
98
+ * associated with the key in the node. It is used when creating a new node or updating the value of
99
+ * an existing node.
100
+ * @param [count=1] - The `count` parameter is an optional parameter that specifies the number of
101
+ * times the key-value pair should be added to the data structure. If not provided, it defaults to 1.
102
+ * @returns either a NODE object or undefined.
102
103
  */
103
- keyValueOrEntryToNode(keyOrNodeOrEntry: KeyOrNodeOrEntry<K, V, NODE>, value?: V, count?: number): NODE | undefined;
104
+ keyValueOrEntryOrRawElementToNode(keyOrNodeOrEntryOrRawElement: R | KeyOrNodeOrEntry<K, V, NODE>, value?: V, count?: number): NODE | undefined;
104
105
  /**
105
- * The function "isNode" checks if a given key, node, or entry is an instance of the TreeMultiMapNode
106
- * class.
107
- * @param keyOrNodeOrEntry - The parameter `keyOrNodeOrEntry` can be of type `KeyOrNodeOrEntry<K, V,
108
- * NODE>`.
109
- * @returns a boolean value indicating whether the input parameter `keyOrNodeOrEntry` is an instance
110
- * of the `TreeMultiMapNode` class.
106
+ * The function checks if the input is an instance of the TreeMultiMapNode class.
107
+ * @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter
108
+ * `keyOrNodeOrEntryOrRawElement` can be of type `R` or `KeyOrNodeOrEntry<K, V, NODE>`.
109
+ * @returns a boolean value indicating whether the input parameter `keyOrNodeOrEntryOrRawElement` is
110
+ * an instance of the `TreeMultiMapNode` class.
111
111
  */
112
- isNode(keyOrNodeOrEntry: KeyOrNodeOrEntry<K, V, NODE>): keyOrNodeOrEntry is NODE;
112
+ isNode(keyOrNodeOrEntryOrRawElement: R | KeyOrNodeOrEntry<K, V, NODE>): keyOrNodeOrEntryOrRawElement is NODE;
113
113
  /**
114
114
  * Time Complexity: O(log n)
115
115
  * Space Complexity: O(1)
@@ -118,16 +118,19 @@ export declare class TreeMultiMap<K extends Comparable, V = any, NODE extends Tr
118
118
  * Time Complexity: O(log n)
119
119
  * Space Complexity: O(1)
120
120
  *
121
- * The function overrides the add method in TypeScript and adds a new node to the data structure.
122
- * @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter can accept three types of values:
121
+ * The function overrides the add method of a class and adds a new node to a data structure, updating
122
+ * the count and returning a boolean indicating success.
123
+ * @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The
124
+ * `keyOrNodeOrEntryOrRawElement` parameter can accept one of the following types:
123
125
  * @param {V} [value] - The `value` parameter represents the value associated with the key in the
124
- * data structure.
126
+ * data structure. It is an optional parameter, so it can be omitted if not needed.
125
127
  * @param [count=1] - The `count` parameter represents the number of times the key-value pair should
126
- * be added to the data structure. By default, it is set to 1, meaning that the key-value pair will
127
- * be added once. However, you can specify a different value for `count` if you want to add
128
- * @returns a boolean value.
128
+ * be added to the data structure. By default, it is set to 1, meaning that if no value is provided
129
+ * for `count`, the key-value pair will be added once.
130
+ * @returns The method is returning a boolean value. It returns true if the addition of the new node
131
+ * was successful, and false otherwise.
129
132
  */
130
- add(keyOrNodeOrEntry: KeyOrNodeOrEntry<K, V, NODE>, value?: V, count?: number): boolean;
133
+ add(keyOrNodeOrEntryOrRawElement: R | KeyOrNodeOrEntry<K, V, NODE>, value?: V, count?: number): boolean;
131
134
  /**
132
135
  * Time Complexity: O(log n)
133
136
  * Space Complexity: O(1)
@@ -136,20 +139,18 @@ export declare class TreeMultiMap<K extends Comparable, V = any, NODE extends Tr
136
139
  * Time Complexity: O(log n)
137
140
  * Space Complexity: O(1)
138
141
  *
139
- * The `delete` function in a TypeScript class is used to delete nodes from a binary tree based on a
140
- * given identifier, and it returns an array of results containing information about the deleted
141
- * nodes.
142
- * @param {ReturnType<C> | null | undefined} identifier - The identifier parameter is the value used
143
- * to identify the node to be deleted. It can be of any type that is returned by the callback
144
- * function. It can also be null or undefined if no node needs to be deleted.
145
- * @param {C} callback - The `callback` parameter is a function that takes a node of type `NODE` as
146
- * input and returns a value of type `ReturnType<C>`. It is used to determine if a node matches the
147
- * identifier for deletion. If no callback is provided, the `_DEFAULT_CALLBACK` function is
148
- * used
149
- * @param [ignoreCount=false] - A boolean value indicating whether to ignore the count of the target
150
- * node when performing deletion. If set to true, the count of the target node will not be considered
151
- * and the node will be deleted regardless of its count. If set to false (default), the count of the
152
- * target node will be decremented
142
+ * The function `delete` is used to remove a node from a binary tree and fix the tree if necessary.
143
+ * @param {ReturnType<C> | null | undefined} identifier - The `identifier` parameter is the value or
144
+ * key that is used to identify the node that needs to be deleted from the binary tree. It can be of
145
+ * any type that is returned by the callback function `C`. It can also be `null` or `undefined` if
146
+ * the node to be deleted
147
+ * @param {C} callback - The `callback` parameter is a function that is used to determine the
148
+ * equality of nodes in the binary tree. It is optional and has a default value of
149
+ * `this._DEFAULT_CALLBACK`. The `callback` function is used to compare nodes when searching for a
150
+ * specific node or when performing other operations on the
151
+ * @param [ignoreCount=false] - A boolean flag indicating whether to ignore the count of the node
152
+ * being deleted. If set to true, the count of the node will not be taken into account when deleting
153
+ * it. If set to false, the count of the node will be decremented by 1 before deleting it.
153
154
  * @returns an array of BinaryTreeDeleteResult<NODE> objects.
154
155
  */
155
156
  delete<C extends BTNCallback<NODE>>(identifier: ReturnType<C> | null | undefined, callback?: C, ignoreCount?: boolean): BinaryTreeDeleteResult<NODE>[];
@@ -175,10 +176,12 @@ export declare class TreeMultiMap<K extends Comparable, V = any, NODE extends Tr
175
176
  *
176
177
  * The `perfectlyBalance` function takes a sorted array of nodes and builds a balanced binary search
177
178
  * tree using either a recursive or iterative approach.
178
- * @param iterationType - The `iterationType` parameter is an optional parameter that specifies the
179
- * type of iteration to use when building the balanced binary search tree. It can have two possible
180
- * values:
181
- * @returns a boolean value.
179
+ * @param {IterationType} iterationType - The `iterationType` parameter is an optional parameter that
180
+ * specifies the type of iteration to use when building the balanced binary search tree. It has a
181
+ * default value of `this.iterationType`, which means it will use the iteration type specified by the
182
+ * `iterationType` property of the current object.
183
+ * @returns The function `perfectlyBalance` returns a boolean value. It returns `true` if the
184
+ * balancing operation is successful, and `false` if there are no nodes to balance.
182
185
  */
183
186
  perfectlyBalance(iterationType?: IterationType): boolean;
184
187
  /**
@@ -194,24 +197,38 @@ export declare class TreeMultiMap<K extends Comparable, V = any, NODE extends Tr
194
197
  */
195
198
  clone(): TREE;
196
199
  /**
197
- * The function swaps the properties of two nodes in a binary search tree.
198
- * @param srcNode - The source node that needs to be swapped with the destination node. It can be
199
- * either a key or a node object.
200
- * @param destNode - The `destNode` parameter is the node in the binary search tree where the
201
- * properties will be swapped with the `srcNode`.
200
+ * Time Complexity: O(1)
201
+ * Space Complexity: O(1)
202
+ */
203
+ /**
204
+ * Time Complexity: O(1)
205
+ * Space Complexity: O(1)
206
+ *
207
+ * The `_swapProperties` function swaps the properties (key, value, count, color) between two nodes
208
+ * in a binary search tree.
209
+ * @param {R | BSTNKeyOrNode<K, NODE>} srcNode - The `srcNode` parameter represents the source node
210
+ * that will be swapped with the `destNode`. It can be either an instance of the `R` class or an
211
+ * instance of the `BSTNKeyOrNode<K, NODE>` class.
212
+ * @param {R | BSTNKeyOrNode<K, NODE>} destNode - The `destNode` parameter represents the destination
213
+ * node where the properties will be swapped with the source node.
202
214
  * @returns The method is returning the `destNode` after swapping its properties with the `srcNode`.
203
- * If both `srcNode` and `destNode` are valid nodes, the method swaps their `key`, `value`, `count`,
204
- * and `color` properties. If the swapping is successful, the method returns the modified `destNode`.
205
- * If either `srcNode` or `destNode` is
215
+ * If either `srcNode` or `destNode` is undefined, it returns undefined.
216
+ */
217
+ protected _swapProperties(srcNode: R | BSTNKeyOrNode<K, NODE>, destNode: R | BSTNKeyOrNode<K, NODE>): NODE | undefined;
218
+ /**
219
+ * Time Complexity: O(1)
220
+ * Space Complexity: O(1)
206
221
  */
207
- protected _swapProperties(srcNode: BSTNKeyOrNode<K, NODE>, destNode: BSTNKeyOrNode<K, NODE>): NODE | undefined;
208
222
  /**
223
+ * Time Complexity: O(1)
224
+ * Space Complexity: O(1)
225
+ *
209
226
  * The function replaces an old node with a new node and updates the count property of the new node.
210
- * @param {NODE} oldNode - The `oldNode` parameter is of type `NODE` and represents the node that
211
- * needs to be replaced in the data structure.
212
- * @param {NODE} newNode - The `newNode` parameter is an object of type `NODE`.
227
+ * @param {NODE} oldNode - The `oldNode` parameter is the node that you want to replace in the data
228
+ * structure.
229
+ * @param {NODE} newNode - The `newNode` parameter is an instance of the `NODE` class.
213
230
  * @returns The method is returning the result of calling the `_replaceNode` method from the
214
- * superclass, after updating the `count` property of the `newNode` object.
231
+ * superclass, which is of type `NODE`.
215
232
  */
216
233
  protected _replaceNode(oldNode: NODE, newNode: NODE): NODE;
217
234
  }
@@ -35,18 +35,18 @@ export class TreeMultiMapNode extends RedBlackTreeNode {
35
35
  }
36
36
  export class TreeMultiMap extends RedBlackTree {
37
37
  /**
38
- * The constructor function initializes a new instance of the TreeMultiMap class with optional
39
- * initial keys, nodes, or entries.
40
- * @param keysOrNodesOrEntries - The `keysOrNodesOrEntries` parameter is an iterable object that can
41
- * contain keys, nodes, or entries. It is used to initialize the TreeMultiMap with the provided keys,
42
- * nodes, or entries.
43
- * @param [options] - The `options` parameter is an optional object that can be passed to the
44
- * constructor. It allows you to customize the behavior of the `TreeMultiMap` instance.
38
+ * The constructor function initializes a TreeMultiMap object with optional initial data.
39
+ * @param keysOrNodesOrEntriesOrRawElements - The parameter `keysOrNodesOrEntriesOrRawElements` is an
40
+ * iterable that can contain keys, nodes, entries, or raw elements. It is used to initialize the
41
+ * TreeMultiMap with initial data.
42
+ * @param [options] - The `options` parameter is an optional object that can be used to customize the
43
+ * behavior of the `TreeMultiMap` constructor. It can include properties such as `compareKeys` and
44
+ * `compareValues`, which are functions used to compare keys and values respectively.
45
45
  */
46
- constructor(keysOrNodesOrEntries = [], options) {
46
+ constructor(keysOrNodesOrEntriesOrRawElements = [], options) {
47
47
  super([], options);
48
- if (keysOrNodesOrEntries)
49
- this.addMany(keysOrNodesOrEntries);
48
+ if (keysOrNodesOrEntriesOrRawElements)
49
+ this.addMany(keysOrNodesOrEntriesOrRawElements);
50
50
  }
51
51
  _count = 0;
52
52
  // TODO the _count is not accurate after nodes count modified
@@ -77,16 +77,15 @@ export class TreeMultiMap extends RedBlackTree {
77
77
  /**
78
78
  * The function creates a new TreeMultiMapNode with the specified key, value, color, and count.
79
79
  * @param {K} key - The key parameter represents the key of the node being created. It is of type K,
80
- * which is a generic type representing the key type of the node.
81
- * @param {V} [value] - The `value` parameter represents the value associated with the key in the
82
- * node. It is an optional parameter, which means it can be omitted when calling the `createNode`
83
- * function. If provided, it should be of type `V`.
80
+ * which is a generic type representing the type of keys in the tree.
81
+ * @param {V} [value] - The `value` parameter is an optional parameter that represents the value
82
+ * associated with the key in the node. It is of type `V`, which can be any data type.
84
83
  * @param {RBTNColor} [color=BLACK] - The color parameter is used to specify the color of the node in
85
84
  * a Red-Black Tree. It can have two possible values: 'RED' or 'BLACK'. The default value is 'BLACK'.
86
85
  * @param {number} [count] - The `count` parameter represents the number of occurrences of a key in
87
86
  * the tree. It is an optional parameter and is used to keep track of the number of values associated
88
87
  * with a key in the tree.
89
- * @returns A new instance of the TreeMultiMapNode class is being returned.
88
+ * @returns A new instance of the TreeMultiMapNode class, casted as NODE.
90
89
  */
91
90
  createNode(key, value, color = 'BLACK', count) {
92
91
  return new TreeMultiMapNode(key, value, count, color);
@@ -94,10 +93,10 @@ export class TreeMultiMap extends RedBlackTree {
94
93
  /**
95
94
  * The function creates a new instance of a TreeMultiMap with the specified options and returns it.
96
95
  * @param [options] - The `options` parameter is an optional object that contains additional
97
- * configuration options for creating the `TreeMultiMap`. It can include properties such as
98
- * `keyComparator`, `valueComparator`, `allowDuplicates`, etc.
96
+ * configuration options for creating the `TreeMultiMap`. It is of type `TreeMultiMapOptions<K, V,
97
+ * R>`.
99
98
  * @returns a new instance of the `TreeMultiMap` class, with the provided options merged with the
100
- * existing `iterationType` option. The returned value is casted as `TREE`.
99
+ * existing `iterationType` property. The returned value is casted as `TREE`.
101
100
  */
102
101
  createTree(options) {
103
102
  return new TreeMultiMap([], {
@@ -106,51 +105,47 @@ export class TreeMultiMap extends RedBlackTree {
106
105
  });
107
106
  }
108
107
  /**
109
- * The function `keyValueOrEntryToNode` takes a key, value, and count and returns a node if the input
110
- * is valid.
111
- * @param keyOrNodeOrEntry - The parameter `keyOrNodeOrEntry` can be of type `KeyOrNodeOrEntry<K, V,
112
- * NODE>`. It can accept three types of values:
113
- * @param {V} [value] - The `value` parameter is an optional value of type `V`. It represents the
114
- * value associated with a key in a key-value pair.
115
- * @param [count=1] - The count parameter is an optional parameter that specifies the number of times
116
- * the key-value pair should be added to the node. If not provided, it defaults to 1.
117
- * @returns a NODE object or undefined.
108
+ * The function `keyValueOrEntryOrRawElementToNode` takes in a key, value, and count and returns a
109
+ * node based on the input.
110
+ * @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter
111
+ * `keyOrNodeOrEntryOrRawElement` can be of type `R` or `KeyOrNodeOrEntry<K, V, NODE>`.
112
+ * @param {V} [value] - The `value` parameter is an optional value that represents the value
113
+ * associated with the key in the node. It is used when creating a new node or updating the value of
114
+ * an existing node.
115
+ * @param [count=1] - The `count` parameter is an optional parameter that specifies the number of
116
+ * times the key-value pair should be added to the data structure. If not provided, it defaults to 1.
117
+ * @returns either a NODE object or undefined.
118
118
  */
119
- keyValueOrEntryToNode(keyOrNodeOrEntry, value, count = 1) {
120
- let node;
121
- if (keyOrNodeOrEntry === undefined || keyOrNodeOrEntry === null) {
119
+ keyValueOrEntryOrRawElementToNode(keyOrNodeOrEntryOrRawElement, value, count = 1) {
120
+ if (keyOrNodeOrEntryOrRawElement === undefined || keyOrNodeOrEntryOrRawElement === null)
122
121
  return;
122
+ if (this.isNode(keyOrNodeOrEntryOrRawElement))
123
+ return keyOrNodeOrEntryOrRawElement;
124
+ if (this.toEntryFn) {
125
+ const [key] = this.toEntryFn(keyOrNodeOrEntryOrRawElement);
126
+ if (key)
127
+ return this.getNodeByKey(key);
123
128
  }
124
- else if (this.isNode(keyOrNodeOrEntry)) {
125
- node = keyOrNodeOrEntry;
126
- }
127
- else if (this.isEntry(keyOrNodeOrEntry)) {
128
- const [key, value] = keyOrNodeOrEntry;
129
- if (key === undefined || key === null) {
129
+ if (this.isEntry(keyOrNodeOrEntryOrRawElement)) {
130
+ const [key, value] = keyOrNodeOrEntryOrRawElement;
131
+ if (key === undefined || key === null)
130
132
  return;
131
- }
132
- else {
133
- node = this.createNode(key, value, 'BLACK', count);
134
- }
133
+ else
134
+ return this.createNode(key, value, 'BLACK', count);
135
135
  }
136
- else if (!this.isNode(keyOrNodeOrEntry)) {
137
- node = this.createNode(keyOrNodeOrEntry, value, 'BLACK', count);
138
- }
139
- else {
140
- return;
141
- }
142
- return node;
136
+ if (this.isKey(keyOrNodeOrEntryOrRawElement))
137
+ return this.createNode(keyOrNodeOrEntryOrRawElement, value, 'BLACK', count);
138
+ return;
143
139
  }
144
140
  /**
145
- * The function "isNode" checks if a given key, node, or entry is an instance of the TreeMultiMapNode
146
- * class.
147
- * @param keyOrNodeOrEntry - The parameter `keyOrNodeOrEntry` can be of type `KeyOrNodeOrEntry<K, V,
148
- * NODE>`.
149
- * @returns a boolean value indicating whether the input parameter `keyOrNodeOrEntry` is an instance
150
- * of the `TreeMultiMapNode` class.
141
+ * The function checks if the input is an instance of the TreeMultiMapNode class.
142
+ * @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The parameter
143
+ * `keyOrNodeOrEntryOrRawElement` can be of type `R` or `KeyOrNodeOrEntry<K, V, NODE>`.
144
+ * @returns a boolean value indicating whether the input parameter `keyOrNodeOrEntryOrRawElement` is
145
+ * an instance of the `TreeMultiMapNode` class.
151
146
  */
152
- isNode(keyOrNodeOrEntry) {
153
- return keyOrNodeOrEntry instanceof TreeMultiMapNode;
147
+ isNode(keyOrNodeOrEntryOrRawElement) {
148
+ return keyOrNodeOrEntryOrRawElement instanceof TreeMultiMapNode;
154
149
  }
155
150
  /**
156
151
  * Time Complexity: O(log n)
@@ -160,17 +155,20 @@ export class TreeMultiMap extends RedBlackTree {
160
155
  * Time Complexity: O(log n)
161
156
  * Space Complexity: O(1)
162
157
  *
163
- * The function overrides the add method in TypeScript and adds a new node to the data structure.
164
- * @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter can accept three types of values:
158
+ * The function overrides the add method of a class and adds a new node to a data structure, updating
159
+ * the count and returning a boolean indicating success.
160
+ * @param {R | KeyOrNodeOrEntry<K, V, NODE>} keyOrNodeOrEntryOrRawElement - The
161
+ * `keyOrNodeOrEntryOrRawElement` parameter can accept one of the following types:
165
162
  * @param {V} [value] - The `value` parameter represents the value associated with the key in the
166
- * data structure.
163
+ * data structure. It is an optional parameter, so it can be omitted if not needed.
167
164
  * @param [count=1] - The `count` parameter represents the number of times the key-value pair should
168
- * be added to the data structure. By default, it is set to 1, meaning that the key-value pair will
169
- * be added once. However, you can specify a different value for `count` if you want to add
170
- * @returns a boolean value.
165
+ * be added to the data structure. By default, it is set to 1, meaning that if no value is provided
166
+ * for `count`, the key-value pair will be added once.
167
+ * @returns The method is returning a boolean value. It returns true if the addition of the new node
168
+ * was successful, and false otherwise.
171
169
  */
172
- add(keyOrNodeOrEntry, value, count = 1) {
173
- const newNode = this.keyValueOrEntryToNode(keyOrNodeOrEntry, value, count);
170
+ add(keyOrNodeOrEntryOrRawElement, value, count = 1) {
171
+ const newNode = this.keyValueOrEntryOrRawElementToNode(keyOrNodeOrEntryOrRawElement, value, count);
174
172
  const orgCount = newNode?.count || 0;
175
173
  const isSuccessAdded = super.add(newNode);
176
174
  if (isSuccessAdded) {
@@ -189,20 +187,18 @@ export class TreeMultiMap extends RedBlackTree {
189
187
  * Time Complexity: O(log n)
190
188
  * Space Complexity: O(1)
191
189
  *
192
- * The `delete` function in a TypeScript class is used to delete nodes from a binary tree based on a
193
- * given identifier, and it returns an array of results containing information about the deleted
194
- * nodes.
195
- * @param {ReturnType<C> | null | undefined} identifier - The identifier parameter is the value used
196
- * to identify the node to be deleted. It can be of any type that is returned by the callback
197
- * function. It can also be null or undefined if no node needs to be deleted.
198
- * @param {C} callback - The `callback` parameter is a function that takes a node of type `NODE` as
199
- * input and returns a value of type `ReturnType<C>`. It is used to determine if a node matches the
200
- * identifier for deletion. If no callback is provided, the `_DEFAULT_CALLBACK` function is
201
- * used
202
- * @param [ignoreCount=false] - A boolean value indicating whether to ignore the count of the target
203
- * node when performing deletion. If set to true, the count of the target node will not be considered
204
- * and the node will be deleted regardless of its count. If set to false (default), the count of the
205
- * target node will be decremented
190
+ * The function `delete` is used to remove a node from a binary tree and fix the tree if necessary.
191
+ * @param {ReturnType<C> | null | undefined} identifier - The `identifier` parameter is the value or
192
+ * key that is used to identify the node that needs to be deleted from the binary tree. It can be of
193
+ * any type that is returned by the callback function `C`. It can also be `null` or `undefined` if
194
+ * the node to be deleted
195
+ * @param {C} callback - The `callback` parameter is a function that is used to determine the
196
+ * equality of nodes in the binary tree. It is optional and has a default value of
197
+ * `this._DEFAULT_CALLBACK`. The `callback` function is used to compare nodes when searching for a
198
+ * specific node or when performing other operations on the
199
+ * @param [ignoreCount=false] - A boolean flag indicating whether to ignore the count of the node
200
+ * being deleted. If set to true, the count of the node will not be taken into account when deleting
201
+ * it. If set to false, the count of the node will be decremented by 1 before deleting it.
206
202
  * @returns an array of BinaryTreeDeleteResult<NODE> objects.
207
203
  */
208
204
  delete(identifier, callback = this._DEFAULT_CALLBACK, ignoreCount = false) {
@@ -318,10 +314,12 @@ export class TreeMultiMap extends RedBlackTree {
318
314
  *
319
315
  * The `perfectlyBalance` function takes a sorted array of nodes and builds a balanced binary search
320
316
  * tree using either a recursive or iterative approach.
321
- * @param iterationType - The `iterationType` parameter is an optional parameter that specifies the
322
- * type of iteration to use when building the balanced binary search tree. It can have two possible
323
- * values:
324
- * @returns a boolean value.
317
+ * @param {IterationType} iterationType - The `iterationType` parameter is an optional parameter that
318
+ * specifies the type of iteration to use when building the balanced binary search tree. It has a
319
+ * default value of `this.iterationType`, which means it will use the iteration type specified by the
320
+ * `iterationType` property of the current object.
321
+ * @returns The function `perfectlyBalance` returns a boolean value. It returns `true` if the
322
+ * balancing operation is successful, and `false` if there are no nodes to balance.
325
323
  */
326
324
  perfectlyBalance(iterationType = this.iterationType) {
327
325
  const sorted = this.dfs(node => node, 'IN'), n = sorted.length;
@@ -376,15 +374,22 @@ export class TreeMultiMap extends RedBlackTree {
376
374
  return cloned;
377
375
  }
378
376
  /**
379
- * The function swaps the properties of two nodes in a binary search tree.
380
- * @param srcNode - The source node that needs to be swapped with the destination node. It can be
381
- * either a key or a node object.
382
- * @param destNode - The `destNode` parameter is the node in the binary search tree where the
383
- * properties will be swapped with the `srcNode`.
377
+ * Time Complexity: O(1)
378
+ * Space Complexity: O(1)
379
+ */
380
+ /**
381
+ * Time Complexity: O(1)
382
+ * Space Complexity: O(1)
383
+ *
384
+ * The `_swapProperties` function swaps the properties (key, value, count, color) between two nodes
385
+ * in a binary search tree.
386
+ * @param {R | BSTNKeyOrNode<K, NODE>} srcNode - The `srcNode` parameter represents the source node
387
+ * that will be swapped with the `destNode`. It can be either an instance of the `R` class or an
388
+ * instance of the `BSTNKeyOrNode<K, NODE>` class.
389
+ * @param {R | BSTNKeyOrNode<K, NODE>} destNode - The `destNode` parameter represents the destination
390
+ * node where the properties will be swapped with the source node.
384
391
  * @returns The method is returning the `destNode` after swapping its properties with the `srcNode`.
385
- * If both `srcNode` and `destNode` are valid nodes, the method swaps their `key`, `value`, `count`,
386
- * and `color` properties. If the swapping is successful, the method returns the modified `destNode`.
387
- * If either `srcNode` or `destNode` is
392
+ * If either `srcNode` or `destNode` is undefined, it returns undefined.
388
393
  */
389
394
  _swapProperties(srcNode, destNode) {
390
395
  srcNode = this.ensureNode(srcNode);
@@ -408,12 +413,19 @@ export class TreeMultiMap extends RedBlackTree {
408
413
  return undefined;
409
414
  }
410
415
  /**
416
+ * Time Complexity: O(1)
417
+ * Space Complexity: O(1)
418
+ */
419
+ /**
420
+ * Time Complexity: O(1)
421
+ * Space Complexity: O(1)
422
+ *
411
423
  * The function replaces an old node with a new node and updates the count property of the new node.
412
- * @param {NODE} oldNode - The `oldNode` parameter is of type `NODE` and represents the node that
413
- * needs to be replaced in the data structure.
414
- * @param {NODE} newNode - The `newNode` parameter is an object of type `NODE`.
424
+ * @param {NODE} oldNode - The `oldNode` parameter is the node that you want to replace in the data
425
+ * structure.
426
+ * @param {NODE} newNode - The `newNode` parameter is an instance of the `NODE` class.
415
427
  * @returns The method is returning the result of calling the `_replaceNode` method from the
416
- * superclass, after updating the `count` property of the `newNode` object.
428
+ * superclass, which is of type `NODE`.
417
429
  */
418
430
  _replaceNode(oldNode, newNode) {
419
431
  newNode.count = oldNode.count + newNode.count;
@@ -231,9 +231,8 @@ export declare abstract class AbstractGraph<V = any, E = any, VO extends Abstrac
231
231
  getMinPathBetween(v1: VO | VertexKey, v2: VO | VertexKey, isWeight?: boolean, isDFS?: boolean): VO[] | undefined;
232
232
  /**
233
233
  * Dijkstra algorithm time: O(VE) space: O(VO + EO)
234
- * /
235
-
236
- /**
234
+ */
235
+ /**
237
236
  * Time Complexity: O(V^2 + E) - Quadratic time in the worst case (no heap optimization).
238
237
  * Space Complexity: O(V + E) - Depends on the implementation (Dijkstra's algorithm).
239
238
  */
@@ -264,9 +263,8 @@ export declare abstract class AbstractGraph<V = any, E = any, VO extends Abstrac
264
263
  * Dijkstra's algorithm is suitable for graphs with non-negative edge weights, whereas the Bellman-Ford algorithm and Floyd-Warshall algorithm can handle negative-weight edgeMap.
265
264
  * The time complexity of Dijkstra's algorithm and the Bellman-Ford algorithm depends on the size of the graph, while the time complexity of the Floyd-Warshall algorithm is O(VO^3), where VO is the number of nodes. For dense graphs, Floyd-Warshall might become slower.
266
265
  *
267
- * /
268
-
269
- /**
266
+ */
267
+ /**
270
268
  * Time Complexity: O((V + E) * log(V)) - Depends on the implementation (using a binary heap).
271
269
  * Space Complexity: O(V + E) - Depends on the implementation (using a binary heap).
272
270
  */
@@ -295,9 +293,8 @@ export declare abstract class AbstractGraph<V = any, E = any, VO extends Abstrac
295
293
  * Time Complexity: O(V * E) - Quadratic time in the worst case (Bellman-Ford algorithm).
296
294
  * Space Complexity: O(V + E) - Depends on the implementation (Bellman-Ford algorithm).
297
295
  * one to rest pairs
298
- * /
299
-
300
- /**
296
+ */
297
+ /**
301
298
  * Time Complexity: O(V * E) - Quadratic time in the worst case (Bellman-Ford algorithm).
302
299
  * Space Complexity: O(V + E) - Depends on the implementation (Bellman-Ford algorithm).
303
300
  *
@@ -325,9 +322,8 @@ export declare abstract class AbstractGraph<V = any, E = any, VO extends Abstrac
325
322
  };
326
323
  /**
327
324
  * Dijkstra algorithm time: O(logVE) space: O(VO + EO)
328
- * /
329
-
330
- /**
325
+ */
326
+ /**
331
327
  * Dijkstra algorithm time: O(logVE) space: O(VO + EO)
332
328
  * Dijkstra's algorithm is used to find the shortest paths from a source node to all other nodes in a graph. Its basic idea is to repeatedly choose the node closest to the source node and update the distances of other nodes using this node as an intermediary. Dijkstra's algorithm requires that the edge weights in the graph are non-negative.
333
329
  */
@@ -343,9 +339,8 @@ export declare abstract class AbstractGraph<V = any, E = any, VO extends Abstrac
343
339
  * Not support graph with negative weight cycle
344
340
  * all pairs
345
341
  * The Floyd-Warshall algorithm is used to find the shortest paths between all pairs of nodes in a graph. It employs dynamic programming to compute the shortest paths from any node to any other node. The Floyd-Warshall algorithm's advantage lies in its ability to handle graphs with negative-weight edgeMap, and it can simultaneously compute shortest paths between any two nodes.
346
- * /
347
-
348
- /**
342
+ */
343
+ /**
349
344
  * Time Complexity: O(V^3) - Cubic time (Floyd-Warshall algorithm).
350
345
  * Space Complexity: O(V^2) - Quadratic space (Floyd-Warshall algorithm).
351
346
  *