max-priority-queue-typed 2.5.2 → 2.5.3

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 (59) hide show
  1. package/dist/cjs/index.cjs +103 -16
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/cjs-legacy/index.cjs +103 -16
  4. package/dist/cjs-legacy/index.cjs.map +1 -1
  5. package/dist/esm/index.mjs +103 -16
  6. package/dist/esm/index.mjs.map +1 -1
  7. package/dist/esm-legacy/index.mjs +103 -16
  8. package/dist/esm-legacy/index.mjs.map +1 -1
  9. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +50 -2
  10. package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +56 -0
  11. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +116 -15
  12. package/dist/types/data-structures/binary-tree/bst.d.ts +99 -3
  13. package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +79 -8
  14. package/dist/types/data-structures/binary-tree/segment-tree.d.ts +24 -0
  15. package/dist/types/data-structures/binary-tree/tree-map.d.ts +520 -1
  16. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +489 -1
  17. package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +393 -1
  18. package/dist/types/data-structures/binary-tree/tree-set.d.ts +500 -1
  19. package/dist/types/data-structures/graph/directed-graph.d.ts +40 -0
  20. package/dist/types/data-structures/graph/undirected-graph.d.ts +36 -0
  21. package/dist/types/data-structures/hash/hash-map.d.ts +51 -6
  22. package/dist/types/data-structures/heap/heap.d.ts +98 -12
  23. package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +75 -0
  24. package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +61 -1
  25. package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +72 -0
  26. package/dist/types/data-structures/matrix/matrix.d.ts +32 -0
  27. package/dist/types/data-structures/queue/deque.d.ts +82 -0
  28. package/dist/types/data-structures/queue/queue.d.ts +61 -0
  29. package/dist/types/data-structures/stack/stack.d.ts +42 -2
  30. package/dist/types/data-structures/trie/trie.d.ts +48 -0
  31. package/dist/types/interfaces/binary-tree.d.ts +2 -3
  32. package/dist/umd/max-priority-queue-typed.js +103 -16
  33. package/dist/umd/max-priority-queue-typed.js.map +1 -1
  34. package/dist/umd/max-priority-queue-typed.min.js +1 -1
  35. package/dist/umd/max-priority-queue-typed.min.js.map +1 -1
  36. package/package.json +2 -2
  37. package/src/data-structures/binary-tree/avl-tree.ts +52 -5
  38. package/src/data-structures/binary-tree/binary-indexed-tree.ts +56 -0
  39. package/src/data-structures/binary-tree/binary-tree.ts +167 -81
  40. package/src/data-structures/binary-tree/bst.ts +101 -7
  41. package/src/data-structures/binary-tree/red-black-tree.ts +82 -15
  42. package/src/data-structures/binary-tree/segment-tree.ts +24 -0
  43. package/src/data-structures/binary-tree/tree-map.ts +540 -3
  44. package/src/data-structures/binary-tree/tree-multi-map.ts +490 -2
  45. package/src/data-structures/binary-tree/tree-multi-set.ts +393 -1
  46. package/src/data-structures/binary-tree/tree-set.ts +520 -3
  47. package/src/data-structures/graph/directed-graph.ts +41 -1
  48. package/src/data-structures/graph/undirected-graph.ts +37 -1
  49. package/src/data-structures/hash/hash-map.ts +67 -12
  50. package/src/data-structures/heap/heap.ts +107 -19
  51. package/src/data-structures/linked-list/doubly-linked-list.ts +88 -0
  52. package/src/data-structures/linked-list/singly-linked-list.ts +61 -1
  53. package/src/data-structures/linked-list/skip-linked-list.ts +72 -0
  54. package/src/data-structures/matrix/matrix.ts +32 -0
  55. package/src/data-structures/queue/deque.ts +85 -0
  56. package/src/data-structures/queue/queue.ts +73 -0
  57. package/src/data-structures/stack/stack.ts +45 -5
  58. package/src/data-structures/trie/trie.ts +48 -0
  59. package/src/interfaces/binary-tree.ts +1 -9
@@ -298,6 +298,10 @@ export class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, D
298
298
 
299
299
 
300
300
 
301
+
302
+
303
+
304
+
301
305
 
302
306
 
303
307
 
@@ -369,6 +373,10 @@ export class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, D
369
373
 
370
374
 
371
375
 
376
+
377
+
378
+
379
+
372
380
 
373
381
 
374
382
 
@@ -439,6 +447,10 @@ export class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, D
439
447
 
440
448
 
441
449
 
450
+
451
+
452
+
453
+
442
454
 
443
455
 
444
456
 
@@ -500,6 +512,10 @@ export class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, D
500
512
 
501
513
 
502
514
 
515
+
516
+
517
+
518
+
503
519
 
504
520
 
