binary-tree-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 +771 -68
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/cjs-legacy/index.cjs +771 -68
  4. package/dist/cjs-legacy/index.cjs.map +1 -1
  5. package/dist/esm/index.mjs +771 -69
  6. package/dist/esm/index.mjs.map +1 -1
  7. package/dist/esm-legacy/index.mjs +771 -69
  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/binary-tree-typed.js +773 -71
  47. package/dist/umd/binary-tree-typed.js.map +1 -1
  48. package/dist/umd/binary-tree-typed.min.js +5 -5
  49. package/dist/umd/binary-tree-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
@@ -279,6 +279,30 @@ export class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, D
279
279
 
280
280
 
281
281
 
282
+
283
+
284
+
285
+
286
+
287
+
288
+
289
+
290
+
291
+
292
+
293
+
294
+
295
+
296
+
297
+
298
+
299
+
300
+
301
+
302
+
303
+
304
+
305
+
282
306
  * @example
283
307
  * // basic DoublyLinkedList creation and push operation
284
308
  * // Create a simple DoublyLinkedList with initial values
@@ -326,6 +350,30 @@ export class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, D
326
350
 
327
351
 
328
352
 
353
+
354
+
355
+
356
+
357
+
358
+
359
+
360
+
361
+
362
+
363
+
364
+
365
+
366
+
367
+
368
+
369
+
370
+
371
+
372
+
373
+
374
+
375
+
376
+
329
377
  * @example
330
378
  * // DoublyLinkedList pop and shift operations
331
379
  * const list = new DoublyLinkedList<number>([10, 20, 30, 40, 50]);
@@ -372,6 +420,30 @@ export class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, D
372
420
 
373
421
 
374
422
 
423
+
424
+
425
+
426
+
427
+
428
+
429
+
430
+
431
+
432
+
433
+
434
+
435
+
436
+
437
+
438
+
439
+
440
+
441
+
442
+
443
+
444
+
445
+
446
+
375
447
  * @example
376
448
  * // Remove from the front
377
449
  * const list = new DoublyLinkedList<number>([10, 20, 30]);
@@ -409,6 +481,30 @@ export class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, D
409
481
 
410
482
 
411
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
+
412
508
  * @example
413
509
  * // Add to the front
414
510
  * const list = new DoublyLinkedList<number>([2, 3]);
@@ -479,6 +575,30 @@ export class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, D
479
575
 
480
576
 
481
577
 
578
+
579
+
580
+
581
+
582
+
583
+
584
+
585
+
586
+
587
+
588
+
589
+
590
+
591
+
592
+
593
+
594
+
595
+
596
+
597
+
598
+
599
+
600
+
601
+
482
602
  * @example
483
603
  * // Access by index
484
604
  * const list = new DoublyLinkedList<string>(['a', 'b', 'c']);
@@ -506,6 +626,30 @@ export class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, D
506
626
 
507
627
 
508
628
 
629
+
630
+
631
+
632
+
633
+
634
+
635
+
636
+
637
+
638
+
639
+
640
+
641
+
642
+
643
+
644
+
645
+
646
+
647
+
648
+
649
+
650
+
651
+
652
+
509
653
  * @example
510
654
  * // Get node at index
511
655
  * const list = new DoublyLinkedList<string>(['a', 'b', 'c']);
@@ -572,6 +716,30 @@ export class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, D
572
716
 
573
717
 
574
718
 
719
+
720
+
721
+
722
+
723
+
724
+
725
+
726
+
727
+
728
+
729
+
730
+
731
+
732
+
733
+
734
+
735
+
736
+
737
+
738
+
739
+
740
+
741
+
742
+
575
743
  * @example
576
744
  * // Insert at position
577
745
  * const list = new DoublyLinkedList<number>([1, 3]);
@@ -674,6 +842,30 @@ export class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, D
674
842
 
675
843
 
676
844
 
845
+
846
+
847
+
848
+
849
+
850
+
851
+
852
+
853
+
854
+
855
+
856
+
857
+
858
+
859
+
860
+
861
+
862
+
863
+
864
+
865
+
866
+
867
+
868
+
677
869
  * @example
678
870
  * // Remove by index
679
871
  * const list = new DoublyLinkedList<string>(['a', 'b', 'c']);
@@ -708,6 +900,30 @@ export class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, D
708
900
 
709
901
 
710
902
 
903
+
904
+
905
+
906
+
907
+
908
+
909
+
910
+
911
+
912
+
913
+
914
+
915
+
916
+
917
+
918
+
919
+
920
+
921
+
922
+
923
+
924
+
925
+
926
+
711
927
  * @example
712
928
  * // Remove first occurrence
713
929
  * const list = new DoublyLinkedList<number>([1, 2, 3, 2]);
@@ -744,6 +960,30 @@ export class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, D
744
960
 
745
961
 
746
962
 
963
+
964
+
965
+
966
+
967
+
968
+
969
+
970
+
971
+
972
+
973
+
974
+
975
+
976
+
977
+
978
+
979
+
980
+
981
+
982
+
983
+
984
+
985
+
986
+
747
987
  * @example
748
988
  * // Check empty
749
989
  * console.log(new DoublyLinkedList().isEmpty()); // true;
@@ -766,6 +1006,30 @@ export class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, D
766
1006
 
767
1007
 
768
1008
 
