tree-multimap-typed 2.4.5 → 2.5.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 (67) hide show
  1. package/dist/types/data-structures/base/iterable-element-base.d.ts +1 -1
  2. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +128 -51
  3. package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +210 -164
  4. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +429 -78
  5. package/dist/types/data-structures/binary-tree/bst.d.ts +311 -28
  6. package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +212 -32
  7. package/dist/types/data-structures/binary-tree/segment-tree.d.ts +218 -152
  8. package/dist/types/data-structures/binary-tree/tree-map.d.ts +1281 -5
  9. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +1087 -201
  10. package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +858 -65
  11. package/dist/types/data-structures/binary-tree/tree-set.d.ts +1133 -5
  12. package/dist/types/data-structures/graph/directed-graph.d.ts +219 -47
  13. package/dist/types/data-structures/graph/map-graph.d.ts +59 -1
  14. package/dist/types/data-structures/graph/undirected-graph.d.ts +204 -59
  15. package/dist/types/data-structures/hash/hash-map.d.ts +230 -77
  16. package/dist/types/data-structures/heap/heap.d.ts +287 -99
  17. package/dist/types/data-structures/heap/max-heap.d.ts +46 -0
  18. package/dist/types/data-structures/heap/min-heap.d.ts +59 -0
  19. package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +286 -44
  20. package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +278 -65
  21. package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +415 -12
  22. package/dist/types/data-structures/matrix/matrix.d.ts +331 -0
  23. package/dist/types/data-structures/priority-queue/max-priority-queue.d.ts +57 -0
  24. package/dist/types/data-structures/priority-queue/min-priority-queue.d.ts +60 -0
  25. package/dist/types/data-structures/priority-queue/priority-queue.d.ts +60 -0
  26. package/dist/types/data-structures/queue/deque.d.ts +272 -65
  27. package/dist/types/data-structures/queue/queue.d.ts +211 -42
  28. package/dist/types/data-structures/stack/stack.d.ts +174 -32
  29. package/dist/types/data-structures/trie/trie.d.ts +213 -43
  30. package/dist/types/types/data-structures/binary-tree/segment-tree.d.ts +1 -1
  31. package/dist/types/types/data-structures/linked-list/skip-linked-list.d.ts +1 -4
  32. package/dist/umd/tree-multimap-typed.js +10290 -2125
  33. package/dist/umd/tree-multimap-typed.js.map +1 -1
  34. package/dist/umd/tree-multimap-typed.min.js +4 -4
  35. package/dist/umd/tree-multimap-typed.min.js.map +1 -1
  36. package/package.json +2 -2
  37. package/src/data-structures/base/iterable-element-base.ts +4 -5
  38. package/src/data-structures/binary-tree/avl-tree.ts +134 -51
  39. package/src/data-structures/binary-tree/binary-indexed-tree.ts +302 -247
  40. package/src/data-structures/binary-tree/binary-tree.ts +429 -79
  41. package/src/data-structures/binary-tree/bst.ts +335 -34
  42. package/src/data-structures/binary-tree/red-black-tree.ts +290 -97
  43. package/src/data-structures/binary-tree/segment-tree.ts +372 -248
  44. package/src/data-structures/binary-tree/tree-map.ts +1284 -6
  45. package/src/data-structures/binary-tree/tree-multi-map.ts +1094 -211
  46. package/src/data-structures/binary-tree/tree-multi-set.ts +858 -65
  47. package/src/data-structures/binary-tree/tree-set.ts +1136 -9
  48. package/src/data-structures/graph/directed-graph.ts +219 -47
  49. package/src/data-structures/graph/map-graph.ts +59 -1
  50. package/src/data-structures/graph/undirected-graph.ts +204 -59
  51. package/src/data-structures/hash/hash-map.ts +230 -77
  52. package/src/data-structures/heap/heap.ts +287 -99
  53. package/src/data-structures/heap/max-heap.ts +46 -0
  54. package/src/data-structures/heap/min-heap.ts +59 -0
  55. package/src/data-structures/linked-list/doubly-linked-list.ts +286 -44
  56. package/src/data-structures/linked-list/singly-linked-list.ts +278 -65
  57. package/src/data-structures/linked-list/skip-linked-list.ts +689 -90
  58. package/src/data-structures/matrix/matrix.ts +416 -12
  59. package/src/data-structures/priority-queue/max-priority-queue.ts +57 -0
  60. package/src/data-structures/priority-queue/min-priority-queue.ts +60 -0
  61. package/src/data-structures/priority-queue/priority-queue.ts +60 -0
  62. package/src/data-structures/queue/deque.ts +272 -65
  63. package/src/data-structures/queue/queue.ts +211 -42
  64. package/src/data-structures/stack/stack.ts +174 -32
  65. package/src/data-structures/trie/trie.ts +213 -43
  66. package/src/types/data-structures/binary-tree/segment-tree.ts +1 -1
  67. package/src/types/data-structures/linked-list/skip-linked-list.ts +2 -1
