data-structure-typed 1.53.7 → 1.53.9

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 (164) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/CONTRIBUTING.md +1 -1
  3. package/dist/cjs/common/index.js +5 -0
  4. package/dist/cjs/common/index.js.map +1 -1
  5. package/dist/cjs/data-structures/base/iterable-entry-base.js +4 -4
  6. package/dist/cjs/data-structures/base/iterable-entry-base.js.map +1 -1
  7. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.d.ts +36 -17
  8. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js +65 -36
  9. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js.map +1 -1
  10. package/dist/cjs/data-structures/binary-tree/avl-tree.d.ts +12 -8
  11. package/dist/cjs/data-structures/binary-tree/avl-tree.js +19 -6
  12. package/dist/cjs/data-structures/binary-tree/avl-tree.js.map +1 -1
  13. package/dist/cjs/data-structures/binary-tree/binary-tree.d.ts +53 -40
  14. package/dist/cjs/data-structures/binary-tree/binary-tree.js +76 -72
  15. package/dist/cjs/data-structures/binary-tree/binary-tree.js.map +1 -1
  16. package/dist/cjs/data-structures/binary-tree/bst.d.ts +87 -52
  17. package/dist/cjs/data-structures/binary-tree/bst.js +111 -63
  18. package/dist/cjs/data-structures/binary-tree/bst.js.map +1 -1
  19. package/dist/cjs/data-structures/binary-tree/index.d.ts +1 -1
  20. package/dist/cjs/data-structures/binary-tree/index.js +1 -1
  21. package/dist/cjs/data-structures/binary-tree/index.js.map +1 -1
  22. package/dist/cjs/data-structures/binary-tree/{rb-tree.d.ts → red-black-tree.d.ts} +83 -10
  23. package/dist/cjs/data-structures/binary-tree/{rb-tree.js → red-black-tree.js} +92 -45
  24. package/dist/cjs/data-structures/binary-tree/red-black-tree.js.map +1 -0
  25. package/dist/cjs/data-structures/binary-tree/tree-multi-map.d.ts +34 -18
  26. package/dist/cjs/data-structures/binary-tree/tree-multi-map.js +66 -40
  27. package/dist/cjs/data-structures/binary-tree/tree-multi-map.js.map +1 -1
  28. package/dist/cjs/data-structures/graph/abstract-graph.js +2 -2
  29. package/dist/cjs/data-structures/graph/abstract-graph.js.map +1 -1
  30. package/dist/cjs/data-structures/hash/hash-map.d.ts +31 -1
  31. package/dist/cjs/data-structures/hash/hash-map.js +35 -5
  32. package/dist/cjs/data-structures/hash/hash-map.js.map +1 -1
  33. package/dist/cjs/data-structures/heap/heap.d.ts +20 -3
  34. package/dist/cjs/data-structures/heap/heap.js +31 -11
  35. package/dist/cjs/data-structures/heap/heap.js.map +1 -1
  36. package/dist/cjs/data-structures/linked-list/doubly-linked-list.d.ts +46 -11
  37. package/dist/cjs/data-structures/linked-list/doubly-linked-list.js +68 -21
  38. package/dist/cjs/data-structures/linked-list/doubly-linked-list.js.map +1 -1
  39. package/dist/cjs/data-structures/linked-list/singly-linked-list.d.ts +44 -11
  40. package/dist/cjs/data-structures/linked-list/singly-linked-list.js +70 -26
  41. package/dist/cjs/data-structures/linked-list/singly-linked-list.js.map +1 -1
  42. package/dist/cjs/data-structures/queue/deque.d.ts +37 -8
  43. package/dist/cjs/data-structures/queue/deque.js +73 -29
  44. package/dist/cjs/data-structures/queue/deque.js.map +1 -1
  45. package/dist/cjs/data-structures/queue/queue.d.ts +41 -1
  46. package/dist/cjs/data-structures/queue/queue.js +51 -9
  47. package/dist/cjs/data-structures/queue/queue.js.map +1 -1
  48. package/dist/cjs/data-structures/stack/stack.d.ts +27 -10
  49. package/dist/cjs/data-structures/stack/stack.js +39 -20
  50. package/dist/cjs/data-structures/stack/stack.js.map +1 -1
  51. package/dist/cjs/data-structures/trie/trie.d.ts +12 -13
  52. package/dist/cjs/data-structures/trie/trie.js +12 -13
  53. package/dist/cjs/data-structures/trie/trie.js.map +1 -1
  54. package/dist/cjs/interfaces/binary-tree.d.ts +3 -4
  55. package/dist/cjs/types/data-structures/base/base.d.ts +1 -1
  56. package/dist/cjs/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +2 -3
  57. package/dist/cjs/types/data-structures/binary-tree/avl-tree.d.ts +2 -3
  58. package/dist/cjs/types/data-structures/binary-tree/binary-tree.d.ts +2 -3
  59. package/dist/cjs/types/data-structures/binary-tree/bst.d.ts +3 -4
  60. package/dist/cjs/types/data-structures/binary-tree/rb-tree.d.ts +4 -5
  61. package/dist/cjs/types/data-structures/binary-tree/tree-multi-map.d.ts +4 -5
  62. package/dist/mjs/common/index.js +5 -0
  63. package/dist/mjs/common/index.js.map +1 -1
  64. package/dist/mjs/data-structures/base/iterable-entry-base.js +4 -4
  65. package/dist/mjs/data-structures/base/iterable-entry-base.js.map +1 -1
  66. package/dist/mjs/data-structures/binary-tree/avl-tree-multi-map.d.ts +36 -17
  67. package/dist/mjs/data-structures/binary-tree/avl-tree-multi-map.js +65 -36
  68. package/dist/mjs/data-structures/binary-tree/avl-tree-multi-map.js.map +1 -1
  69. package/dist/mjs/data-structures/binary-tree/avl-tree.d.ts +12 -8
  70. package/dist/mjs/data-structures/binary-tree/avl-tree.js +19 -6
  71. package/dist/mjs/data-structures/binary-tree/avl-tree.js.map +1 -1
  72. package/dist/mjs/data-structures/binary-tree/binary-tree.d.ts +53 -40
  73. package/dist/mjs/data-structures/binary-tree/binary-tree.js +76 -72
  74. package/dist/mjs/data-structures/binary-tree/binary-tree.js.map +1 -1
  75. package/dist/mjs/data-structures/binary-tree/bst.d.ts +87 -52
  76. package/dist/mjs/data-structures/binary-tree/bst.js +127 -79
  77. package/dist/mjs/data-structures/binary-tree/bst.js.map +1 -1
  78. package/dist/mjs/data-structures/binary-tree/index.d.ts +1 -1
  79. package/dist/mjs/data-structures/binary-tree/index.js +1 -1
  80. package/dist/mjs/data-structures/binary-tree/index.js.map +1 -1
  81. package/dist/mjs/data-structures/binary-tree/{rb-tree.d.ts → red-black-tree.d.ts} +83 -10
  82. package/dist/mjs/data-structures/binary-tree/{rb-tree.js → red-black-tree.js} +92 -45
  83. package/dist/mjs/data-structures/binary-tree/red-black-tree.js.map +1 -0
  84. package/dist/mjs/data-structures/binary-tree/tree-multi-map.d.ts +34 -18
  85. package/dist/mjs/data-structures/binary-tree/tree-multi-map.js +64 -38
  86. package/dist/mjs/data-structures/binary-tree/tree-multi-map.js.map +1 -1
  87. package/dist/mjs/data-structures/graph/abstract-graph.js +2 -2
  88. package/dist/mjs/data-structures/graph/abstract-graph.js.map +1 -1
  89. package/dist/mjs/data-structures/hash/hash-map.d.ts +31 -1
  90. package/dist/mjs/data-structures/hash/hash-map.js +35 -5
  91. package/dist/mjs/data-structures/hash/hash-map.js.map +1 -1
  92. package/dist/mjs/data-structures/heap/heap.d.ts +20 -3
  93. package/dist/mjs/data-structures/heap/heap.js +31 -11
  94. package/dist/mjs/data-structures/heap/heap.js.map +1 -1
  95. package/dist/mjs/data-structures/linked-list/doubly-linked-list.d.ts +46 -11
  96. package/dist/mjs/data-structures/linked-list/doubly-linked-list.js +68 -21
  97. package/dist/mjs/data-structures/linked-list/doubly-linked-list.js.map +1 -1
  98. package/dist/mjs/data-structures/linked-list/singly-linked-list.d.ts +44 -11
  99. package/dist/mjs/data-structures/linked-list/singly-linked-list.js +70 -26
  100. package/dist/mjs/data-structures/linked-list/singly-linked-list.js.map +1 -1
  101. package/dist/mjs/data-structures/queue/deque.d.ts +37 -8
  102. package/dist/mjs/data-structures/queue/deque.js +73 -29
  103. package/dist/mjs/data-structures/queue/deque.js.map +1 -1
  104. package/dist/mjs/data-structures/queue/queue.d.ts +41 -1
  105. package/dist/mjs/data-structures/queue/queue.js +51 -9
  106. package/dist/mjs/data-structures/queue/queue.js.map +1 -1
  107. package/dist/mjs/data-structures/stack/stack.d.ts +27 -10
  108. package/dist/mjs/data-structures/stack/stack.js +39 -20
  109. package/dist/mjs/data-structures/stack/stack.js.map +1 -1
  110. package/dist/mjs/data-structures/trie/trie.d.ts +12 -13
  111. package/dist/mjs/data-structures/trie/trie.js +12 -13
  112. package/dist/mjs/data-structures/trie/trie.js.map +1 -1
  113. package/dist/mjs/interfaces/binary-tree.d.ts +3 -4
  114. package/dist/mjs/types/data-structures/base/base.d.ts +1 -1
  115. package/dist/mjs/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +2 -3
  116. package/dist/mjs/types/data-structures/binary-tree/avl-tree.d.ts +2 -3
  117. package/dist/mjs/types/data-structures/binary-tree/binary-tree.d.ts +2 -3
  118. package/dist/mjs/types/data-structures/binary-tree/bst.d.ts +3 -4
  119. package/dist/mjs/types/data-structures/binary-tree/rb-tree.d.ts +4 -5
  120. package/dist/mjs/types/data-structures/binary-tree/tree-multi-map.d.ts +4 -5
  121. package/dist/umd/data-structure-typed.js +722 -356
  122. package/dist/umd/data-structure-typed.min.js +3 -3
  123. package/dist/umd/data-structure-typed.min.js.map +1 -1
  124. package/package.json +6 -6
  125. package/src/common/index.ts +7 -1
  126. package/src/data-structures/base/iterable-entry-base.ts +4 -4
  127. package/src/data-structures/binary-tree/avl-tree-multi-map.ts +82 -55
  128. package/src/data-structures/binary-tree/avl-tree.ts +32 -15
  129. package/src/data-structures/binary-tree/binary-tree.ts +89 -84
  130. package/src/data-structures/binary-tree/bst.ts +149 -97
  131. package/src/data-structures/binary-tree/index.ts +1 -1
  132. package/src/data-structures/binary-tree/{rb-tree.ts → red-black-tree.ts} +105 -55
  133. package/src/data-structures/binary-tree/tree-multi-map.ts +81 -51
  134. package/src/data-structures/graph/abstract-graph.ts +2 -2
  135. package/src/data-structures/hash/hash-map.ts +37 -7
  136. package/src/data-structures/heap/heap.ts +33 -10
  137. package/src/data-structures/linked-list/doubly-linked-list.ts +75 -21
  138. package/src/data-structures/linked-list/singly-linked-list.ts +77 -27
  139. package/src/data-structures/queue/deque.ts +72 -28
  140. package/src/data-structures/queue/queue.ts +50 -7
  141. package/src/data-structures/stack/stack.ts +39 -20
  142. package/src/data-structures/trie/trie.ts +8 -3
  143. package/src/interfaces/binary-tree.ts +3 -13
  144. package/src/types/data-structures/base/base.ts +1 -1
  145. package/src/types/data-structures/binary-tree/avl-tree-multi-map.ts +2 -4
  146. package/src/types/data-structures/binary-tree/avl-tree.ts +2 -4
  147. package/src/types/data-structures/binary-tree/binary-tree.ts +3 -3
  148. package/src/types/data-structures/binary-tree/bst.ts +3 -5
  149. package/src/types/data-structures/binary-tree/rb-tree.ts +4 -6
  150. package/src/types/data-structures/binary-tree/tree-multi-map.ts +4 -6
  151. package/test/integration/index.html +3 -3
  152. package/test/performance/data-structures/binary-tree/binary-tree-overall.test.ts +3 -3
  153. package/test/unit/data-structures/binary-tree/avl-tree-multi-map.test.ts +12 -12
  154. package/test/unit/data-structures/binary-tree/avl-tree.test.ts +10 -10
  155. package/test/unit/data-structures/binary-tree/binary-tree.test.ts +45 -45
  156. package/test/unit/data-structures/binary-tree/bst.test.ts +90 -96
  157. package/test/unit/data-structures/binary-tree/data/cost-of-living-by-country.ts +259 -0
  158. package/test/unit/data-structures/binary-tree/overall.test.ts +2 -0
  159. package/test/unit/data-structures/binary-tree/{rb-tree.test.ts → red-black-tree.test.ts} +67 -92
  160. package/test/unit/data-structures/binary-tree/tree-multi-map.test.ts +10 -10
  161. package/test/unit/data-structures/graph/directed-graph.test.ts +4 -4
  162. package/test/unit/data-structures/hash/hash-map.test.ts +12 -12
  163. package/dist/cjs/data-structures/binary-tree/rb-tree.js.map +0 -1
  164. package/dist/mjs/data-structures/binary-tree/rb-tree.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import type { BinaryTreeDeleteResult, BTNRep, CRUD, RBTNColor, RBTreeOptions, RedBlackTreeNested, RedBlackTreeNodeNested } from '../../types';
