binary-tree-typed 2.5.2 → 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 (59) hide show
  1. package/dist/cjs/index.cjs +194 -55
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/cjs-legacy/index.cjs +194 -55
  4. package/dist/cjs-legacy/index.cjs.map +1 -1
  5. package/dist/esm/index.mjs +194 -55
  6. package/dist/esm/index.mjs.map +1 -1
  7. package/dist/esm-legacy/index.mjs +194 -55
  8. package/dist/esm-legacy/index.mjs.map +1 -1
  9. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +50 -2
  10. package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +56 -0
  11. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +116 -15
  12. package/dist/types/data-structures/binary-tree/bst.d.ts +99 -3
  13. package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +79 -8
  14. package/dist/types/data-structures/binary-tree/segment-tree.d.ts +24 -0
  15. package/dist/types/data-structures/binary-tree/tree-map.d.ts +520 -1
  16. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +489 -1
  17. package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +393 -1
  18. package/dist/types/data-structures/binary-tree/tree-set.d.ts +500 -1
  19. package/dist/types/data-structures/graph/directed-graph.d.ts +40 -0
  20. package/dist/types/data-structures/graph/undirected-graph.d.ts +36 -0
  21. package/dist/types/data-structures/hash/hash-map.d.ts +51 -6
  22. package/dist/types/data-structures/heap/heap.d.ts +98 -12
  23. package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +75 -0
  24. package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +61 -1
  25. package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +72 -0
  26. package/dist/types/data-structures/matrix/matrix.d.ts +32 -0
  27. package/dist/types/data-structures/queue/deque.d.ts +82 -0
  28. package/dist/types/data-structures/queue/queue.d.ts +61 -0
  29. package/dist/types/data-structures/stack/stack.d.ts +42 -2
  30. package/dist/types/data-structures/trie/trie.d.ts +48 -0
  31. package/dist/types/interfaces/binary-tree.d.ts +2 -3
  32. package/dist/umd/binary-tree-typed.js +194 -55
  33. package/dist/umd/binary-tree-typed.js.map +1 -1
  34. package/dist/umd/binary-tree-typed.min.js +5 -5
  35. package/dist/umd/binary-tree-typed.min.js.map +1 -1
  36. package/package.json +2 -2
  37. package/src/data-structures/binary-tree/avl-tree.ts +52 -5
  38. package/src/data-structures/binary-tree/binary-indexed-tree.ts +56 -0
  39. package/src/data-structures/binary-tree/binary-tree.ts +167 -81
  40. package/src/data-structures/binary-tree/bst.ts +101 -7
  41. package/src/data-structures/binary-tree/red-black-tree.ts +82 -15
  42. package/src/data-structures/binary-tree/segment-tree.ts +24 -0
  43. package/src/data-structures/binary-tree/tree-map.ts +540 -3
  44. package/src/data-structures/binary-tree/tree-multi-map.ts +490 -2
  45. package/src/data-structures/binary-tree/tree-multi-set.ts +393 -1
  46. package/src/data-structures/binary-tree/tree-set.ts +520 -3
  47. package/src/data-structures/graph/directed-graph.ts +41 -1
  48. package/src/data-structures/graph/undirected-graph.ts +37 -1
  49. package/src/data-structures/hash/hash-map.ts +67 -12
  50. package/src/data-structures/heap/heap.ts +107 -19
  51. package/src/data-structures/linked-list/doubly-linked-list.ts +88 -0
  52. package/src/data-structures/linked-list/singly-linked-list.ts +61 -1
  53. package/src/data-structures/linked-list/skip-linked-list.ts +72 -0
  54. package/src/data-structures/matrix/matrix.ts +32 -0
  55. package/src/data-structures/queue/deque.ts +85 -0
  56. package/src/data-structures/queue/queue.ts +73 -0
  57. package/src/data-structures/stack/stack.ts +45 -5
  58. package/src/data-structures/trie/trie.ts +48 -0
  59. package/src/interfaces/binary-tree.ts +1 -9
@@ -5,7 +5,7 @@
5
5
  * @copyright Copyright (c) 2022 Pablo Zeng <zrwusa@gmail.com>
6
6
  * @license MIT License
7
7
  */