@@ -27,7 +27,7 @@ export declare abstract class IterableElementBase<E, R> implements Iterable<E> {
27
27
  * @remarks
28
28
  * Time O(1), Space O(1).
29
29
  */
30
- protected readonly _toElementFn?: (rawElement: R) => E;
30
+ protected _toElementFn?: (rawElement: R) => E;
31
31
  /**
32
32
  * Exposes the current `toElementFn`, if configured.
33
33
  *
@@ -80,12 +80,6 @@ export declare class AVLTreeNode<K = any, V = any> {
80
80
  * @returns The node's color.
81
81
  */
82
82
  get color(): RBTNColor;
83
- /**
84
- * Sets the color of the node.
85
- * @remarks Time O(1), Space O(1)
86
- *
87
- * @param value - The new color.
88
- */
89
83
  set color(value: RBTNColor);
90
84
  _count: number;
91
85
  /**
@@ -95,12 +89,6 @@ export declare class AVLTreeNode<K = any, V = any> {
95
89
  * @returns The subtree node count.
96
90
  */
97
91
  get count(): number;
98
- /**
99
- * Sets the count of nodes in the subtree.
100
- * @remarks Time O(1), Space O(1)
101
- *
102
- * @param value - The new count.
103
- */
104
92
  set count(value: number);
105
93
  /**
106
94
  * Gets the position of the node relative to its parent.
@@ -127,28 +115,6 @@ export declare class AVLTreeNode<K = any, V = any> {
127
115
  * 7. Path Length: The path length from the root to any leaf is longer compared to an unbalanced BST, but shorter than a linear chain of nodes.
128
116
  *
129
117
  * @example
130
- * // basic AVLTree creation and add operation
131
- * // Create a simple AVLTree with initial values
132
- * const tree = new AVLTree([5, 2, 8, 1, 9]);
133
- *
134
- * tree.print();
135
- * // _2___
136
- * // / \
137
- * // 1 _8_
138
- * // / \
139
- * // 5 9
140
- *
141
- * // Verify the tree maintains sorted order
142
- * console.log([...tree.keys()]); // [1, 2, 5, 8, 9];
143
- *
144
- * // Check size
145
- * console.log(tree.size); // 5;
146
- *
147
- * // Add a new element
148
- * tree.set(3);
149
- * console.log(tree.size); // 6;
150
- * console.log([...tree.keys()]); // [1, 2, 3, 5, 8, 9];
151
- * @example
152
118
  * // AVLTree has and get operations
153
119
  * const tree = new AVLTree<number>([11, 3, 15, 1, 8, 13, 16, 2, 6, 9, 12, 14, 4, 7, 10, 5]);
154
120
  *
@@ -163,23 +129,6 @@ export declare class AVLTreeNode<K = any, V = any> {
163
129
  * // Verify tree is balanced
164
130
  * console.log(tree.isAVLBalanced()); // true;
165
131
  * @example
166
- * // AVLTree delete and balance verification
167
- * const tree = new AVLTree([11, 3, 15, 1, 8, 13, 16, 2, 6, 9, 12, 14, 4, 7, 10, 5]);
168
- *
169
- * // Delete an element
170
- * tree.delete(10);
171
- * console.log(tree.has(10)); // false;
172
- *
173
- * // Tree should remain balanced after deletion
174
- * console.log(tree.isAVLBalanced()); // true;
175
- *
176
- * // Size decreased
177
- * console.log(tree.size); // 15;
178
- *
179
- * // Remaining elements are still sorted
180
- * const keys = [...tree.keys()];
181
- * console.log(keys); // [1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16];
182
- * @example
183
132
  * // AVLTree for university ranking system with strict balance
184
133
  * interface University {
185
134
  * name: string;
@@ -318,6 +267,48 @@ export declare class AVLTree<K = any, V = any, R = any> extends BST<K, V, R> imp
318
267
  * @param keyNodeOrEntry - The key, node, or entry to set.
319
268
  * @param [value] - The value, if providing just a key.
320
269
  * @returns True if the addition was successful, false otherwise.
270
+
271
+
272
+
273
+
274
+
275
+
276
+
277
+
278
+
279
+
280
+
281
+
282
+
283
+
284
+
285
+
286
+
287
+
288
+
289
+
290
+
291
+
292
+
293
+
294
+
295
+
296
+
297
+
298
+
299
+
300
+
301
+
302
+
303
+
304
+
305
+
306
+ * @example
307
+ * // Set a key-value pair
308
+ * const avl = new AVLTree<number, string>();
309
+ * avl.set(1, 'one');
310
+ * avl.set(2, 'two');
311
+ * console.log(avl.get(1)); // 'one';
321
312
  */
322
313
  set(keyNodeOrEntry: K | AVLTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, value?: V): boolean;
323
314
  /**
@@ -326,6 +317,45 @@ export declare class AVLTree<K = any, V = any, R = any> extends BST<K, V, R> imp
326
317
  *
327
318
  * @param keyNodeOrEntry - The node to delete.
328
319
  * @returns An array containing deletion results.
320
+
321
+
322
+
323
+
324
+
325
+
326
+
327
+
328
+
329
+
330
+
331
+
332
+
333
+
334
+
335
+
336
+
337
+
338
+
339
+
340
+
341
+
342
+
343
+
344
+
345
+
346
+
347
+
348
+
349
+
350
+
351
+
352
+
353
+ * @example
354
+ * // Remove nodes and verify structure
355
+ * const avl = new AVLTree<number>([5, 3, 7, 1, 4, 6, 8]);
356
+ * avl.delete(3);
357
+ * console.log(avl.has(3)); // false;
358
+ * console.log(avl.size); // 6;
329
359
  */
330
360
  delete(keyNodeOrEntry: K | AVLTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined): BinaryTreeDeleteResult<AVLTreeNode<K, V>>[];
331
361
  /**
@@ -335,6 +365,26 @@ export declare class AVLTree<K = any, V = any, R = any> extends BST<K, V, R> imp
335
365
  *
336
366
  * @param [iterationType=this.iterationType] - The traversal method for the initial node export.
337
367
  * @returns True if successful, false if the tree was empty.
368
+
369
+
370
+
371
+
372
+
373
+
374
+
375
+
376
+
377
+
378
+
379
+
380
+ * @example
381
+ * // Rebalance the tree
382
+ * const avl = new AVLTree<number>();
383
+ * // Insert in sorted order (worst case for BST)
384
+ * for (let i = 1; i <= 7; i++) avl.add(i);
385
+ * console.log(avl.isAVLBalanced()); // false;
386
+ * avl.perfectlyBalance();
387
+ * console.log(avl.isAVLBalanced()); // true;
338
388
  */
339
389
  perfectlyBalance(iterationType?: IterationType): boolean;
340
390
  /**
@@ -348,6 +398,33 @@ export declare class AVLTree<K = any, V = any, R = any> extends BST<K, V, R> imp
348
398
  * @param [options] - Options for the new AVLTree.
349
399
  * @param [thisArg] - `this` context for the callback.
350
400
  * @returns A new, mapped AVLTree.
401
+
402
+
403
+
404
+
405
+
406
+
407
+
408
+
409
+
410
+
411
+
412
+
413
+
414
+
415
+
416
+
417
+
418
+
419
+
420
+
421
+
422
+
423
+ * @example
424
+ * // Transform to new tree
425
+ * const avl = new AVLTree<number, number>([[1, 10], [2, 20], [3, 30]]);
426
+ * const doubled = avl.map((value, key) => [key, (value ?? 0) * 2] as [number, number]);
427
+ * console.log([...doubled.values()]); // [20, 40, 60];
351
428
  */
352
429
  map<MK = K, MV = V, MR = any>(callback: EntryCallback<K, V | undefined, [MK, MV]>, options?: Partial<BinaryTreeOptions<MK, MV, MR>>, thisArg?: unknown): AVLTree<MK, MV, MR>;
353
430
  /**
@@ -1,174 +1,220 @@
1
1
  /**
2
+ * Binary Indexed Tree (Fenwick Tree).
2
3
  *
4
+ * Efficient prefix sums and point updates in O(log n).
5
+ * Standard array-based implementation per C++ competitive programming conventions.
6
+ *
7
+ * All indices are 0-based externally; internally converted to 1-based for BIT arithmetic.
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * const bit = new BinaryIndexedTree(6);
12
+ * bit.update(0, 3); // index 0 += 3
13
+ * bit.update(1, 2); // index 1 += 2
14
+ * bit.update(2, 7); // index 2 += 7
15
+ *
16
+ * bit.query(2); // prefix sum [0..2] = 12
17
+ * bit.queryRange(1, 2); // range sum [1..2] = 9
18
+ * bit.get(1); // point value at index 1 = 2
19
+ * ```
3
20
  */
4
- export declare class BinaryIndexedTree {
5
- protected readonly _freq: number;
6
- protected readonly _max: number;
7
- /**
8
- * The constructor initializes the properties of an object, including default frequency, maximum
9
- * value, a freqMap data structure, the most significant bit, and the count of negative frequencies.
10
- * @param - - `frequency`: The default frequency value. It is optional and has a default
11
- * value of 0.
12
- */
13
- constructor({ frequency, max }: {
14
- frequency?: number;
15
- max: number;
16
- });
17
- protected _freqMap: Record<number, number>;
18
- /**
19
- * The function returns the frequency map of numbers.
20
- * @returns The `_freqMap` property, which is a record with number keys and number values, is being
21
- * returned.
22
- */
23
- get freqMap(): Record<number, number>;
24
- protected _msb: number;
25
- /**
26
- * The function returns the value of the _msb property.
27
- * @returns The `_msb` property of the object.
28
- */
29
- get msb(): number;
30
- protected _negativeCount: number;
31
- /**
32
- * The function returns the value of the _negativeCount property.
33
- * @returns The method is returning the value of the variable `_negativeCount`, which is of type
34
- * `number`.
35
- */
36
- get negativeCount(): number;
37
- /**
38
- * The above function returns the value of the protected variable `_freq`.
39
- * @returns The frequency value stored in the protected variable `_freq`.
40
- */
41
- get freq(): number;
42
- /**
43
- * The above function returns the maximum value.
44
- * @returns The maximum value stored in the variable `_max`.
45
- */
46
- get max(): number;
47
- /**
48
- * The function "readSingle" reads a single number from a specified index.
49
- * @param {number} index - The `index` parameter is a number that represents the index of an element in a
50
- * collection or array.
51
- * @returns a number.
52
- */
53
- readSingle(index: number): number;
54
- /**
55
- * The "update" function updates the value at a given index by adding a delta and triggers a callback
56
- * to notify of the change.
57
- * @param {number} position - The `index` parameter represents the index of the element that needs to be
58
- * updated in the data structure.
59
- * @param {number} change - The "delta" parameter represents the change in value that needs to be
60
- * applied to the frequency at the specified index.
61
- */
62
- update(position: number, change: number): void;
63
- /**
64
- * The function "writeSingle" checks the index and writes a single value with a given frequency.
65
- * @param {number} index - The `index` parameter is a number that represents the index of an element. It
66
- * is used to identify the specific element that needs to be written.
67
- * @param {number} freq - The `freq` parameter represents the frequency value that needs to be
68
- * written.
69
- */
70
- writeSingle(index: number, freq: number): void;
71
- /**
72
- * The read function takes a count parameter, checks if it is an integer, and returns the result of
73
- * calling the _read function with the count parameter clamped between 0 and the maximum value.
74
- * @param {number} count - The `count` parameter is a number that represents the number of items to
75
- * read.
76
- * @returns a number.
77
- */
78
- read(count: number): number;
79
- /**
80
- * The function returns the lower bound of a non-descending sequence that sums up to a given number.
81
- * @param {number} sum - The `sum` parameter is a number that represents the target sum that we want
82
- * to find in the sequence.
83
- * @returns The lowerBound function is returning a number.
21
+ export declare class BinaryIndexedTree implements Iterable<number> {
22
+ protected readonly _size: number;
23
+ protected _tree: number[];
24
+ /**
25
+ * Construct a BIT of given size (all zeros), or from an initial values array.
26
+ * @param sizeOrElements - number of elements, or an array of initial values
27
+ */
28
+ constructor(sizeOrElements: number | number[]);
29
+ /**
30
+ * Point update: add delta to the value at index (0-based).
31
+ * Time: O(log n)
32
+
33
+
34
+
35
+
36
+
37
+
38
+
39
+
40
+
41
+
42
+
43
+
44
+
45
+
46
+ * @example
47
+ * // Add delta at index
48
+ * const bit = new BinaryIndexedTree([1, 2, 3, 4, 5]);
49
+ * bit.update(2, 7);
50
+ * console.log(bit.get(2)); // 10;
51
+ */
52
+ update(index: number, delta: number): void;
53
+ /**
54
+ * Point set: set the value at index to an absolute value (0-based).
55
+ * Time: O(log n)
56
+
57
+
58
+
59
+
60
+
61
+
62
+
63
+
64
+
65
+
66
+
67
+
68
+
69
+
70
+
71
+ * @example
72
+ * // Set value at index
73
+ * const bit = new BinaryIndexedTree([1, 2, 3]);
74
+ * bit.set(1, 10);
75
+ * console.log(bit.get(1)); // 10;
76
+ */
77
+ set(index: number, value: number): void;
78
+ /**
79
+ * Get the point value at index (0-based).
80
+ * Time: O(log n)
81
+
82
+
83
+
84
+
85
+
86
+
87
+
88
+
89
+
90
+
91
+
92
+
93
+
94
+
95
+ * @example
96
+ * // Get value at index
97
+ * const bit = new BinaryIndexedTree([1, 2, 3]);
98
+ * console.log(bit.get(0)); // 1;
99
+ * console.log(bit.get(2)); // 3;
100
+ */
101
+ get(index: number): number;
102
+ /**
103
+ * Prefix sum query: returns sum of elements [0..index] (inclusive, 0-based).
104
+ * Time: O(log n)
105
+
106
+
107
+
108
+
109
+
110
+
111
+
112
+
113
+
114
+
115
+
116
+
117
+
118
+
119
+
120
+ * @example
121
+ * // Prefix sum
122
+ * const bit = new BinaryIndexedTree([1, 2, 3, 4]);
123
+ * console.log(bit.query(2)); // 6;
124
+ */
125
+ query(index: number): number;
126
+ /**
127
+ * Range sum query: returns sum of elements [start..end] (inclusive, 0-based).
128
+ * Time: O(log n)
129
+
130
+
131
+
132
+
133
+
134
+
135
+
136
+
137
+
138
+
139
+
140
+
141
+
142
+
143
+ * @example
144
+ * // Range sum
145
+ * const bit = new BinaryIndexedTree([1, 2, 3, 4]);
146
+ * console.log(bit.queryRange(1, 2)); // 5;
147
+ */
148
+ queryRange(start: number, end: number): number;
149
+ /**
150
+ * Find the smallest index i such that prefix sum [0..i] >= sum.
151
+ * Requires all values to be non-negative (behavior undefined otherwise).
152
+ * Returns size if no such index exists.
153
+ * Time: O(log n)
154
+
155
+
156
+
157
+
158
+
159
+
160
+
161
+
162
+
163
+
164
+
165
+
166
+
167
+
168
+
169
+ * @example
170
+ * // Find index with prefix sum ≥ target
171
+ * const bit = new BinaryIndexedTree([1, 2, 3, 4]);
172
+ * const idx = bit.lowerBound(4);
173
+ * console.log(idx); // >= 0;
84
174
  */
85
175
  lowerBound(sum: number): number;
86
176
  /**
87
- * The upperBound function returns the index of the first element in a sequence that is greater than
88
- * or equal to a given sum.
89
- * @param {number} sum - The "sum" parameter is a number that represents the target sum that we want
90
- * to find in the sequence.
91
- * @returns The upperBound function is returning a number.
177
+ * Find the smallest index i such that prefix sum [0..i] > sum.
178
+ * Requires all values to be non-negative (behavior undefined otherwise).
179
+ * Returns size if no such index exists.
180
+ * Time: O(log n)
181
+
182
+
183
+ * @example
184
+ * // Find index with prefix sum > target
185
+ * const bit = new BinaryIndexedTree([1, 2, 3, 4]);
186
+ * const idx = bit.upperBound(4);
187
+ * console.log(idx); // >= 0;
92
188
  */
93
189
  upperBound(sum: number): number;
94
- /**
95
- * The function calculates the prefix sum of an array using a binary indexed tree.
96
- * @param {number} i - The parameter "i" in the function "getPrefixSum" represents the index of the element in the
97
- * array for which we want to calculate the prefix sum.
98
- * @returns The function `getPrefixSum` returns the prefix sum of the elements in the binary indexed tree up to index
99
- * `i`.
100
- */
101
- getPrefixSum(i: number): number;
102
- /**
103
- * The function returns the value of a specific index in a freqMap data structure, or a default value if
104
- * the index is not found.
105
- * @param {number} index - The `index` parameter is a number that represents the index of a node in a
106
- * freqMap data structure.
107
- * @returns a number.
108
- */
109
- protected _getFrequency(index: number): number;
110
- /**
111
- * The function _updateFrequency adds a delta value to the element at the specified index in the freqMap array.
112
- * @param {number} index - The index parameter is a number that represents the index of the freqMap
113
- * element that needs to be updated.
114
- * @param {number} delta - The `delta` parameter represents the change in value that needs to be
115
- * added to the freqMap at the specified `index`.
116
- */
117
- protected _updateFrequency(index: number, delta: number): void;
118
- /**
119
- * The function checks if the given index is valid and within the range.
120
- * @param {number} index - The parameter "index" is of type number and represents the index value
121
- * that needs to be checked.
122
- */
190
+ get size(): number;
191
+ isEmpty(): boolean;
192
+ clear(): void;
193
+ clone(): BinaryIndexedTree;
194
+ /**
195
+ * Returns the point values as a plain array.
196
+ * Time: O(n log n)
197
+
198
+
199
+ * @example
200
+ * // Convert to array
201
+ * const bit = new BinaryIndexedTree([1, 2, 3]);
202
+ * console.log(bit.toArray()); // [1, 2, 3];
203
+ */
204
+ toArray(): number[];
205
+ /**
206
+ * Iterate over point values in index order.
207
+ */
208
+ [Symbol.iterator](): IterableIterator<number>;
209
+ forEach(callback: (value: number, index: number) => void): void;
210
+ print(): void;
211
+ /** 1-based prefix sum up to pos (inclusive). */
212
+ protected _prefixSum(pos: number): number;
213
+ /** 1-based point update: add delta to position pos. */
214
+ protected _pointUpdate(pos: number, delta: number): void;
215
+ /** 1-based point query: get exact value at pos. */
216
+ protected _pointQuery(pos: number): number;
123
217
  protected _checkIndex(index: number): void;
124
- /**
125
- * The function calculates the sum of elements in an array up to a given index using a binary indexed
126
- * freqMap.
127
- * @param {number} index - The `index` parameter is a number that represents the index of an element in a
128
- * data structure.
129
- * @returns a number.
130
- */
131
- protected _readSingle(index: number): number;
132
- /**
133
- * The function `_updateNegativeCount` updates a counter based on changes in frequency values.
134
- * @param {number} freqCur - The current frequency value.
135
- * @param {number} freqNew - The freqNew parameter represents the new frequency value.
136
- */
137
- protected _updateNegativeCount(freqCur: number, freqNew: number): void;
138
- /**
139
- * The `_update` function updates the values in a binary indexed freqMap starting from a given index and
140
- * propagating the changes to its parent nodes.
141
- * @param {number} index - The `index` parameter is a number that represents the index of the element in
142
- * the data structure that needs to be updated.
143
- * @param {number} delta - The `delta` parameter represents the change in value that needs to be
144
- * applied to the elements in the data structure.
145
- */
146
- protected _update(index: number, delta: number): void;
147
- /**
148
- * The `_writeSingle` function updates the frequency at a specific index and triggers a callback if
149
- * the frequency has changed.
150
- * @param {number} index - The `index` parameter is a number that represents the index of the element
151
- * being modified or accessed.
152
- * @param {number} freq - The `freq` parameter represents the new frequency value that needs to be
153
- * written to the specified index `index`.
154
- */
155
- protected _writeSingle(index: number, freq: number): void;
156
- /**
157
- * The `_read` function calculates the sum of values in a binary freqMap up to a given count.
158
- * @param {number} count - The `count` parameter is a number that represents the number of elements
159
- * to read from the freqMap.
160
- * @returns the sum of the values obtained from calling the `_getFrequency` method for each index in the
161
- * range from `count` to 1.
162
- */
163
- protected _read(count: number): number;
164
- /**
165
- * The function `_binarySearch` performs a binary search to find the largest number that satisfies a given
166
- * condition.
167
- * @param {number} sum - The sum parameter is a number that represents the target sum value.
168
- * @param before - The `before` parameter is a function that takes two numbers `x` and `y` as
169
- * arguments and returns a boolean value. It is used to determine if `x` is less than or equal to
170
- * `y`. The purpose of this function is to compare two numbers and determine their order.
171
- * @returns the value of the variable "left".
172
- */
173
- protected _binarySearch(sum: number, before: (x: number, y: number) => boolean): number;
218
+ /** Returns highest power of 2 <= n. */
219
+ protected _highBit(n: number): number;
174
220
  }