max-priority-queue-typed 2.5.1 → 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 (75) hide show
  1. package/dist/cjs/index.cjs +207 -71
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/cjs-legacy/index.cjs +206 -70
  4. package/dist/cjs-legacy/index.cjs.map +1 -1
  5. package/dist/esm/index.mjs +207 -72
  6. package/dist/esm/index.mjs.map +1 -1
  7. package/dist/esm-legacy/index.mjs +206 -71
  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/binary-tree/avl-tree.d.ts +86 -2
  12. package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +98 -0
  13. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +189 -13
  14. package/dist/types/data-structures/binary-tree/bst.d.ts +270 -3
  15. package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +136 -8
  16. package/dist/types/data-structures/binary-tree/segment-tree.d.ts +42 -0
  17. package/dist/types/data-structures/binary-tree/tree-map.d.ts +1089 -161
  18. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +1243 -350
  19. package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +980 -255
  20. package/dist/types/data-structures/binary-tree/tree-set.d.ts +1174 -284
  21. package/dist/types/data-structures/graph/directed-graph.d.ts +70 -0
  22. package/dist/types/data-structures/graph/undirected-graph.d.ts +63 -0
  23. package/dist/types/data-structures/hash/hash-map.d.ts +84 -6
  24. package/dist/types/data-structures/heap/heap.d.ts +140 -12
  25. package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +126 -0
  26. package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +106 -1
  27. package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +126 -0
  28. package/dist/types/data-structures/matrix/matrix.d.ts +56 -0
  29. package/dist/types/data-structures/queue/deque.d.ts +127 -0
  30. package/dist/types/data-structures/queue/queue.d.ts +97 -0
  31. package/dist/types/data-structures/stack/stack.d.ts +72 -2
  32. package/dist/types/data-structures/trie/trie.d.ts +84 -0
  33. package/dist/types/interfaces/binary-tree.d.ts +2 -3
  34. package/dist/types/types/data-structures/binary-tree/bst.d.ts +1 -0
  35. package/dist/types/types/data-structures/binary-tree/tree-map.d.ts +5 -0
  36. package/dist/types/types/data-structures/binary-tree/tree-multi-set.d.ts +4 -0
  37. package/dist/types/types/data-structures/binary-tree/tree-set.d.ts +4 -0
  38. package/dist/umd/max-priority-queue-typed.js +204 -69
  39. package/dist/umd/max-priority-queue-typed.js.map +1 -1
  40. package/dist/umd/max-priority-queue-typed.min.js +1 -1
  41. package/dist/umd/max-priority-queue-typed.min.js.map +1 -1
  42. package/package.json +2 -2
  43. package/src/common/error.ts +19 -1
  44. package/src/common/index.ts +1 -1
  45. package/src/data-structures/base/iterable-element-base.ts +3 -2
  46. package/src/data-structures/binary-tree/avl-tree.ts +99 -5
  47. package/src/data-structures/binary-tree/binary-indexed-tree.ts +102 -4
  48. package/src/data-structures/binary-tree/binary-tree.ts +239 -78
  49. package/src/data-structures/binary-tree/bst.ts +542 -13
  50. package/src/data-structures/binary-tree/red-black-tree.ts +155 -15
  51. package/src/data-structures/binary-tree/segment-tree.ts +42 -0
  52. package/src/data-structures/binary-tree/tree-map.ts +1223 -261
  53. package/src/data-structures/binary-tree/tree-multi-map.ts +939 -30
  54. package/src/data-structures/binary-tree/tree-multi-set.ts +746 -10
  55. package/src/data-structures/binary-tree/tree-set.ts +1018 -99
  56. package/src/data-structures/graph/abstract-graph.ts +2 -2
  57. package/src/data-structures/graph/directed-graph.ts +71 -1
  58. package/src/data-structures/graph/undirected-graph.ts +64 -1
  59. package/src/data-structures/hash/hash-map.ts +102 -16
  60. package/src/data-structures/heap/heap.ts +153 -23
  61. package/src/data-structures/heap/max-heap.ts +2 -2
  62. package/src/data-structures/linked-list/doubly-linked-list.ts +139 -0
  63. package/src/data-structures/linked-list/singly-linked-list.ts +106 -1
  64. package/src/data-structures/linked-list/skip-linked-list.ts +131 -5
  65. package/src/data-structures/matrix/matrix.ts +65 -9
  66. package/src/data-structures/priority-queue/max-priority-queue.ts +2 -2
  67. package/src/data-structures/queue/deque.ts +130 -0
  68. package/src/data-structures/queue/queue.ts +109 -0
  69. package/src/data-structures/stack/stack.ts +75 -5
  70. package/src/data-structures/trie/trie.ts +86 -2
  71. package/src/interfaces/binary-tree.ts +1 -9
  72. package/src/types/data-structures/binary-tree/bst.ts +1 -0
  73. package/src/types/data-structures/binary-tree/tree-map.ts +6 -0
  74. package/src/types/data-structures/binary-tree/tree-multi-set.ts +5 -0
  75. package/src/types/data-structures/binary-tree/tree-set.ts +5 -0