8
- import type { BinaryTreeDeleteResult, BSTNOptKeyOrNode, BSTOptions, BTNRep, Comparator, DFSOrderPattern, EntryCallback, FamilyPosition, IterationType, NodeCallback, NodePredicate, OptNode, RBTNColor } from '../../types';
8
+ import type { BSTNOptKeyOrNode, BSTOptions, BTNRep, Comparator, DFSOrderPattern, EntryCallback, FamilyPosition, IterationType, NodeCallback, NodePredicate, OptNode, RBTNColor } from '../../types';
9
9
  import { BinaryTree } from './binary-tree';
10
10
  import { IBinaryTree } from '../../interfaces';
11
11
  import { Range } from '../../common';
@@ -372,6 +372,14 @@ export declare class BST<K = any, V = any, R = any> extends BinaryTree<K, V, R>
372
372
 
373
373
 
374
374
 
375
+
376
+
377
+
378
+
379
+
380
+
381
+
382
+
375
383
 
376
384
 
377
385
 
@@ -444,6 +452,14 @@ export declare class BST<K = any, V = any, R = any> extends BinaryTree<K, V, R>
444
452
 
445
453
 
446
454
 
455
+
456
+
457
+
458
+
459
+
460
+
461
+
462
+
447
463
 
448
464
 
449
465
 
@@ -519,6 +535,14 @@ export declare class BST<K = any, V = any, R = any> extends BinaryTree<K, V, R>
519
535
 
520
536
 
521
537
 
538
+
539
+
540
+
541
+
542
+
543
+
544
+
545
+
522
546
 
523
547
 
524
548
 
@@ -532,7 +556,7 @@ export declare class BST<K = any, V = any, R = any> extends BinaryTree<K, V, R>
532
556
  * // Level-order grouping
533
557
  * const bst = new BST<number>([5, 3, 7, 1, 4]);
534
558
  * const levels = bst.listLevels(node => node.key);
535
- * console.log(levels.length); // > 0;
559
+ * console.log(levels); // toBeInstanceOf;
536
560
  * console.log(levels[0].length); // 1; // root level has 1 node
537
561
  * const allKeys = levels.flat().sort((a, b) => a - b);
538
562
  * console.log(allKeys); // [1, 3, 4, 5, 7];
@@ -605,6 +629,14 @@ export declare class BST<K = any, V = any, R = any> extends BinaryTree<K, V, R>
605
629
 
606
630
 
607
631
 
632
+
633
+
634
+
635
+
636
+
637
+
638
+
639
+
608
640
 
609
641
 
610
642
 
@@ -675,6 +707,14 @@ export declare class BST<K = any, V = any, R = any> extends BinaryTree<K, V, R>
675
707
 
676
708
 
677
709
 
710
+
711
+
712
+
713
+
714
+
715
+
716
+
717
+
678
718
 
679
719
 
680
720
 
@@ -724,6 +764,10 @@ export declare class BST<K = any, V = any, R = any> extends BinaryTree<K, V, R>
724
764
 
725
765
 
726
766
 
767
+
768
+
769
+
770
+
727
771
 
728
772
 
729
773
 
@@ -890,6 +934,18 @@ export declare class BST<K = any, V = any, R = any> extends BinaryTree<K, V, R>
890
934
 
891
935
 
892
936
 
937
+
938
+
939
+
940
+
941
+
942
+
943
+
944
+
945
+
946
+
947
+
948
+
893
949
 
894
950
 
895
951
 
@@ -972,6 +1028,14 @@ export declare class BST<K = any, V = any, R = any> extends BinaryTree<K, V, R>
972
1028
 
973
1029
 
974
1030
 
1031
+
1032
+
1033
+
1034
+
1035
+
1036
+
1037
+
1038
+
975
1039
 
976
1040
 
977
1041
 
@@ -1024,6 +1088,10 @@ export declare class BST<K = any, V = any, R = any> extends BinaryTree<K, V, R>
1024
1088
 
1025
1089
 
1026
1090
 
1091
+
1092
+
1093
+
1094
+
1027
1095
 
1028
1096
 
1029
1097
 
@@ -1078,6 +1146,10 @@ export declare class BST<K = any, V = any, R = any> extends BinaryTree<K, V, R>
1078
1146
 
