data-structure-typed 2.6.1 → 2.6.2

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 (116) hide show
  1. package/CHANGELOG.md +9 -1
  2. package/dist/cjs/binary-tree.cjs +2927 -23688
  3. package/dist/cjs/graph.cjs +845 -2634
  4. package/dist/cjs/hash.cjs +185 -616
  5. package/dist/cjs/heap.cjs +266 -818
  6. package/dist/cjs/index.cjs +5116 -31358
  7. package/dist/cjs/linked-list.cjs +644 -2615
  8. package/dist/cjs/matrix.cjs +220 -535
  9. package/dist/cjs/priority-queue.cjs +266 -818
  10. package/dist/cjs/queue.cjs +637 -2343
  11. package/dist/cjs/stack.cjs +124 -530
  12. package/dist/cjs/trie.cjs +145 -592
  13. package/dist/cjs-legacy/binary-tree.cjs +4352 -25113
  14. package/dist/cjs-legacy/graph.cjs +847 -2636
  15. package/dist/cjs-legacy/hash.cjs +181 -612
  16. package/dist/cjs-legacy/heap.cjs +266 -818
  17. package/dist/cjs-legacy/index.cjs +6657 -32899
  18. package/dist/cjs-legacy/linked-list.cjs +640 -2611
  19. package/dist/cjs-legacy/matrix.cjs +220 -535
  20. package/dist/cjs-legacy/priority-queue.cjs +266 -818
  21. package/dist/cjs-legacy/queue.cjs +634 -2340
  22. package/dist/cjs-legacy/stack.cjs +124 -530
  23. package/dist/cjs-legacy/trie.cjs +145 -592
  24. package/dist/esm/binary-tree.mjs +2927 -23688
  25. package/dist/esm/graph.mjs +845 -2634
  26. package/dist/esm/hash.mjs +185 -616
  27. package/dist/esm/heap.mjs +266 -818
  28. package/dist/esm/index.mjs +5116 -31358
  29. package/dist/esm/linked-list.mjs +644 -2615
  30. package/dist/esm/matrix.mjs +220 -535
  31. package/dist/esm/priority-queue.mjs +266 -818
  32. package/dist/esm/queue.mjs +637 -2343
  33. package/dist/esm/stack.mjs +124 -530
  34. package/dist/esm/trie.mjs +145 -592
  35. package/dist/esm-legacy/binary-tree.mjs +4352 -25113
  36. package/dist/esm-legacy/graph.mjs +847 -2636
  37. package/dist/esm-legacy/hash.mjs +181 -612
  38. package/dist/esm-legacy/heap.mjs +266 -818
  39. package/dist/esm-legacy/index.mjs +6657 -32899
  40. package/dist/esm-legacy/linked-list.mjs +640 -2611
  41. package/dist/esm-legacy/matrix.mjs +220 -535
  42. package/dist/esm-legacy/priority-queue.mjs +266 -818
  43. package/dist/esm-legacy/queue.mjs +634 -2340
  44. package/dist/esm-legacy/stack.mjs +124 -530
  45. package/dist/esm-legacy/trie.mjs +145 -592
  46. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +29 -500
  47. package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +38 -563
  48. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +230 -1212
  49. package/dist/types/data-structures/binary-tree/bst.d.ts +124 -1063
  50. package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +99 -854
  51. package/dist/types/data-structures/binary-tree/segment-tree.d.ts +62 -314
  52. package/dist/types/data-structures/binary-tree/tree-map.d.ts +366 -5057
  53. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +277 -4885
  54. package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +253 -3929
  55. package/dist/types/data-structures/binary-tree/tree-set.d.ts +261 -4782
  56. package/dist/types/data-structures/graph/abstract-graph.d.ts +44 -44
  57. package/dist/types/data-structures/graph/directed-graph.d.ts +130 -527
  58. package/dist/types/data-structures/graph/undirected-graph.d.ts +125 -482
  59. package/dist/types/data-structures/hash/hash-map.d.ts +132 -562
  60. package/dist/types/data-structures/heap/heap.d.ts +194 -746
  61. package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +120 -809
  62. package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +121 -733
  63. package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +193 -863
  64. package/dist/types/data-structures/matrix/matrix.d.ts +159 -474
  65. package/dist/types/data-structures/priority-queue/max-priority-queue.d.ts +1 -6
  66. package/dist/types/data-structures/priority-queue/min-priority-queue.d.ts +6 -11
  67. package/dist/types/data-structures/priority-queue/priority-queue.d.ts +1 -1
  68. package/dist/types/data-structures/queue/deque.d.ts +196 -804
  69. package/dist/types/data-structures/queue/queue.d.ts +99 -585
  70. package/dist/types/data-structures/stack/stack.d.ts +75 -481
  71. package/dist/types/data-structures/trie/trie.d.ts +98 -584
  72. package/dist/umd/data-structure-typed.js +6580 -32822
  73. package/dist/umd/data-structure-typed.min.js +3 -3
  74. package/docs-site-docusaurus/docs/api/classes/AVLTree.md +162 -215
  75. package/docs-site-docusaurus/docs/api/classes/AVLTreeNode.md +9 -9
  76. package/docs-site-docusaurus/docs/api/classes/AbstractGraph.md +47 -47
  77. package/docs-site-docusaurus/docs/api/classes/BST.md +155 -208
  78. package/docs-site-docusaurus/docs/api/classes/BSTNode.md +7 -7
  79. package/docs-site-docusaurus/docs/api/classes/BinaryIndexedTree.md +13 -29
  80. package/docs-site-docusaurus/docs/api/classes/BinaryTree.md +104 -158
  81. package/docs-site-docusaurus/docs/api/classes/BinaryTreeNode.md +13 -13
  82. package/docs-site-docusaurus/docs/api/classes/Deque.md +72 -104
  83. package/docs-site-docusaurus/docs/api/classes/DirectedGraph.md +60 -80
  84. package/docs-site-docusaurus/docs/api/classes/DoublyLinkedList.md +67 -101
  85. package/docs-site-docusaurus/docs/api/classes/DoublyLinkedListNode.md +6 -6
  86. package/docs-site-docusaurus/docs/api/classes/FibonacciHeap.md +9 -9
  87. package/docs-site-docusaurus/docs/api/classes/FibonacciHeapNode.md +1 -1
  88. package/docs-site-docusaurus/docs/api/classes/HashMap.md +52 -48
  89. package/docs-site-docusaurus/docs/api/classes/Heap.md +40 -68
  90. package/docs-site-docusaurus/docs/api/classes/IterableElementBase.md +17 -17
  91. package/docs-site-docusaurus/docs/api/classes/LinearBase.md +38 -38
  92. package/docs-site-docusaurus/docs/api/classes/LinearLinkedBase.md +45 -45
  93. package/docs-site-docusaurus/docs/api/classes/LinkedHashMap.md +23 -23
  94. package/docs-site-docusaurus/docs/api/classes/LinkedListQueue.md +68 -96
  95. package/docs-site-docusaurus/docs/api/classes/MapGraph.md +60 -80
  96. package/docs-site-docusaurus/docs/api/classes/Matrix.md +57 -52
  97. package/docs-site-docusaurus/docs/api/classes/MaxHeap.md +38 -66
  98. package/docs-site-docusaurus/docs/api/classes/MaxPriorityQueue.md +41 -74
  99. package/docs-site-docusaurus/docs/api/classes/MinHeap.md +38 -66
  100. package/docs-site-docusaurus/docs/api/classes/MinPriorityQueue.md +46 -79
  101. package/docs-site-docusaurus/docs/api/classes/PriorityQueue.md +40 -68
  102. package/docs-site-docusaurus/docs/api/classes/Queue.md +54 -78
  103. package/docs-site-docusaurus/docs/api/classes/RedBlackTree.md +171 -225
  104. package/docs-site-docusaurus/docs/api/classes/SegmentTree.md +10 -22
  105. package/docs-site-docusaurus/docs/api/classes/SinglyLinkedList.md +68 -98
  106. package/docs-site-docusaurus/docs/api/classes/SinglyLinkedListNode.md +4 -4
  107. package/docs-site-docusaurus/docs/api/classes/SkipList.md +98 -75
  108. package/docs-site-docusaurus/docs/api/classes/Stack.md +33 -53
  109. package/docs-site-docusaurus/docs/api/classes/TreeMap.md +104 -129
  110. package/docs-site-docusaurus/docs/api/classes/TreeMultiMap.md +57 -124
  111. package/docs-site-docusaurus/docs/api/classes/TreeSet.md +45 -116
  112. package/docs-site-docusaurus/docs/api/classes/Trie.md +37 -61
  113. package/docs-site-docusaurus/docs/api/classes/TrieNode.md +8 -8
  114. package/docs-site-docusaurus/docs/api/classes/UndirectedGraph.md +59 -77
  115. package/package.json +1 -1
  116. package/src/data-structures/binary-tree/tree-multi-set.ts +15 -11
