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
@@ -131,7 +131,7 @@ export declare abstract class AbstractGraph<V = any, E = any, VO extends Abstrac
131
131
  * @returns `true` if string/number; else `false`.
132
132
  * @remarks Time O(1), Space O(1)
133
133
  */
134
- isVertexKey(potentialKey: any): potentialKey is VertexKey;
134
+ isVertexKey(potentialKey: unknown): potentialKey is VertexKey;
135
135
  /**
136
136
  * Delete a vertex and its incident edges.
137
137
  * @param vertexOrKey - Vertex or key.
@@ -252,13 +252,13 @@ export declare abstract class AbstractGraph<V = any, E = any, VO extends Abstrac
252
252
  * @returns A new graph of the same concrete class (`this` type).
253
253
  * @remarks Time O(V + E), Space O(V + E)
254
254
  */
255
- filter(predicate: EntryCallback<VertexKey, V | undefined, boolean>, thisArg?: any): this;
255
+ filter(predicate: EntryCallback<VertexKey, V | undefined, boolean>, thisArg?: unknown): this;
256
256
  /**
257
257
  * Preserve the old behavior: return filtered entries as an array.
258
258
  * @remarks Time O(V), Space O(V)
259
259
  */
260
- filterEntries(predicate: EntryCallback<VertexKey, V | undefined, boolean>, thisArg?: any): [VertexKey, V | undefined][];
261
- map<T>(callback: EntryCallback<VertexKey, V | undefined, T>, thisArg?: any): T[];
260
+ filterEntries(predicate: EntryCallback<VertexKey, V | undefined, boolean>, thisArg?: unknown): [VertexKey, V | undefined][];
261
+ map<T>(callback: EntryCallback<VertexKey, V | undefined, T>, thisArg?: unknown): T[];
262
262
  /**
263
263
  * Create a deep clone of the graph with the same species.
264
264
  * @remarks Time O(V + E), Space O(V + E)
@@ -165,6 +165,30 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
165
165
 
166
166
 
167
167
 
168
+
169
+
170
+
171
+
172
+
173
+
174
+
175
+
176
+
177
+
178
+
179
+
180
+
181
+
182
+
183
+
184
+
185
+
186
+
187
+
188
+
189
+
190
+
191
+
168
192
  * @example
169
193
  * // Get edge between vertices
170
194
  * const g = new DirectedGraph();
@@ -200,6 +224,30 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
200
224
 
201
225
 
202
226
 
227
+
228
+
229
+
230
+
231
+
232
+
233
+
234
+
235
+
236
+
237
+
238
+
239
+
240
+
241
+
242
+
243
+
244
+
245
+
246
+
247
+
248
+
249
+
250
+
203
251
  * @example
204
252
  * // DirectedGraph deleteEdge and vertex operations
205
253
  * const graph = new DirectedGraph<string>();
@@ -237,6 +285,30 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
237
285
 
238
286
 
239
287
 
288
+
289
+
290
+
291
+
292
+
293
+
294
+
295
+
296
+
297
+
298
+
299
+
300
+
301
+
302
+
303
+
304
+
305
+
306
+
307
+
308
+
309
+
310
+
311
+
240
312
  * @example
241
313
  * // Remove a vertex
242
314
  * const g = new DirectedGraph();
@@ -262,6 +334,30 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
262
334
 
263
335
 
264
336
 
337
+
338
+
339
+
340
+
341
+
342
+
343
+
344
+
345
+
346
+
347
+
348
+
349
+
350
+
351
+
352
+
353
+
354
+
355
+
356
+
357
+
358
+
359
+
360
+
265
361
  * @example
266
362
  * // Get incoming edges
267
363
  * const g = new DirectedGraph();
@@ -286,6 +382,30 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
286
382
 
287
383
 
288
384
 
385
+
386
+
387
+
388
+
389
+
390
+
391
+
392
+
393
+
394
+
395
+
396
+
397
+
398
+
399
+
400
+
401
+
402
+
403
+
404
+
405
+
406
+
407
+
408
+
289
409
  * @example
290
410
  * // Get outgoing edges
291
411
  * const g = new DirectedGraph();
@@ -338,6 +458,30 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
338
458
 
339
459
 
340
460
 
461
+
462
+
463
+
464
+
465
+
466
+
467
+
468
+
469
+
470
+
471
+
472
+
473
+
474
+
475
+
476
+
477
+
478
+
479
+
480
+
481
+
482
+
483
+
484
+
341
485
  * @example
342
486
  * // DirectedGraph topologicalSort for task scheduling
343
487
  * const graph = new DirectedGraph<string>();
@@ -372,6 +516,30 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
372
516
 
373
517
 
374
518
 
519
+
520
+
521
+
522
+
523
+
524
+
525
+
526
+
527
+
528
+
529
+
530
+
531
+
532
+
533
+
534
+
535
+
536
+
537
+
538
+
539
+
540
+
541
+
542
+
375
543
  * @example
376
544
  * // Get all edges
377
545
  * const g = new DirectedGraph();
@@ -392,6 +560,30 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
392
560
 
393
561
 
394
562
 
563
+
564
+
565
+
566
+
567
+
568
+
569
+
570
+
571
+
572
+
573
+
574
+
575
+
576
+
577
+
578
+
579
+
580
+
581
+
582
+
583
+
584
+
585
+
586
+
395
587
  * @example
396
588
  * // Get outgoing neighbors
397
589
  * const g = new DirectedGraph();
@@ -439,6 +631,30 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
439
631
 
440
632
 
441
633
 
634
+
635
+
636
+
637
+
638
+
639
+
640
+
641
+
642
+
643
+
644
+
645
+
646
+
647
+
648
+
649
+
650
+
651
+
652
+
653
+
654
+
655
+
656
+
657
+
442
658
  * @example
443
659
  * // Find strongly connected components
444
660
  * const g = new DirectedGraph();
@@ -482,6 +698,30 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
482
698
 
483
699
 
484
700
 
701
+
702
+
703
+
704
+
705
+
706
+
707
+
708
+
709
+
710
+
711
+
712
+
713
+
714
+
715
+
716
+
717
+
718
+
719
+
720
+
721
+
722
+
723
+
724
+
485
725
  * @example
486
726
  * // Get strongly connected components
487
727
  * const g = new DirectedGraph();
@@ -182,6 +182,30 @@ export declare class UndirectedGraph<V = any, E = any, VO extends UndirectedVert
182
182
 
183
183
 
184
184
 
185
+
186
+
187
+
188
+
189
+
190
+
191
+
192
+
193
+
194
+
195
+
196
+
197
+
198
+
199
+
200
+
201
+
202
+
203
+
204
+
205
+
206
+
207
+
208
+
185
209
  * @example
186
210
  * // Get edge between vertices
187
211
  * const g = new UndirectedGraph();
@@ -216,6 +240,30 @@ export declare class UndirectedGraph<V = any, E = any, VO extends UndirectedVert
216
240
 
217
241
 
218
242
 
243
+
244
+
245
+
246
+
247
+
248
+
249
+
250
+
251
+
252
+
253
+
254
+
255
+
256
+
257
+
258
+
259
+
260
+
261
+
262
+
263
+
264
+
265
+
266
+
219
267
  * @example
220
268
  * // UndirectedGraph deleteEdge and vertex operations
221
269
  * const graph = new UndirectedGraph<string>();
@@ -258,6 +306,30 @@ export declare class UndirectedGraph<V = any, E = any, VO extends UndirectedVert
258
306
 
259
307
 
260
308
 
309
+
310
+
311
+
312
+
313
+
314
+
315
+
316
+
317
+
318
+
319
+
320
+
321
+
322
+
323
+
324
+
325
+
326
+
327
+
328
+
329
+
330
+
331
+
332
+
261
333
  * @example
262
334
  * // Remove vertex and edges
263
335
  * const g = new UndirectedGraph();
@@ -294,6 +366,30 @@ export declare class UndirectedGraph<V = any, E = any, VO extends UndirectedVert
294
366
 
295
367
 
296
368
 
369
+
370
+
371
+
372
+
373
+
374
+
375
+
376
+
377
+
378
+
379
+
380
+
381
+
382
+
383
+
384
+
385
+
386
+
387
+
388
+
389
+
390
+
391
+
392
+
297
393
  * @example
298
394
  * // Get all edges
299
395
  * const g = new UndirectedGraph();
@@ -316,6 +412,30 @@ export declare class UndirectedGraph<V = any, E = any, VO extends UndirectedVert
316
412
 
317
413
 
318
414
 
415
+
416
+
417
+
418
+
419
+
420
+
421
+
422
+
423
+
424
+
425
+
426
+
427
+
428
+
429
+
430
+
431
+
432
+
433
+
434
+
435
+
436
+
437
+
438
+
319
439
  * @example
320
440
  * // UndirectedGraph connectivity and neighbors
321
441
  * const graph = new UndirectedGraph<string>();
@@ -385,6 +505,30 @@ export declare class UndirectedGraph<V = any, E = any, VO extends UndirectedVert
385
505
 
386
506
 
387
507
 
508
+
509
+
510
+
511
+
512
+
513
+
514
+
515
+
516
+
517
+
518
+
519
+
520
+
521
+
522
+
523
+
524
+
525
+
526
+
527
+
528
+
529
+
530
+
531
+
388
532
  * @example
389
533
  * // Find articulation points and bridges
390
534
  * const g = new UndirectedGraph();
@@ -422,6 +566,30 @@ export declare class UndirectedGraph<V = any, E = any, VO extends UndirectedVert
422
566
 
423
567
 
424
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
+
425
593
  * @example
426
594
  * // Detect cycle
427
595
  * const g = new UndirectedGraph();
@@ -447,6 +615,30 @@ export declare class UndirectedGraph<V = any, E = any, VO extends UndirectedVert
447
615
 
448
616
 
449
617
 
618
+
619
+
620
+
621
+
622
+
623
+
624
+
625
+
626
+
627
+
628
+
629
+
630
+
631
+
632
+
633
+
634
+
635
+
636
+
637
+
638
+
639
+
640
+
641
+
450
642
  * @example
451
643
  * // Find bridge edges
452
644
  * const g = new UndirectedGraph();
@@ -471,6 +663,30 @@ export declare class UndirectedGraph<V = any, E = any, VO extends UndirectedVert
471
663
 
472
664
 
473
665
 
666
+
667
+
668
+
669
+
670
+
671
+
672
+
673
+
674
+
675
+
676
+
677
+
678
+
679
+
680
+
681
+
682
+
683
+
684
+
685
+
686
+
687
+
688
+
689
+
474
690
  * @example
475
691
  * // Find articulation points
476
692
  * const g = new UndirectedGraph();