505
521
 
@@ -594,6 +610,10 @@ export class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, D
594
610
 
595
611
 
596
612
 
613
+
614
+
615
+
616
+
597
617
 
598
618
 
599
619
 
@@ -645,6 +665,10 @@ export class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, D
645
665
 
646
666
 
647
667
 
668
+
669
+
670
+
671
+
648
672
 
649
673
 
650
674
 
@@ -735,6 +759,10 @@ export class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, D
735
759
 
736
760
 
737
761
 
762
+
763
+
764
+
765
+
738
766
 
739
767
 
740
768
 
@@ -861,6 +889,10 @@ export class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, D
861
889
 
862
890
 
863
891
 
892
+
893
+
894
+
895
+
864
896
 
865
897
 
866
898
 
@@ -919,6 +951,10 @@ export class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, D
919
951
 
920
952
 
921
953
 
954
+
955
+
956
+
957
+
922
958
 
923
959
 
924
960
 
@@ -979,6 +1015,10 @@ export class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, D
979
1015
 
980
1016
 
981
1017
 
1018
+
1019
+
1020
+
1021
+
982
1022
 
983
1023
 
984
1024
 
@@ -1025,6 +1065,10 @@ export class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, D
1025
1065
 
1026
1066
 
1027
1067
 
1068
+
1069
+
1070
+
1071
+
1028
1072
 
1029
1073
 
1030
1074
 
@@ -1075,6 +1119,10 @@ export class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, D
1075
1119
 
1076
1120
 
1077
1121
 
1122
+
1123
+
1124
+
1125
+
1078
1126
 
1079
1127
 
1080
1128
 
@@ -1131,6 +1179,10 @@ export class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, D
1131
1179
 
1132
1180
 
1133
1181
 
1182
+
1183
+
1184
+
1185
+
1134
1186
 
1135
1187
 
1136
1188
 
@@ -1190,6 +1242,10 @@ export class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, D
1190
1242
 
1191
1243
 
1192
1244
 
1245
+
1246
+
1247
+
1248
+
1193
1249
 
1194
1250
 
1195
1251
 
@@ -1213,6 +1269,26 @@ export class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, D
1213
1269
  return this;
1214
1270
  }
1215
1271
 
