binary-tree-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.
Files changed (75) hide show
  1. package/dist/cjs/index.cjs +609 -0
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/cjs-legacy/index.cjs +609 -0
  4. package/dist/cjs-legacy/index.cjs.map +1 -1
  5. package/dist/esm/index.mjs +609 -0
  6. package/dist/esm/index.mjs.map +1 -1
  7. package/dist/esm-legacy/index.mjs +609 -0
  8. package/dist/esm-legacy/index.mjs.map +1 -1
  9. package/dist/types/data-structures/base/index.d.ts +1 -0
  10. package/dist/types/data-structures/base/iterable-entry-base.d.ts +8 -8
  11. package/dist/types/data-structures/base/linear-base.d.ts +3 -3
  12. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +252 -0
  13. package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +294 -0
  14. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +527 -2
  15. package/dist/types/data-structures/binary-tree/bst.d.ts +505 -1
  16. package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +399 -0
  17. package/dist/types/data-structures/binary-tree/segment-tree.d.ts +126 -1
  18. package/dist/types/data-structures/binary-tree/tree-map.d.ts +2881 -382
  19. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +2867 -347
  20. package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +2328 -312
  21. package/dist/types/data-structures/binary-tree/tree-set.d.ts +2671 -277
  22. package/dist/types/data-structures/graph/abstract-graph.d.ts +4 -4
  23. package/dist/types/data-structures/graph/directed-graph.d.ts +210 -0
  24. package/dist/types/data-structures/graph/undirected-graph.d.ts +189 -0
  25. package/dist/types/data-structures/hash/hash-map.d.ts +241 -10
  26. package/dist/types/data-structures/heap/heap.d.ts +294 -0
  27. package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +360 -3
  28. package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +318 -3
  29. package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +380 -2
  30. package/dist/types/data-structures/matrix/matrix.d.ts +168 -0
  31. package/dist/types/data-structures/queue/deque.d.ts +319 -4
  32. package/dist/types/data-structures/queue/queue.d.ts +252 -0
  33. package/dist/types/data-structures/stack/stack.d.ts +210 -0
  34. package/dist/types/data-structures/trie/trie.d.ts +256 -4
  35. package/dist/types/interfaces/graph.d.ts +1 -1
  36. package/dist/types/types/common.d.ts +2 -2
  37. package/dist/types/types/data-structures/heap/heap.d.ts +1 -0
  38. package/dist/types/types/data-structures/priority-queue/priority-queue.d.ts +1 -0
  39. package/dist/types/types/utils/validate-type.d.ts +4 -4
  40. package/dist/umd/binary-tree-typed.js +609 -0
  41. package/dist/umd/binary-tree-typed.js.map +1 -1
  42. package/dist/umd/binary-tree-typed.min.js +5 -5
  43. package/dist/umd/binary-tree-typed.min.js.map +1 -1
  44. package/package.json +2 -2
  45. package/src/data-structures/base/index.ts +1 -0
  46. package/src/data-structures/base/iterable-entry-base.ts +8 -8
  47. package/src/data-structures/base/linear-base.ts +3 -3
  48. package/src/data-structures/binary-tree/avl-tree.ts +252 -0
  49. package/src/data-structures/binary-tree/binary-indexed-tree.ts +295 -1
  50. package/src/data-structures/binary-tree/binary-tree.ts +527 -2
  51. package/src/data-structures/binary-tree/bst.ts +505 -1
  52. package/src/data-structures/binary-tree/red-black-tree.ts +399 -0
  53. package/src/data-structures/binary-tree/segment-tree.ts +127 -2
  54. package/src/data-structures/binary-tree/tree-map.ts +2958 -459
  55. package/src/data-structures/binary-tree/tree-multi-map.ts +3069 -549
  56. package/src/data-structures/binary-tree/tree-multi-set.ts +2476 -460
  57. package/src/data-structures/binary-tree/tree-set.ts +2816 -422
  58. package/src/data-structures/graph/abstract-graph.ts +4 -4
  59. package/src/data-structures/graph/directed-graph.ts +210 -0
  60. package/src/data-structures/graph/undirected-graph.ts +189 -0
  61. package/src/data-structures/hash/hash-map.ts +246 -15
  62. package/src/data-structures/heap/heap.ts +294 -0
  63. package/src/data-structures/linked-list/doubly-linked-list.ts +360 -3
  64. package/src/data-structures/linked-list/singly-linked-list.ts +318 -3
  65. package/src/data-structures/linked-list/skip-linked-list.ts +380 -2
  66. package/src/data-structures/matrix/matrix.ts +169 -1
  67. package/src/data-structures/queue/deque.ts +320 -5
  68. package/src/data-structures/queue/queue.ts +252 -0
  69. package/src/data-structures/stack/stack.ts +210 -0
  70. package/src/data-structures/trie/trie.ts +257 -5
  71. package/src/interfaces/graph.ts +1 -1
  72. package/src/types/common.ts +2 -2
  73. package/src/types/data-structures/heap/heap.ts +1 -0
  74. package/src/types/data-structures/priority-queue/priority-queue.ts +1 -0
  75. 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,27 @@ 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
