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.
Files changed (90) hide show
  1. package/dist/cjs/index.cjs +398 -55
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/cjs-legacy/index.cjs +397 -54
  4. package/dist/cjs-legacy/index.cjs.map +1 -1
  5. package/dist/esm/index.mjs +398 -56
  6. package/dist/esm/index.mjs.map +1 -1
  7. package/dist/esm-legacy/index.mjs +397 -55
  8. package/dist/esm-legacy/index.mjs.map +1 -1
  9. package/dist/types/common/error.d.ts +9 -0
  10. package/dist/types/common/index.d.ts +1 -1
  11. package/dist/types/data-structures/base/index.d.ts +1 -0
  12. package/dist/types/data-structures/base/iterable-entry-base.d.ts +8 -8
  13. package/dist/types/data-structures/base/linear-base.d.ts +3 -3
  14. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +288 -0
  15. package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +336 -0
  16. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +618 -18
  17. package/dist/types/data-structures/binary-tree/bst.d.ts +676 -1
  18. package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +456 -0
  19. package/dist/types/data-structures/binary-tree/segment-tree.d.ts +144 -1
  20. package/dist/types/data-structures/binary-tree/tree-map.d.ts +3307 -399
  21. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +3285 -360
  22. package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +2674 -325
  23. package/dist/types/data-structures/binary-tree/tree-set.d.ts +3072 -287
  24. package/dist/types/data-structures/graph/abstract-graph.d.ts +4 -4
  25. package/dist/types/data-structures/graph/directed-graph.d.ts +240 -0
  26. package/dist/types/data-structures/graph/undirected-graph.d.ts +216 -0
  27. package/dist/types/data-structures/hash/hash-map.d.ts +274 -10
  28. package/dist/types/data-structures/heap/heap.d.ts +336 -0
  29. package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +411 -3
  30. package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +363 -3
  31. package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +434 -2
  32. package/dist/types/data-structures/matrix/matrix.d.ts +192 -0
  33. package/dist/types/data-structures/queue/deque.d.ts +364 -4
  34. package/dist/types/data-structures/queue/queue.d.ts +288 -0
  35. package/dist/types/data-structures/stack/stack.d.ts +240 -0
  36. package/dist/types/data-structures/trie/trie.d.ts +292 -4
  37. package/dist/types/interfaces/graph.d.ts +1 -1
  38. package/dist/types/types/common.d.ts +2 -2
  39. package/dist/types/types/data-structures/binary-tree/bst.d.ts +1 -0
  40. package/dist/types/types/data-structures/binary-tree/tree-map.d.ts +5 -0
  41. package/dist/types/types/data-structures/binary-tree/tree-multi-set.d.ts +4 -0
  42. package/dist/types/types/data-structures/binary-tree/tree-set.d.ts +4 -0
  43. package/dist/types/types/data-structures/heap/heap.d.ts +1 -0
  44. package/dist/types/types/data-structures/priority-queue/priority-queue.d.ts +1 -0
  45. package/dist/types/types/utils/validate-type.d.ts +4 -4
  46. package/dist/umd/max-priority-queue-typed.js +395 -53
  47. package/dist/umd/max-priority-queue-typed.js.map +1 -1
  48. package/dist/umd/max-priority-queue-typed.min.js +1 -1
  49. package/dist/umd/max-priority-queue-typed.min.js.map +1 -1
  50. package/package.json +2 -2
  51. package/src/common/error.ts +19 -1
  52. package/src/common/index.ts +1 -1
  53. package/src/data-structures/base/index.ts +1 -0
  54. package/src/data-structures/base/iterable-element-base.ts +3 -2
  55. package/src/data-structures/base/iterable-entry-base.ts +8 -8
  56. package/src/data-structures/base/linear-base.ts +3 -3
  57. package/src/data-structures/binary-tree/avl-tree.ts +299 -0
  58. package/src/data-structures/binary-tree/binary-indexed-tree.ts +341 -5
  59. package/src/data-structures/binary-tree/binary-tree.ts +606 -6
  60. package/src/data-structures/binary-tree/bst.ts +946 -7
  61. package/src/data-structures/binary-tree/red-black-tree.ts +472 -0
  62. package/src/data-structures/binary-tree/segment-tree.ts +145 -2
  63. package/src/data-structures/binary-tree/tree-map.ts +3423 -499
  64. package/src/data-structures/binary-tree/tree-multi-map.ts +3537 -596
  65. package/src/data-structures/binary-tree/tree-multi-set.ts +2855 -495
  66. package/src/data-structures/binary-tree/tree-set.ts +3209 -413
  67. package/src/data-structures/graph/abstract-graph.ts +6 -6
  68. package/src/data-structures/graph/directed-graph.ts +240 -0
  69. package/src/data-structures/graph/undirected-graph.ts +216 -0
  70. package/src/data-structures/hash/hash-map.ts +281 -19
  71. package/src/data-structures/heap/heap.ts +340 -4
  72. package/src/data-structures/heap/max-heap.ts +2 -2
  73. package/src/data-structures/linked-list/doubly-linked-list.ts +411 -3
  74. package/src/data-structures/linked-list/singly-linked-list.ts +363 -3
  75. package/src/data-structures/linked-list/skip-linked-list.ts +439 -7
  76. package/src/data-structures/matrix/matrix.ts +202 -10
  77. package/src/data-structures/priority-queue/max-priority-queue.ts +2 -2
  78. package/src/data-structures/queue/deque.ts +365 -5
  79. package/src/data-structures/queue/queue.ts +288 -0
  80. package/src/data-structures/stack/stack.ts +240 -0
  81. package/src/data-structures/trie/trie.ts +295 -7
  82. package/src/interfaces/graph.ts +1 -1
  83. package/src/types/common.ts +2 -2
  84. package/src/types/data-structures/binary-tree/bst.ts +1 -0
  85. package/src/types/data-structures/binary-tree/tree-map.ts +6 -0
  86. package/src/types/data-structures/binary-tree/tree-multi-set.ts +5 -0
  87. package/src/types/data-structures/binary-tree/tree-set.ts +5 -0
  88. package/src/types/data-structures/heap/heap.ts +1 -0
  89. package/src/types/data-structures/priority-queue/priority-queue.ts +1 -0
  90. package/src/types/utils/validate-type.ts +4 -4