1009
+
1010
+
1011
+
1012
+
1013
+
1014
+
1015
+
1016
+
1017
+
1018
+
1019
+
1020
+
1021
+
1022
+
1023
+
1024
+
1025
+
1026
+
1027
+
1028
+
1029
+
1030
+
1031
+
1032
+
769
1033
  * @example
770
1034
  * // Remove all
771
1035
  * const list = new DoublyLinkedList<number>([1, 2]);
@@ -792,6 +1056,30 @@ export class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, D
792
1056
 
793
1057
 
794
1058
 
1059
+
1060
+
1061
+
1062
+
1063
+
1064
+
1065
+
1066
+
1067
+
1068
+
1069
+
1070
+
1071
+
1072
+
1073
+
1074
+
1075
+
1076
+
1077
+
1078
+
1079
+
1080
+
1081
+
1082
+
795
1083
  * @example
796
1084
  * // Search with predicate
797
1085
  * const list = new DoublyLinkedList<number>([10, 20, 30]);
@@ -824,6 +1112,30 @@ export class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, D
824
1112
 
825
1113
 
826
1114
 
1115
+
1116
+
1117
+
1118
+
1119
+
1120
+
1121
+
1122
+
1123
+
1124
+
1125
+
1126
+
1127
+
1128
+
1129
+
1130
+
1131
+
1132
+
1133
+
1134
+
1135
+
1136
+
1137
+
1138
+
827
1139
  * @example
828
1140
  * // Find value scanning from tail
829
1141
  * const list = new DoublyLinkedList<number>([1, 2, 3, 4]);
@@ -859,6 +1171,30 @@ export class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, D
859
1171
 
860
1172
 
861
1173
 
1174
+
1175
+
1176
+
1177
+
1178
+
1179
+
1180
+
1181
+
1182
+
1183
+
1184
+
1185
+
1186
+
1187
+
1188
+
1189
+
1190
+
1191
+
1192
+
1193
+
1194
+
1195
+
1196
+
1197
+
862
1198
  * @example
863
1199
  * // Reverse in-place
864
1200
  * const list = new DoublyLinkedList<number>([1, 2, 3]);
@@ -902,6 +1238,30 @@ export class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, D
902
1238
 
903
1239
 
904
1240
 
1241
+
1242
+
1243
+
1244
+
1245
+
1246
+
1247
+
1248
+
1249
+
1250
+
1251
+
1252
+
1253
+
1254
+
1255
+
1256
+
1257
+
1258
+
1259
+
1260
+
1261
+
1262
+
1263
+
1264
+
905
1265
  * @example
906
1266
  * // Deep copy
907
1267
  * const list = new DoublyLinkedList<number>([1, 2, 3]);
@@ -933,6 +1293,30 @@ export class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, D
933
1293
 
934
1294
 
935
1295
 
1296
+
1297
+
1298
+
1299
+
1300
+
1301
+
1302
+
1303
+
1304
+
1305
+
1306
+
1307
+
1308
+
1309
+
1310
+
1311
+
1312
+
1313
+
1314
+
1315
+
1316
+
1317
+
1318
+
1319
+
936
1320
  * @example
937
1321
  * // Filter elements
938
1322
  * const list = new DoublyLinkedList<number>([1, 2, 3, 4, 5]);
@@ -940,7 +1324,7 @@ export class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, D
940
1324
  * console.log([...evens]); // [2, 4];
941
1325
  */
942
1326
 
943
- filter(callback: ElementCallback<E, R, boolean>, thisArg?: any): this {
1327
+ filter(callback: ElementCallback<E, R, boolean>, thisArg?: unknown): this {
944
1328
  const out = this._createInstance({ toElementFn: this._toElementFn, maxLen: this._maxLen });
945
1329
  let index = 0;
946
1330
  for (const v of this) if (callback.call(thisArg, v, index++, this)) out.push(v);
@@ -955,7 +1339,7 @@ export class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, D
955
1339
  * @returns A new list with mapped values.
956
1340
  */
957
1341
 
958
- mapSame(callback: ElementCallback<E, R, E>, thisArg?: any): this {
1342
+ mapSame(callback: ElementCallback<E, R, E>, thisArg?: unknown): this {
959
1343
  const out = this._createInstance({ toElementFn: this._toElementFn, maxLen: this._maxLen });
960
1344
  let index = 0;
961
1345
  for (const v of this) {
@@ -985,6 +1369,30 @@ export class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, D
985
1369
 
986
1370
 
987
1371
 
1372
+
1373
+
1374
+
1375
+
1376
+
1377
+
1378
+
1379
+
1380
+
1381
+
1382
+
1383
+
1384
+
1385
+
1386
+
1387
+
1388
+
1389
+
1390
+
1391
+
1392
+
1393
+
1394
+
1395
+
988
1396
  * @example
989
1397
  * // DoublyLinkedList for...of iteration and map operation
990
1398
  * const list = new DoublyLinkedList<number>([1, 2, 3, 4, 5]);
@@ -1004,7 +1412,7 @@ export class DoublyLinkedList<E = any, R = any> extends LinearLinkedBase<E, R, D
1004
1412
  map<EM, RM>(
1005
1413
  callback: ElementCallback<E, R, EM>,
1006
1414
  options?: DoublyLinkedListOptions<EM, RM>,
1007
- thisArg?: any
1415
+ thisArg?: unknown
1008
1416
  ): DoublyLinkedList<EM, RM> {
1009
1417
  const out = this._createLike<EM, RM>([], { ...(options ?? {}), maxLen: this._maxLen });
1010
1418
  let index = 0;