+
168
189
  * @example
169
190
  * // Get edge between vertices
170
191
  * const g = new DirectedGraph();
@@ -200,6 +221,27 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
200
221
 
201
222
 
202
223
 
224
+
225
+
226
+
227
+
228
+
229
+
230
+
231
+
232
+
233
+
234
+
235
+
236
+
237
+
238
+
239
+
240
+
241
+
242
+
243
+
244
+
203
245
  * @example
204
246
  * // DirectedGraph deleteEdge and vertex operations
205
247
  * const graph = new DirectedGraph<string>();
@@ -237,6 +279,27 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
237
279
 
238
280
 
239
281
 
282
+
283
+
284
+
285
+
286
+
287
+
288
+
289
+
290
+
291
+
292
+
293
+
294
+
295
+
296
+
297
+
298
+
299
+
300
+
301
+
302
+
240
303
  * @example
241
304
  * // Remove a vertex
242
305
  * const g = new DirectedGraph();
@@ -262,6 +325,27 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
262
325
 
263
326
 
264
327
 
328
+
329
+
330
+
331
+
332
+
333
+
334
+
335
+
336
+
337
+
338
+
339
+
340
+
341
+
342
+
343
+
344
+
345
+
346
+
347
+
348
+
265
349
  * @example
266
350
  * // Get incoming edges
267
351
  * const g = new DirectedGraph();
@@ -286,6 +370,27 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
286
370
 
287
371
 
288
372
 
373
+
374
+
375
+
376
+
377
+
378
+
379
+
380
+
381
+
382
+
383
+
384
+
385
+
386
+
387
+
388
+
389
+
390
+
391
+
392
+
393
+
289
394
  * @example
290
395
  * // Get outgoing edges
291
396
  * const g = new DirectedGraph();
@@ -338,6 +443,27 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
338
443
 
339
444
 
340
445
 
446
+
447
+
448
+
449
+
450
+
451
+
452
+
453
+
454
+
455
+
456
+
457
+
458
+
459
+
460
+
461
+
462
+
463
+
464
+
465
+
466
+
341
467
  * @example
342
468
  * // DirectedGraph topologicalSort for task scheduling
343
469
  * const graph = new DirectedGraph<string>();
@@ -372,6 +498,27 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
372
498
 
373
499
 
374
500
 
501
+
502
+
503
+
504
+
505
+
506
+
507
+
508
+
509
+
510
+
511
+
512
+
513
+
514
+
515
+
516
+
517
+
518
+
519
+
520
+
521
+
375
522
  * @example
376
523
  * // Get all edges
377
524
  * const g = new DirectedGraph();
@@ -392,6 +539,27 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
392
539
 
393
540
 
394
541
 
542
+
543
+
544
+
545
+
546
+
547
+
548
+
549
+
550
+
551
+
552
+
553
+
554
+
555
+
556
+
557
+
558
+
559
+
560
+
561
+
562
+
395
563
  * @example
396
564
  * // Get outgoing neighbors
397
565
  * const g = new DirectedGraph();
@@ -439,6 +607,27 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
439
607
 
440
608
 
441
609
 
610
+
611
+
612
+
613
+
614
+
615
+
616
+
617
+
618
+
619
+
620
+
621
+
622
+
623
+
624
+
625
+
626
+
627
+
628
+
629
+
630
+
442
631
  * @example
443
632
  * // Find strongly connected components
444
633
  * const g = new DirectedGraph();
@@ -482,6 +671,27 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
482
671
 
483
672
 
484
673
 