@@ -60,6 +60,30 @@ export declare class SkipList<K = any, V = any, R = [K, V]> extends IterableEntr
60
60
 
61
61
 
62
62
 
63
+
64
+
65
+
66
+
67
+
68
+
69
+
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+
78
+
79
+
80
+
81
+
82
+
83
+
84
+
85
+
86
+
63
87
  * @example
64
88
  * // Check if empty
65
89
  * const sl = new SkipList<number, string>();
@@ -76,6 +100,30 @@ export declare class SkipList<K = any, V = any, R = [K, V]> extends IterableEntr
76
100
 
77
101
 
78
102
 
103
+
104
+
105
+
106
+
107
+
108
+
109
+
110
+
111
+
112
+
113
+
114
+
115
+
116
+
117
+
118
+
119
+
120
+
121
+
122
+
123
+
124
+
125
+
126
+
79
127
  * @example
80
128
  * // Remove all entries
81
129
  * const sl = new SkipList<number, string>([[1, 'a'], [2, 'b']]);
@@ -93,6 +141,30 @@ export declare class SkipList<K = any, V = any, R = [K, V]> extends IterableEntr
93
141
 
94
142
 
95
143
 
144
+
145
+
146
+
147
+
148
+
149
+
150
+
151
+
152
+
153
+
154
+
155
+
156
+
157
+
158
+
159
+
160
+
161
+
162
+
163
+
164
+
165
+
166
+
167
+
96
168
  * @example
97
169
  * // Create independent copy
98
170
  * const sl = new SkipList<number, string>([[1, 'a'], [2, 'b']]);
@@ -115,6 +187,30 @@ export declare class SkipList<K = any, V = any, R = [K, V]> extends IterableEntr
115
187
 
116
188
 
117
189
 
190
+
191
+
192
+
193
+
194
+
195
+
196
+
197
+
198
+
199
+
200
+
201
+
202
+
203
+
204
+
205
+
206
+
207
+
208
+
209
+
210
+
211
+
212
+
213
+
118
214
  * @example
119
215
  * // In-memory sorted key-value store
120
216
  * const store = new SkipList<number, string>();
@@ -147,6 +243,30 @@ export declare class SkipList<K = any, V = any, R = [K, V]> extends IterableEntr
147
243
 
148
244
 
