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
|
@@ -212,7 +212,7 @@ export abstract class AbstractGraph<
|
|
|
212
212
|
* @returns `true` if string/number; else `false`.
|
|
213
213
|
* @remarks Time O(1), Space O(1)
|
|
214
214
|
*/
|
|
215
|
-
isVertexKey(potentialKey:
|
|
215
|
+
isVertexKey(potentialKey: unknown): potentialKey is VertexKey {
|
|
216
216
|
const potentialKeyType = typeof potentialKey;
|
|
217
217
|
return potentialKeyType === 'string' || potentialKeyType === 'number';
|
|
218
218
|
}
|
|
@@ -894,7 +894,7 @@ export abstract class AbstractGraph<
|
|
|
894
894
|
* @returns A new graph of the same concrete class (`this` type).
|
|
895
895
|
* @remarks Time O(V + E), Space O(V + E)
|
|
896
896
|
*/
|
|
897
|
-
filter(predicate: EntryCallback<VertexKey, V | undefined, boolean>, thisArg?:
|
|
897
|
+
filter(predicate: EntryCallback<VertexKey, V | undefined, boolean>, thisArg?: unknown): this {
|
|
898
898
|
const filtered: [VertexKey, V | undefined][] = [];
|
|
899
899
|
let index = 0;
|
|
900
900
|
for (const [key, value] of this) {
|
|
@@ -912,7 +912,7 @@ export abstract class AbstractGraph<
|
|
|
912
912
|
*/
|
|
913
913
|
filterEntries(
|
|
914
914
|
predicate: EntryCallback<VertexKey, V | undefined, boolean>,
|
|
915
|
-
thisArg?:
|
|
915
|
+
thisArg?: unknown
|
|
916
916
|
): [VertexKey, V | undefined][] {
|
|
917
917
|
const filtered: [VertexKey, V | undefined][] = [];
|
|
918
918
|
let index = 0;
|
|
@@ -925,7 +925,7 @@ export abstract class AbstractGraph<
|
|
|
925
925
|
return filtered;
|
|
926
926
|
}
|
|
927
927
|
|
|
928
|
-
map<T>(callback: EntryCallback<VertexKey, V | undefined, T>, thisArg?:
|
|
928
|
+
map<T>(callback: EntryCallback<VertexKey, V | undefined, T>, thisArg?: unknown): T[] {
|
|
929
929
|
const mapped: T[] = [];
|
|
930
930
|
let index = 0;
|
|
931
931
|
for (const [key, value] of this) {
|
|
@@ -225,6 +225,27 @@ export class DirectedGraph<
|
|
|
225
225
|
|
|
226
226
|
|
|
227
227
|
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
|
|
228
249
|
* @example
|
|
229
250
|
* // Get edge between vertices
|
|
230
251
|
* const g = new DirectedGraph();
|
|
@@ -296,6 +317,27 @@ export class DirectedGraph<
|
|
|
296
317
|
|
|
297
318
|
|
|
298
319
|
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
|
|
336
|
+
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
|
|
299
341
|
* @example
|
|
300
342
|
* // DirectedGraph deleteEdge and vertex operations
|
|
301
343
|
* const graph = new DirectedGraph<string>();
|
|
@@ -362,6 +404,27 @@ export class DirectedGraph<
|
|
|
362
404
|
|
|
363
405
|
|
|
364
406
|
|
|
407
|
+
|
|
408
|
+
|
|
409
|
+
|
|
410
|
+
|
|
411
|
+
|
|
412
|
+
|
|
413
|
+
|
|
414
|
+
|
|
415
|
+
|
|
416
|
+
|
|
417
|
+
|
|
418
|
+
|
|
419
|
+
|
|
420
|
+
|
|
421
|
+
|
|
422
|
+
|
|
423
|
+
|
|
424
|
+
|
|
425
|
+
|
|
426
|
+
|
|
427
|
+
|
|
365
428
|
* @example
|
|
366
429
|
* // Remove a vertex
|
|
367
430
|
* const g = new DirectedGraph();
|
|
@@ -428,6 +491,27 @@ export class DirectedGraph<
|
|
|
428
491
|
|
|
429
492
|
|
|
430
493
|
|
|
494
|
+
|
|
495
|
+
|
|
496
|
+
|
|
497
|
+
|
|
498
|
+
|
|
499
|
+
|
|
500
|
+
|
|
501
|
+
|
|
502
|
+
|
|
503
|
+
|
|
504
|
+
|
|
505
|
+
|
|
506
|
+
|
|
507
|
+
|
|
508
|
+
|
|
509
|
+
|
|
510
|
+
|
|
511
|
+
|
|
512
|
+
|
|
513
|
+
|
|
514
|
+
|
|
431
515
|
* @example
|
|
432
516
|
* // Get incoming edges
|
|
433
517
|
* const g = new DirectedGraph();
|
|
@@ -459,6 +543,27 @@ export class DirectedGraph<
|
|
|
459
543
|
|
|
460
544
|
|
|
461
545
|
|
|
546
|
+
|
|
547
|
+
|
|
548
|
+
|
|
549
|
+
|
|
550
|
+
|
|
551
|
+
|
|
552
|
+
|
|
553
|
+
|
|
554
|
+
|
|
555
|
+
|
|
556
|
+
|
|
557
|
+
|
|
558
|
+
|
|
559
|
+
|
|
560
|
+
|
|
561
|
+
|
|
562
|
+
|
|
563
|
+
|
|
564
|
+
|
|
565
|
+
|
|
566
|
+
|
|
462
567
|
* @example
|
|
463
568
|
* // Get outgoing edges
|
|
464
569
|
* const g = new DirectedGraph();
|
|
@@ -562,6 +667,27 @@ export class DirectedGraph<
|
|
|
562
667
|
|
|
563
668
|
|
|
564
669
|
|
|
670
|
+
|
|
671
|
+
|
|
672
|
+
|
|
673
|
+
|
|
674
|
+
|
|
675
|
+
|
|
676
|
+
|
|
677
|
+
|
|
678
|
+
|
|
679
|
+
|
|
680
|
+
|
|
681
|
+
|
|
682
|
+
|
|
683
|
+
|
|
684
|
+
|
|
685
|
+
|
|
686
|
+
|
|
687
|
+
|
|
688
|
+
|
|
689
|
+
|
|
690
|
+
|
|
565
691
|
* @example
|
|
566
692
|
* // DirectedGraph topologicalSort for task scheduling
|
|
567
693
|
* const graph = new DirectedGraph<string>();
|
|
@@ -632,6 +758,27 @@ export class DirectedGraph<
|
|
|
632
758
|
|
|
633
759
|
|
|
634
760
|
|
|
761
|
+
|
|
762
|
+
|
|
763
|
+
|
|
764
|
+
|
|
765
|
+
|
|
766
|
+
|
|
767
|
+
|
|
768
|
+
|
|
769
|
+
|
|
770
|
+
|
|
771
|
+
|
|
772
|
+
|
|
773
|
+
|
|
774
|
+
|
|
775
|
+
|
|
776
|
+
|
|
777
|
+
|
|
778
|
+
|
|
779
|
+
|
|
780
|
+
|
|
781
|
+
|
|
635
782
|
* @example
|
|
636
783
|
* // Get all edges
|
|
637
784
|
* const g = new DirectedGraph();
|
|
@@ -659,6 +806,27 @@ export class DirectedGraph<
|
|
|
659
806
|
|
|
660
807
|
|
|
661
808
|
|
|
809
|
+
|
|
810
|
+
|
|
811
|
+
|
|
812
|
+
|
|
813
|
+
|
|
814
|
+
|
|
815
|
+
|
|
816
|
+
|
|
817
|
+
|
|
818
|
+
|
|
819
|
+
|
|
820
|
+
|
|
821
|
+
|
|
822
|
+
|
|
823
|
+
|
|
824
|
+
|
|
825
|
+
|
|
826
|
+
|
|
827
|
+
|
|
828
|
+
|
|
829
|
+
|
|
662
830
|
* @example
|
|
663
831
|
* // Get outgoing neighbors
|
|
664
832
|
* const g = new DirectedGraph();
|
|
@@ -744,6 +912,27 @@ export class DirectedGraph<
|
|
|
744
912
|
|
|
745
913
|
|
|
746
914
|
|
|
915
|
+
|
|
916
|
+
|
|
917
|
+
|
|
918
|
+
|
|
919
|
+
|
|
920
|
+
|
|
921
|
+
|
|
922
|
+
|
|
923
|
+
|
|
924
|
+
|
|
925
|
+
|
|
926
|
+
|
|
927
|
+
|
|
928
|
+
|
|
929
|
+
|
|
930
|
+
|
|
931
|
+
|
|
932
|
+
|
|
933
|
+
|
|
934
|
+
|
|
935
|
+
|
|
747
936
|
* @example
|
|
748
937
|
* // Find strongly connected components
|
|
749
938
|
* const g = new DirectedGraph();
|
|
@@ -839,6 +1028,27 @@ export class DirectedGraph<
|
|
|
839
1028
|
|
|
840
1029
|
|
|
841
1030
|
|
|
1031
|
+
|
|
1032
|
+
|
|
1033
|
+
|
|
1034
|
+
|
|
1035
|
+
|
|
1036
|
+
|
|
1037
|
+
|
|
1038
|
+
|
|
1039
|
+
|
|
1040
|
+
|
|
1041
|
+
|
|
1042
|
+
|
|
1043
|
+
|
|
1044
|
+
|
|
1045
|
+
|
|
1046
|
+
|
|
1047
|
+
|
|
1048
|
+
|
|
1049
|
+
|
|
1050
|
+
|
|
1051
|
+
|
|
842
1052
|
* @example
|
|
843
1053
|
* // Get strongly connected components
|
|
844
1054
|
* const g = new DirectedGraph();
|
|
@@ -234,6 +234,27 @@ export class UndirectedGraph<
|
|
|
234
234
|
|
|
235
235
|
|
|
236
236
|
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
|
|
237
258
|
* @example
|
|
238
259
|
* // Get edge between vertices
|
|
239
260
|
* const g = new UndirectedGraph();
|
|
@@ -301,6 +322,27 @@ export class UndirectedGraph<
|
|
|
301
322
|
|
|
302
323
|
|
|
303
324
|
|
|
325
|
+
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
|
|
336
|
+
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
|
|
344
|
+
|
|
345
|
+
|
|
304
346
|
* @example
|
|
305
347
|
* // UndirectedGraph deleteEdge and vertex operations
|
|
306
348
|
* const graph = new UndirectedGraph<string>();
|
|
@@ -363,6 +405,27 @@ export class UndirectedGraph<
|
|
|
363
405
|
|
|
364
406
|
|
|
365
407
|
|
|
408
|
+
|
|
409
|
+
|
|
410
|
+
|
|
411
|
+
|
|
412
|
+
|
|
413
|
+
|
|
414
|
+
|
|
415
|
+
|
|
416
|
+
|
|
417
|
+
|
|
418
|
+
|
|
419
|
+
|
|
420
|
+
|
|
421
|
+
|
|
422
|
+
|
|
423
|
+
|
|
424
|
+
|
|
425
|
+
|
|
426
|
+
|
|
427
|
+
|
|
428
|
+
|
|
366
429
|
* @example
|
|
367
430
|
* // Remove vertex and edges
|
|
368
431
|
* const g = new UndirectedGraph();
|
|
@@ -449,6 +512,27 @@ export class UndirectedGraph<
|
|
|
449
512
|
|
|
450
513
|
|
|
451
514
|
|
|
515
|
+
|
|
516
|
+
|
|
517
|
+
|
|
518
|
+
|
|
519
|
+
|
|
520
|
+
|
|
521
|
+
|
|
522
|
+
|
|
523
|
+
|
|
524
|
+
|
|
525
|
+
|
|
526
|
+
|
|
527
|
+
|
|
528
|
+
|
|
529
|
+
|
|
530
|
+
|
|
531
|
+
|
|
532
|
+
|
|
533
|
+
|
|
534
|
+
|
|
535
|
+
|
|
452
536
|
* @example
|
|
453
537
|
* // Get all edges
|
|
454
538
|
* const g = new UndirectedGraph();
|
|
@@ -480,6 +564,27 @@ export class UndirectedGraph<
|
|
|
480
564
|
|
|
481
565
|
|
|
482
566
|
|
|
567
|
+
|
|
568
|
+
|
|
569
|
+
|
|
570
|
+
|
|
571
|
+
|
|
572
|
+
|
|
573
|
+
|
|
574
|
+
|
|
575
|
+
|
|
576
|
+
|
|
577
|
+
|
|
578
|
+
|
|
579
|
+
|
|
580
|
+
|
|
581
|
+
|
|
582
|
+
|
|
583
|
+
|
|
584
|
+
|
|
585
|
+
|
|
586
|
+
|
|
587
|
+
|
|
483
588
|
* @example
|
|
484
589
|
* // UndirectedGraph connectivity and neighbors
|
|
485
590
|
* const graph = new UndirectedGraph<string>();
|
|
@@ -585,6 +690,27 @@ export class UndirectedGraph<
|
|
|
585
690
|
|
|
586
691
|
|
|
587
692
|
|
|
693
|
+
|
|
694
|
+
|
|
695
|
+
|
|
696
|
+
|
|
697
|
+
|
|
698
|
+
|
|
699
|
+
|
|
700
|
+
|
|
701
|
+
|
|
702
|
+
|
|
703
|
+
|
|
704
|
+
|
|
705
|
+
|
|
706
|
+
|
|
707
|
+
|
|
708
|
+
|
|
709
|
+
|
|
710
|
+
|
|
711
|
+
|
|
712
|
+
|
|
713
|
+
|
|
588
714
|
* @example
|
|
589
715
|
* // Find articulation points and bridges
|
|
590
716
|
* const g = new UndirectedGraph();
|
|
@@ -734,6 +860,27 @@ export class UndirectedGraph<
|
|
|
734
860
|
|
|
735
861
|
|
|
736
862
|
|
|
863
|
+
|
|
864
|
+
|
|
865
|
+
|
|
866
|
+
|
|
867
|
+
|
|
868
|
+
|
|
869
|
+
|
|
870
|
+
|
|
871
|
+
|
|
872
|
+
|
|
873
|
+
|
|
874
|
+
|
|
875
|
+
|
|
876
|
+
|
|
877
|
+
|
|
878
|
+
|
|
879
|
+
|
|
880
|
+
|
|
881
|
+
|
|
882
|
+
|
|
883
|
+
|
|
737
884
|
* @example
|
|
738
885
|
* // Detect cycle
|
|
739
886
|
* const g = new UndirectedGraph();
|
|
@@ -781,6 +928,27 @@ export class UndirectedGraph<
|
|
|
781
928
|
|
|
782
929
|
|
|
783
930
|
|
|
931
|
+
|
|
932
|
+
|
|
933
|
+
|
|
934
|
+
|
|
935
|
+
|
|
936
|
+
|
|
937
|
+
|
|
938
|
+
|
|
939
|
+
|
|
940
|
+
|
|
941
|
+
|
|
942
|
+
|
|
943
|
+
|
|
944
|
+
|
|
945
|
+
|
|
946
|
+
|
|
947
|
+
|
|
948
|
+
|
|
949
|
+
|
|
950
|
+
|
|
951
|
+
|
|
784
952
|
* @example
|
|
785
953
|
* // Find bridge edges
|
|
786
954
|
* const g = new UndirectedGraph();
|
|
@@ -808,6 +976,27 @@ export class UndirectedGraph<
|
|
|
808
976
|
|
|
809
977
|
|
|
810
978
|
|
|
979
|
+
|
|
980
|
+
|
|
981
|
+
|
|
982
|
+
|
|
983
|
+
|
|
984
|
+
|
|
985
|
+
|
|
986
|
+
|
|
987
|
+
|
|
988
|
+
|
|
989
|
+
|
|
990
|
+
|
|
991
|
+
|
|
992
|
+
|
|
993
|
+
|
|
994
|
+
|
|
995
|
+
|
|
996
|
+
|
|
997
|
+
|
|
998
|
+
|
|
999
|
+
|
|
811
1000
|
* @example
|
|
812
1001
|
* // Find articulation points
|
|
813
1002
|
* const g = new UndirectedGraph();
|