1
+ import type { BinaryTreeDeleteResult, BTNRep, CRUD, EntryCallback, RBTNColor, RedBlackTreeOptions, RedBlackTreeNodeNested } from '../../types';
2
2
  import { BST, BSTNode } from './bst';
3
3
  import { IBinaryTree } from '../../interfaces';
4
4
  export declare class RedBlackTreeNode<K = any, V = any, NODE extends RedBlackTreeNode<K, V, NODE> = RedBlackTreeNodeNested<K, V>> extends BSTNode<K, V, NODE> {
@@ -29,19 +29,68 @@ export declare class RedBlackTreeNode<K = any, V = any, NODE extends RedBlackTre
29
29
  /**
30
30
  * 1. Efficient self-balancing, but not completely balanced. Compared with AVLTree, the addition and deletion efficiency is high but the query efficiency is slightly lower.
31
31
  * 2. It is BST itself. Compared with Heap which is not completely ordered, RedBlackTree is completely ordered.
32
+ * @example
33
+ * // Find elements in a range
34
+ * const bst = new RedBlackTree<number>([10, 5, 15, 3, 7, 12, 18]);
35
+ * console.log(bst.search(new Range(5, 10))); // [5, 10, 7]
36
+ * console.log(bst.search(new Range(4, 12))); // [5, 10, 12, 7]
37
+ * console.log(bst.search(new Range(15, 20))); // [15, 18]
38
+ * @example
39
+ * // using Red-Black Tree as a price-based index for stock data
40
+ * // Define the structure of individual stock records
41
+ * interface StockRecord {
42
+ * price: number; // Stock price (key for indexing)
43
+ * symbol: string; // Stock ticker symbol
44
+ * volume: number; // Trade volume
45
+ * }
46
+ *
47
+ * // Simulate stock market data as it might come from an external feed
48
+ * const marketStockData: StockRecord[] = [
49
+ * { price: 142.5, symbol: 'AAPL', volume: 1000000 },
50
+ * { price: 335.2, symbol: 'MSFT', volume: 800000 },
51
+ * { price: 3285.04, symbol: 'AMZN', volume: 500000 },
52
+ * { price: 267.98, symbol: 'META', volume: 750000 },
53
+ * { price: 234.57, symbol: 'GOOGL', volume: 900000 }
54
+ * ];
55
+ *
56
+ * // Extend the stock record type to include metadata for database usage
57
+ * type StockTableRecord = StockRecord & { lastUpdated: Date };
58
+ *
59
+ * // Create a Red-Black Tree to index stock records by price
60
+ * // Simulates a database index with stock price as the key for quick lookups
61
+ * const priceIndex = new RedBlackTree<number, StockTableRecord, StockRecord>(marketStockData, {
62
+ * toEntryFn: stockRecord => [
63
+ * stockRecord.price, // Use stock price as the key
64
+ * {
65
+ * ...stockRecord,
66
+ * lastUpdated: new Date() // Add a timestamp for when the record was indexed
67
+ * }
68
+ * ]
69
+ * });
70
+ *
71
+ * // Query the stock with the highest price
72
+ * const highestPricedStock = priceIndex.getRightMost();
73
+ * console.log(priceIndex.get(highestPricedStock)?.symbol); // 'AMZN' // Amazon has the highest price
74
+ *
75
+ * // Query stocks within a specific price range (200 to 400)
76
+ * const stocksInRange = priceIndex.rangeSearch(
77
+ * [200, 400], // Price range
78
+ * node => priceIndex.get(node)?.symbol // Extract stock symbols for the result
79
+ * );
80
+ * console.log(stocksInRange); // ['GOOGL', 'MSFT', 'META']
32
81
  */
33
- export declare class RedBlackTree<K = any, V = any, R = object, NODE extends RedBlackTreeNode<K, V, NODE> = RedBlackTreeNode<K, V, RedBlackTreeNodeNested<K, V>>, TREE extends RedBlackTree<K, V, R, NODE, TREE> = RedBlackTree<K, V, R, NODE, RedBlackTreeNested<K, V, R, NODE>>> extends BST<K, V, R, NODE, TREE> implements IBinaryTree<K, V, R, NODE, TREE> {
82
+ export declare class RedBlackTree<K = any, V = any, R = object, NODE extends RedBlackTreeNode<K, V, NODE> = RedBlackTreeNode<K, V, RedBlackTreeNodeNested<K, V>>> extends BST<K, V, R, NODE> implements IBinaryTree<K, V, R, NODE> {
34
83
  /**
35
84
  * This is the constructor function for a Red-Black Tree data structure in TypeScript.
36
85
  * @param keysNodesEntriesOrRaws - The `keysNodesEntriesOrRaws` parameter is an
37
86
  * iterable object that can contain either keys, nodes, entries, or raw elements. It is used to
38
- * initialize the RBTree with the provided elements.
87
+ * initialize the RedBlackTree with the provided elements.
39
88
  * @param [options] - The `options` parameter is an optional object that can be passed to the
40
- * constructor. It is of type `RBTreeOptions<K, V, R>`. This object can contain various options for
89
+ * constructor. It is of type `RedBlackTreeOptions<K, V, R>`. This object can contain various options for
41
90
  * configuring the behavior of the Red-Black Tree. The specific properties and their meanings would
42
91
  * depend on the implementation
43
92
  */
44
- constructor(keysNodesEntriesOrRaws?: Iterable<R | BTNRep<K, V, NODE>>, options?: RBTreeOptions<K, V, R>);
93
+ constructor(keysNodesEntriesOrRaws?: Iterable<R | BTNRep<K, V, NODE>>, options?: RedBlackTreeOptions<K, V, R>);
45
94
  protected _root: NODE | undefined;
46
95
  /**
47
96
  * The function returns the root node of a tree or undefined if there is no root.
@@ -64,12 +113,15 @@ export declare class RedBlackTree<K = any, V = any, R = object, NODE extends Red
64
113
  */
65
114
  createNode(key: K, value?: V, color?: RBTNColor): NODE;
66
115
  /**
67
- * The function creates a new Red-Black Tree with the specified options.
68
- * @param [options] - The `options` parameter is an optional object that contains additional
69
- * configuration options for creating the Red-Black Tree. It has the following properties:
70
- * @returns a new instance of a RedBlackTree object.
116
+ * The function `createTree` overrides the default implementation to create a Red-Black Tree with
117
+ * specified options in TypeScript.
118
+ * @param [options] - The `options` parameter in the `createTree` method is of type `RedBlackTreeOptions<K,
119
+ * V, R>`, which is a generic type with three type parameters `K`, `V`, and `R`. This parameter
120
+ * allows you to pass additional configuration options when creating a new Red-
121
+ * @returns A new instance of a RedBlackTree with the specified options and properties from the
122
+ * current object is being returned.
71
123
  */
72
- createTree(options?: RBTreeOptions<K, V, R>): TREE;
124
+ createTree(options?: RedBlackTreeOptions<K, V, R>): RedBlackTree<K, V, R, RedBlackTreeNode<K, V, RedBlackTreeNodeNested<K, V>>>;
73
125
  /**
74
126
  * Time Complexity: O(1)
75
127
  * Space Complexity: O(1)
@@ -120,6 +172,27 @@ export declare class RedBlackTree<K = any, V = any, R = object, NODE extends Red
120
172
  * balancing is needed.
121
173
  */
122
174
  delete(keyNodeEntryOrRaw: BTNRep<K, V, NODE> | R): BinaryTreeDeleteResult<NODE>[];
175
+ /**
176
+ * Time Complexity: O(n)
177
+ * Space Complexity: O(n)
178
+ *
179
+ * The `map` function in TypeScript overrides the default behavior to create a new Red-Black Tree by
180
+ * applying a callback to each entry in the original tree.
181
+ * @param callback - A function that will be called for each entry in the tree, with parameters
182
+ * representing the key, value, index, and the tree itself. It should return an entry for the new
183
+ * tree.
184
+ * @param [options] - The `options` parameter in the `map` method is of type `RedBlackTreeOptions<MK, MV,
185
+ * MR>`. This parameter allows you to specify additional options or configurations for the Red-Black
186
+ * Tree that will be created during the mapping process. These options could include things like
187
+ * custom comparators
188
+ * @param {any} [thisArg] - The `thisArg` parameter in the `override map` function is used to specify
189
+ * the value of `this` when executing the `callback` function. It allows you to set the context
190
+ * (value of `this`) for the callback function. This can be useful when you want to access properties
191
+ * or
192
+ * @returns A new Red-Black Tree is being returned, where each entry has been transformed using the
193
+ * provided callback function.
194
+ */
195
+ map<MK, MV, MR>(callback: EntryCallback<K, V | undefined, [MK, MV]>, options?: RedBlackTreeOptions<MK, MV, MR>, thisArg?: any): RedBlackTree<MK, MV, MR, RedBlackTreeNode<MK, MV, RedBlackTreeNodeNested<MK, MV>>>;
123
196
  /**
124
197
  * Time Complexity: O(1)
125
198
  * Space Complexity: O(1)
@@ -37,15 +37,64 @@ exports.RedBlackTreeNode = RedBlackTreeNode;
37
37
  /**
38
38
  * 1. Efficient self-balancing, but not completely balanced. Compared with AVLTree, the addition and deletion efficiency is high but the query efficiency is slightly lower.
39
39
  * 2. It is BST itself. Compared with Heap which is not completely ordered, RedBlackTree is completely ordered.
40
+ * @example
41
+ * // Find elements in a range
42
+ * const bst = new RedBlackTree<number>([10, 5, 15, 3, 7, 12, 18]);
43
+ * console.log(bst.search(new Range(5, 10))); // [5, 10, 7]
44
+ * console.log(bst.search(new Range(4, 12))); // [5, 10, 12, 7]
45
+ * console.log(bst.search(new Range(15, 20))); // [15, 18]
46
+ * @example
47
+ * // using Red-Black Tree as a price-based index for stock data
48
+ * // Define the structure of individual stock records
49
+ * interface StockRecord {
50
+ * price: number; // Stock price (key for indexing)
51
+ * symbol: string; // Stock ticker symbol
52
+ * volume: number; // Trade volume
53
+ * }
54
+ *
55
+ * // Simulate stock market data as it might come from an external feed
56
+ * const marketStockData: StockRecord[] = [
57
+ * { price: 142.5, symbol: 'AAPL', volume: 1000000 },
58
+ * { price: 335.2, symbol: 'MSFT', volume: 800000 },
59
+ * { price: 3285.04, symbol: 'AMZN', volume: 500000 },
60
+ * { price: 267.98, symbol: 'META', volume: 750000 },
61
+ * { price: 234.57, symbol: 'GOOGL', volume: 900000 }
62
+ * ];
63
+ *
64
+ * // Extend the stock record type to include metadata for database usage
65
+ * type StockTableRecord = StockRecord & { lastUpdated: Date };
66
+ *
67
+ * // Create a Red-Black Tree to index stock records by price
68
+ * // Simulates a database index with stock price as the key for quick lookups
69
+ * const priceIndex = new RedBlackTree<number, StockTableRecord, StockRecord>(marketStockData, {
70
+ * toEntryFn: stockRecord => [
71
+ * stockRecord.price, // Use stock price as the key
72
+ * {
73
+ * ...stockRecord,
74
+ * lastUpdated: new Date() // Add a timestamp for when the record was indexed
75
+ * }
76
+ * ]
77
+ * });
78
+ *
79
+ * // Query the stock with the highest price
80
+ * const highestPricedStock = priceIndex.getRightMost();
81
+ * console.log(priceIndex.get(highestPricedStock)?.symbol); // 'AMZN' // Amazon has the highest price
82
+ *
83
+ * // Query stocks within a specific price range (200 to 400)
84
+ * const stocksInRange = priceIndex.rangeSearch(
85
+ * [200, 400], // Price range
86
+ * node => priceIndex.get(node)?.symbol // Extract stock symbols for the result
87
+ * );
88
+ * console.log(stocksInRange); // ['GOOGL', 'MSFT', 'META']
40
89
  */
41
90
  class RedBlackTree extends bst_1.BST {
42
91
  /**
43
92
  * This is the constructor function for a Red-Black Tree data structure in TypeScript.
44
93
  * @param keysNodesEntriesOrRaws - The `keysNodesEntriesOrRaws` parameter is an
45
94
  * iterable object that can contain either keys, nodes, entries, or raw elements. It is used to
46
- * initialize the RBTree with the provided elements.
95
+ * initialize the RedBlackTree with the provided elements.
47
96
  * @param [options] - The `options` parameter is an optional object that can be passed to the
48
- * constructor. It is of type `RBTreeOptions<K, V, R>`. This object can contain various options for
97
+ * constructor. It is of type `RedBlackTreeOptions<K, V, R>`. This object can contain various options for
49
98
  * configuring the behavior of the Red-Black Tree. The specific properties and their meanings would
50
99
  * depend on the implementation
51
100
  */
@@ -81,13 +130,17 @@ class RedBlackTree extends bst_1.BST {
81
130
  return new RedBlackTreeNode(key, this._isMapMode ? undefined : value, color);
82
131
  }
83
132
  /**
84
- * The function creates a new Red-Black Tree with the specified options.
85
- * @param [options] - The `options` parameter is an optional object that contains additional
86
- * configuration options for creating the Red-Black Tree. It has the following properties:
87
- * @returns a new instance of a RedBlackTree object.
133
+ * The function `createTree` overrides the default implementation to create a Red-Black Tree with
134
+ * specified options in TypeScript.
135
+ * @param [options] - The `options` parameter in the `createTree` method is of type `RedBlackTreeOptions<K,
136
+ * V, R>`, which is a generic type with three type parameters `K`, `V`, and `R`. This parameter
137
+ * allows you to pass additional configuration options when creating a new Red-
138
+ * @returns A new instance of a RedBlackTree with the specified options and properties from the
139
+ * current object is being returned.
88
140
  */
141
+ // @ts-ignore
89
142
  createTree(options) {
90
- return new RedBlackTree([], Object.assign({ iterationType: this.iterationType, isMapMode: this._isMapMode, extractComparable: this._extractComparable, toEntryFn: this._toEntryFn }, options));
143
+ return new RedBlackTree([], Object.assign({ iterationType: this.iterationType, isMapMode: this._isMapMode, specifyComparable: this._specifyComparable, toEntryFn: this._toEntryFn }, options));
91
144
  }
92
145
  /**
93
146
  * Time Complexity: O(1)
@@ -102,41 +155,6 @@ class RedBlackTree extends bst_1.BST {
102
155
  isNode(keyNodeEntryOrRaw) {
103
156
  return keyNodeEntryOrRaw instanceof RedBlackTreeNode;
104
157
  }
105
- // /**
106
- // * Time Complexity: O(1)
107
- // * Space Complexity: O(1)
108
- // */
109
- //
110
- // /**
111
- // * Time Complexity: O(1)
112
- // * Space Complexity: O(1)
113
- // *
114
- // * The function `keyValueNodeEntryRawToNodeAndValue` takes a key, value, or entry and returns a node if it is
115
- // * valid, otherwise it returns undefined.
116
- // * @param {BTNRep<K, V, NODE>} keyNodeEntryOrRaw - The key, value, or entry to convert.
117
- // * @param {V} [value] - The value associated with the key (if `keyNodeEntryOrRaw` is a key).
118
- // * @returns {NODE | undefined} - The corresponding Red-Black Tree node, or `undefined` if conversion fails.
119
- // */
120
- // override keyValueNodeEntryRawToNodeAndValue(keyNodeEntryOrRaw: BTNRep<K, V, NODE> | R, value?: V): NODE | undefined {
121
- //
122
- // if (keyNodeEntryOrRaw === null || keyNodeEntryOrRaw === undefined) return;
123
- // if (this.isNode(keyNodeEntryOrRaw)) return keyNodeEntryOrRaw;
124
- //
125
- // if (this._toEntryFn) {
126
- // const [key, entryValue] = this._toEntryFn(keyNodeEntryOrRaw as R);
127
- // if (this.isKey(key)) return this.createNode(key, value ?? entryValue, 'RED');
128
- // }
129
- //
130
- // if (this.isEntry(keyNodeEntryOrRaw)) {
131
- // const [key, value] = keyNodeEntryOrRaw;
132
- // if (key === undefined || key === null) return;
133
- // else return this.createNode(key, value, 'RED');
134
- // }
135
- //
136
- // if (this.isKey(keyNodeEntryOrRaw)) return this.createNode(keyNodeEntryOrRaw, value, 'RED');
137
- //
138
- // return ;
139
- // }
140
158
  /**
141
159
  * Time Complexity: O(1)
142
160
  * Space Complexity: O(1)
@@ -164,7 +182,7 @@ class RedBlackTree extends bst_1.BST {
164
182
  * returns true. If the node cannot be added or updated, the method returns false.
165
183
  */
166
184
  add(keyNodeEntryOrRaw, value) {
167
- const [newNode, newValue] = this.keyValueNodeEntryRawToNodeAndValue(keyNodeEntryOrRaw, value);
185
+ const [newNode, newValue] = this._keyValueNodeEntryRawToNodeAndValue(keyNodeEntryOrRaw, value);
168
186
  if (!this.isRealNode(newNode))
169
187
  return false;
170
188
  const insertStatus = this._insert(newNode);
@@ -259,6 +277,35 @@ class RedBlackTree extends bst_1.BST {
259
277
  results.push({ deleted: nodeToDelete, needBalanced: undefined });
260
278
  return results;
261
279
  }
280
+ /**
281
+ * Time Complexity: O(n)
282
+ * Space Complexity: O(n)
283
+ *
284
+ * The `map` function in TypeScript overrides the default behavior to create a new Red-Black Tree by
285
+ * applying a callback to each entry in the original tree.
286
+ * @param callback - A function that will be called for each entry in the tree, with parameters
287
+ * representing the key, value, index, and the tree itself. It should return an entry for the new
288
+ * tree.
289
+ * @param [options] - The `options` parameter in the `map` method is of type `RedBlackTreeOptions<MK, MV,
290
+ * MR>`. This parameter allows you to specify additional options or configurations for the Red-Black
291
+ * Tree that will be created during the mapping process. These options could include things like
292
+ * custom comparators
293
+ * @param {any} [thisArg] - The `thisArg` parameter in the `override map` function is used to specify
294
+ * the value of `this` when executing the `callback` function. It allows you to set the context
295
+ * (value of `this`) for the callback function. This can be useful when you want to access properties
296
+ * or
297
+ * @returns A new Red-Black Tree is being returned, where each entry has been transformed using the
298
+ * provided callback function.
299
+ */
300
+ // @ts-ignore
301
+ map(callback, options, thisArg) {
302
+ const newTree = new RedBlackTree([], options);
303
+ let index = 0;
304
+ for (const [key, value] of this) {
305
+ newTree.add(callback.call(thisArg, key, value, index++, this));
306
+ }
307
+ return newTree;
308
+ }
262
309
  /**
263
310
  * Time Complexity: O(1)
264
311
  * Space Complexity: O(1)
@@ -323,7 +370,7 @@ class RedBlackTree extends bst_1.BST {
323
370
  if (!parent) {
324
371
  this._setRoot(node);
325
372
  }
326
- else if (node.key < parent.key) {
373
+ else if (this._compare(node.key, parent.key) < 0) {
327
374
  parent.left = node;
328
375
  }
329
376
  else {
@@ -576,4 +623,4 @@ class RedBlackTree extends bst_1.BST {
576
623
  }
577
624
  }
578
625
  exports.RedBlackTree = RedBlackTree;
579
- //# sourceMappingURL=rb-tree.js.map
626
+ //# sourceMappingURL=red-black-tree.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"red-black-tree.js","sourceRoot":"","sources":["../../../../src/data-structures/binary-tree/red-black-tree.ts"],"names":[],"mappings":";;;AAUA,+BAAqC;AAGrC,MAAa,gBAIX,SAAQ,aAAmB;IAC3B;;;;;;;;;;OAUG;IACH,YAAY,GAAM,EAAE,KAAS,EAAE,QAAmB,OAAO;QACvD,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAClB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACtB,CAAC;IAID;;;OAGG;IACH,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED;;;OAGG;IACH,IAAI,KAAK,CAAC,KAAgB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M,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;QACjB,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC;QAEjB,IAAI,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC;YAC7B,CAAC,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;QACrB,CAAC;QAED,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC;QAEpB,IAAI,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;YACd,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;QACnB,CAAC;aAAM,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;YAC/B,CAAC,CAAC,MAAM,CAAC,IAAI,GAAG,CAAC,CAAC;QACpB,CAAC;aAAM,CAAC;YACN,CAAC,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC;QACrB,CAAC;QAED,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC;QACZ,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;IACf,CAAC;CACF;AA3jBD,oCA2jBC"}
@@ -5,9 +5,9 @@
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 { BinaryTreeDeleteResult, BSTNOptKeyOrNode, BTNRep, EntryCallback, IterationType, RBTNColor, TreeMultiMapNodeNested, TreeMultiMapOptions } from '../../types';
9
9
  import { IBinaryTree } from '../../interfaces';
10
- import { RedBlackTree, RedBlackTreeNode } from './rb-tree';
10
+ import { RedBlackTree, RedBlackTreeNode } from './red-black-tree';
11
11
  export declare class TreeMultiMapNode<K = any, V = any, NODE extends TreeMultiMapNode<K, V, NODE> = TreeMultiMapNodeNested<K, V>> extends RedBlackTreeNode<K, V, NODE> {
12
12
  /**
13
13
  * The constructor function initializes a Red-Black Tree node with a key, value, count, and color.
@@ -35,7 +35,7 @@ export declare class TreeMultiMapNode<K = any, V = any, NODE extends TreeMultiMa
35
35
  */
36
36
  set count(value: number);
37
37
  }
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> {
38
+ export declare class TreeMultiMap<K = any, V = any, R = object, NODE extends TreeMultiMapNode<K, V, NODE> = TreeMultiMapNode<K, V, TreeMultiMapNodeNested<K, V>>> extends RedBlackTree<K, V, R, NODE> implements IBinaryTree<K, V, R, NODE> {
39
39
  /**
40
40
  * The constructor function initializes a TreeMultiMap object with optional initial data.
41
41
  * @param keysNodesEntriesOrRaws - The parameter `keysNodesEntriesOrRaws` is an
@@ -83,20 +83,7 @@ export declare class TreeMultiMap<K = any, V = any, R = object, NODE extends Tre
83
83
  * @returns a new instance of the `TreeMultiMap` class, with the provided options merged with the
84
84
  * existing `iterationType` property. The returned value is casted as `TREE`.
85
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];
86
+ createTree(options?: TreeMultiMapOptions<K, V, R>): TreeMultiMap<K, V, R, NODE>;
100
87
  /**
101
88
  * The function checks if the input is an instance of the TreeMultiMapNode class.
102
89
  * @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - The parameter
@@ -167,7 +154,36 @@ export declare class TreeMultiMap<K = any, V = any, R = object, NODE extends Tre
167
154
  * The function overrides the clone method to create a deep copy of a tree object.
168
155
  * @returns The `clone()` method is returning a cloned instance of the `TREE` object.
169
156
  */
170
- clone(): TREE;
157
+ clone(): TreeMultiMap<K, V, R, NODE>;
158
+ /**
159
+ * The `map` function in TypeScript overrides the default behavior to create a new TreeMultiMap with
160
+ * modified entries based on a provided callback.
161
+ * @param callback - The `callback` parameter is a function that will be called for each entry in the
162
+ * map. It takes four arguments:
163
+ * @param [options] - The `options` parameter in the `override map` function is of type
164
+ * `TreeMultiMapOptions<MK, MV, MR>`. This parameter allows you to provide additional configuration
165
+ * options when creating a new `TreeMultiMap` instance within the `map` function. These options could
166
+ * include things like
167
+ * @param {any} [thisArg] - The `thisArg` parameter in the `override map` function is used to specify
168
+ * the value of `this` when executing the `callback` function. It allows you to set the context
169
+ * (value of `this`) for the callback function when it is called within the `map` function. This
170
+ * @returns A new TreeMultiMap instance is being returned, which is populated with entries generated
171
+ * by the provided callback function.
172
+ */
173
+ map<MK, MV, MR>(callback: EntryCallback<K, V | undefined, [MK, MV]>, options?: TreeMultiMapOptions<MK, MV, MR>, thisArg?: any): TreeMultiMap<MK, MV, MR, TreeMultiMapNode<MK, MV, TreeMultiMapNodeNested<MK, MV>>>;
174
+ /**
175
+ * The function `keyValueNodeEntryRawToNodeAndValue` takes in a key, value, and count and returns a
176
+ * node based on the input.
177
+ * @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - The parameter
178
+ * `keyNodeEntryOrRaw` can be of type `R` or `BTNRep<K, V, NODE>`.
179
+ * @param {V} [value] - The `value` parameter is an optional value that represents the value
180
+ * associated with the key in the node. It is used when creating a new node or updating the value of
181
+ * an existing node.
182
+ * @param [count=1] - The `count` parameter is an optional parameter that specifies the number of
183
+ * times the key-value pair should be added to the data structure. If not provided, it defaults to 1.
184
+ * @returns either a NODE object or undefined.
185
+ */
186
+ protected _keyValueNodeEntryRawToNodeAndValue(keyNodeEntryOrRaw: BTNRep<K, V, NODE> | R, value?: V, count?: number): [NODE | undefined, V | undefined];
171
187
  /**
172
188
  * Time Complexity: O(1)
173
189
  * Space Complexity: O(1)
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TreeMultiMap = exports.TreeMultiMapNode = void 0;
4
- const rb_tree_1 = require("./rb-tree");
5
- class TreeMultiMapNode extends rb_tree_1.RedBlackTreeNode {
4
+ const red_black_tree_1 = require("./red-black-tree");
5
+ class TreeMultiMapNode extends red_black_tree_1.RedBlackTreeNode {
6
6
  /**
7
7
  * The constructor function initializes a Red-Black Tree node with a key, value, count, and color.
8
8
  * @param {K} key - The key parameter represents the key of the node in the Red-Black Tree. It is
@@ -37,7 +37,7 @@ class TreeMultiMapNode extends rb_tree_1.RedBlackTreeNode {
37
37
  }
38
38
  }
39
39
  exports.TreeMultiMapNode = TreeMultiMapNode;
40
- class TreeMultiMap extends rb_tree_1.RedBlackTree {
40
+ class TreeMultiMap extends red_black_tree_1.RedBlackTree {
41
41
  /**
42
42
  * The constructor function initializes a TreeMultiMap object with optional initial data.
43
43
  * @param keysNodesEntriesOrRaws - The parameter `keysNodesEntriesOrRaws` is an
@@ -98,43 +98,9 @@ class TreeMultiMap extends rb_tree_1.RedBlackTree {
98
98
  * @returns a new instance of the `TreeMultiMap` class, with the provided options merged with the
99
99
  * existing `iterationType` property. The returned value is casted as `TREE`.
100
100
  */
101
+ // @ts-ignore
101
102
  createTree(options) {
102
- return new TreeMultiMap([], Object.assign({ iterationType: this.iterationType, isMapMode: this._isMapMode, extractComparable: this._extractComparable, toEntryFn: this._toEntryFn }, options));
103
- }
104
- /**
105
- * The function `keyValueNodeEntryRawToNodeAndValue` takes in a key, value, and count and returns a
106
- * node based on the input.
107
- * @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - The parameter
108
- * `keyNodeEntryOrRaw` can be of type `R` or `BTNRep<K, V, NODE>`.
109
- * @param {V} [value] - The `value` parameter is an optional value that represents the value
110
- * associated with the key in the node. It is used when creating a new node or updating the value of
111
- * an existing node.
112
- * @param [count=1] - The `count` parameter is an optional parameter that specifies the number of
113
- * times the key-value pair should be added to the data structure. If not provided, it defaults to 1.
114
- * @returns either a NODE object or undefined.
115
- */
116
- keyValueNodeEntryRawToNodeAndValue(keyNodeEntryOrRaw, value, count = 1) {
117
- if (keyNodeEntryOrRaw === undefined || keyNodeEntryOrRaw === null)
118
- return [undefined, undefined];
119
- if (this.isNode(keyNodeEntryOrRaw))
120
- return [keyNodeEntryOrRaw, value];
121
- if (this.isEntry(keyNodeEntryOrRaw)) {
122
- const [key, entryValue] = keyNodeEntryOrRaw;
123
- if (key === undefined || key === null)
124
- return [undefined, undefined];
125
- const finalValue = value !== null && value !== void 0 ? value : entryValue;
126
- if (this.isKey(key))
127
- return [this.createNode(key, finalValue, 'BLACK', count), finalValue];
128
- }
129
- if (this.isRaw(keyNodeEntryOrRaw)) {
130
- const [key, entryValue] = this._toEntryFn(keyNodeEntryOrRaw);
131
- const finalValue = value !== null && value !== void 0 ? value : entryValue;
132
- if (this.isKey(key))
133
- return [this.createNode(key, finalValue, 'BLACK', count), finalValue];
134
- }
135
- if (this.isKey(keyNodeEntryOrRaw))
136
- return [this.createNode(keyNodeEntryOrRaw, value, 'BLACK', count), value];
137
- return [undefined, undefined];
103
+ return new TreeMultiMap([], Object.assign({ iterationType: this.iterationType, isMapMode: this._isMapMode, specifyComparable: this._specifyComparable, toEntryFn: this._toEntryFn }, options));
138
104
  }
139
105
  /**
140
106
  * The function checks if the input is an instance of the TreeMultiMapNode class.
@@ -163,7 +129,7 @@ class TreeMultiMap extends rb_tree_1.RedBlackTree {
163
129
  * was successful, and false otherwise.
164
130
  */
165
131
  add(keyNodeEntryOrRaw, value, count = 1) {
166
- const [newNode, newValue] = this.keyValueNodeEntryRawToNodeAndValue(keyNodeEntryOrRaw, value, count);
132
+ const [newNode, newValue] = this._keyValueNodeEntryRawToNodeAndValue(keyNodeEntryOrRaw, value, count);
167
133
  const orgCount = (newNode === null || newNode === void 0 ? void 0 : newNode.count) || 0;
168
134
  const isSuccessAdded = super.add(newNode, newValue);
169
135
  if (isSuccessAdded) {
@@ -353,6 +319,7 @@ class TreeMultiMap extends rb_tree_1.RedBlackTree {
353
319
  * The function overrides the clone method to create a deep copy of a tree object.
354
320
  * @returns The `clone()` method is returning a cloned instance of the `TREE` object.
355
321
  */
322
+ // @ts-ignore
356
323
  clone() {
357
324
  const cloned = this.createTree();
358
325
  this.bfs(node => cloned.add(node.key, undefined, node.count));
@@ -360,6 +327,65 @@ class TreeMultiMap extends rb_tree_1.RedBlackTree {
360
327
  cloned._store = this._store;
361
328
  return cloned;
362
329
  }
330
+ /**
331
+ * The `map` function in TypeScript overrides the default behavior to create a new TreeMultiMap with
332
+ * modified entries based on a provided callback.
333
+ * @param callback - The `callback` parameter is a function that will be called for each entry in the
334
+ * map. It takes four arguments:
335
+ * @param [options] - The `options` parameter in the `override map` function is of type
336
+ * `TreeMultiMapOptions<MK, MV, MR>`. This parameter allows you to provide additional configuration
337
+ * options when creating a new `TreeMultiMap` instance within the `map` function. These options could
338
+ * include things like
339
+ * @param {any} [thisArg] - The `thisArg` parameter in the `override map` function is used to specify
340
+ * the value of `this` when executing the `callback` function. It allows you to set the context
341
+ * (value of `this`) for the callback function when it is called within the `map` function. This
342
+ * @returns A new TreeMultiMap instance is being returned, which is populated with entries generated
343
+ * by the provided callback function.
344
+ */
345
+ // @ts-ignore
346
+ map(callback, options, thisArg) {
347
+ const newTree = new TreeMultiMap([], options);
348
+ let index = 0;
349
+ for (const [key, value] of this) {
350
+ newTree.add(callback.call(thisArg, key, value, index++, this));
351
+ }
352
+ return newTree;
353
+ }
354
+ /**
355
+ * The function `keyValueNodeEntryRawToNodeAndValue` takes in a key, value, and count and returns a
356
+ * node based on the input.
357
+ * @param {BTNRep<K, V, NODE> | R} keyNodeEntryOrRaw - The parameter
358
+ * `keyNodeEntryOrRaw` can be of type `R` or `BTNRep<K, V, NODE>`.
359
+ * @param {V} [value] - The `value` parameter is an optional value that represents the value
360
+ * associated with the key in the node. It is used when creating a new node or updating the value of
361
+ * an existing node.
362
+ * @param [count=1] - The `count` parameter is an optional parameter that specifies the number of
363
+ * times the key-value pair should be added to the data structure. If not provided, it defaults to 1.
364
+ * @returns either a NODE object or undefined.
365
+ */
366
+ _keyValueNodeEntryRawToNodeAndValue(keyNodeEntryOrRaw, value, count = 1) {
367
+ if (keyNodeEntryOrRaw === undefined || keyNodeEntryOrRaw === null)
368
+ return [undefined, undefined];
369
+ if (this.isNode(keyNodeEntryOrRaw))
370
+ return [keyNodeEntryOrRaw, value];
371
+ if (this.isEntry(keyNodeEntryOrRaw)) {
372
+ const [key, entryValue] = keyNodeEntryOrRaw;
373
+ if (key === undefined || key === null)
374
+ return [undefined, undefined];
375
+ const finalValue = value !== null && value !== void 0 ? value : entryValue;
376
+ if (this.isKey(key))
377
+ return [this.createNode(key, finalValue, 'BLACK', count), finalValue];
378
+ }
379
+ if (this.isRaw(keyNodeEntryOrRaw)) {
380
+ const [key, entryValue] = this._toEntryFn(keyNodeEntryOrRaw);
381
+ const finalValue = value !== null && value !== void 0 ? value : entryValue;
382
+ if (this.isKey(key))
383
+ return [this.createNode(key, finalValue, 'BLACK', count), finalValue];
384
+ }
385
+ if (this.isKey(keyNodeEntryOrRaw))
386
+ return [this.createNode(keyNodeEntryOrRaw, value, 'BLACK', count), value];
387
+ return [undefined, undefined];
388
+ }
363
389
  /**
364
390
  * Time Complexity: O(1)
365
391
  * Space Complexity: O(1)
@@ -1 +1 @@
1
- {"version":3,"file":"tree-multi-map.js","sourceRoot":"","sources":["../../../../src/data-structures/binary-tree/tree-multi-map.ts"],"names":[],"mappings":";;;AAmBA,uCAA2D;AAE3D,MAAa,gBAIX,SAAQ,0BAA4B;IACpC;;;;;;;;;;;OAWG;IACH,YAAY,GAAM,EAAE,KAAS,EAAE,KAAK,GAAG,CAAC,EAAE,QAAmB,OAAO;QAClE,KAAK,CAAC,GAAG,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;QAIjB,WAAM,GAAW,CAAC,CAAC;QAH3B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAID;;;OAGG;IACH,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED;;;;OAIG;IACH,IAAI,KAAK,CAAC,KAAa;QACrB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACtB,CAAC;CACF;AAxCD,4CAwCC;AAED,MAAa,YAOX,SAAQ,sBAAiC;IAGzC;;;;;;;;OAQG;IACH,YAAY,yBAAuD,EAAE,EAAE,OAAsC;QAC3G,KAAK,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;QAIX,WAAM,GAAG,CAAC,CAAC;QAHnB,IAAI,sBAAsB;YAAE,IAAI,CAAC,OAAO,CAAC,sBAAsB,CAAC,CAAC;IACnE,CAAC;IAID,6DAA6D;IAC7D;;;OAGG;IACH,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED;;;;;;;OAOG;IACH,gBAAgB;QACd,IAAI,GAAG,GAAG,CAAC,CAAC;QACZ,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;QACtC,OAAO,GAAG,CAAC;IACb,CAAC;IAED;;;;;;;;;;;;O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,GAAG,QAAQ,CAAC,KAAK,CAAC;gBAC/B,OAAO,CAAC,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC;YACjC,CAAC;YAED,OAAO,QAAQ,CAAC;QAClB,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;;;;;;;;;OAUG;IACgB,YAAY,CAAC,OAAa,EAAE,OAAa;QAC1D,OAAO,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAC9C,OAAO,KAAK,CAAC,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC9C,CAAC;CACF;AArZD,oCAqZC"}
1
+ {"version":3,"file":"tree-multi-map.js","sourceRoot":"","sources":["../../../../src/data-structures/binary-tree/tree-multi-map.ts"],"names":[],"mappings":";;;AAmBA,qDAAkE;AAElE,MAAa,gBAIX,SAAQ,iCAA4B;IACpC;;;;;;;;;;;OAWG;IACH,YAAY,GAAM,EAAE,KAAS,EAAE,KAAK,GAAG,CAAC,EAAE,QAAmB,OAAO;QAClE,KAAK,CAAC,GAAG,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;QAIjB,WAAM,GAAW,CAAC,CAAC;QAH3B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAID;;;OAGG;IACH,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED;;;;OAIG;IACH,IAAI,KAAK,CAAC,KAAa;QACrB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACtB,CAAC;CACF;AAxCD,4CAwCC;AAED,MAAa,YAMX,SAAQ,6BAA2B;IAGnC;;;;;;;;OAQG;IACH,YAAY,yBAAuD,EAAE,EAAE,OAAsC;QAC3G,KAAK,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;QAIX,WAAM,GAAG,CAAC,CAAC;QAHnB,IAAI,sBAAsB;YAAE,IAAI,CAAC,OAAO,CAAC,sBAAsB,CAA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