max-priority-queue-typed 2.5.3 → 2.6.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 (61) hide show
  1. package/dist/cjs/index.cjs +71 -0
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/cjs-legacy/index.cjs +71 -0
  4. package/dist/cjs-legacy/index.cjs.map +1 -1
  5. package/dist/esm/index.mjs +71 -0
  6. package/dist/esm/index.mjs.map +1 -1
  7. package/dist/esm-legacy/index.mjs +71 -0
  8. package/dist/esm-legacy/index.mjs.map +1 -1
  9. package/dist/types/data-structures/base/iterable-element-base.d.ts +17 -0
  10. package/dist/types/data-structures/base/linear-base.d.ts +6 -0
  11. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +36 -0
  12. package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +42 -0
  13. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +75 -0
  14. package/dist/types/data-structures/binary-tree/bst.d.ts +72 -0
  15. package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +57 -0
  16. package/dist/types/data-structures/binary-tree/segment-tree.d.ts +18 -0
  17. package/dist/types/data-structures/binary-tree/tree-map.d.ts +375 -0
  18. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +389 -0
  19. package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +330 -0
  20. package/dist/types/data-structures/binary-tree/tree-set.d.ts +438 -0
  21. package/dist/types/data-structures/graph/directed-graph.d.ts +30 -0
  22. package/dist/types/data-structures/graph/undirected-graph.d.ts +27 -0
  23. package/dist/types/data-structures/hash/hash-map.d.ts +33 -0
  24. package/dist/types/data-structures/heap/heap.d.ts +42 -0
  25. package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +75 -2
  26. package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +45 -0
  27. package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +54 -0
  28. package/dist/types/data-structures/matrix/matrix.d.ts +24 -0
  29. package/dist/types/data-structures/queue/deque.d.ts +90 -1
  30. package/dist/types/data-structures/queue/queue.d.ts +36 -0
  31. package/dist/types/data-structures/stack/stack.d.ts +30 -0
  32. package/dist/types/data-structures/trie/trie.d.ts +36 -0
  33. package/dist/umd/max-priority-queue-typed.js +71 -0
  34. package/dist/umd/max-priority-queue-typed.js.map +1 -1
  35. package/dist/umd/max-priority-queue-typed.min.js +1 -1
  36. package/dist/umd/max-priority-queue-typed.min.js.map +1 -1
  37. package/package.json +2 -2
  38. package/src/data-structures/base/iterable-element-base.ts +32 -0
  39. package/src/data-structures/base/linear-base.ts +11 -0
  40. package/src/data-structures/binary-tree/avl-tree.ts +36 -0
  41. package/src/data-structures/binary-tree/binary-indexed-tree.ts +42 -0
  42. package/src/data-structures/binary-tree/binary-tree.ts +75 -0
  43. package/src/data-structures/binary-tree/bst.ts +72 -0
  44. package/src/data-structures/binary-tree/red-black-tree.ts +57 -0
  45. package/src/data-structures/binary-tree/segment-tree.ts +18 -0
  46. package/src/data-structures/binary-tree/tree-map.ts +375 -0
  47. package/src/data-structures/binary-tree/tree-multi-map.ts +392 -0
  48. package/src/data-structures/binary-tree/tree-multi-set.ts +336 -0
  49. package/src/data-structures/binary-tree/tree-set.ts +492 -0
  50. package/src/data-structures/graph/directed-graph.ts +30 -0
  51. package/src/data-structures/graph/undirected-graph.ts +27 -0
  52. package/src/data-structures/hash/hash-map.ts +33 -0
  53. package/src/data-structures/heap/heap.ts +42 -0
  54. package/src/data-structures/linked-list/doubly-linked-list.ts +90 -2
  55. package/src/data-structures/linked-list/singly-linked-list.ts +45 -0
  56. package/src/data-structures/linked-list/skip-linked-list.ts +54 -0
  57. package/src/data-structures/matrix/matrix.ts +24 -0
  58. package/src/data-structures/queue/deque.ts +103 -1
  59. package/src/data-structures/queue/queue.ts +36 -0
  60. package/src/data-structures/stack/stack.ts +30 -0
  61. package/src/data-structures/trie/trie.ts +36 -0