@@ -131,7 +131,6 @@ import { IterableElementBase } from '../base';
131
131
  * console.log(stack.toArray()); // [1, 2, 3];
132
132
  */
133
133
  export declare class Stack<E = any, R = any> extends IterableElementBase<E, R> {
134
- protected _equals: (a: E, b: E) => boolean;
135
134
  /**
136
135
  * Create a Stack and optionally bulk-push elements.
137
136
  * @remarks Time O(N), Space O(N)
@@ -151,50 +150,10 @@ export declare class Stack<E = any, R = any> extends IterableElementBase<E, R> {
151
150
  * Get the number of stored elements.
152
151
  * @remarks Time O(1), Space O(1)
153
152
  * @returns Current size.
154
-
155
-
156
-
157
-
158
-
159
-
160
-
161
-
162
-
163
-
164
-
165
-
166
-
167
-
168
-
169
-
170
-
171
-
172
-
173
-
174
-
175
-
176
-
177
-
178
-
179
-
180
-
181
-
182
-
183
-
184
-
185
-
186
-
187
-
188
-
189
-
190
-
191
-
192
-
193
-
194
- * @example
195
- * // Get number of elements
196
- * const stack = new Stack<number>([1, 2, 3]);
197
- * console.log(stack.size); // 3;
153
+ * @example
154
+ * // Get number of elements
155
+ * const stack = new Stack<number>([1, 2, 3]);
156
+ * console.log(stack.size); // 3;
198
157
  */
199
158
  get size(): number;
200
159
  /**
@@ -212,107 +171,23 @@ export declare class Stack<E = any, R = any> extends IterableElementBase<E, R> {
212
171
  * Check whether the stack is empty.
213
172
  * @remarks Time O(1), Space O(1)
214
173
  * @returns True if size is 0.
215
-
216
-
217
-
218
-
219
-
220
-
221
-
222
-
223
-
224
-
225
-
226
-
227
-
228
-
229
-
230
-
231
-
232
-
233
-
234
-
235
-
236
-
237
-
238
-
239
-
240
-
241
-
242
-
243
-
244
-
245
-
246
-
247
-
248
-
249
-
250
-
251
-
252
-
253
-
254
-
255
-
256
-
257
- * @example
258
- * // Check if stack has elements
259
- * const stack = new Stack<number>();
260
- * console.log(stack.isEmpty()); // true;
261
- * stack.push(1);
262
- * console.log(stack.isEmpty()); // false;
174
+ * @example
175
+ * // Check if stack has elements
176
+ * const stack = new Stack<number>();
177
+ * console.log(stack.isEmpty()); // true;
178
+ * stack.push(1);
179
+ * console.log(stack.isEmpty()); // false;
263
180
  */
264
181
  isEmpty(): boolean;
265
182
  /**
266
183
  * Get the top element without removing it.
267
184
  * @remarks Time O(1), Space O(1)
268
185
  * @returns Top element or undefined.
269
-
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
-
307
-
308
-
309
-
310
-
311
- * @example
312
- * // View the top element without removing it
313
- * const stack = new Stack<string>(['a', 'b', 'c']);
314
- * console.log(stack.peek()); // 'c';
315
- * console.log(stack.size); // 3;
186
+ * @example
187
+ * // View the top element without removing it
188
+ * const stack = new Stack<string>(['a', 'b', 'c']);
189
+ * console.log(stack.peek()); // 'c';
190
+ * console.log(stack.size); // 3;
316
191
  */
317
192
  peek(): E | undefined;
318
193
  /**
@@ -320,128 +195,44 @@ export declare class Stack<E = any, R = any> extends IterableElementBase<E, R> {
320
195
  * @remarks Time O(1), Space O(1)
321
196
  * @param element - Element to push.
322
197
  * @returns True when pushed.
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
-
354
-
355
-
356
-
357
-
358
-
359
-
360
-
361
-
362
-
363
-
364
-
365
- * @example
366
- * // basic Stack creation and push operation
367
- * // Create a simple Stack with initial values
368
- * const stack = new Stack([1, 2, 3, 4, 5]);
369
- *
370
- * // Verify the stack maintains insertion order (LIFO will be shown in pop)
371
- * console.log([...stack]); // [1, 2, 3, 4, 5];
372
- *
373
- * // Check length
374
- * console.log(stack.size); // 5;
375
- *
376
- * // Push a new element to the top
377
- * stack.push(6);
378
- * console.log(stack.size); // 6;
198
+ * @example
199
+ * // basic Stack creation and push operation
200
+ * // Create a simple Stack with initial values
201
+ * const stack = new Stack([1, 2, 3, 4, 5]);
202
+ *
203
+ * // Verify the stack maintains insertion order (LIFO will be shown in pop)
204
+ * console.log([...stack]); // [1, 2, 3, 4, 5];
205
+ *
206
+ * // Check length
207
+ * console.log(stack.size); // 5;
208
+ *
209
+ * // Push a new element to the top
210
+ * stack.push(6);
211
+ * console.log(stack.size); // 6;
379
212
  */
380
213
  push(element: E): boolean;
381
214
  /**
382
215
  * Pop and return the top element.
383
216
  * @remarks Time O(1), Space O(1)
384
217
  * @returns Removed element or undefined.
385
-
386
-
387
-
388
-
389
-
390
-
391
-
392
-
393
-
394
-
395
-
396
-
397
-
398
-
399
-
400
-
401
-
402
-
403
-
404
-
405
-
406
-
407
-
408
-
409
-
410
-
411
-
412
-
413
-
414
-
415
-
416
-
417
-
418
-
419
-
420
-
421
-
422
-
423
-
424
-
425
-
426
-
427
- * @example
428
- * // Stack pop operation (LIFO - Last In First Out)
429
- * const stack = new Stack<number>([10, 20, 30, 40, 50]);
430
- *
431
- * // Peek at the top element without removing
432
- * const top = stack.peek();
433
- * console.log(top); // 50;
434
- *
435
- * // Pop removes from the top (LIFO order)
436
- * const popped = stack.pop();
437
- * console.log(popped); // 50;
438
- *
439
- * // Next pop gets the previous element
440
- * const next = stack.pop();
441
- * console.log(next); // 40;
442
- *
443
- * // Verify length decreased
444
- * console.log(stack.size); // 3;
218
+ * @example
219
+ * // Stack pop operation (LIFO - Last In First Out)
220
+ * const stack = new Stack<number>([10, 20, 30, 40, 50]);
221
+ *
222
+ * // Peek at the top element without removing
223
+ * const top = stack.peek();
224
+ * console.log(top); // 50;
225
+ *
226
+ * // Pop removes from the top (LIFO order)
227
+ * const popped = stack.pop();
228
+ * console.log(popped); // 50;
229
+ *
230
+ * // Next pop gets the previous element
231
+ * const next = stack.pop();
232
+ * console.log(next); // 40;
233
+ *
234
+ * // Verify length decreased
235
+ * console.log(stack.size); // 3;
445
236
  */
446
237
  pop(): E | undefined;
447
238
  /**
@@ -456,50 +247,11 @@ export declare class Stack<E = any, R = any> extends IterableElementBase<E, R> {
456
247
  * @remarks Time O(N), Space O(1)
457
248
  * @param element - Element to remove (using the configured equality).
458
249
  * @returns True if an element was removed.
459
-
460
-
461
-
462
-
463
-
464
-
465
-
466
-
467
-
468
-
469
-
470
-
471
-
472
-
473
-
474
-
475
-
476
-
477
-
478
-
479
-
480
-
481
-
482
-
483
-
484
-
485
-
486
-
487
-
488
-
489
-
490
-
491
-
492
-
493
-
494
-
495
-
496
-
497
-
498
- * @example
499
- * // Remove element
500
- * const stack = new Stack<number>([1, 2, 3]);
501
- * stack.delete(2);
502
- * console.log(stack.toArray()); // [1, 3];
250
+ * @example
251
+ * // Remove element
252
+ * const stack = new Stack<number>([1, 2, 3]);
253
+ * stack.delete(2);
254
+ * console.log(stack.toArray()); // [1, 3];
503
255
  */
504
256
  delete(element: E): boolean;
505
257
  /**
@@ -520,104 +272,24 @@ export declare class Stack<E = any, R = any> extends IterableElementBase<E, R> {
520
272
  * Remove all elements and reset storage.
521
273
  * @remarks Time O(1), Space O(1)
522
274
  * @returns void
523
-
524
-
525
-
526
-
527
-
528
-
529
-
530
-
531
-
532
-
533
-
534
-
535
-
536
-
537
-
538
-
539
-
540
-
541
-
542
-
543
-
544
-
545
-
546
-
547
-
548
-
549
-
550
-
551
-
552
-
553
-
554
-
555
-
556
-
557
-
558
-
559
-
560
-
561
-
562
-
563
- * @example
564
- * // Remove all elements
565
- * const stack = new Stack<number>([1, 2, 3]);
566
- * stack.clear();
567
- * console.log(stack.isEmpty()); // true;
275
+ * @example
276
+ * // Remove all elements
277
+ * const stack = new Stack<number>([1, 2, 3]);
278
+ * stack.clear();
279
+ * console.log(stack.isEmpty()); // true;
568
280
  */
569
281
  clear(): void;
570
282
  /**
571
283
  * Deep clone this stack.
572
284
  * @remarks Time O(N), Space O(N)
573
285
  * @returns A new stack with the same content.
574
-
575
-
576
-
577
-
578
-
579
-
580
-
581
-
582
-
583
-
584
-
585
-
586
-
587
-
588
-
589
-
590
-
591
-
592
-
593
-
594
-
595
-
596
-
597
-
598
-
599
-
600
-
601
-
602
-
603
-
604
-
605
-
606
-
607
-
608
-
609
-
610
-
611
-
612
-
613
-
614
- * @example
615
- * // Create independent copy
616
- * const stack = new Stack<number>([1, 2, 3]);
617
- * const copy = stack.clone();
618
- * copy.pop();
619
- * console.log(stack.size); // 3;
620
- * console.log(copy.size); // 2;
286
+ * @example
287
+ * // Create independent copy
288
+ * const stack = new Stack<number>([1, 2, 3]);
289
+ * const copy = stack.clone();
290
+ * copy.pop();
291
+ * console.log(stack.size); // 3;
292
+ * console.log(copy.size); // 2;
621
293
  */
622
294
  clone(): this;
623
295
  /**
@@ -626,51 +298,11 @@ export declare class Stack<E = any, R = any> extends IterableElementBase<E, R> {
626
298
  * @param predicate - Predicate (value, index, stack) → boolean to keep value.
627
299
  * @param [thisArg] - Value for `this` inside the predicate.
628
300
  * @returns A new stack with kept values.
629
-
630
-
631
-
632
-
633
-
634
-
635
-
636
-
637
-
638
-
639
-
640
-
641
-
642
-
643
-
644
-
645
-
646
-
647
-
648
-
649
-
650
-
651
-
652
-
653
-
654
-
655
-
656
-
657
-
658
-
659
-
660
-
661
-
662
-
663
-
664
-
665
-
666
-
667
-
668
-
669
- * @example
670
- * // Filter elements
671
- * const stack = new Stack<number>([1, 2, 3, 4, 5]);
672
- * const evens = stack.filter(x => x % 2 === 0);
673
- * console.log(evens.toArray()); // [2, 4];
301
+ * @example
302
+ * // Filter elements
303
+ * const stack = new Stack<number>([1, 2, 3, 4, 5]);
304
+ * const evens = stack.filter(x => x % 2 === 0);
305
+ * console.log(evens.toArray()); // [2, 4];
674
306
  */
675
307
  filter(predicate: ElementCallback<E, R, boolean>, thisArg?: unknown): this;
676
308
  /**
@@ -690,50 +322,11 @@ export declare class Stack<E = any, R = any> extends IterableElementBase<E, R> {
690
322
  * @param [options] - Options for the output stack (e.g., toElementFn).
691
323
  * @param [thisArg] - Value for `this` inside the callback.
692
324
  * @returns A new Stack with mapped elements.
693
-
694
-
695
-
696
-
697
-
698
-
699
-
700
-
701
-
702
-
703
-
704
-
705
-
706
-
707
-
708
-
709
-
710
-
711
-
712
-
713
-
714
-
715
-
716
-
717
-
718
-
719
-
720
-
721
-
722
-
723
-
724
-
725
-
726
-
727
-
728
-
729
-
730
-
731
-
732
- * @example
733
- * // Transform elements
734
- * const stack = new Stack<number>([1, 2, 3]);
735
- * const doubled = stack.map(x => x * 2);
736
- * console.log(doubled.toArray()); // [2, 4, 6];
325
+ * @example
326
+ * // Transform elements
327
+ * const stack = new Stack<number>([1, 2, 3]);
328
+ * const doubled = stack.map(x => x * 2);
329
+ * console.log(doubled.toArray()); // [2, 4, 6];
737
330
  */
738
331
  map<EM, RM>(callback: ElementCallback<E, R, EM>, options?: IterableElementBaseOptions<EM, RM>, thisArg?: unknown): Stack<EM, RM>;
739
332
  /**
@@ -743,6 +336,7 @@ export declare class Stack<E = any, R = any> extends IterableElementBase<E, R> {
743
336
  * @returns This stack.
744
337
  */
745
338
  setEquality(equals: (a: E, b: E) => boolean): this;
339
+ protected _equals: (a: E, b: E) => boolean;
746
340
  /**
747
341
  * (Protected) Find the index of a target element using the equality function.
748
342
  * @remarks Time O(N), Space O(1)