@@ -166,6 +166,13 @@ export declare class Matrix {
166
166
 
167
167
 
168
168
 
169
+
170
+
171
+
172
+
173
+
174
+
175
+
169
176
 
170
177
 
171
178
 
@@ -227,6 +234,13 @@ export declare class Matrix {
227
234
 
228
235
 
229
236
 
237
+
238
+
239
+
240
+
241
+
242
+
243
+
230
244
 
231
245
 
232
246
 
@@ -280,6 +294,13 @@ export declare class Matrix {
280
294
 
281
295
 
282
296
 
297
+
298
+
299
+
300
+
301
+
302
+
303
+
283
304
 
284
305
 
285
306
 
@@ -342,6 +363,13 @@ export declare class Matrix {
342
363
 
343
364
 
344
365
 
366
+
367
+
368
+
369
+
370
+
371
+
372
+
345
373
 
346
374
 
347
375
 
@@ -387,6 +415,13 @@ export declare class Matrix {
387
415
 
388
416
 
389
417
 
418
+
419
+
420
+
421
+
422
+
423
+
424
+
390
425
 
391
426
 
392
427
 
@@ -447,6 +482,13 @@ export declare class Matrix {
447
482
 
448
483
 
449
484
 
485
+
486
+
487
+
488
+
489
+
490
+
491
+
450
492
 
451
493
 
452
494
 
@@ -503,6 +545,13 @@ export declare class Matrix {
503
545
 
504
546
 
505
547
 
548
+
549
+
550
+
551
+
552
+
553
+
554
+
506
555
 
507
556
 
508
557
 
@@ -552,6 +601,13 @@ export declare class Matrix {
552
601
 
553
602
 
554
603
 
604
+
605
+
606
+
607
+
608
+
609
+
610
+
555
611
 
556
612
 
557
613
 
@@ -191,6 +191,12 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
191
191
 
192
192
 
193
193
 
194
+
195
+
196
+
197
+
198
+
199
+
194
200
 
195
201
 
196
202
 
@@ -213,6 +219,29 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
213
219
  * // Length unchanged
214
220
  * console.log(deque.length); // 5;
215
221
  */
222
+ /**
223
+ * Peek at the front element without removing it (alias for `first`).
224
+ * @remarks Time O(1), Space O(1)
225
+ * @returns Front element or undefined.
226
+ */
227
+ peek(): E | undefined;
228
+ /**
229
+ * Deque peek at both ends
230
+ * @example
231
+ * // Deque peek at both ends
232
+ * const deque = new Deque<number>([10, 20, 30, 40, 50]);
233
+ *
234
+ * // Get first element without removing
235
+ * const first = deque.at(0);
236
+ * console.log(first); // 10;
237
+ *
238
+ * // Get last element without removing
239
+ * const last = deque.at(deque.length - 1);
240
+ * console.log(last); // 50;
241
+ *
242
+ * // Length unchanged
243
+ * console.log(deque.length); // 5;
244
+ */
216
245
  get first(): E | undefined;
217
246
  /**
218
247
  * Get the last element without removing it.
@@ -242,6 +271,13 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
242
271
 
243
272
 
244
273
 
274
+
275
+
276
+
277
+
278
+
279
+
280
+
245
281
 
246
282
 
247
283
 
@@ -297,6 +333,13 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
297
333
 
298
334
 
299
335
 
336
+
337
+
338
+
339
+
340
+
341
+
342
+
300
343
 
301
344
 
302
345
 
@@ -353,6 +396,13 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
353
396
 
354
397
 
355
398
 
399
+
400
+
401
+
402
+
403
+
404
+
405
+
356
406
 
357
407
 
358
408
 
@@ -396,6 +446,13 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
396
446
 
397
447
 
398
448
 
449
+
450
+
451
+
452
+
453
+
454
+
455
+
399
456
 
400
457
 
401
458
 
@@ -440,6 +497,13 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
440
497
 
441
498
 
442
499
 
500
+
501
+
502
+
503
+
504
+
505
+
506
+
443
507
 
444
508
 
445
509
 
@@ -505,6 +569,13 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
505
569
 
506
570
 
507
571
 
572
+
573
+
574
+
575
+
576
+
577
+
578
+
508
579
 
509
580
 
510
581
 
@@ -545,6 +616,13 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
545
616
 
546
617
 
547
618
 
619
+
620
+
621
+
622
+
623
+
624
+
625
+
548
626
 
549
627
 
550
628
 
@@ -586,6 +664,13 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
586
664
 
587
665
 
588
666
 
667
+
668
+
669
+
670
+
671
+
672
+
673
+
589
674
 
590
675
 
591
676
 
@@ -676,6 +761,13 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
676
761
 
677
762
 
678
763
 
764
+
765
+
766
+
767
+
768
+
769
+
770
+
679
771
 
680
772
 
681
773
 
@@ -733,6 +825,13 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
733
825
 
734
826
 
735
827
 
828
+
829
+
830
+
831
+
832
+
833
+
834
+
736
835
 
737
836
 
738
837
 
@@ -808,6 +907,13 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
808
907
 
809
908
 
810
909
 
910
+
911
+
912
+
913
+
914
+
915
+
916
+
811
917
 
812
918
 
813
919
 
@@ -852,6 +958,13 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
852
958
 
853
959
 
854
960
 
961
+
962
+
963
+
964
+
965
+
966
+
967
+
855
968
 
856
969
 
857
970
 
@@ -897,6 +1010,13 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
897
1010
 
898
1011
 
899
1012
 
1013
+
1014
+
1015
+
1016
+
1017
+
1018
+
1019
+
900
1020
 
901
1021
 
902
1022
 
@@ -950,6 +1070,13 @@ export declare class Deque<E = any, R = any> extends LinearBase<E, R> {
950
1070
 
951
1071
 
952
1072
 
1073
+
1074
+
1075
+
1076
+
1077
+
1078
+
1079
+
953
1080
 
954
1081
 
955
1082
 
@@ -151,6 +151,13 @@ export declare class Queue<E = any, R = any> extends LinearBase<E, R> {
151
151
 
152
152
 
153
153
 
154
+
155
+
156
+
157
+
158
+
159
+
160
+
154
161
 
155
162
 
156
163
 
@@ -196,6 +203,13 @@ export declare class Queue<E = any, R = any> extends LinearBase<E, R> {
196
203
 
197
204
 
198
205
 
206
+
207
+
208
+
209
+
210
+
211
+
212
+
199
213
 
200
214
 
201
215
 
@@ -211,6 +225,12 @@ export declare class Queue<E = any, R = any> extends LinearBase<E, R> {
211
225
  * console.log(q.length); // 3;
212
226
  */
213
227
  get first(): E | undefined;
228
+ /**
229
+ * Peek at the front element without removing it (alias for `first`).
230
+ * @remarks Time O(1), Space O(1)
231
+ * @returns Front element or undefined.
232
+ */
233
+ peek(): E | undefined;
214
234
  /**
215
235
  * Get the last element (back) without removing it.
216
236
  * @remarks Time O(1), Space O(1)
@@ -253,6 +273,13 @@ export declare class Queue<E = any, R = any> extends LinearBase<E, R> {
253
273
 
254
274
 
255
275
 
276
+
277
+
278
+
279
+
280
+
281
+
282
+
256
283
 
257
284
 
258
285
 
@@ -310,6 +337,13 @@ export declare class Queue<E = any, R = any> extends LinearBase<E, R> {
310
337
 
311
338
 
312
339
 
340
+
341
+
342
+
343
+
344
+
345
+
346
+
313
347
 
314
348
 
315
349
 
@@ -365,6 +399,13 @@ export declare class Queue<E = any, R = any> extends LinearBase<E, R> {
365
399
 
366
400
 
367
401
 
402
+
403
+
404
+
405
+
406
+
407
+
408
+
368
409
 
369
410
 
370
411
 
@@ -415,6 +456,13 @@ export declare class Queue<E = any, R = any> extends LinearBase<E, R> {
415
456
 
416
457
 
417
458
 
459
+
460
+
461
+
462
+
463
+
464
+
465
+
418
466
 
419
467
 
420
468
 
@@ -456,6 +504,13 @@ export declare class Queue<E = any, R = any> extends LinearBase<E, R> {
456
504
 
457
505
 
458
506
 
507
+
508
+
509
+
510
+
511
+
512
+
513
+
459
514
 
460
515
 
461
516
 
@@ -494,6 +549,13 @@ export declare class Queue<E = any, R = any> extends LinearBase<E, R> {
494
549
  * @returns True if updated.
495
550
  */
496
551
  setAt(index: number, newElement: E): boolean;
552
+ /**
553
+ * Delete the first element that satisfies a predicate.
554
+ * @remarks Time O(N), Space O(N)
555
+ * @param predicate - Function (value, index, queue) → boolean to decide deletion.
556
+ * @returns True if a match was removed.
557
+ */
558
+ deleteWhere(predicate: (value: E, index: number, queue: this) => boolean): boolean;
497
559
  /**
498
560
  * Reverse the queue in-place by compacting then reversing.
499
561
  * @remarks Time O(N), Space O(N)
@@ -526,6 +588,13 @@ export declare class Queue<E = any, R = any> extends LinearBase<E, R> {
526
588
 
527
589
 
528
590
 
591
+
592
+
593
+
594
+
595
+
596
+
597
+
529
598
 
530
599
 
531
600
 
@@ -566,6 +635,13 @@ export declare class Queue<E = any, R = any> extends LinearBase<E, R> {
566
635
 
567
636
 
568
637
 
638
+
639
+
640
+
641
+
642
+
643
+
644
+
569
645
 
570
646
 
571
647
 
@@ -618,6 +694,13 @@ export declare class Queue<E = any, R = any> extends LinearBase<E, R> {
618
694
 
619
695
 
620
696
 
697
+
698
+
699
+
700
+
701
+
702
+
703
+
621
704
 
622
705
 
623
706
 
@@ -663,6 +746,13 @@ export declare class Queue<E = any, R = any> extends LinearBase<E, R> {
663
746
 
664
747
 
665
748
 
749
+
750
+
751
+
752
+
753
+
754
+
755
+
666
756
 
667
757
 
668
758
 
@@ -708,6 +798,13 @@ export declare class Queue<E = any, R = any> extends LinearBase<E, R> {
708
798
 
709
799
 
710
800
 
801
+
802
+
803
+
804
+
805
+
806
+
807
+
711
808
 
712
809
 
713
810
 
@@ -173,6 +173,13 @@ export declare class Stack<E = any, R = any> extends IterableElementBase<E, R> {
173
173
 
174
174
 
175
175
 
176
+
177
+
178
+
179
+
180
+
181
+
182
+
176
183
 
177
184
 
178
185
 
@@ -226,6 +233,13 @@ export declare class Stack<E = any, R = any> extends IterableElementBase<E, R> {
226
233
 
227
234
 
228
235
 
236
+
237
+
238
+
239
+
240
+
241
+
242
+
229
243
 
230
244
 
231
245
 
@@ -270,6 +284,13 @@ export declare class Stack<E = any, R = any> extends IterableElementBase<E, R> {
270
284
 
271
285
 
272
286
 
287
+
288
+
289
+
290
+
291
+
292
+
293
+
273
294
 
274
295
 
275
296
 
@@ -314,6 +335,13 @@ export declare class Stack<E = any, R = any> extends IterableElementBase<E, R> {
314
335
 
315
336
 
316
337
 
338
+
339
+
340
+
341
+
342
+
343
+
344
+
317
345
 
318
346
 
319
347
 
@@ -366,6 +394,13 @@ export declare class Stack<E = any, R = any> extends IterableElementBase<E, R> {
366
394
 
367
395
 
368
396
 
397
+
398
+
399
+
400
+
401
+
402
+
403
+
369
404
 
370
405
 
371
406
 
@@ -427,6 +462,13 @@ export declare class Stack<E = any, R = any> extends IterableElementBase<E, R> {
427
462
 
428
463
 
429
464
 
465
+
466
+
467
+
468
+
469
+
470
+
471
+
430
472
 
431
473
 
432
474
 
@@ -446,9 +488,9 @@ export declare class Stack<E = any, R = any> extends IterableElementBase<E, R> {
446
488
  * Delete the element at an index.
447
489
  * @remarks Time O(N), Space O(1)
448
490
  * @param index - Zero-based index from the bottom.
449
- * @returns True if removed.
491
+ * @returns The removed element, or undefined if the index is out of range.
450
492
  */
451
- deleteAt(index: number): boolean;
493
+ deleteAt(index: number): E | undefined;
452
494
  /**
453
495
  * Delete the first element that satisfies a predicate.
454
496
  * @remarks Time O(N), Space O(1)
@@ -482,6 +524,13 @@ export declare class Stack<E = any, R = any> extends IterableElementBase<E, R> {
482
524
 
483
525
 
484
526
 
527
+
528
+
529
+
530
+
531
+
532
+
533
+
485
534
 
486
535
 
487
536
 
@@ -523,6 +572,13 @@ export declare class Stack<E = any, R = any> extends IterableElementBase<E, R> {
523
572
 
524
573
 
525
574
 
575
+
576
+
577
+
578
+
579
+
580
+
581
+
526
582
 
527
583
 
528
584
 
@@ -568,6 +624,13 @@ export declare class Stack<E = any, R = any> extends IterableElementBase<E, R> {
568
624
 
569
625
 
570
626
 
627
+
628
+
629
+
630
+
631
+
632
+
633
+
571
634
 
572
635
 
573
636
 
@@ -621,6 +684,13 @@ export declare class Stack<E = any, R = any> extends IterableElementBase<E, R> {
621
684
 
622
685
 
623
686
 
687
+
688
+
689
+
690
+
691
+
692
+
693
+
624
694
 
625
695
 
626
696