min-heap-typed 1.50.1 → 1.50.3

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 (85) hide show
  1. package/dist/data-structures/base/iterable-base.d.ts +120 -9
  2. package/dist/data-structures/base/iterable-base.js +143 -7
  3. package/dist/data-structures/binary-tree/avl-tree.d.ts +72 -47
  4. package/dist/data-structures/binary-tree/avl-tree.js +101 -72
  5. package/dist/data-structures/binary-tree/binary-indexed-tree.d.ts +22 -0
  6. package/dist/data-structures/binary-tree/binary-indexed-tree.js +22 -0
  7. package/dist/data-structures/binary-tree/binary-tree.d.ts +244 -199
  8. package/dist/data-structures/binary-tree/binary-tree.js +484 -376
  9. package/dist/data-structures/binary-tree/bst.d.ts +92 -79
  10. package/dist/data-structures/binary-tree/bst.js +68 -76
  11. package/dist/data-structures/binary-tree/rb-tree.d.ts +127 -57
  12. package/dist/data-structures/binary-tree/rb-tree.js +152 -99
  13. package/dist/data-structures/binary-tree/segment-tree.d.ts +99 -6
  14. package/dist/data-structures/binary-tree/segment-tree.js +127 -10
  15. package/dist/data-structures/binary-tree/tree-multimap.d.ts +72 -58
  16. package/dist/data-structures/binary-tree/tree-multimap.js +102 -85
  17. package/dist/data-structures/graph/abstract-graph.d.ts +1 -78
  18. package/dist/data-structures/graph/abstract-graph.js +3 -189
  19. package/dist/data-structures/graph/directed-graph.d.ts +73 -0
  20. package/dist/data-structures/graph/directed-graph.js +131 -0
  21. package/dist/data-structures/graph/map-graph.d.ts +8 -0
  22. package/dist/data-structures/graph/map-graph.js +14 -0
  23. package/dist/data-structures/graph/undirected-graph.d.ts +76 -7
  24. package/dist/data-structures/graph/undirected-graph.js +151 -18
  25. package/dist/data-structures/hash/hash-map.d.ts +254 -28
  26. package/dist/data-structures/hash/hash-map.js +347 -78
  27. package/dist/data-structures/heap/heap.d.ts +95 -25
  28. package/dist/data-structures/heap/heap.js +95 -26
  29. package/dist/data-structures/linked-list/doubly-linked-list.d.ts +126 -63
  30. package/dist/data-structures/linked-list/doubly-linked-list.js +141 -77
  31. package/dist/data-structures/linked-list/singly-linked-list.d.ts +154 -106
  32. package/dist/data-structures/linked-list/singly-linked-list.js +164 -115
  33. package/dist/data-structures/linked-list/skip-linked-list.d.ts +63 -36
  34. package/dist/data-structures/linked-list/skip-linked-list.js +63 -36
  35. package/dist/data-structures/matrix/matrix.d.ts +35 -4
  36. package/dist/data-structures/matrix/matrix.js +50 -11
  37. package/dist/data-structures/priority-queue/max-priority-queue.d.ts +10 -0
  38. package/dist/data-structures/priority-queue/max-priority-queue.js +10 -0
  39. package/dist/data-structures/priority-queue/min-priority-queue.d.ts +11 -0
  40. package/dist/data-structures/priority-queue/min-priority-queue.js +11 -0
  41. package/dist/data-structures/priority-queue/priority-queue.d.ts +8 -0
  42. package/dist/data-structures/priority-queue/priority-queue.js +8 -0
  43. package/dist/data-structures/queue/deque.d.ts +139 -35
  44. package/dist/data-structures/queue/deque.js +200 -62
  45. package/dist/data-structures/queue/queue.d.ts +103 -49
  46. package/dist/data-structures/queue/queue.js +111 -49
  47. package/dist/data-structures/stack/stack.d.ts +51 -21
  48. package/dist/data-structures/stack/stack.js +58 -22
  49. package/dist/data-structures/tree/tree.d.ts +57 -3
  50. package/dist/data-structures/tree/tree.js +77 -11
  51. package/dist/data-structures/trie/trie.d.ts +135 -34
  52. package/dist/data-structures/trie/trie.js +153 -33
  53. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +1 -1
  54. package/dist/types/data-structures/hash/hash-map.d.ts +4 -3
  55. package/dist/types/utils/utils.d.ts +1 -0
  56. package/package.json +2 -2
  57. package/src/data-structures/base/iterable-base.ts +184 -19
  58. package/src/data-structures/binary-tree/avl-tree.ts +134 -100
  59. package/src/data-structures/binary-tree/binary-indexed-tree.ts +22 -0
  60. package/src/data-structures/binary-tree/binary-tree.ts +674 -671
  61. package/src/data-structures/binary-tree/bst.ts +127 -136
  62. package/src/data-structures/binary-tree/rb-tree.ts +199 -166
  63. package/src/data-structures/binary-tree/segment-tree.ts +145 -11
  64. package/src/data-structures/binary-tree/tree-multimap.ts +138 -115
  65. package/src/data-structures/graph/abstract-graph.ts +4 -211
  66. package/src/data-structures/graph/directed-graph.ts +152 -0
  67. package/src/data-structures/graph/map-graph.ts +15 -0
  68. package/src/data-structures/graph/undirected-graph.ts +171 -19
  69. package/src/data-structures/hash/hash-map.ts +389 -96
  70. package/src/data-structures/heap/heap.ts +97 -26
  71. package/src/data-structures/linked-list/doubly-linked-list.ts +156 -83
  72. package/src/data-structures/linked-list/singly-linked-list.ts +174 -120
  73. package/src/data-structures/linked-list/skip-linked-list.ts +63 -37
  74. package/src/data-structures/matrix/matrix.ts +52 -12
  75. package/src/data-structures/priority-queue/max-priority-queue.ts +10 -0
  76. package/src/data-structures/priority-queue/min-priority-queue.ts +11 -0
  77. package/src/data-structures/priority-queue/priority-queue.ts +8 -0
  78. package/src/data-structures/queue/deque.ts +225 -70
  79. package/src/data-structures/queue/queue.ts +118 -49
  80. package/src/data-structures/stack/stack.ts +63 -23
  81. package/src/data-structures/tree/tree.ts +89 -15
  82. package/src/data-structures/trie/trie.ts +173 -38
  83. package/src/types/data-structures/binary-tree/binary-tree.ts +1 -1
  84. package/src/types/data-structures/hash/hash-map.ts +4 -3
  85. package/src/types/utils/utils.ts +2 -0