149
245
 
246
+
247
+
248
+
249
+
250
+
251
+
252
+
253
+
254
+
255
+
256
+
257
+
258
+
259
+
260
+
261
+
262
+
263
+
264
+
265
+
266
+
267
+
268
+
269
+
150
270
  * @example
151
271
  * // Building a sorted index
152
272
  * type Product = { id: number; name: string; price: number };
@@ -156,8 +276,8 @@ export declare class SkipList<K = any, V = any, R = [K, V]> extends IterableEntr
156
276
  * { id: 3, name: 'Doohickey', price: 15 }
157
277
  * ];
158
278
  *
159
- * const index = new SkipList<number, Product>(products as any, {
160
- * toEntryFn: (p: any) => [p.price, p]
279
+ * const index = new SkipList<number, Product, Product>(products, {
280
+ * toEntryFn: (p: Product) => [p.price, p]
161
281
  * });
162
282
  *
163
283
  * // Iterate in sorted order by price
@@ -183,6 +303,30 @@ export declare class SkipList<K = any, V = any, R = [K, V]> extends IterableEntr
183
303
 
184
304
 
185
305
 
306
+
307
+
308
+
309
+
310
+
311
+
312
+
313
+
314
+
315
+
316
+
317
+
318
+
319
+
320
+
321
+
322
+
323
+
324
+
325
+
326
+
327
+
328
+
329
+
186
330
  * @example
187
331
  * // Check key existence
188
332
  * const sl = new SkipList<number, string>([[1, 'a'], [3, 'c'], [5, 'e']]);
@@ -203,6 +347,30 @@ export declare class SkipList<K = any, V = any, R = [K, V]> extends IterableEntr
203
347
 
204
348
 
205
349
 
350
+
351
+
352
+
353
+
354
+
355
+
356
+
357
+
358
+
359
+
360
+
361
+
362
+
363
+
364
+
365
+
366
+
367
+
368
+
369
+
370
+
371
+
372
+
373
+
206
374
  * @example
207
375
  * // Fast lookup with deletion
208
376
  * const cache = new SkipList<string, number>();
@@ -230,6 +398,30 @@ export declare class SkipList<K = any, V = any, R = [K, V]> extends IterableEntr
230
398
 
231
399
 
232
400
 
401
+
402
+
403
+
404
+
405
+
406
+
407
+
408
+
409
+
410
+
411
+
412
+
413
+
414
+
415
+
416
+
417
+
418
+
419
+
420
+
421
+
422
+
423
+
424
+
233
425
  * @example
234
426
  * // Access the minimum entry
235
427
  * const sl = new SkipList<number, string>([[5, 'e'], [1, 'a'], [3, 'c']]);
@@ -249,6 +441,30 @@ export declare class SkipList<K = any, V = any, R = [K, V]> extends IterableEntr
249
441
 
250
442
 
251
443
 
444
+
445
+
446
+
447
+
448
+
449
+
450
+
451
+
452
+
453
+
454
+
455
+
456
+
457
+
458
+
459
+
460
+
461
+
462
+
463
+
464
+
465
+
466
+
467
+
252
468
  * @example
253
469
  * // Access the maximum entry
254
470
  * const sl = new SkipList<number, string>([[5, 'e'], [1, 'a'], [3, 'c']]);
@@ -265,6 +481,30 @@ export declare class SkipList<K = any, V = any, R = [K, V]> extends IterableEntr
265
481
 
266
482
 
267
483
 
484
+
485
+
486
+
487
+
488
+
489
+
490
+
491
+
492
+
493
+
494
+
495
+
496
+
497
+
498
+
499
+
500
+
501
+
502
+
503
+
504
+
505
+
506
+
507
+
268
508
  * @example
269
509
  * // Remove and return smallest
270
510
  * const sl = new SkipList<number, string>([[1, 'a'], [2, 'b'], [3, 'c']]);
@@ -282,6 +522,30 @@ export declare class SkipList<K = any, V = any, R = [K, V]> extends IterableEntr
282
522
 
283
523
 
284
524
 
525
+
526
+
527
+
528
+
529
+
530
+
531
+
532
+
533
+
534
+
535
+
536
+
537
+
538
+
539
+
540
+
541
+
542
+
543
+
544
+
545
+
546
+
547
+
548
+
285
549
  * @example
286
550
  * // Remove and return largest
287
551
  * const sl = new SkipList<number, string>([[1, 'a'], [2, 'b'], [3, 'c']]);
@@ -302,6 +566,30 @@ export declare class SkipList<K = any, V = any, R = [K, V]> extends IterableEntr
302
566
 
303
567
 
304
568
 
569
+
570
+
571
+
572
+
573
+
574
+
575
+
576
+
577
+
578
+
579
+
580
+
581
+
582
+
583
+
584
+
585
+
586
+
587
+
588
+
589
+
590
+
591
+
592
+
305
593
  * @example
306
594
  * // Least entry ≥ key
307
595
  * const sl = new SkipList<number, string>([[10, 'a'], [20, 'b'], [30, 'c']]);
@@ -322,6 +610,30 @@ export declare class SkipList<K = any, V = any, R = [K, V]> extends IterableEntr
322
610
 
323
611
 
324
612
 
613
+
614
+
615
+
616
+
617
+
618
+
619
+
620
+
621
+
622
+
623
+
624
+
625
+
626
+
627
+
628
+
629
+
630
+
631
+
632
+
633
+
634
+
635
+
636
+
325
637
  * @example
326
638
  * // Greatest entry ≤ key
327
639
  * const sl = new SkipList<number, string>([[10, 'a'], [20, 'b'], [30, 'c']]);
@@ -339,6 +651,30 @@ export declare class SkipList<K = any, V = any, R = [K, V]> extends IterableEntr
339
651
 
340
652
 
341
653
 
654
+
655
+
656
+
657
+
658
+
659
+
660
+
661
+
662
+
663
+
664
+
665
+
666
+
667
+
668
+
669
+
670
+
671
+
672
+
673
+
674
+
675
+
676
+
677
+
342
678
  * @example
343
679
  * // Strictly greater entry
344
680
  * const sl = new SkipList<number, string>([[10, 'a'], [20, 'b'], [30, 'c']]);
@@ -356,6 +692,30 @@ export declare class SkipList<K = any, V = any, R = [K, V]> extends IterableEntr
356
692
 
357
693
 
358
694
 
695
+
696
+
697
+
698
+
699
+
700
+
701
+
702
+
703
+
704
+
705
+
706
+
707
+
708
+
709
+
710
+
711
+
712
+
713
+
714
+
715
+
716
+
717
+
718
+
359
719
  * @example
360
720
  * // Strictly less entry
361
721
  * const sl = new SkipList<number, string>([[10, 'a'], [20, 'b'], [30, 'c']]);
@@ -376,6 +736,30 @@ export declare class SkipList<K = any, V = any, R = [K, V]> extends IterableEntr
376
736
 
377
737
 
378
738
 
739
+
740
+
741
+
742
+
743
+
744
+
745
+
746
+
747
+
748
+
749
+
750
+
751
+
752
+
753
+
754
+
755
+
756
+
757
+
758
+
759
+
760
+
761
+
762
+
379
763
  * @example
380
764
  * // Find entries in a range
381
765
  * const sl = new SkipList<number, string>([[1, 'a'], [2, 'b'], [3, 'c'], [4, 'd'], [5, 'e']]);
@@ -393,6 +777,30 @@ export declare class SkipList<K = any, V = any, R = [K, V]> extends IterableEntr
393
777
 
394
778
 
395
779
 
780
+
781
+
782
+
783
+
784
+
785
+
786
+
787
+
788
+
789
+
790
+
791
+
792
+
793
+
794
+
795
+
796
+
797
+
798
+
799
+
800
+
801
+
802
+
803
+
396
804
  * @example
397
805
  * // Transform entries
398
806
  * const sl = new SkipList<number, string>([[1, 'a'], [2, 'b']]);
@@ -410,6 +818,30 @@ export declare class SkipList<K = any, V = any, R = [K, V]> extends IterableEntr
410
818
 
411
819
 
412
820
 
821
+
822
+
823
+
824
+
825
+
826
+
827
+
828
+
829
+
830
+
831
+
832
+
833
+
834
+
835
+
836
+
837
+
838
+
839
+
840
+
841
+
842
+
843
+
844
+
413
845
  * @example
414
846
  * // Filter entries
415
847
  * const sl = new SkipList<number, string>([[1, 'a'], [2, 'b'], [3, 'c']]);