max-priority-queue-typed 2.5.0 → 2.5.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.
- package/dist/cjs/index.cjs +398 -55
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs-legacy/index.cjs +397 -54
- package/dist/cjs-legacy/index.cjs.map +1 -1
- package/dist/esm/index.mjs +398 -56
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm-legacy/index.mjs +397 -55
- package/dist/esm-legacy/index.mjs.map +1 -1
- package/dist/types/common/error.d.ts +9 -0
- package/dist/types/common/index.d.ts +1 -1
- package/dist/types/data-structures/base/index.d.ts +1 -0
- package/dist/types/data-structures/base/iterable-entry-base.d.ts +8 -8
- package/dist/types/data-structures/base/linear-base.d.ts +3 -3
- package/dist/types/data-structures/binary-tree/avl-tree.d.ts +288 -0
- package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +336 -0
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +618 -18
- package/dist/types/data-structures/binary-tree/bst.d.ts +676 -1
- package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +456 -0
- package/dist/types/data-structures/binary-tree/segment-tree.d.ts +144 -1
- package/dist/types/data-structures/binary-tree/tree-map.d.ts +3307 -399
- package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +3285 -360
- package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +2674 -325
- package/dist/types/data-structures/binary-tree/tree-set.d.ts +3072 -287
- package/dist/types/data-structures/graph/abstract-graph.d.ts +4 -4
- package/dist/types/data-structures/graph/directed-graph.d.ts +240 -0
- package/dist/types/data-structures/graph/undirected-graph.d.ts +216 -0
- package/dist/types/data-structures/hash/hash-map.d.ts +274 -10
- package/dist/types/data-structures/heap/heap.d.ts +336 -0
- package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +411 -3
- package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +363 -3
- package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +434 -2
- package/dist/types/data-structures/matrix/matrix.d.ts +192 -0
- package/dist/types/data-structures/queue/deque.d.ts +364 -4
- package/dist/types/data-structures/queue/queue.d.ts +288 -0
- package/dist/types/data-structures/stack/stack.d.ts +240 -0
- package/dist/types/data-structures/trie/trie.d.ts +292 -4
- package/dist/types/interfaces/graph.d.ts +1 -1
- package/dist/types/types/common.d.ts +2 -2
- package/dist/types/types/data-structures/binary-tree/bst.d.ts +1 -0
- package/dist/types/types/data-structures/binary-tree/tree-map.d.ts +5 -0
- package/dist/types/types/data-structures/binary-tree/tree-multi-set.d.ts +4 -0
- package/dist/types/types/data-structures/binary-tree/tree-set.d.ts +4 -0
- package/dist/types/types/data-structures/heap/heap.d.ts +1 -0
- package/dist/types/types/data-structures/priority-queue/priority-queue.d.ts +1 -0
- package/dist/types/types/utils/validate-type.d.ts +4 -4
- package/dist/umd/max-priority-queue-typed.js +395 -53
- package/dist/umd/max-priority-queue-typed.js.map +1 -1
- package/dist/umd/max-priority-queue-typed.min.js +1 -1
- package/dist/umd/max-priority-queue-typed.min.js.map +1 -1
- package/package.json +2 -2
- package/src/common/error.ts +19 -1
- package/src/common/index.ts +1 -1
- package/src/data-structures/base/index.ts +1 -0
- package/src/data-structures/base/iterable-element-base.ts +3 -2
- package/src/data-structures/base/iterable-entry-base.ts +8 -8
- package/src/data-structures/base/linear-base.ts +3 -3
- package/src/data-structures/binary-tree/avl-tree.ts +299 -0
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +341 -5
- package/src/data-structures/binary-tree/binary-tree.ts +606 -6
- package/src/data-structures/binary-tree/bst.ts +946 -7
- package/src/data-structures/binary-tree/red-black-tree.ts +472 -0
- package/src/data-structures/binary-tree/segment-tree.ts +145 -2
- package/src/data-structures/binary-tree/tree-map.ts +3423 -499
- package/src/data-structures/binary-tree/tree-multi-map.ts +3537 -596
- package/src/data-structures/binary-tree/tree-multi-set.ts +2855 -495
- package/src/data-structures/binary-tree/tree-set.ts +3209 -413
- package/src/data-structures/graph/abstract-graph.ts +6 -6
- package/src/data-structures/graph/directed-graph.ts +240 -0
- package/src/data-structures/graph/undirected-graph.ts +216 -0
- package/src/data-structures/hash/hash-map.ts +281 -19
- package/src/data-structures/heap/heap.ts +340 -4
- package/src/data-structures/heap/max-heap.ts +2 -2
- package/src/data-structures/linked-list/doubly-linked-list.ts +411 -3
- package/src/data-structures/linked-list/singly-linked-list.ts +363 -3
- package/src/data-structures/linked-list/skip-linked-list.ts +439 -7
- package/src/data-structures/matrix/matrix.ts +202 -10
- package/src/data-structures/priority-queue/max-priority-queue.ts +2 -2
- package/src/data-structures/queue/deque.ts +365 -5
- package/src/data-structures/queue/queue.ts +288 -0
- package/src/data-structures/stack/stack.ts +240 -0
- package/src/data-structures/trie/trie.ts +295 -7
- package/src/interfaces/graph.ts +1 -1
- package/src/types/common.ts +2 -2
- package/src/types/data-structures/binary-tree/bst.ts +1 -0
- package/src/types/data-structures/binary-tree/tree-map.ts +6 -0
- package/src/types/data-structures/binary-tree/tree-multi-set.ts +5 -0
- package/src/types/data-structures/binary-tree/tree-set.ts +5 -0
- package/src/types/data-structures/heap/heap.ts +1 -0
- package/src/types/data-structures/priority-queue/priority-queue.ts +1 -0
- package/src/types/utils/validate-type.ts +4 -4
|
@@ -245,6 +245,30 @@ export declare class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase
|
|
|
245
245
|
|
|
246
246
|
|
|
247
247
|
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
|
|
248
272
|
* @example
|
|
249
273
|
* // basic SinglyLinkedList creation and push operation
|
|
250
274
|
* // Create a simple SinglyLinkedList with initial values
|
|
@@ -277,6 +301,30 @@ export declare class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase
|
|
|
277
301
|
|
|
278
302
|
|
|
279
303
|
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
|
|
326
|
+
|
|
327
|
+
|
|
280
328
|
* @example
|
|
281
329
|
* // SinglyLinkedList pop and shift operations
|
|
282
330
|
* const list = new SinglyLinkedList<number>([10, 20, 30, 40, 50]);
|
|
@@ -309,6 +357,30 @@ export declare class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase
|
|
|
309
357
|
|
|
310
358
|
|
|
311
359
|
|
|
360
|
+
|
|
361
|
+
|
|
362
|
+
|
|
363
|
+
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+
|
|
368
|
+
|
|
369
|
+
|
|
370
|
+
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+
|
|
374
|
+
|
|
375
|
+
|
|
376
|
+
|
|
377
|
+
|
|
378
|
+
|
|
379
|
+
|
|
380
|
+
|
|
381
|
+
|
|
382
|
+
|
|
383
|
+
|
|
312
384
|
* @example
|
|
313
385
|
* // Remove from the front
|
|
314
386
|
* const list = new SinglyLinkedList<number>([10, 20, 30]);
|
|
@@ -332,6 +404,30 @@ export declare class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase
|
|
|
332
404
|
|
|
333
405
|
|
|
334
406
|
|
|
407
|
+
|
|
408
|
+
|
|
409
|
+
|
|
410
|
+
|
|
411
|
+
|
|
412
|
+
|
|
413
|
+
|
|
414
|
+
|
|
415
|
+
|
|
416
|
+
|
|
417
|
+
|
|
418
|
+
|
|
419
|
+
|
|
420
|
+
|
|
421
|
+
|
|
422
|
+
|
|
423
|
+
|
|
424
|
+
|
|
425
|
+
|
|
426
|
+
|
|
427
|
+
|
|
428
|
+
|
|
429
|
+
|
|
430
|
+
|
|
335
431
|
* @example
|
|
336
432
|
* // SinglyLinkedList unshift and forward traversal
|
|
337
433
|
* const list = new SinglyLinkedList<number>([20, 30, 40]);
|
|
@@ -391,6 +487,30 @@ export declare class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase
|
|
|
391
487
|
|
|
392
488
|
|
|
393
489
|
|
|
490
|
+
|
|
491
|
+
|
|
492
|
+
|
|
493
|
+
|
|
494
|
+
|
|
495
|
+
|
|
496
|
+
|
|
497
|
+
|
|
498
|
+
|
|
499
|
+
|
|
500
|
+
|
|
501
|
+
|
|
502
|
+
|
|
503
|
+
|
|
504
|
+
|
|
505
|
+
|
|
506
|
+
|
|
507
|
+
|
|
508
|
+
|
|
509
|
+
|
|
510
|
+
|
|
511
|
+
|
|
512
|
+
|
|
513
|
+
|
|
394
514
|
* @example
|
|
395
515
|
* // Access element by index
|
|
396
516
|
* const list = new SinglyLinkedList<string>(['a', 'b', 'c', 'd']);
|
|
@@ -419,6 +539,30 @@ export declare class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase
|
|
|
419
539
|
|
|
420
540
|
|
|
421
541
|
|
|
542
|
+
|
|
543
|
+
|
|
544
|
+
|
|
545
|
+
|
|
546
|
+
|
|
547
|
+
|
|
548
|
+
|
|
549
|
+
|
|
550
|
+
|
|
551
|
+
|
|
552
|
+
|
|
553
|
+
|
|
554
|
+
|
|
555
|
+
|
|
556
|
+
|
|
557
|
+
|
|
558
|
+
|
|
559
|
+
|
|
560
|
+
|
|
561
|
+
|
|
562
|
+
|
|
563
|
+
|
|
564
|
+
|
|
565
|
+
|
|
422
566
|
* @example
|
|
423
567
|
* // Get node at index
|
|
424
568
|
* const list = new SinglyLinkedList<string>(['a', 'b', 'c']);
|
|
@@ -438,6 +582,30 @@ export declare class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase
|
|
|
438
582
|
|
|
439
583
|
|
|
440
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
|
+
|
|
441
609
|
* @example
|
|
442
610
|
* // Remove by index
|
|
443
611
|
* const list = new SinglyLinkedList<string>(['a', 'b', 'c']);
|
|
@@ -458,6 +626,30 @@ export declare class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase
|
|
|
458
626
|
|
|
459
627
|
|
|
460
628
|
|
|
629
|
+
|
|
630
|
+
|
|
631
|
+
|
|
632
|
+
|
|
633
|
+
|
|
634
|
+
|
|
635
|
+
|
|
636
|
+
|
|
637
|
+
|
|
638
|
+
|
|
639
|
+
|
|
640
|
+
|
|
641
|
+
|
|
642
|
+
|
|
643
|
+
|
|
644
|
+
|
|
645
|
+
|
|
646
|
+
|
|
647
|
+
|
|
648
|
+
|
|
649
|
+
|
|
650
|
+
|
|
651
|
+
|
|
652
|
+
|
|
461
653
|
* @example
|
|
462
654
|
* // Remove first occurrence
|
|
463
655
|
* const list = new SinglyLinkedList<number>([1, 2, 3, 2]);
|
|
@@ -479,6 +671,30 @@ export declare class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase
|
|
|
479
671
|
|
|
480
672
|
|
|
481
673
|
|
|
674
|
+
|
|
675
|
+
|
|
676
|
+
|
|
677
|
+
|
|
678
|
+
|
|
679
|
+
|
|
680
|
+
|
|
681
|
+
|
|
682
|
+
|
|
683
|
+
|
|
684
|
+
|
|
685
|
+
|
|
686
|
+
|
|
687
|
+
|
|
688
|
+
|
|
689
|
+
|
|
690
|
+
|
|
691
|
+
|
|
692
|
+
|
|
693
|
+
|
|
694
|
+
|
|
695
|
+
|
|
696
|
+
|
|
697
|
+
|
|
482
698
|
* @example
|
|
483
699
|
* // Insert at index
|
|
484
700
|
* const list = new SinglyLinkedList<number>([1, 3]);
|
|
@@ -507,6 +723,30 @@ export declare class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase
|
|
|
507
723
|
|
|
508
724
|
|
|
509
725
|
|
|
726
|
+
|
|
727
|
+
|
|
728
|
+
|
|
729
|
+
|
|
730
|
+
|
|
731
|
+
|
|
732
|
+
|
|
733
|
+
|
|
734
|
+
|
|
735
|
+
|
|
736
|
+
|
|
737
|
+
|
|
738
|
+
|
|
739
|
+
|
|
740
|
+
|
|
741
|
+
|
|
742
|
+
|
|
743
|
+
|
|
744
|
+
|
|
745
|
+
|
|
746
|
+
|
|
747
|
+
|
|
748
|
+
|
|
749
|
+
|
|
510
750
|
* @example
|
|
511
751
|
* // Check empty
|
|
512
752
|
* console.log(new SinglyLinkedList().isEmpty()); // true;
|
|
@@ -525,6 +765,30 @@ export declare class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase
|
|
|
525
765
|
|
|
526
766
|
|
|
527
767
|
|
|
768
|
+
|
|
769
|
+
|
|
770
|
+
|
|
771
|
+
|
|
772
|
+
|
|
773
|
+
|
|
774
|
+
|
|
775
|
+
|
|
776
|
+
|
|
777
|
+
|
|
778
|
+
|
|
779
|
+
|
|
780
|
+
|
|
781
|
+
|
|
782
|
+
|
|
783
|
+
|
|
784
|
+
|
|
785
|
+
|
|
786
|
+
|
|
787
|
+
|
|
788
|
+
|
|
789
|
+
|
|
790
|
+
|
|
791
|
+
|
|
528
792
|
* @example
|
|
529
793
|
* // Remove all
|
|
530
794
|
* const list = new SinglyLinkedList<number>([1, 2, 3]);
|
|
@@ -547,6 +811,30 @@ export declare class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase
|
|
|
547
811
|
|
|
548
812
|
|
|
549
813
|
|
|
814
|
+
|
|
815
|
+
|
|
816
|
+
|
|
817
|
+
|
|
818
|
+
|
|
819
|
+
|
|
820
|
+
|
|
821
|
+
|
|
822
|
+
|
|
823
|
+
|
|
824
|
+
|
|
825
|
+
|
|
826
|
+
|
|
827
|
+
|
|
828
|
+
|
|
829
|
+
|
|
830
|
+
|
|
831
|
+
|
|
832
|
+
|
|
833
|
+
|
|
834
|
+
|
|
835
|
+
|
|
836
|
+
|
|
837
|
+
|
|
550
838
|
* @example
|
|
551
839
|
* // Reverse the list in-place
|
|
552
840
|
* const list = new SinglyLinkedList<number>([1, 2, 3, 4]);
|
|
@@ -620,6 +908,30 @@ export declare class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase
|
|
|
620
908
|
|
|
621
909
|
|
|
622
910
|
|
|
911
|
+
|
|
912
|
+
|
|
913
|
+
|
|
914
|
+
|
|
915
|
+
|
|
916
|
+
|
|
917
|
+
|
|
918
|
+
|
|
919
|
+
|
|
920
|
+
|
|
921
|
+
|
|
922
|
+
|
|
923
|
+
|
|
924
|
+
|
|
925
|
+
|
|
926
|
+
|
|
927
|
+
|
|
928
|
+
|
|
929
|
+
|
|
930
|
+
|
|
931
|
+
|
|
932
|
+
|
|
933
|
+
|
|
934
|
+
|
|
623
935
|
* @example
|
|
624
936
|
* // Deep copy
|
|
625
937
|
* const list = new SinglyLinkedList<number>([1, 2, 3]);
|
|
@@ -646,6 +958,30 @@ export declare class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase
|
|
|
646
958
|
|
|
647
959
|
|
|
648
960
|
|
|
961
|
+
|
|
962
|
+
|
|
963
|
+
|
|
964
|
+
|
|
965
|
+
|
|
966
|
+
|
|
967
|
+
|
|
968
|
+
|
|
969
|
+
|
|
970
|
+
|
|
971
|
+
|
|
972
|
+
|
|
973
|
+
|
|
974
|
+
|
|
975
|
+
|
|
976
|
+
|
|
977
|
+
|
|
978
|
+
|
|
979
|
+
|
|
980
|
+
|
|
981
|
+
|
|
982
|
+
|
|
983
|
+
|
|
984
|
+
|
|
649
985
|
* @example
|
|
650
986
|
* // SinglyLinkedList filter and map operations
|
|
651
987
|
* const list = new SinglyLinkedList<number>([1, 2, 3, 4, 5]);
|
|
@@ -662,7 +998,7 @@ export declare class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase
|
|
|
662
998
|
* const sum = list.reduce((acc, value) => acc + value, 0);
|
|
663
999
|
* console.log(sum); // 15;
|
|
664
1000
|
*/
|
|
665
|
-
filter(callback: ElementCallback<E, R, boolean>, thisArg?:
|
|
1001
|
+
filter(callback: ElementCallback<E, R, boolean>, thisArg?: unknown): this;
|
|
666
1002
|
/**
|
|
667
1003
|
* Map values into a new list of the same class.
|
|
668
1004
|
* @remarks Time O(N), Space O(N)
|
|
@@ -670,7 +1006,7 @@ export declare class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase
|
|
|
670
1006
|
* @param [thisArg] - Value for `this` inside the callback.
|
|
671
1007
|
* @returns A new list with mapped values.
|
|
672
1008
|
*/
|
|
673
|
-
mapSame(callback: ElementCallback<E, R, E>, thisArg?:
|
|
1009
|
+
mapSame(callback: ElementCallback<E, R, E>, thisArg?: unknown): this;
|
|
674
1010
|
/**
|
|
675
1011
|
* Map values into a new list (possibly different element type).
|
|
676
1012
|
* @remarks Time O(N), Space O(N)
|
|
@@ -691,13 +1027,37 @@ export declare class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase
|
|
|
691
1027
|
|
|
692
1028
|
|
|
693
1029
|
|
|
1030
|
+
|
|
1031
|
+
|
|
1032
|
+
|
|
1033
|
+
|
|
1034
|
+
|
|
1035
|
+
|
|
1036
|
+
|
|
1037
|
+
|
|
1038
|
+
|
|
1039
|
+
|
|
1040
|
+
|
|
1041
|
+
|
|
1042
|
+
|
|
1043
|
+
|
|
1044
|
+
|
|
1045
|
+
|
|
1046
|
+
|
|
1047
|
+
|
|
1048
|
+
|
|
1049
|
+
|
|
1050
|
+
|
|
1051
|
+
|
|
1052
|
+
|
|
1053
|
+
|
|
694
1054
|
* @example
|
|
695
1055
|
* // Transform elements
|
|
696
1056
|
* const list = new SinglyLinkedList<number>([1, 2, 3]);
|
|
697
1057
|
* const doubled = list.map(n => n * 2);
|
|
698
1058
|
* console.log([...doubled]); // [2, 4, 6];
|
|
699
1059
|
*/
|
|
700
|
-
map<EM, RM = any>(callback: ElementCallback<E, R, EM>, options?: SinglyLinkedListOptions<EM, RM>, thisArg?:
|
|
1060
|
+
map<EM, RM = any>(callback: ElementCallback<E, R, EM>, options?: SinglyLinkedListOptions<EM, RM>, thisArg?: unknown): SinglyLinkedList<EM, RM>;
|
|
701
1061
|
/**
|
|
702
1062
|
* (Protected) Create a node from a value.
|
|
703
1063
|
* @remarks Time O(1), Space O(1)
|