674
+
675
+
676
+
677
+
678
+
679
+
680
+
681
+
682
+
683
+
684
+
685
+
686
+
687
+
688
+
689
+
690
+
691
+
692
+
693
+
694
+
485
695
  * @example
486
696
  * // Get strongly connected components
487
697
  * const g = new DirectedGraph();
@@ -182,6 +182,27 @@ 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
+
185
206
  * @example
186
207
  * // Get edge between vertices
187
208
  * const g = new UndirectedGraph();
@@ -216,6 +237,27 @@ export declare class UndirectedGraph<V = any, E = any, VO extends UndirectedVert
216
237
 
217
238
 
218
239
 
240
+
241
+
242
+
243
+
244
+
245
+
246
+
247
+
248
+
249
+
250
+
251
+
252
+
253
+
254
+
255
+
256
+
257
+
258
+
259
+
260
+
219
261
  * @example
220
262
  * // UndirectedGraph deleteEdge and vertex operations
221
263
  * const graph = new UndirectedGraph<string>();
@@ -258,6 +300,27 @@ export declare class UndirectedGraph<V = any, E = any, VO extends UndirectedVert
258
300
 
259
301
 
260
302
 
303
+
304
+
305
+
306
+
307
+
308
+
309
+
310
+
311
+
312
+
313
+
314
+
315
+
316
+
317
+
318
+
319
+
320
+
321
+
322
+
323
+
261
324
  * @example
262
325
  * // Remove vertex and edges
263
326
  * const g = new UndirectedGraph();
@@ -294,6 +357,27 @@ export declare class UndirectedGraph<V = any, E = any, VO extends UndirectedVert
294
357
 
295
358
 
296
359
 
360
+
361
+
362
+
363
+
364
+
365
+
366
+
367
+
368
+
369
+
370
+
371
+
372
+
373
+
374
+
375
+
376
+
377
+
378
+
379
+
380
+
297
381
  * @example
298
382
  * // Get all edges
299
383
  * const g = new UndirectedGraph();
@@ -316,6 +400,27 @@ export declare class UndirectedGraph<V = any, E = any, VO extends UndirectedVert
316
400
 
317
401
 
318
402
 
403
+
404
+
405
+
406
+
407
+
408
+
409
+
410
+
411
+
412
+
413
+
414
+
415
+
416
+
417
+
418
+
419
+
420
+
421
+
422
+
423
+
319
424
  * @example
320
425
  * // UndirectedGraph connectivity and neighbors
321
426
  * const graph = new UndirectedGraph<string>();
@@ -385,6 +490,27 @@ export declare class UndirectedGraph<V = any, E = any, VO extends UndirectedVert
385
490
 
386
491
 
387
492
 
493
+
494
+
495
+
496
+
497
+
498
+
499
+
500
+
501
+
502
+
503
+
504
+
505
+
506
+
507
+
508
+
509
+
510
+
511
+
512
+
513
+
388
514
  * @example
389
515
  * // Find articulation points and bridges
390
516
  * const g = new UndirectedGraph();
@@ -422,6 +548,27 @@ export declare class UndirectedGraph<V = any, E = any, VO extends UndirectedVert
422
548
 
423
549
 
424
550
 
551
+
552
+
553
+
554
+
555
+
556
+
557
+
558
+
559
+
560
+
561
+
562
+
563
+
564
+
565
+
566
+
567
+
568
+
569
+
570
+
571
+
425
572
  * @example
426
573
  * // Detect cycle
427
574
  * const g = new UndirectedGraph();
@@ -447,6 +594,27 @@ export declare class UndirectedGraph<V = any, E = any, VO extends UndirectedVert
447
594
 
448
595
 
449
596
 
597
+
598
+
599
+
600
+
601
+
602
+
603
+
604
+
605
+
606
+
607
+
608
+
609
+
610
+
611
+
612
+
613
+
614
+
615
+
616
+
617
+
450
618
  * @example
451
619
  * // Find bridge edges
452
620
  * const g = new UndirectedGraph();
@@ -471,6 +639,27 @@ export declare class UndirectedGraph<V = any, E = any, VO extends UndirectedVert
471
639
 
472
640
 
473
641
 
642
+
643
+
644
+
645
+
646
+
647
+
648
+
649
+
650
+
651
+
652
+
653
+
654
+
655
+
656
+
657
+
658
+
659
+
660
+
661
+
662
+
474
663
  * @example
475
664
  * // Find articulation points
476
665
  * const g = new UndirectedGraph();