1079
1147
 
1080
1148
 
1149
+
1150
+
1151
+
1152
+
1081
1153
 
1082
1154
 
1083
1155
 
@@ -1131,6 +1203,10 @@ export declare class BST<K = any, V = any, R = any> extends BinaryTree<K, V, R>
1131
1203
 
1132
1204
 
1133
1205
 
1206
+
1207
+
1208
+
1209
+
1134
1210
 
1135
1211
 
1136
1212
 
@@ -1185,6 +1261,10 @@ export declare class BST<K = any, V = any, R = any> extends BinaryTree<K, V, R>
1185
1261
 
1186
1262
 
1187
1263
 
1264
+
1265
+
1266
+
1267
+
1188
1268
 
1189
1269
 
1190
1270
 
@@ -1239,6 +1319,10 @@ export declare class BST<K = any, V = any, R = any> extends BinaryTree<K, V, R>
1239
1319
 
1240
1320
 
1241
1321
 
1322
+
1323
+
1324
+
1325
+
1242
1326
 
1243
1327
 
1244
1328
 
@@ -1288,6 +1372,10 @@ export declare class BST<K = any, V = any, R = any> extends BinaryTree<K, V, R>
1288
1372
 
1289
1373
 
1290
1374
 
1375
+
1376
+
1377
+
1378
+
1291
1379
 
1292
1380
 
1293
1381
 
@@ -1369,6 +1457,14 @@ export declare class BST<K = any, V = any, R = any> extends BinaryTree<K, V, R>
1369
1457
 
1370
1458
 
1371
1459
 
1460
+
1461
+
1462
+
1463
+
1464
+
1465
+
1466
+
1467
+
1372
1468
 
1373
1469
 
1374
1470
 
@@ -1421,7 +1517,7 @@ export declare class BST<K = any, V = any, R = any> extends BinaryTree<K, V, R>
1421
1517
  * - Value: true if the deletion succeeded, false if it failed (e.g., key not found during deletion phase).
1422
1518
  * - If no nodes match the search criteria, the returned map is empty.
1423
1519
  */
1424
- deleteWhere(keyNodeEntryOrPredicate: K | BSTNode<K, V> | [K | null | undefined, V | undefined] | null | undefined | NodePredicate<BSTNode<K, V>> | Range<K>, onlyOne?: boolean, startNode?: K | BSTNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, iterationType?: IterationType): BinaryTreeDeleteResult<BSTNode<K, V>>[];
1520
+ deleteWhere(keyNodeEntryOrPredicate: K | BSTNode<K, V> | [K | null | undefined, V | undefined] | null | undefined | NodePredicate<BSTNode<K, V>> | Range<K>, onlyOne?: boolean, startNode?: K | BSTNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, iterationType?: IterationType): boolean;
1425
1521
  /**
1426
1522
  * (Protected) Creates the default comparator function for keys that don't have a custom comparator.
1427
1523
  * @remarks Time O(1) Space O(1)
@@ -5,7 +5,7 @@
5
5
  * @copyright Copyright (c) 2022 Pablo Zeng <zrwusa@gmail.com>
6
6
  * @license MIT License
7
7
  */
8
- import type { BinaryTreeDeleteResult, BTNRep, CRUD, EntryCallback, FamilyPosition, NodePredicate, RBTNColor, IterationType, RedBlackTreeOptions } from '../../types';
8
+ import type { BTNRep, CRUD, EntryCallback, FamilyPosition, NodePredicate, RBTNColor, IterationType, RedBlackTreeOptions } from '../../types';
9
9
  import { BST } from './bst';
10
10
  import { IBinaryTree } from '../../interfaces';