@@ -84,6 +84,9 @@ export declare class SkipList<K = any, V = any, R = [K, V]> extends IterableEntr
84
84
 
85
85
 
86
86
 
87
+
88
+
89
+
87
90
 
88
91
 
89
92
 
@@ -128,6 +131,9 @@ export declare class SkipList<K = any, V = any, R = [K, V]> extends IterableEntr
128
131
 
129
132
 
130
133
 
134
+
135
+
136
+
131
137
 
132
138
 
133
139
 
@@ -173,6 +179,9 @@ export declare class SkipList<K = any, V = any, R = [K, V]> extends IterableEntr
173
179
 
174
180
 
175
181
 
182
+
183
+
184
+
176
185
 
177
186
 
178
187
 
@@ -223,6 +232,9 @@ export declare class SkipList<K = any, V = any, R = [K, V]> extends IterableEntr
223
232
 
224
233
 
225
234
 
235
+
236
+
237
+
226
238
 
227
239
 
228
240
 
@@ -283,6 +295,9 @@ export declare class SkipList<K = any, V = any, R = [K, V]> extends IterableEntr
283
295
 
284
296
 
285
297
 
298
+
299
+
300
+
286
301
 
287
302
 
288
303
 
@@ -347,6 +362,9 @@ export declare class SkipList<K = any, V = any, R = [K, V]> extends IterableEntr
347
362
 
348
363
 
349
364
 
365
+
366
+
367
+
350
368
 
351
369
 
352
370
 
@@ -395,6 +413,9 @@ export declare class SkipList<K = any, V = any, R = [K, V]> extends IterableEntr
395
413
 
396
414
 
397
415
 
416
+
417
+
418
+
398
419
 
399
420
 
400
421
 
@@ -450,6 +471,9 @@ export declare class SkipList<K = any, V = any, R = [K, V]> extends IterableEntr
450
471
 
451
472
 
452
473
 
474
+
475
+
476
+
453
477
 
454
478
 
455
479
 
@@ -497,6 +521,9 @@ export declare class SkipList<K = any, V = any, R = [K, V]> extends IterableEntr
497
521
 
498
522
 
499
523
 
524
+
525
+
526
+
500
527
 
501
528
 
502
529
 
@@ -541,6 +568,9 @@ export declare class SkipList<K = any, V = any, R = [K, V]> extends IterableEntr
541
568
 
542
569
 
543
570
 
571
+
572
+
573
+
544
574
 
545
575
 
546
576
 
@@ -586,6 +616,9 @@ export declare class SkipList<K = any, V = any, R = [K, V]> extends IterableEntr
586
616
 
587
617
 
588
618
 
619
+
620
+
621
+
589
622
 
590
623
 
591
624
 
@@ -634,6 +667,9 @@ export declare class SkipList<K = any, V = any, R = [K, V]> extends IterableEntr
634
667
 
635
668
 
636
669
 
670
+
671
+
672
+
637
673
 
638
674
 
639
675
 
@@ -682,6 +718,9 @@ export declare class SkipList<K = any, V = any, R = [K, V]> extends IterableEntr
682
718
 
683
719
 
684
720
 
721
+
722
+
723
+
685
724
 
686
725
 
687
726
 
@@ -727,6 +766,9 @@ export declare class SkipList<K = any, V = any, R = [K, V]> extends IterableEntr
727
766
 
728
767
 
729
768
 
769
+
770
+
771
+
730
772
 
731
773
 
732
774
 
@@ -772,6 +814,9 @@ export declare class SkipList<K = any, V = any, R = [K, V]> extends IterableEntr
772
814
 
773
815
 
774
816
 
817
+
818
+
819
+
775
820
 
776
821
 
777
822
 
@@ -820,6 +865,9 @@ export declare class SkipList<K = any, V = any, R = [K, V]> extends IterableEntr
820
865
 
821
866
 
822
867
 
868
+
869
+
870
+
823
871
 
824
872
 
825
873
 