1272
+ /**
1273
+ * Delete the first element that satisfies a predicate.
1274
+ * @remarks Time O(N), Space O(1)
1275
+ * @param predicate - Function (value, index, list) → boolean to decide deletion.
1276
+ * @returns True if a match was removed.
1277
+ */
1278
+ deleteWhere(predicate: (value: E, index: number, list: this) => boolean): boolean {
1279
+ let current = this.head;
1280
+ let index = 0;
1281
+ while (current) {
1282
+ if (predicate(current.value, index, this)) {
1283
+ this.delete(current);
1284
+ return true;
1285
+ }
1286
+ current = current.next;
1287
+ index++;
1288
+ }
1289
+ return false;
1290
+ }
1291
+
1216
1292
  /**
1217
1293
  * Set the equality comparator used to compare values.
1218
1294
  * @remarks Time O(1), Space O(1)
@@ -1257,6 +1333,10 @@ export class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, D
1257
1333
 
1258
1334
 
1259
1335
 
1336
+
1337
+
1338
+
1339
+
1260
1340
 
1261
1341
 
1262
1342
 
@@ -1312,6 +1392,10 @@ export class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, D
1312
1392
 
1313
1393
 
1314
1394
 
1395
+
1396
+
1397
+
1398
+
1315
1399
 
1316
1400
 
1317
1401
 
@@ -1388,6 +1472,10 @@ export class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, D
1388
1472
 
1389
1473
 
1390
1474
 
1475
+
1476
+
1477
+
1478
+
1391
1479
 
1392
1480
 
1393
1481
 
@@ -57,7 +57,7 @@ export class SinglyLinkedListNode<E = any> extends LinkedListNode<E> {
57
57
  * @remarks Time O(1), Space O(1)
58
58
  * @template E
59
59
  * @template R
60
- * 1. Node Structure: Each node contains three parts: a data field, a pointer (or reference) to the previous node, and a pointer to the next node. This structure allows traversal of the linked list in both directions.
60
+ * 1. Node Structure: Each node contains two parts: a data field and a pointer (or reference) to the next node. This structure allows forward-only traversal of the linked list.
61
61
  * 2. Bidirectional Traversal: Unlike doubly linked lists, singly linked lists can be easily traversed forwards but not backwards.
62
62
  * 3. No Centralized Index: Unlike arrays, elements in a linked list are not stored contiguously, so there is no centralized index. Accessing elements in a linked list typically requires traversing from the head or tail node.
63
63
  * 4. High Efficiency in Insertion and Deletion: Adding or removing elements in a linked list does not require moving other elements, making these operations more efficient than in arrays.
@@ -326,6 +326,10 @@ export class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, S
326
326
 
327
327
 
328
328
 
329
+
330
+
331
+
332
+
329
333
 
330
334
 
331
335
 
@@ -395,6 +399,10 @@ export class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, S
395
399
 
396
400
 
397
401
 
402
+
403
+
404
+
405
+
398
406
 
399
407
 
400
408
 
@@ -469,6 +477,10 @@ export class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, S
469
477
 
470
478
 
471
479
 
480
+
481
+
482
+
483
+
472
484
 
473
485
 
474
486
 
@@ -525,6 +537,10 @@ export class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, S
525
537
 
526
538
 
527
539
 
540
+
541
+
542
+
543
+
528
544
 
529
545
 
530
546
 
@@ -650,6 +666,10 @@ export class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, S
650
666
 
651
667
 
652
668
 
669
+
670
+
671
+
672
+
653
673
 
654
674
 
655
675
 
@@ -715,6 +735,10 @@ export class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, S
715
735
 
716
736
 
717
737
 
738
+
739
+
740
+
741
+
718
742
 
719
743
 
720
744
 
@@ -765,6 +789,10 @@ export class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, S
765
789
 
766
790
 
767
791
 
792
+
793
+
794
+
795
+
768
796
 
769
797
 
770
798
 
@@ -821,6 +849,10 @@ export class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, S
821
849
 
822
850
 
823
851
 
852
+
853
+
854
+
855
+
824
856
 
825
857
 
826
858
 
@@ -883,6 +915,10 @@ export class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, S
883
915
 
884
916
 
885
917
 
918
+
919
+
920
+
921
+
886
922
 
887
923
 
888
924
 
@@ -954,6 +990,10 @@ export class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, S
954
990
 
955
991
 
956
992
 
993
+
994
+
995
+
996
+
957
997
 
958
998
 
959
999
 
@@ -1000,6 +1040,10 @@ export class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, S
1000
1040
 
1001
1041
 
1002
1042
 
1043
+
1044
+
1045
+
1046
+
1003
1047
 
1004
1048
 
1005
1049
 
@@ -1052,6 +1096,10 @@ export class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, S
1052
1096
 
1053
1097
 
1054
1098
 
1099
+
1100
+
1101
+
1102
+
1055
1103
 
1056
1104
 
1057
1105
 
@@ -1298,6 +1346,10 @@ export class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, S
1298
1346
 
1299
1347
 
1300
1348
 
1349
+
1350
+
1351
+
1352
+
1301
1353
 
1302
1354
 
1303
1355
 
@@ -1354,6 +1406,10 @@ export class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, S
1354
1406
 
1355
1407
 
1356
1408
 
1409
+
1410
+
1411
+
1412
+
1357
1413
 
1358
1414
 
1359
1415
 
@@ -1440,6 +1496,10 @@ export class SinglyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, S
1440
1496
 
1441
1497
 
1442
1498
 
1499
+
1500
+
1501
+
1502
+
1443
1503
 
1444
1504
 
1445
1505
 
@@ -164,6 +164,10 @@ export class SkipList<K = any, V = any, R = [K, V]> extends IterableEntryBase<K,
164
164
 
165
165
 
166
166
 
167
+
168
+
169
+
170
+
167
171
 
168
172
 
169
173
 
@@ -207,6 +211,10 @@ export class SkipList<K = any, V = any, R = [K, V]> extends IterableEntryBase<K,
207
211
 
208
212
 
209
213
 
214
+
215
+
216
+
217
+
210
218
 
211
219
 
212
220
 
@@ -253,6 +261,10 @@ export class SkipList<K = any, V = any, R = [K, V]> extends IterableEntryBase<K,
253
261
 
254
262
 
255
263
 
264
+
265
+
266
+
267
+
256
268
 
257
269
 
258
270
 
@@ -308,6 +320,10 @@ export class SkipList<K = any, V = any, R = [K, V]> extends IterableEntryBase<K,
308
320
 
309
321
 
310
322
 
323
+
324
+
325
+
326
+
311
327
 
312
328
 
313
329
 
@@ -393,6 +409,10 @@ export class SkipList<K = any, V = any, R = [K, V]> extends IterableEntryBase<K,
393
409
 
394
410
 
395
411
 
412
+
413
+
414
+
415
+
396
416
 
397
417
 
398
418
 
@@ -457,6 +477,10 @@ export class SkipList<K = any, V = any, R = [K, V]> extends IterableEntryBase<K,
457
477
 
458
478
 
459
479
 
480
+
481
+
482
+
483
+
460
484
 
461
485
 
462
486
 
@@ -504,6 +528,10 @@ export class SkipList<K = any, V = any, R = [K, V]> extends IterableEntryBase<K,
504
528
 
505
529
 
506
530
 
531
+
532
+
533
+
534
+
507
535
 
508
536
 
509
537
 
@@ -576,6 +604,10 @@ export class SkipList<K = any, V = any, R = [K, V]> extends IterableEntryBase<K,
576
604
 
577
605
 
578
606
 
607
+
608
+
609
+
610
+
579
611
 
580
612
 
581
613
 
@@ -623,6 +655,10 @@ export class SkipList<K = any, V = any, R = [K, V]> extends IterableEntryBase<K,
623
655
 
624
656
 
625
657
 
658
+
659
+
660
+
661
+
626
662
 
627
663
 
628
664
 
@@ -672,6 +708,10 @@ export class SkipList<K = any, V = any, R = [K, V]> extends IterableEntryBase<K,
672
708
 
673
709
 
674
710
 
711
+
712
+
713
+
714
+
675
715
 
676
716
 
677
717
 
@@ -719,6 +759,10 @@ export class SkipList<K = any, V = any, R = [K, V]> extends IterableEntryBase<K,
719
759
 
720
760
 
721
761
 
762
+
763
+
764
+
765
+
722
766
 
723
767
 
724
768
 
@@ -769,6 +813,10 @@ export class SkipList<K = any, V = any, R = [K, V]> extends IterableEntryBase<K,
769
813
 
770
814
 
771
815
 
816
+
817
+
818
+
819
+
772
820
 
773
821
 
774
822
 
@@ -824,6 +872,10 @@ export class SkipList<K = any, V = any, R = [K, V]> extends IterableEntryBase<K,
824
872
 
825
873
 
826
874
 
875
+
876
+
877
+
878
+
827
879
 
828
880
 
829
881
 
@@ -879,6 +931,10 @@ export class SkipList<K = any, V = any, R = [K, V]> extends IterableEntryBase<K,
879
931
 
880
932
 
881
933
 
934
+
935
+
936
+
937
+
882
938
 
883
939
 
884
940
 
@@ -931,6 +987,10 @@ export class SkipList<K = any, V = any, R = [K, V]> extends IterableEntryBase<K,
931
987
 
932
988
 
933
989
 
990
+
991
+
992
+
993
+
934
994
 
935
995
 
936
996
 
@@ -989,6 +1049,10 @@ export class SkipList<K = any, V = any, R = [K, V]> extends IterableEntryBase<K,
989
1049
 
990
1050
 
991
1051
 
1052
+
1053
+
1054
+
1055
+
992
1056
 
993
1057
 
994
1058
 
@@ -1062,6 +1126,10 @@ export class SkipList<K = any, V = any, R = [K, V]> extends IterableEntryBase<K,
1062
1126
 
1063
1127
 
1064
1128
 
1129
+
1130
+
1131
+
1132
+
1065
1133
 
1066
1134
 
1067
1135
 
@@ -1115,6 +1183,10 @@ export class SkipList<K = any, V = any, R = [K, V]> extends IterableEntryBase<K,
1115
1183
 
1116
1184
 
1117
1185
 
1186
+
1187
+
1188
+
1189
+
1118
1190
 
1119
1191
 
1120
1192
 
@@ -219,6 +219,10 @@ export class Matrix {
219
219
 
220
220
 
221
221
 
222
+
223
+
224
+
225
+
222
226
 
223
227
 
224
228
 
@@ -288,6 +292,10 @@ export class Matrix {
288
292
 
289
293
 
290
294
 
295
+
296
+
297
+
298
+
291
299
 
292
300
 
293
301
 
@@ -354,6 +362,10 @@ export class Matrix {
354
362
 
355
363
 
356
364
 
365
+
366
+
367
+
368
+
357
369
 
358
370
 
359
371
 
@@ -444,6 +456,10 @@ export class Matrix {
444
456
 
445
457
 
446
458
 
459
+
460
+
461
+
462
+
447
463
 
448
464
 
449
465
 
@@ -517,6 +533,10 @@ export class Matrix {
517
533
 
518
534
 
519
535
 
536
+
537
+
538
+
539
+
520
540
 
521
541
 
522
542
 
@@ -612,6 +632,10 @@ export class Matrix {
612
632
 
613
633
 
614
634
 
635
+
636
+
637
+
638
+
615
639
 
616
640
 
617
641
 
@@ -694,6 +718,10 @@ export class Matrix {
694
718
 
695
719
 
696
720
 
721
+
722
+
723
+
724
+
697
725
 
698
726
 
699
727
 
@@ -820,6 +848,10 @@ export class Matrix {
820
848
 
821
849
 
822
850
 
851
+
852
+
853
+
854
+
823
855
 
824
856
 
825
857