11
11
  export declare class RedBlackTreeNode<K = any, V = any> {
@@ -217,13 +217,24 @@ export declare class RedBlackTree<K = any, V = any, R = any> extends BST<K, V, R
217
217
  */
218
218
  isNode(keyNodeOrEntry: K | RedBlackTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined): keyNodeOrEntry is RedBlackTreeNode<K, V>;
219
219
  /**
220
- * Remove all nodes and clear the key→value store (if in map mode).
220
+ * Remove all nodes, clear the key→value store (if in map mode) and internal caches.
221
221
  * @remarks Time O(n), Space O(1)
222
- * @returns void
223
- */
224
- /**
225
- * Remove all nodes and clear internal caches.
226
- * @remarks Time O(n) average, Space O(1)
222
+
223
+
224
+
225
+
226
+
227
+
228
+
229
+
230
+
231
+
232
+
233
+
234
+
235
+
236
+
237
+
227
238
 
228
239
 
229
240
 
@@ -576,6 +587,22 @@ export declare class RedBlackTree<K = any, V = any, R = any> extends BST<K, V, R
576
587
 
577
588
 
578
589
 
590
+
591
+
592
+
593
+
594
+
595
+
596
+
597
+
598
+
599
+
600
+
601
+
602
+
603
+
604
+
605
+
579
606
 
580
607
 
581
608
 
@@ -734,6 +761,22 @@ export declare class RedBlackTree<K = any, V = any, R = any> extends BST<K, V, R
734
761
 
735
762
 
736
763
 
764
+
765
+
766
+
767
+
768
+
769
+
770
+
771
+
772
+
773
+
774
+
775
+
776
+
777
+
778
+
779
+
737
780
 
738
781
 
739
782
 
@@ -758,7 +801,7 @@ export declare class RedBlackTree<K = any, V = any, R = any> extends BST<K, V, R
758
801
  * console.log(rbt.has(5)); // false;
759
802
  * console.log(rbt.size); // 4;
760
803
  */
761
- delete(keyNodeEntryRawOrPredicate: BTNRep<K, V, RedBlackTreeNode<K, V>> | NodePredicate<RedBlackTreeNode<K, V> | null>): BinaryTreeDeleteResult<RedBlackTreeNode<K, V>>[];
804
+ delete(keyNodeEntryRawOrPredicate: BTNRep<K, V, RedBlackTreeNode<K, V>> | NodePredicate<RedBlackTreeNode<K, V> | null>): boolean;
762
805
  /**
763
806
  * Transform entries into a like-kind red-black tree with possibly different key/value types.
764
807
  * @remarks Time O(n) average, Space O(n)
@@ -858,6 +901,18 @@ export declare class RedBlackTree<K = any, V = any, R = any> extends BST<K, V, R
858
901
 
859
902
 
860
903
 
904
+
905
+
906
+
907
+
908
+
909
+
910
+
911
+
912
+
913
+
914
+
915
+
861
916
 
862
917
 
863
918
 
@@ -994,6 +1049,22 @@ export declare class RedBlackTree<K = any, V = any, R = any> extends BST<K, V, R
994
1049
 
995
1050
 
996
1051
 
1052
+
1053
+
1054
+
1055
+
1056
+
1057
+
1058
+
1059
+
1060
+
1061
+
1062
+
1063
+
1064
+
1065
+
1066
+
1067
+
997
1068
 
998
1069
 
999
1070
 
@@ -75,6 +75,10 @@ export declare class SegmentTree<E = number> implements Iterable<E> {
75
75
 
76
76
 
77
77
 
78
+
79
+
80
+
81
+
78
82
 
79
83
 
80
84
 
@@ -136,6 +140,10 @@ export declare class SegmentTree<E = number> implements Iterable<E> {
136
140
 
137
141
 
138
142
 
143
+
144
+
145
+
146
+
139
147
 
140
148
 
141
149
 
@@ -193,6 +201,10 @@ export declare class SegmentTree<E = number> implements Iterable<E> {
193
201
 
194
202
 
195
203
 
204
+
205
+
206
+
207
+
196
208
 
197
209
 
198
210
 
@@ -245,6 +257,10 @@ export declare class SegmentTree<E = number> implements Iterable<E> {
245
257
 
246
258
 
247
259
 
260
+
261
+
262
+
263
+
248
264
 
249
265
 
250
266
 
@@ -292,6 +308,10 @@ export declare class SegmentTree<E = number> implements Iterable<E> {
292
308
 
293
309
 
294
310
 
311
+
312
+
313
+
314
+
295
315
 
296
316
 
297
317
 
@@ -342,6 +362,10 @@ export declare class SegmentTree<E = number> implements Iterable<E> {
342
362
 
343
363
 
344
364
 
365
+
366
+
367
+
368
+
345
369
 
346
370
 
347
371