@@ -15,16 +15,68 @@ import { IterableElementBase } from '../base';
15
15
  * 5. Performance jitter: Deque may experience performance jitter, but DoublyLinkedList will not
16
16
  */
17
17
  export declare class Deque<E> extends IterableElementBase<E> {
18
+ /**
19
+ * The constructor initializes a Deque object with an optional iterable of elements and options.
20
+ * @param elements - An iterable object (such as an array or a Set) that contains the initial
21
+ * elements to be added to the deque. It can also be an object with a `length` or `size` property
22
+ * that represents the number of elements in the iterable object. If no elements are provided, an
23
+ * empty deque
24
+ * @param {DequeOptions} [options] - The `options` parameter is an optional object that can contain
25
+ * configuration options for the deque. In this code, it is used to set the `bucketSize` option,
26
+ * which determines the size of each bucket in the deque. If the `bucketSize` option is not provided
27
+ * or is not a number
28
+ */
29
+ constructor(elements?: IterableWithSizeOrLength<E>, options?: DequeOptions);
30
+ protected _bucketSize: number;
31
+ /**
32
+ * The bucketSize function returns the size of the bucket.
33
+ *
34
+ * @return The size of the bucket
35
+ */
36
+ get bucketSize(): number;
18
37
  protected _bucketFirst: number;
38
+ /**
39
+ * The function returns the value of the protected variable `_bucketFirst`.
40
+ * @returns The value of the `_bucketFirst` property.
41
+ */
42
+ get bucketFirst(): number;
19
43
  protected _firstInBucket: number;
44
+ /**
45
+ * The function returns the value of the protected variable _firstInBucket.
46
+ * @returns The method is returning the value of the variable `_firstInBucket`, which is of type
47
+ * `number`.
48
+ */
49
+ get firstInBucket(): number;
20
50
  protected _bucketLast: number;
51
+ /**
52
+ * The function returns the value of the protected variable `_bucketLast`.
53
+ * @returns The value of the `_bucketLast` property, which is a number.
54
+ */
55
+ get bucketLast(): number;
21
56
  protected _lastInBucket: number;
57
+ /**
58
+ * The function returns the value of the protected variable _lastInBucket.
59
+ * @returns The method is returning the value of the variable `_lastInBucket`, which is of type
60
+ * `number`.
61
+ */
62
+ get lastInBucket(): number;
22
63
  protected _bucketCount: number;
23
- protected readonly _bucketSize: number;
24
- constructor(elements?: IterableWithSizeOrLength<E>, options?: DequeOptions);
64
+ /**
65
+ * The function returns the number of buckets.
66
+ * @returns The number of buckets.
67
+ */
68
+ get bucketCount(): number;
25
69
  protected _buckets: E[][];
70
+ /**
71
+ * The buckets function returns the buckets property of the object.
72
+ * @return The buckets property
73
+ */
26
74
  get buckets(): E[][];
27
75
  protected _size: number;
76
+ /**
77
+ * The size function returns the number of items in the stack.
78
+ * @return The number of values in the set
79
+ */
28
80
  get size(): number;
29
81
  /**
30
82
  * The function returns the first element in a collection if it exists, otherwise it returns
@@ -32,6 +84,10 @@ export declare class Deque<E> extends IterableElementBase<E> {
32
84
  * @returns The first element of the collection, of type E, is being returned.
33
85
  */
34
86
  get first(): E | undefined;
87
+ /**
88
+ * The last function returns the last element in the queue.
89
+ * @return The last element in the array
90
+ */
35
91
  get last(): E | undefined;
36
92
  /**
37
93
  * Time Complexity - Amortized O(1) (possible reallocation)
@@ -90,11 +146,25 @@ export declare class Deque<E> extends IterableElementBase<E> {
90
146
  */
91
147
  shift(): E | undefined;
92
148
  /**
93
- * Time Complexity: O(1) - Removes the last element.
94
- * Space Complexity: O(1) - Operates in-place.
149
+ * Time Complexity: O(1)
150
+ * Space Complexity: O(1)
151
+ */
152
+ /**
153
+ * Time Complexity: O(1)
154
+ * Space Complexity: O(1)
155
+ *
156
+ * The function checks if the size of an object is equal to zero and returns a boolean value.
157
+ * @returns A boolean value indicating whether the size of the object is 0 or not.
95
158
  */
96
159
  isEmpty(): boolean;
97
160
  /**
161
+ * Time Complexity: O(1)
162
+ * Space Complexity: O(1)
163
+ */
164
+ /**
165
+ * Time Complexity: O(1)
166
+ * Space Complexity: O(1)
167
+ *
98
168
  * The clear() function resets the state of the object by initializing all variables to their default
99
169
  * values.
100
170
  */
@@ -116,13 +186,13 @@ export declare class Deque<E> extends IterableElementBase<E> {
116
186
  * Time Complexity: O(1)
117
187
  * Space Complexity: O(1)
118
188
  *
119
- * The `getAt` function retrieves an element at a specified position in an array-like data structure.
189
+ * The `at` function retrieves an element at a specified position in an array-like data structure.
120
190
  * @param {number} pos - The `pos` parameter represents the position of the element that you want to
121
191
  * retrieve from the data structure. It is of type `number` and should be a valid index within the
122
192
  * range of the data structure.
123
193
  * @returns The element at the specified position in the data structure is being returned.
124
194
  */
125
- getAt(pos: number): E;
195
+ at(pos: number): E;
126
196
  /**
127
197
  * Time Complexity: O(1)
128
198
  * Space Complexity: O(1)
@@ -170,16 +240,37 @@ export declare class Deque<E> extends IterableElementBase<E> {
170
240
  * updated size.
171
241
  * @param {number} pos - The `pos` parameter represents the position at which the string should be
172
242
  * cut. It is a number that indicates the index of the character where the cut should be made.
243
+ * @param {boolean} isCutSelf - If true, the original deque will not be cut, and return a new deque
173
244
  * @returns The method is returning the updated size of the data structure.
174
245
  */
175
- cut(pos: number): number;
246
+ cut(pos: number, isCutSelf?: boolean): Deque<E>;
247
+ /**
248
+ * Time Complexity: O(1)
249
+ * Space Complexity: O(1) or O(n)
250
+ */
251
+ /**
252
+ * Time Complexity: O(1)
253
+ * Space Complexity: O(1) or O(n)
254
+ *
255
+ * The `cutRest` function cuts the elements from a specified position in a deque and returns a new
256
+ * deque with the cut elements.
257
+ * @param {number} pos - The `pos` parameter represents the position from which to cut the Deque. It
258
+ * is a number that indicates the index of the element in the Deque where the cut should start.
259
+ * @param [isCutSelf=false] - isCutSelf is a boolean parameter that determines whether the original
260
+ * Deque should be modified or a new Deque should be created. If isCutSelf is true, the original
261
+ * Deque will be modified by cutting off elements starting from the specified position. If isCutSelf
262
+ * is false, a new De
263
+ * @returns The function `cutRest` returns either the modified original deque (`this`) or a new deque
264
+ * (`newDeque`) depending on the value of the `isCutSelf` parameter.
265
+ */
266
+ cutRest(pos: number, isCutSelf?: boolean): Deque<E>;
176
267
  /**
177
268
  * Time Complexity: O(n)
178
- * Space Complexity: O(1)
269
+ * Space Complexity: O(1) or O(n)
179
270
  */
180
271
  /**
181
272
  * Time Complexity: O(n)
182
- * Space Complexity: O(1)
273
+ * Space Complexity: O(1) or O(n)
183
274
  *
184
275
  * The `deleteAt` function removes an element at a specified position in an array-like data
185
276
  * structure.
@@ -260,22 +351,6 @@ export declare class Deque<E> extends IterableElementBase<E> {
260
351
  * `this.size` is 0, but it does not return any value.
261
352
  */
262
353
  shrinkToFit(): void;
263
- /**
264
- * Time Complexity: O(n)
265
- * Space Complexity: O(1)
266
- */
267
- /**
268
- * Time Complexity: O(n)
269
- * Space Complexity: O(1)
270
- *
271
- * The `find` function iterates over the elements in a deque and returns the first element for which
272
- * the callback function returns true, or undefined if no such element is found.
273
- * @param callback - A function that takes three parameters: element, index, and deque. It should
274
- * return a boolean value indicating whether the element satisfies a certain condition.
275
- * @returns The method `find` returns the first element in the deque that satisfies the condition
276
- * specified by the callback function. If no element satisfies the condition, it returns `undefined`.
277
- */
278
- find(callback: (element: E, index: number, deque: Deque<E>) => boolean): E | undefined;
279
354
  /**
280
355
  * Time Complexity: O(n)
281
356
  * Space Complexity: O(1)
@@ -304,6 +379,20 @@ export declare class Deque<E> extends IterableElementBase<E> {
304
379
  * @returns The `toArray()` method is returning an array of elements of type `E`.
305
380
  */
306
381
  toArray(): E[];
382
+ /**
383
+ * Time Complexity: O(n)
384
+ * Space Complexity: O(n)
385
+ */
386
+ /**
387
+ * Time Complexity: O(n)
388
+ * Space Complexity: O(n)
389
+ *
390
+ * The `clone()` function returns a new instance of the `Deque` class with the same elements and
391
+ * bucket size as the original instance.
392
+ * @returns The `clone()` method is returning a new instance of the `Deque` class with the same
393
+ * elements as the original deque (`this`) and the same bucket size.
394
+ */
395
+ clone(): Deque<E>;
307
396
  /**
308
397
  * Time Complexity: O(n)
309
398
  * Space Complexity: O(n)
@@ -348,8 +437,8 @@ export declare class Deque<E> extends IterableElementBase<E> {
348
437
  * Space Complexity: O(n) - Due to potential resizing.
349
438
  */
350
439
  /**
351
- * Time Complexity: O(1)
352
- * Space Complexity: O(n) - In worst case, resizing doubles the array size.
440
+ * Time Complexity: Amortized O(1) - Similar to push, resizing leads to O(n).
441
+ * Space Complexity: O(n) - Due to potential resizing.
353
442
  *
354
443
  * The addLast function adds an element to the end of an array.
355
444
  * @param {E} element - The element parameter represents the element that you want to add to the end of the
@@ -357,20 +446,25 @@ export declare class Deque<E> extends IterableElementBase<E> {
357
446
  */
358
447
  addLast(element: E): boolean;
359
448
  /**
360
- * Time Complexity: O(1) - Removes the first element.
361
- * Space Complexity: O(1) - In-place operation.
449
+ * Time Complexity: O(1)
450
+ * Space Complexity: O(1)
362
451
  */
363
452
  /**
364
- * Time Complexity: O(1) - Removes the last element.
365
- * Space Complexity: O(1) - Operates in-place.
453
+ * Time Complexity: O(1)
454
+ * Space Complexity: O(1)
366
455
  *
367
456
  * The function "pollLast" removes and returns the last element of an array.
368
457
  * @returns The last element of the array is being returned.
369
458
  */
370
459
  pollLast(): E | undefined;
371
460
  /**
372
- * Time Complexity: O(1).
373
- * Space Complexity: O(n) - Due to potential resizing.
461
+ * Time Complexity: O(1)
462
+ * Space Complexity: O(1)
463
+ * /
464
+
465
+ /**
466
+ * Time Complexity: O(1)
467
+ * Space Complexity: O(1)
374
468
  *
375
469
  * The "addFirst" function adds an element to the beginning of an array.
376
470
  * @param {E} element - The parameter "element" represents the element that you want to add to the
@@ -378,8 +472,13 @@ export declare class Deque<E> extends IterableElementBase<E> {
378
472
  */
379
473
  addFirst(element: E): boolean;
380
474
  /**
381
- * Time Complexity: O(1) - Removes the first element.
382
- * Space Complexity: O(1) - In-place operation.
475
+ * Time Complexity: O(1)
476
+ * Space Complexity: O(1)
477
+ * /
478
+
479
+ /**
480
+ * Time Complexity: O(1)
481
+ * Space Complexity: O(1)
383
482
  *
384
483
  * The function "pollFirst" removes and returns the first element of an array.
385
484
  * @returns The method `pollFirst()` is returning the first element of the array after removing it
@@ -387,6 +486,11 @@ export declare class Deque<E> extends IterableElementBase<E> {
387
486
  */
388
487
  pollFirst(): E | undefined;
389
488
  /**
489
+ * Time Complexity: O(n)
490
+ * Space Complexity: O(1)
491
+ * /
492
+
493
+ /**
390
494
  * Time Complexity: O(n)
391
495
  * Space Complexity: O(1)
392
496
  *