@@ -865,6 +913,9 @@ export declare class SkipList<K = any, V = any, R = [K, V]> extends IterableEntr
865
913
 
866
914
 
867
915
 
916
+
917
+
918
+
868
919
 
869
920
 
870
921
 
@@ -910,6 +961,9 @@ export declare class SkipList<K = any, V = any, R = [K, V]> extends IterableEntr
910
961
 
911
962
 
912
963
 
964
+
965
+
966
+
913
967
 
914
968
 
915
969
 
@@ -177,6 +177,9 @@ export declare class Matrix {
177
177
 
178
178
 
179
179
 
180
+
181
+
182
+
180
183
 
181
184
 
182
185
 
@@ -245,6 +248,9 @@ export declare class Matrix {
245
248
 
246
249
 
247
250
 
251
+
252
+
253
+
248
254
 
249
255
 
250
256
 
@@ -305,6 +311,9 @@ export declare class Matrix {
305
311
 
306
312
 
307
313
 
314
+
315
+
316
+
308
317
 
309
318
 
310
319
 
@@ -374,6 +383,9 @@ export declare class Matrix {
374
383
 
375
384
 
376
385
 
386
+
387
+
388
+
377
389
 
378
390
 
379
391
 
@@ -426,6 +438,9 @@ export declare class Matrix {
426
438
 
427
439
 
428
440
 
441
+
442
+
443
+
429
444
 
430
445
 
431
446
 
@@ -493,6 +508,9 @@ export declare class Matrix {
493
508
 
494
509
 
495
510
 
511
+
512
+
513
+
496
514
 
497
515
 
498
516
 
@@ -556,6 +574,9 @@ export declare class Matrix {
556
574
 
557
575
 
558
576
 
577
+
578
+
579
+
559
580
 
560
581
 
561
582
 
@@ -612,6 +633,9 @@ export declare class Matrix {
612
633
 
613
634
 
614
635
 
636
+
637
+
638
+
615
639
 
616
640
 
617
641
 
@@ -227,7 +227,10 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
227
227
  peek(): E | undefined;
228
228
  /**
229
229
  * Deque peek at both ends
230
- * @example
230
+
231
+
232
+
233
+ * @example
231
234
  * // Deque peek at both ends
232
235
  * const deque = new Deque<number>([10, 20, 30, 40, 50]);
233
236
  *
@@ -282,6 +285,9 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
282
285
 
283
286
 
284
287
 
288
+
289
+
290
+
285
291
 
286
292
 
287
293
 
@@ -344,6 +350,9 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
344
350
 
345
351
 
346
352
 
353
+
354
+
355
+
347
356
 
348
357
 
349
358
 
@@ -407,6 +416,9 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
407
416
 
408
417
 
409
418
 
419
+
420
+
421
+
410
422
 
411
423
 
412
424
 
@@ -457,6 +469,9 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
457
469
 
458
470
 
459
471
 
472
+
473
+
474
+
460
475
 
461
476
 
462
477
 
@@ -508,6 +523,9 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
508
523
 
509
524
 
510
525
 
526
+
527
+
528
+
511
529
 
512
530
 
513
531
 
@@ -580,6 +598,9 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
580
598
 
581
599
 
582
600
 
601
+
602
+
603
+
583
604
 
584
605
 
585
606
 
@@ -627,6 +648,9 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
627
648
 
628
649
 
629
650
 
651
+
652
+
653
+
630
654
 
631
655
 
632
656
 
@@ -675,6 +699,9 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
675
699
 
676
700
 
677
701
 
702
+
703
+
704
+
678
705
 
679
706
 
680
707
 
@@ -772,6 +799,9 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
772
799
 
773
800
 
774
801
 
802
+
803
+
804
+
775
805
 
776
806
 
777
807
 
@@ -859,6 +889,53 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
859
889
  * }
860
890
  * console.log(backward); // ['D', 'C', 'B', 'A'];
861
891
  */
892
+ /**
893
+ * Find the last value matching a predicate (scans back-to-front).
894
+ * @remarks Provided for familiarity when migrating from Array. Time O(n), Space O(1).
895
+ * @param predicate - Function called with (value, index, deque).
896
+ * @returns Matching value or undefined.
897
+ * @example
898
+ * // Find last matching value
899
+ * const d = new Deque([1, 2, 3, 4, 5]);
900
+ * console.log(d.findLast(v => v > 2)); // 5;
901
+ * console.log(d.findLast(v => v % 2 === 0)); // 4;
902
+ */
903
+ findLast(predicate: (value: E, index: number, deque: this) => boolean): E | undefined;
904
+ /**
905
+ * Find the index of the last value matching a predicate (scans back-to-front).
906
+ * @remarks Provided for familiarity when migrating from Array. Time O(n), Space O(1).
907
+ * @param predicate - Function called with (value, index, deque).
908
+ * @returns Matching index, or -1 if not found.
909
+ * @example
910
+ * // Find last matching index
911
+ * const d = new Deque([10, 20, 30, 20, 10]);
912
+ * console.log(d.findLastIndex(v => v === 20)); // 3;
913
+ * console.log(d.findLastIndex(v => v === 10)); // 4;
914
+ */
915
+ findLastIndex(predicate: (value: E, index: number, deque: this) => boolean): number;
916
+ /**
917
+ * Deque for...of iteration and reverse
918
+
919
+
920
+ * @example
921
+ * // Deque for...of iteration and reverse
922
+ * const deque = new Deque<string>(['A', 'B', 'C', 'D']);
923
+ *
924
+ * // Iterate forward
925
+ * const forward: string[] = [];
926
+ * for (const item of deque) {
927
+ * forward.push(item);
928
+ * }
929
+ * console.log(forward); // ['A', 'B', 'C', 'D'];
930
+ *
931
+ * // Reverse the deque
932
+ * deque.reverse();
933
+ * const backward: string[] = [];
934
+ * for (const item of deque) {
935
+ * backward.push(item);
936
+ * }
937
+ * console.log(backward); // ['D', 'C', 'B', 'A'];
938
+ */
862
939
  reverse(): this;
863
940
  /**
864
941
  * Deduplicate consecutive equal elements in-place.
@@ -918,6 +995,9 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
918
995
 
919
996
 
920
997
 
998
+
999
+
1000
+
921
1001
 
922
1002
 
923
1003
 
@@ -969,6 +1049,9 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
969
1049
 
970
1050
 
971
1051
 
1052
+
1053
+
1054
+
972
1055
 
973
1056
 
974
1057
 
@@ -1021,6 +1104,9 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
1021
1104
 
1022
1105
 
1023
1106
 
1107
+
1108
+
1109
+
1024
1110
 
1025
1111
 
1026
1112
 
@@ -1081,6 +1167,9 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
1081
1167
 
1082
1168
 
1083
1169
 
1170
+
1171
+
1172
+
1084
1173
 
1085
1174
 
1086
1175
 
@@ -162,6 +162,9 @@ export declare class Queue<E = any, R = any> extends LinearBase<E, R> {
162
162
 
163
163
 
164
164
 
165
+
166
+
167
+
165
168
 
166
169
 
167
170
 
@@ -214,6 +217,9 @@ export declare class Queue<E = any, R = any> extends LinearBase<E, R> {
214
217
 
215
218
 
216
219
 
220
+
221
+
222
+
217
223
 
218
224
 
219
225
 
@@ -284,6 +290,9 @@ export declare class Queue<E = any, R = any> extends LinearBase<E, R> {
284
290
 
285
291
 
286
292
 
293
+
294
+
295
+
287
296
 
288
297
 
289
298
 
@@ -348,6 +357,9 @@ export declare class Queue<E = any, R = any> extends LinearBase<E, R> {
348
357
 
349
358
 
350
359
 
360
+
361
+
362
+
351
363
 
352
364
 
353
365
 
@@ -410,6 +422,9 @@ export declare class Queue<E = any, R = any> extends LinearBase<E, R> {
410
422
 
411
423
 
412
424
 
425
+
426
+
427
+
413
428
 
414
429
 
415
430
 
@@ -467,6 +482,9 @@ export declare class Queue<E = any, R = any> extends LinearBase<E, R> {
467
482
 
468
483
 
469
484
 
485
+
486
+
487
+
470
488
 
471
489
 
472
490
 
@@ -515,6 +533,9 @@ export declare class Queue<E = any, R = any> extends LinearBase<E, R> {
515
533
 
516
534
 
517
535
 
536
+
537
+
538
+
518
539
 
519
540
 
520
541
 
@@ -599,6 +620,9 @@ export declare class Queue<E = any, R = any> extends LinearBase<E, R> {
599
620
 
600
621
 
601
622
 
623
+
624
+
625
+
602
626
 
603
627
 
604
628
 
@@ -646,6 +670,9 @@ export declare class Queue<E = any, R = any> extends LinearBase<E, R> {
646
670
 
647
671
 
648
672
 
673
+
674
+
675
+
649
676
 
650
677
 
651
678
 
@@ -705,6 +732,9 @@ export declare class Queue<E = any, R = any> extends LinearBase<E, R> {
705
732
 
706
733
 
707
734
 
735
+
736
+
737
+
708
738
 
709
739
 
710
740
 
@@ -757,6 +787,9 @@ export declare class Queue<E = any, R = any> extends LinearBase<E, R> {
757
787
 
758
788
 
759
789
 
790
+
791
+
792
+
760
793
 
761
794
 
762
795
 
@@ -809,6 +842,9 @@ export declare class Queue<E = any, R = any> extends LinearBase<E, R> {
809
842
 
810
843
 
811
844
 
845
+
846
+
847
+
812
848
 
813
849
 
814
850
 
@@ -184,6 +184,9 @@ export declare class Stack<E = any, R = any> extends IterableElementBase<E, R> {
184
184
 
185
185
 
186
186
 
187
+
188
+
189
+
187
190
 
188
191
 
189
192
 
@@ -244,6 +247,9 @@ export declare class Stack<E = any, R = any> extends IterableElementBase<E, R> {
244
247
 
245
248
 
246
249
 
250
+
251
+
252
+
247
253
 
248
254
 
249
255
 
@@ -295,6 +301,9 @@ export declare class Stack<E = any, R = any> extends IterableElementBase<E, R> {
295
301
 
296
302
 
297
303
 
304
+
305
+
306
+
298
307
 
299
308
 
300
309
 
@@ -346,6 +355,9 @@ export declare class Stack<E = any, R = any> extends IterableElementBase<E, R> {
346
355
 
347
356
 
348
357
 
358
+
359
+
360
+
349
361
 
350
362
 
351
363
 
@@ -405,6 +417,9 @@ export declare class Stack<E = any, R = any> extends IterableElementBase<E, R> {
405
417
 
406
418
 
407
419
 
420
+
421
+
422
+
408
423
 
409
424
 
410
425
 
@@ -473,6 +488,9 @@ export declare class Stack<E = any, R = any> extends IterableElementBase<E, R> {
473
488
 
474
489
 
475
490
 
491
+
492
+
493
+
476
494
 
477
495
 
478
496
 
@@ -535,6 +553,9 @@ export declare class Stack<E = any, R = any> extends IterableElementBase<E, R> {
535
553
 
536
554
 
537
555
 
556
+
557
+
558
+
538
559
 
539
560
 
540
561
 
@@ -583,6 +604,9 @@ export declare class Stack<E = any, R = any> extends IterableElementBase<E, R> {
583
604
 
584
605
 
585
606
 
607
+
608
+
609
+
586
610
 
587
611
 
588
612
 
@@ -635,6 +659,9 @@ export declare class Stack<E = any, R = any> extends IterableElementBase<E, R> {
635
659
 
636
660
 
637
661
 
662
+
663
+
664
+
638
665
 
639
666
 
640
667
 
@@ -695,6 +722,9 @@ export declare class Stack<E = any, R = any> extends IterableElementBase<E, R> {
695
722
 
696
723
 
697
724
 
725
+
726
+
727
+
698
728
 
699
729
 
700
730