max-priority-queue-typed 2.5.0 → 2.5.1
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 +294 -0
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs-legacy/index.cjs +294 -0
- package/dist/cjs-legacy/index.cjs.map +1 -1
- package/dist/esm/index.mjs +294 -0
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm-legacy/index.mjs +294 -0
- package/dist/esm-legacy/index.mjs.map +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 +252 -0
- package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +294 -0
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +527 -2
- package/dist/types/data-structures/binary-tree/bst.d.ts +505 -1
- package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +399 -0
- package/dist/types/data-structures/binary-tree/segment-tree.d.ts +126 -1
- package/dist/types/data-structures/binary-tree/tree-map.d.ts +2881 -382
- package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +2867 -347
- package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +2328 -312
- package/dist/types/data-structures/binary-tree/tree-set.d.ts +2671 -277
- package/dist/types/data-structures/graph/abstract-graph.d.ts +4 -4
- package/dist/types/data-structures/graph/directed-graph.d.ts +210 -0
- package/dist/types/data-structures/graph/undirected-graph.d.ts +189 -0
- package/dist/types/data-structures/hash/hash-map.d.ts +241 -10
- package/dist/types/data-structures/heap/heap.d.ts +294 -0
- package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +360 -3
- package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +318 -3
- package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +380 -2
- package/dist/types/data-structures/matrix/matrix.d.ts +168 -0
- package/dist/types/data-structures/queue/deque.d.ts +319 -4
- package/dist/types/data-structures/queue/queue.d.ts +252 -0
- package/dist/types/data-structures/stack/stack.d.ts +210 -0
- package/dist/types/data-structures/trie/trie.d.ts +256 -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/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 +294 -0
- package/dist/umd/max-priority-queue-typed.js.map +1 -1
- package/dist/umd/max-priority-queue-typed.min.js.map +1 -1
- package/package.json +2 -2
- package/src/data-structures/base/index.ts +1 -0
- 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 +252 -0
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +295 -1
- package/src/data-structures/binary-tree/binary-tree.ts +527 -2
- package/src/data-structures/binary-tree/bst.ts +505 -1
- package/src/data-structures/binary-tree/red-black-tree.ts +399 -0
- package/src/data-structures/binary-tree/segment-tree.ts +127 -2
- package/src/data-structures/binary-tree/tree-map.ts +2958 -459
- package/src/data-structures/binary-tree/tree-multi-map.ts +3069 -549
- package/src/data-structures/binary-tree/tree-multi-set.ts +2476 -460
- package/src/data-structures/binary-tree/tree-set.ts +2816 -422
- package/src/data-structures/graph/abstract-graph.ts +4 -4
- package/src/data-structures/graph/directed-graph.ts +210 -0
- package/src/data-structures/graph/undirected-graph.ts +189 -0
- package/src/data-structures/hash/hash-map.ts +246 -15
- package/src/data-structures/heap/heap.ts +294 -0
- package/src/data-structures/linked-list/doubly-linked-list.ts +360 -3
- package/src/data-structures/linked-list/singly-linked-list.ts +318 -3
- package/src/data-structures/linked-list/skip-linked-list.ts +380 -2
- package/src/data-structures/matrix/matrix.ts +169 -1
- package/src/data-structures/queue/deque.ts +320 -5
- package/src/data-structures/queue/queue.ts +252 -0
- package/src/data-structures/stack/stack.ts +210 -0
- package/src/data-structures/trie/trie.ts +257 -5
- package/src/interfaces/graph.ts +1 -1
- package/src/types/common.ts +2 -2
- 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
|
@@ -196,6 +196,27 @@ export declare class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase
|
|
|
196
196
|
|
|
197
197
|
|
|
198
198
|
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
|
|
199
220
|
* @example
|
|
200
221
|
* // basic DoublyLinkedList creation and push operation
|
|
201
222
|
* // Create a simple DoublyLinkedList with initial values
|
|
@@ -228,6 +249,27 @@ export declare class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase
|
|
|
228
249
|
|
|
229
250
|
|
|
230
251
|
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
|
|
231
273
|
* @example
|
|
232
274
|
* // DoublyLinkedList pop and shift operations
|
|
233
275
|
* const list = new DoublyLinkedList<number>([10, 20, 30, 40, 50]);
|
|
@@ -260,6 +302,27 @@ export declare class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase
|
|
|
260
302
|
|
|
261
303
|
|
|
262
304
|
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
|
|
263
326
|
* @example
|
|
264
327
|
* // Remove from the front
|
|
265
328
|
* const list = new DoublyLinkedList<number>([10, 20, 30]);
|
|
@@ -283,6 +346,27 @@ export declare class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase
|
|
|
283
346
|
|
|
284
347
|
|
|
285
348
|
|
|
349
|
+
|
|
350
|
+
|
|
351
|
+
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
|
|
355
|
+
|
|
356
|
+
|
|
357
|
+
|
|
358
|
+
|
|
359
|
+
|
|
360
|
+
|
|
361
|
+
|
|
362
|
+
|
|
363
|
+
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+
|
|
368
|
+
|
|
369
|
+
|
|
286
370
|
* @example
|
|
287
371
|
* // Add to the front
|
|
288
372
|
* const list = new DoublyLinkedList<number>([2, 3]);
|
|
@@ -320,6 +404,27 @@ export declare class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase
|
|
|
320
404
|
|
|
321
405
|
|
|
322
406
|
|
|
407
|
+
|
|
408
|
+
|
|
409
|
+
|
|
410
|
+
|
|
411
|
+
|
|
412
|
+
|
|
413
|
+
|
|
414
|
+
|
|
415
|
+
|
|
416
|
+
|
|
417
|
+
|
|
418
|
+
|
|
419
|
+
|
|
420
|
+
|
|
421
|
+
|
|
422
|
+
|
|
423
|
+
|
|
424
|
+
|
|
425
|
+
|
|
426
|
+
|
|
427
|
+
|
|
323
428
|
* @example
|
|
324
429
|
* // Access by index
|
|
325
430
|
* const list = new DoublyLinkedList<string>(['a', 'b', 'c']);
|
|
@@ -340,6 +445,27 @@ export declare class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase
|
|
|
340
445
|
|
|
341
446
|
|
|
342
447
|
|
|
448
|
+
|
|
449
|
+
|
|
450
|
+
|
|
451
|
+
|
|
452
|
+
|
|
453
|
+
|
|
454
|
+
|
|
455
|
+
|
|
456
|
+
|
|
457
|
+
|
|
458
|
+
|
|
459
|
+
|
|
460
|
+
|
|
461
|
+
|
|
462
|
+
|
|
463
|
+
|
|
464
|
+
|
|
465
|
+
|
|
466
|
+
|
|
467
|
+
|
|
468
|
+
|
|
343
469
|
* @example
|
|
344
470
|
* // Get node at index
|
|
345
471
|
* const list = new DoublyLinkedList<string>(['a', 'b', 'c']);
|
|
@@ -367,6 +493,27 @@ export declare class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase
|
|
|
367
493
|
|
|
368
494
|
|
|
369
495
|
|
|
496
|
+
|
|
497
|
+
|
|
498
|
+
|
|
499
|
+
|
|
500
|
+
|
|
501
|
+
|
|
502
|
+
|
|
503
|
+
|
|
504
|
+
|
|
505
|
+
|
|
506
|
+
|
|
507
|
+
|
|
508
|
+
|
|
509
|
+
|
|
510
|
+
|
|
511
|
+
|
|
512
|
+
|
|
513
|
+
|
|
514
|
+
|
|
515
|
+
|
|
516
|
+
|
|
370
517
|
* @example
|
|
371
518
|
* // Insert at position
|
|
372
519
|
* const list = new DoublyLinkedList<number>([1, 3]);
|
|
@@ -411,6 +558,27 @@ export declare class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase
|
|
|
411
558
|
|
|
412
559
|
|
|
413
560
|
|
|
561
|
+
|
|
562
|
+
|
|
563
|
+
|
|
564
|
+
|
|
565
|
+
|
|
566
|
+
|
|
567
|
+
|
|
568
|
+
|
|
569
|
+
|
|
570
|
+
|
|
571
|
+
|
|
572
|
+
|
|
573
|
+
|
|
574
|
+
|
|
575
|
+
|
|
576
|
+
|
|
577
|
+
|
|
578
|
+
|
|
579
|
+
|
|
580
|
+
|
|
581
|
+
|
|
414
582
|
* @example
|
|
415
583
|
* // Remove by index
|
|
416
584
|
* const list = new DoublyLinkedList<string>(['a', 'b', 'c']);
|
|
@@ -431,6 +599,27 @@ export declare class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase
|
|
|
431
599
|
|
|
432
600
|
|
|
433
601
|
|
|
602
|
+
|
|
603
|
+
|
|
604
|
+
|
|
605
|
+
|
|
606
|
+
|
|
607
|
+
|
|
608
|
+
|
|
609
|
+
|
|
610
|
+
|
|
611
|
+
|
|
612
|
+
|
|
613
|
+
|
|
614
|
+
|
|
615
|
+
|
|
616
|
+
|
|
617
|
+
|
|
618
|
+
|
|
619
|
+
|
|
620
|
+
|
|
621
|
+
|
|
622
|
+
|
|
434
623
|
* @example
|
|
435
624
|
* // Remove first occurrence
|
|
436
625
|
* const list = new DoublyLinkedList<number>([1, 2, 3, 2]);
|
|
@@ -451,6 +640,27 @@ export declare class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase
|
|
|
451
640
|
|
|
452
641
|
|
|
453
642
|
|
|
643
|
+
|
|
644
|
+
|
|
645
|
+
|
|
646
|
+
|
|
647
|
+
|
|
648
|
+
|
|
649
|
+
|
|
650
|
+
|
|
651
|
+
|
|
652
|
+
|
|
653
|
+
|
|
654
|
+
|
|
655
|
+
|
|
656
|
+
|
|
657
|
+
|
|
658
|
+
|
|
659
|
+
|
|
660
|
+
|
|
661
|
+
|
|
662
|
+
|
|
663
|
+
|
|
454
664
|
* @example
|
|
455
665
|
* // Check empty
|
|
456
666
|
* console.log(new DoublyLinkedList().isEmpty()); // true;
|
|
@@ -469,6 +679,27 @@ export declare class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase
|
|
|
469
679
|
|
|
470
680
|
|
|
471
681
|
|
|
682
|
+
|
|
683
|
+
|
|
684
|
+
|
|
685
|
+
|
|
686
|
+
|
|
687
|
+
|
|
688
|
+
|
|
689
|
+
|
|
690
|
+
|
|
691
|
+
|
|
692
|
+
|
|
693
|
+
|
|
694
|
+
|
|
695
|
+
|
|
696
|
+
|
|
697
|
+
|
|
698
|
+
|
|
699
|
+
|
|
700
|
+
|
|
701
|
+
|
|
702
|
+
|
|
472
703
|
* @example
|
|
473
704
|
* // Remove all
|
|
474
705
|
* const list = new DoublyLinkedList<number>([1, 2]);
|
|
@@ -489,6 +720,27 @@ export declare class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase
|
|
|
489
720
|
|
|
490
721
|
|
|
491
722
|
|
|
723
|
+
|
|
724
|
+
|
|
725
|
+
|
|
726
|
+
|
|
727
|
+
|
|
728
|
+
|
|
729
|
+
|
|
730
|
+
|
|
731
|
+
|
|
732
|
+
|
|
733
|
+
|
|
734
|
+
|
|
735
|
+
|
|
736
|
+
|
|
737
|
+
|
|
738
|
+
|
|
739
|
+
|
|
740
|
+
|
|
741
|
+
|
|
742
|
+
|
|
743
|
+
|
|
492
744
|
* @example
|
|
493
745
|
* // Search with predicate
|
|
494
746
|
* const list = new DoublyLinkedList<number>([10, 20, 30]);
|
|
@@ -509,6 +761,27 @@ export declare class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase
|
|
|
509
761
|
|
|
510
762
|
|
|
511
763
|
|
|
764
|
+
|
|
765
|
+
|
|
766
|
+
|
|
767
|
+
|
|
768
|
+
|
|
769
|
+
|
|
770
|
+
|
|
771
|
+
|
|
772
|
+
|
|
773
|
+
|
|
774
|
+
|
|
775
|
+
|
|
776
|
+
|
|
777
|
+
|
|
778
|
+
|
|
779
|
+
|
|
780
|
+
|
|
781
|
+
|
|
782
|
+
|
|
783
|
+
|
|
784
|
+
|
|
512
785
|
* @example
|
|
513
786
|
* // Find value scanning from tail
|
|
514
787
|
* const list = new DoublyLinkedList<number>([1, 2, 3, 4]);
|
|
@@ -532,6 +805,27 @@ export declare class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase
|
|
|
532
805
|
|
|
533
806
|
|
|
534
807
|
|
|
808
|
+
|
|
809
|
+
|
|
810
|
+
|
|
811
|
+
|
|
812
|
+
|
|
813
|
+
|
|
814
|
+
|
|
815
|
+
|
|
816
|
+
|
|
817
|
+
|
|
818
|
+
|
|
819
|
+
|
|
820
|
+
|
|
821
|
+
|
|
822
|
+
|
|
823
|
+
|
|
824
|
+
|
|
825
|
+
|
|
826
|
+
|
|
827
|
+
|
|
828
|
+
|
|
535
829
|
* @example
|
|
536
830
|
* // Reverse in-place
|
|
537
831
|
* const list = new DoublyLinkedList<number>([1, 2, 3]);
|
|
@@ -559,6 +853,27 @@ export declare class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase
|
|
|
559
853
|
|
|
560
854
|
|
|
561
855
|
|
|
856
|
+
|
|
857
|
+
|
|
858
|
+
|
|
859
|
+
|
|
860
|
+
|
|
861
|
+
|
|
862
|
+
|
|
863
|
+
|
|
864
|
+
|
|
865
|
+
|
|
866
|
+
|
|
867
|
+
|
|
868
|
+
|
|
869
|
+
|
|
870
|
+
|
|
871
|
+
|
|
872
|
+
|
|
873
|
+
|
|
874
|
+
|
|
875
|
+
|
|
876
|
+
|
|
562
877
|
* @example
|
|
563
878
|
* // Deep copy
|
|
564
879
|
* const list = new DoublyLinkedList<number>([1, 2, 3]);
|
|
@@ -584,13 +899,34 @@ export declare class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase
|
|
|
584
899
|
|
|
585
900
|
|
|
586
901
|
|
|
902
|
+
|
|
903
|
+
|
|
904
|
+
|
|
905
|
+
|
|
906
|
+
|
|
907
|
+
|
|
908
|
+
|
|
909
|
+
|
|
910
|
+
|
|
911
|
+
|
|
912
|
+
|
|
913
|
+
|
|
914
|
+
|
|
915
|
+
|
|
916
|
+
|
|
917
|
+
|
|
918
|
+
|
|
919
|
+
|
|
920
|
+
|
|
921
|
+
|
|
922
|
+
|
|
587
923
|
* @example
|
|
588
924
|
* // Filter elements
|
|
589
925
|
* const list = new DoublyLinkedList<number>([1, 2, 3, 4, 5]);
|
|
590
926
|
* const evens = list.filter(n => n % 2 === 0);
|
|
591
927
|
* console.log([...evens]); // [2, 4];
|
|
592
928
|
*/
|
|
593
|
-
filter(callback: ElementCallback<E, R, boolean>, thisArg?:
|
|
929
|
+
filter(callback: ElementCallback<E, R, boolean>, thisArg?: unknown): this;
|
|
594
930
|
/**
|
|
595
931
|
* Map values into a new list of the same class.
|
|
596
932
|
* @remarks Time O(N), Space O(N)
|
|
@@ -598,7 +934,7 @@ export declare class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase
|
|
|
598
934
|
* @param [thisArg] - Value for `this` inside the callback.
|
|
599
935
|
* @returns A new list with mapped values.
|
|
600
936
|
*/
|
|
601
|
-
mapSame(callback: ElementCallback<E, R, E>, thisArg?:
|
|
937
|
+
mapSame(callback: ElementCallback<E, R, E>, thisArg?: unknown): this;
|
|
602
938
|
/**
|
|
603
939
|
* Map values into a new list (possibly different element type).
|
|
604
940
|
* @remarks Time O(N), Space O(N)
|
|
@@ -619,6 +955,27 @@ export declare class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase
|
|
|
619
955
|
|
|
620
956
|
|
|
621
957
|
|
|
958
|
+
|
|
959
|
+
|
|
960
|
+
|
|
961
|
+
|
|
962
|
+
|
|
963
|
+
|
|
964
|
+
|
|
965
|
+
|
|
966
|
+
|
|
967
|
+
|
|
968
|
+
|
|
969
|
+
|
|
970
|
+
|
|
971
|
+
|
|
972
|
+
|
|
973
|
+
|
|
974
|
+
|
|
975
|
+
|
|
976
|
+
|
|
977
|
+
|
|
978
|
+
|
|
622
979
|
* @example
|
|
623
980
|
* // DoublyLinkedList for...of iteration and map operation
|
|
624
981
|
* const list = new DoublyLinkedList<number>([1, 2, 3, 4, 5]);
|
|
@@ -634,7 +991,7 @@ export declare class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase
|
|
|
634
991
|
* }
|
|
635
992
|
* console.log(result); // [1, 2, 3, 4, 5];
|
|
636
993
|
*/
|
|
637
|
-
map<EM, RM>(callback: ElementCallback<E, R, EM>, options?: DoublyLinkedListOptions<EM, RM>, thisArg?:
|
|
994
|
+
map<EM, RM>(callback: ElementCallback<E, R, EM>, options?: DoublyLinkedListOptions<EM, RM>, thisArg?: unknown): DoublyLinkedList<EM, RM>;
|
|
638
995
|
/**
|
|
639
996
|
* (Protected) Create or return a node for the given input (node or raw element).
|
|
640
997
|
* @remarks Time O(1), Space O(1)
|