data-structure-typed 2.5.2 → 2.6.0

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 (162) hide show
  1. package/.husky/pre-commit +3 -0
  2. package/CHANGELOG.md +3 -1
  3. package/MIGRATION.md +217 -0
  4. package/README.md +80 -8
  5. package/README_CN.md +569 -143
  6. package/SPECIFICATION.md +44 -14
  7. package/SPECIFICATION.zh-CN.md +44 -14
  8. package/dist/cjs/binary-tree.cjs +5841 -1678
  9. package/dist/cjs/graph.cjs +422 -14
  10. package/dist/cjs/hash.cjs +95 -7
  11. package/dist/cjs/heap.cjs +174 -16
  12. package/dist/cjs/index.cjs +7751 -2449
  13. package/dist/cjs/linked-list.cjs +443 -2
  14. package/dist/cjs/matrix.cjs +56 -0
  15. package/dist/cjs/priority-queue.cjs +172 -14
  16. package/dist/cjs/queue.cjs +435 -0
  17. package/dist/cjs/stack.cjs +103 -4
  18. package/dist/cjs/trie.cjs +106 -0
  19. package/dist/cjs-legacy/binary-tree.cjs +5933 -1772
  20. package/dist/cjs-legacy/graph.cjs +422 -14
  21. package/dist/cjs-legacy/hash.cjs +95 -7
  22. package/dist/cjs-legacy/heap.cjs +174 -16
  23. package/dist/cjs-legacy/index.cjs +8154 -2854
  24. package/dist/cjs-legacy/linked-list.cjs +443 -2
  25. package/dist/cjs-legacy/matrix.cjs +56 -0
  26. package/dist/cjs-legacy/priority-queue.cjs +172 -14
  27. package/dist/cjs-legacy/queue.cjs +435 -0
  28. package/dist/cjs-legacy/stack.cjs +103 -4
  29. package/dist/cjs-legacy/trie.cjs +106 -0
  30. package/dist/esm/binary-tree.mjs +5841 -1678
  31. package/dist/esm/graph.mjs +422 -14
  32. package/dist/esm/hash.mjs +95 -7
  33. package/dist/esm/heap.mjs +174 -16
  34. package/dist/esm/index.mjs +7751 -2449
  35. package/dist/esm/linked-list.mjs +443 -2
  36. package/dist/esm/matrix.mjs +56 -0
  37. package/dist/esm/priority-queue.mjs +172 -14
  38. package/dist/esm/queue.mjs +435 -0
  39. package/dist/esm/stack.mjs +103 -4
  40. package/dist/esm/trie.mjs +106 -0
  41. package/dist/esm-legacy/binary-tree.mjs +5933 -1772
  42. package/dist/esm-legacy/graph.mjs +422 -14
  43. package/dist/esm-legacy/hash.mjs +95 -7
  44. package/dist/esm-legacy/heap.mjs +174 -16
  45. package/dist/esm-legacy/index.mjs +8154 -2854
  46. package/dist/esm-legacy/linked-list.mjs +443 -2
  47. package/dist/esm-legacy/matrix.mjs +56 -0
  48. package/dist/esm-legacy/priority-queue.mjs +172 -14
  49. package/dist/esm-legacy/queue.mjs +435 -0
  50. package/dist/esm-legacy/stack.mjs +103 -4
  51. package/dist/esm-legacy/trie.mjs +106 -0
  52. package/dist/types/data-structures/base/iterable-element-base.d.ts +17 -0
  53. package/dist/types/data-structures/base/linear-base.d.ts +6 -0
  54. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +86 -2
  55. package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +98 -0
  56. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +191 -15
  57. package/dist/types/data-structures/binary-tree/bst.d.ts +171 -3
  58. package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +136 -8
  59. package/dist/types/data-structures/binary-tree/segment-tree.d.ts +42 -0
  60. package/dist/types/data-structures/binary-tree/tree-map.d.ts +1061 -167
  61. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +1232 -355
  62. package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +916 -194
  63. package/dist/types/data-structures/binary-tree/tree-set.d.ts +1078 -141
  64. package/dist/types/data-structures/graph/directed-graph.d.ts +70 -0
  65. package/dist/types/data-structures/graph/undirected-graph.d.ts +63 -0
  66. package/dist/types/data-structures/hash/hash-map.d.ts +84 -6
  67. package/dist/types/data-structures/heap/heap.d.ts +140 -12
  68. package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +150 -2
  69. package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +106 -1
  70. package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +126 -0
  71. package/dist/types/data-structures/matrix/matrix.d.ts +56 -0
  72. package/dist/types/data-structures/queue/deque.d.ts +171 -0
  73. package/dist/types/data-structures/queue/queue.d.ts +97 -0
  74. package/dist/types/data-structures/stack/stack.d.ts +72 -2
  75. package/dist/types/data-structures/trie/trie.d.ts +84 -0
  76. package/dist/types/interfaces/binary-tree.d.ts +2 -3
  77. package/dist/umd/data-structure-typed.js +7784 -2484
  78. package/dist/umd/data-structure-typed.min.js +4 -4
  79. package/docs-site-docusaurus/docs/api/classes/AVLTree.md +188 -200
  80. package/docs-site-docusaurus/docs/api/classes/AVLTreeNode.md +11 -11
  81. package/docs-site-docusaurus/docs/api/classes/AbstractGraph.md +62 -62
  82. package/docs-site-docusaurus/docs/api/classes/BST.md +183 -195
  83. package/docs-site-docusaurus/docs/api/classes/BSTNode.md +13 -13
  84. package/docs-site-docusaurus/docs/api/classes/BinaryIndexedTree.md +15 -15
  85. package/docs-site-docusaurus/docs/api/classes/BinaryTree.md +143 -155
  86. package/docs-site-docusaurus/docs/api/classes/BinaryTreeNode.md +13 -13
  87. package/docs-site-docusaurus/docs/api/classes/Deque.md +99 -85
  88. package/docs-site-docusaurus/docs/api/classes/DirectedGraph.md +73 -73
  89. package/docs-site-docusaurus/docs/api/classes/DoublyLinkedList.md +100 -70
  90. package/docs-site-docusaurus/docs/api/classes/DoublyLinkedListNode.md +8 -8
  91. package/docs-site-docusaurus/docs/api/classes/FibonacciHeap.md +12 -12
  92. package/docs-site-docusaurus/docs/api/classes/FibonacciHeapNode.md +1 -1
  93. package/docs-site-docusaurus/docs/api/classes/HashMap.md +38 -38
  94. package/docs-site-docusaurus/docs/api/classes/Heap.md +96 -85
  95. package/docs-site-docusaurus/docs/api/classes/IterableElementBase.md +25 -25
  96. package/docs-site-docusaurus/docs/api/classes/IterableEntryBase.md +23 -23
  97. package/docs-site-docusaurus/docs/api/classes/LinearBase.md +48 -48
  98. package/docs-site-docusaurus/docs/api/classes/LinearLinkedBase.md +52 -52
  99. package/docs-site-docusaurus/docs/api/classes/LinkedHashMap.md +46 -42
  100. package/docs-site-docusaurus/docs/api/classes/LinkedListNode.md +6 -6
  101. package/docs-site-docusaurus/docs/api/classes/LinkedListQueue.md +74 -74
  102. package/docs-site-docusaurus/docs/api/classes/MapGraph.md +73 -73
  103. package/docs-site-docusaurus/docs/api/classes/Matrix.md +31 -31
  104. package/docs-site-docusaurus/docs/api/classes/MaxHeap.md +104 -89
  105. package/docs-site-docusaurus/docs/api/classes/MaxPriorityQueue.md +104 -89
  106. package/docs-site-docusaurus/docs/api/classes/MinHeap.md +104 -89
  107. package/docs-site-docusaurus/docs/api/classes/MinPriorityQueue.md +104 -89
  108. package/docs-site-docusaurus/docs/api/classes/Navigator.md +5 -5
  109. package/docs-site-docusaurus/docs/api/classes/PriorityQueue.md +103 -88
  110. package/docs-site-docusaurus/docs/api/classes/Queue.md +111 -59
  111. package/docs-site-docusaurus/docs/api/classes/RedBlackTree.md +200 -212
  112. package/docs-site-docusaurus/docs/api/classes/SegmentTree.md +10 -10
  113. package/docs-site-docusaurus/docs/api/classes/SinglyLinkedList.md +75 -75
  114. package/docs-site-docusaurus/docs/api/classes/SinglyLinkedListNode.md +6 -6
  115. package/docs-site-docusaurus/docs/api/classes/SkipList.md +37 -37
  116. package/docs-site-docusaurus/docs/api/classes/Stack.md +42 -42
  117. package/docs-site-docusaurus/docs/api/classes/TreeMap.md +107 -36
  118. package/docs-site-docusaurus/docs/api/classes/TreeMultiMap.md +43 -43
  119. package/docs-site-docusaurus/docs/api/classes/TreeSet.md +106 -35
  120. package/docs-site-docusaurus/docs/api/classes/Trie.md +43 -43
  121. package/docs-site-docusaurus/docs/api/classes/TrieNode.md +8 -8
  122. package/docs-site-docusaurus/docs/api/classes/UndirectedGraph.md +72 -72
  123. package/docs-site-docusaurus/docs/guide/architecture.md +75 -7
  124. package/docs-site-docusaurus/docs/guide/concepts.md +53 -34
  125. package/docs-site-docusaurus/docs/guide/faq.md +53 -0
  126. package/docs-site-docusaurus/docs/guide/guides.md +8 -9
  127. package/docs-site-docusaurus/docs/guide/integrations.md +74 -177
  128. package/docs-site-docusaurus/docs/guide/overview.md +131 -17
  129. package/docs-site-docusaurus/src/pages/index.tsx +4 -0
  130. package/docs-site-docusaurus/typedoc.json +1 -0
  131. package/jest.integration.config.js +1 -2
  132. package/package.json +10 -7
  133. package/src/data-structures/base/iterable-element-base.ts +32 -0
  134. package/src/data-structures/base/linear-base.ts +11 -0
  135. package/src/data-structures/binary-tree/avl-tree.ts +88 -5
  136. package/src/data-structures/binary-tree/binary-indexed-tree.ts +98 -0
  137. package/src/data-structures/binary-tree/binary-tree.ts +242 -81
  138. package/src/data-structures/binary-tree/bst.ts +173 -7
  139. package/src/data-structures/binary-tree/red-black-tree.ts +139 -15
  140. package/src/data-structures/binary-tree/segment-tree.ts +42 -0
  141. package/src/data-structures/binary-tree/tree-map.ts +948 -36
  142. package/src/data-structures/binary-tree/tree-multi-map.ts +893 -13
  143. package/src/data-structures/binary-tree/tree-multi-set.ts +761 -33
  144. package/src/data-structures/binary-tree/tree-set.ts +1260 -251
  145. package/src/data-structures/graph/directed-graph.ts +71 -1
  146. package/src/data-structures/graph/undirected-graph.ts +64 -1
  147. package/src/data-structures/hash/hash-map.ts +100 -12
  148. package/src/data-structures/heap/heap.ts +149 -19
  149. package/src/data-structures/linked-list/doubly-linked-list.ts +178 -2
  150. package/src/data-structures/linked-list/singly-linked-list.ts +106 -1
  151. package/src/data-structures/linked-list/skip-linked-list.ts +126 -0
  152. package/src/data-structures/matrix/matrix.ts +56 -0
  153. package/src/data-structures/queue/deque.ts +187 -0
  154. package/src/data-structures/queue/queue.ts +109 -0
  155. package/src/data-structures/stack/stack.ts +75 -5
  156. package/src/data-structures/trie/trie.ts +84 -0
  157. package/src/interfaces/binary-tree.ts +1 -9
  158. package/.vitepress/cache/deps_temp_51f5f1b0/chunk-7OIKW5WK.js +0 -12984
  159. package/.vitepress/cache/deps_temp_51f5f1b0/package.json +0 -3
  160. package/.vitepress/cache/deps_temp_51f5f1b0/vitepress___@vue_devtools-api.js +0 -4505
  161. package/.vitepress/cache/deps_temp_51f5f1b0/vitepress___@vueuse_core.js +0 -9731
  162. package/.vitepress/cache/deps_temp_51f5f1b0/vue.js +0 -347
@@ -136,7 +136,7 @@ export declare class BinaryTreeNode<K = any, V = any> {
136
136
  * node?: BinaryTreeNode<string> | null,
137
137
  * conditions?: { [key: string]: boolean }
138
138
  * ): string {
139
- * if (!node) raise(Error, 'Invalid node');
139
+ * if (!node) throw new Error('Invalid node');
140
140
  *
141
141
  * // If it's a leaf node, return the decision result
142
142
  * if (!node.left && !node.right) return node.key;
@@ -181,7 +181,7 @@ export declare class BinaryTreeNode<K = any, V = any> {
181
181
  * case '/':
182
182
  * return rightValue !== 0 ? leftValue / rightValue : 0; // Handle division by zero
183
183
  * default:
184
- * raise(Error, `Unsupported operator: ${node.key}`);
184
+ * throw new Error(`Unsupported operator: ${node.key}`);
185
185
  * }
186
186
  * }
187
187
  *
@@ -353,7 +353,7 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
353
353
  isValidKey(key: unknown): key is K;
354
354
  /**
355
355
  * Adds a new node to the tree.
356
- * @remarks Time O(log N), For BST, Red-Black Tree, and AVL Tree subclasses, the worst-case time is O(log N). This implementation adds the node at the first available position in a level-order (BFS) traversal. This is NOT a Binary Search Tree insertion. Time O(N), where N is the number of nodes. It must traverse level-by-level to find an empty slot. Space O(N) in the worst case for the BFS queue (e.g., a full last level).
356
+ * @remarks Time O(N) level-order traversal to find an empty slot. Space O(N) for the BFS queue. BST/Red-Black Tree/AVL Tree subclasses override to O(log N).
357
357
  *
358
358
  * @param keyNodeOrEntry - The key, node, or entry to add.
359
359
  * @returns True if the addition was successful, false otherwise.
@@ -379,6 +379,13 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
379
379
 
380
380
 
381
381
 
382
+
383
+
384
+
385
+
386
+
387
+
388
+
382
389
 
383
390
 
384
391
 
@@ -399,7 +406,7 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
399
406
  add(keyNodeOrEntry: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined): boolean;
400
407
  /**
401
408
  * Adds or updates a new node to the tree.
402
- * @remarks Time O(log N), For BST, Red-Black Tree, and AVL Tree subclasses, the worst-case time is O(log N). This implementation sets the node at the first available position in a level-order (BFS) traversal. This is NOT a Binary Search Tree insertion. Time O(N), where N is the number of nodes. It must traverse level-by-level to find an empty slot. Space O(N) in the worst case for the BFS queue (e.g., a full last level).
409
+ * @remarks Time O(N) level-order traversal to find an empty slot. Space O(N) for the BFS queue. BST/Red-Black Tree/AVL Tree subclasses override to O(log N).
403
410
  *
404
411
  * @param keyNodeOrEntry - The key, node, or entry to set or update.
405
412
  * @param [value] - The value, if providing just a key.
@@ -431,6 +438,13 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
431
438
 
432
439
 
433
440
 
441
+
442
+
443
+
444
+
445
+
446
+
447
+
434
448
 
435
449
 
436
450
 
@@ -495,6 +509,13 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
495
509
 
496
510
 
497
511
 
512
+
513
+
514
+
515
+
516
+
517
+
518
+
498
519
 
499
520
 
500
521
 
@@ -535,6 +556,13 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
535
556
 
536
557
 
537
558
 
559
+
560
+
561
+
562
+
563
+
564
+
565
+
538
566
 
539
567
 
540
568
 
@@ -580,6 +608,13 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
580
608
 
581
609
 
582
610
 
611
+
612
+
613
+
614
+
615
+
616
+
617
+
583
618
 
584
619
 
585
620
 
@@ -597,19 +632,27 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
597
632
  */
598
633
  merge(anotherTree: BinaryTree<K, V, R>): void;
599
634
  /**
600
- * Clears the tree and refills it with new items.
601
- * @remarks Time O(N) (for `clear`) + O(N * M) (for `setMany`) = O(N * M). Space O(M) (from `setMany`).
635
+ * Deletes a node from the tree (internal, returns balancing metadata).
636
+ * @remarks Time O(N) O(N) to find the node + O(H) for predecessor swap. Space O(1). BST/Red-Black Tree/AVL Tree subclasses override to O(log N).
637
+ * @internal Used by AVL/BST subclasses that need balancing metadata after deletion.
602
638
  *
603
- * @param keysNodesEntriesOrRaws - An iterable of items to set.
604
- * @param [values] - An optional parallel iterable of values.
639
+ * @param keyNodeEntryRawOrPredicate - The node to delete.
640
+ * @returns An array containing deletion results with balancing metadata.
605
641
  */
606
- refill(keysNodesEntriesOrRaws: Iterable<K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined | R>, values?: Iterable<V | undefined>): void;
642
+ protected _deleteInternal(keyNodeEntryRawOrPredicate: BTNRep<K, V, BinaryTreeNode<K, V>> | NodePredicate<BinaryTreeNode<K, V> | null>): BinaryTreeDeleteResult<BinaryTreeNode<K, V>>[];
607
643
  /**
608
644
  * Deletes a node from the tree.
609
- * @remarks Time O(log N), For BST, Red-Black Tree, and AVL Tree subclasses, the worst-case time is O(log N). This implementation finds the node, and if it has two children, swaps it with the rightmost node of its left subtree (in-order predecessor) before deleting. Time O(N) in the worst case. O(N) to find the node (`getNode`) and O(H) (which is O(N) worst-case) to find the rightmost node. Space O(1) (if `getNode` is iterative, which it is).
645
+ * @remarks Time O(N) O(N) to find the node + O(H) for predecessor swap. Space O(1). BST/Red-Black Tree/AVL Tree subclasses override to O(log N).
610
646
  *
611
647
  * @param keyNodeEntryRawOrPredicate - The node to delete.
612
- * @returns An array containing deletion results (for compatibility with self-balancing trees).
648
+ * @returns True if the node was found and deleted, false otherwise.
649
+
650
+
651
+
652
+
653
+
654
+
655
+
613
656
 
614
657
 
615
658
 
@@ -652,7 +695,7 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
652
695
  * console.log(tree.has(3)); // false;
653
696
  * console.log(tree.size); // 4;
654
697
  */
655
- delete(keyNodeEntryRawOrPredicate: BTNRep<K, V, BinaryTreeNode<K, V>> | NodePredicate<BinaryTreeNode<K, V> | null>): BinaryTreeDeleteResult<BinaryTreeNode<K, V>>[];
698
+ delete(keyNodeEntryRawOrPredicate: BTNRep<K, V, BinaryTreeNode<K, V>> | NodePredicate<BinaryTreeNode<K, V> | null>): boolean;
656
699
  /**
657
700
  * Search by predicate
658
701
 
@@ -673,6 +716,13 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
673
716
 
674
717
 
675
718
 
719
+
720
+
721
+
722
+
723
+
724
+
725
+
676
726
 
677
727
 
678
728
 
@@ -722,6 +772,13 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
722
772
 
723
773
 
724
774
 
775
+
776
+
777
+
778
+
779
+
780
+
781
+
725
782
 
726
783
 
727
784
 
@@ -739,7 +796,7 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
739
796
  getNodes(keyNodeEntryOrPredicate: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined | NodePredicate<BinaryTreeNode<K, V>>, onlyOne?: boolean, startNode?: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, iterationType?: IterationType): BinaryTreeNode<K, V>[];
740
797
  /**
741
798
  * Gets the first node matching a predicate.
742
- * @remarks Time O(log N), For BST, Red-Black Tree, and AVL Tree subclasses, the worst-case time is O(log N). Time O(N) in the worst case (via `search`). Space O(H) or O(N) (via `search`).
799
+ * @remarks Time O(N) via `search`. Space O(H) or O(N). BST/Red-Black Tree/AVL Tree subclasses override to O(log N) for key lookups.
743
800
  *
744
801
  * @param keyNodeEntryOrPredicate - The key, node, entry, or predicate function to search for.
745
802
  * @param [startNode=this._root] - The node to start the search from.
@@ -770,6 +827,13 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
770
827
 
771
828
 
772
829
 
830
+
831
+
832
+
833
+
834
+
835
+
836
+
773
837
 
774
838
 
775
839
 
@@ -786,7 +850,7 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
786
850
  getNode(keyNodeEntryOrPredicate: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined | NodePredicate<BinaryTreeNode<K, V> | null>, startNode?: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, iterationType?: IterationType): BinaryTreeNode<K, V> | null | undefined;
787
851
  /**
788
852
  * Gets the value associated with a key.
789
- * @remarks Time O(log N), For BST, Red-Black Tree, and AVL Tree subclasses, the worst-case time is O(log N). Time O(1) if in Map mode. O(N) if not in Map mode (uses `getNode`). Space O(1) if in Map mode. O(H) or O(N) otherwise.
853
+ * @remarks Time O(1) in Map mode, O(N) otherwise (via `getNode`). Space O(1) in Map mode, O(H) or O(N) otherwise. BST subclasses override non-Map-mode to O(log N).
790
854
  *
791
855
  * @param keyNodeEntryOrPredicate - The key, node, or entry to get the value for.
792
856
  * @param [startNode=this._root] - The node to start searching from (if not in Map mode).
@@ -819,6 +883,13 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
819
883
 
820
884
 
821
885
 
886
+
887
+
888
+
889
+
890
+
891
+
892
+
822
893
 
823
894
 
824
895
 
@@ -836,7 +907,7 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
836
907
  get(keyNodeEntryOrPredicate: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, startNode?: K | BinaryTreeNode<K, V> | [K | null | undefined, V | undefined] | null | undefined, iterationType?: IterationType): V | undefined;
837
908
  /**
838
909
  * Checks if a node matching the predicate exists in the tree.
839
- * @remarks Time O(log N), For BST, Red-Black Tree, and AVL Tree subclasses, the worst-case time is O(log N). Time O(N) in the worst case (via `search`). Space O(H) or O(N) (via `search`).
910
+ * @remarks Time O(N) via `search`. Space O(H) or O(N). BST/Red-Black Tree/AVL Tree subclasses override to O(log N) for key lookups.
840
911
  *
841
912
  * @param [keyNodeEntryOrPredicate] - The key, node, entry, or predicate to check for.
842
913
  * @param [startNode] - The node to start the search from.
@@ -869,6 +940,13 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
869
940
 
870
941
 
871
942
 
943
+
944
+
945
+
946
+
947
+
948
+
949
+
872
950
 
873
951
 
874
952
 
@@ -935,6 +1013,13 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
935
1013
 
936
1014
 
937
1015
 
1016
+
1017
+
1018
+
1019
+
1020
+
1021
+
1022
+
938
1023
 
939
1024
 
940
1025
 
@@ -980,6 +1065,13 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
980
1065
 
981
1066
 
982
1067
 
1068
+
1069
+
1070
+
1071
+
1072
+
1073
+
1074
+
983
1075
 
984
1076
 
985
1077
 
@@ -1033,6 +1125,13 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
1033
1125
 
1034
1126
 
1035
1127
 
1128
+
1129
+
1130
+
1131
+
1132
+
1133
+
1134
+
1036
1135
 
1037
1136
 
1038
1137
 
@@ -1082,6 +1181,13 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
1082
1181
 
1083
1182
 
1084
1183
 
1184
+
1185
+
1186
+
1187
+
1188
+
1189
+
1190
+
1085
1191
 
1086
1192
 
1087
1193
 
@@ -1131,6 +1237,13 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
1131
1237
 
1132
1238
 
1133
1239
 
1240
+
1241
+
1242
+
1243
+
1244
+
1245
+
1246
+
1134
1247
 
1135
1248
 
1136
1249
 
@@ -1205,6 +1318,13 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
1205
1318
 
1206
1319
 
1207
1320
 
1321
+
1322
+
1323
+
1324
+
1325
+
1326
+
1327
+
1208
1328
 
1209
1329
 
1210
1330
 
@@ -1251,6 +1371,13 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
1251
1371
 
1252
1372
 
1253
1373
 
1374
+
1375
+
1376
+
1377
+
1378
+
1379
+
1380
+
1254
1381
 
1255
1382
 
1256
1383
 
@@ -1317,6 +1444,13 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
1317
1444
 
1318
1445
 
1319
1446
 
1447
+
1448
+
1449
+
1450
+
1451
+
1452
+
1453
+
1320
1454
 
1321
1455
 
1322
1456
 
@@ -1359,6 +1493,13 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
1359
1493
 
1360
1494
 
1361
1495
 
1496
+
1497
+
1498
+
1499
+
1500
+
1501
+
1502
+
1362
1503
 
1363
1504
 
1364
1505
 
@@ -1403,6 +1544,13 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
1403
1544
 
1404
1545
 
1405
1546
 
1547
+
1548
+
1549
+
1550
+
1551
+
1552
+
1553
+
1406
1554
 
1407
1555
 
1408
1556
 
@@ -1449,6 +1597,13 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
1449
1597
 
1450
1598
 
1451
1599
 
1600
+
1601
+
1602
+
1603
+
1604
+
1605
+
1606
+
1452
1607
 
1453
1608
 
1454
1609
 
@@ -1497,6 +1652,13 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
1497
1652
 
1498
1653
 
1499
1654
 
1655
+
1656
+
1657
+
1658
+
1659
+
1660
+
1661
+
1500
1662
 
1501
1663
 
1502
1664
 
@@ -1548,6 +1710,13 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
1548
1710
 
1549
1711
 
1550
1712
 
1713
+
1714
+
1715
+
1716
+
1717
+
1718
+
1719
+
1551
1720
 
1552
1721
 
1553
1722
 
@@ -1603,6 +1772,13 @@ export declare class BinaryTree<K = any, V = any, R = any> extends IterableEntry
1603
1772
 
1604
1773
 
1605
1774
 
1775
+
1776
+
1777
+
1778
+
1779
+
1780
+
1781
+
1606
1782
 
1607
1783
 
1608
1784
 
@@ -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';
@@ -366,6 +366,20 @@ export declare class BST<K = any, V = any, R = any> extends BinaryTree<K, V, R>
366
366
 
367
367
 
368
368
 
369
+
370
+
371
+
372
+
373
+
374
+
375
+
376
+
377
+
378
+
379
+
380
+
381
+
382
+
369
383
 
370
384
 
371
385
 
@@ -438,6 +452,20 @@ export declare class BST<K = any, V = any, R = any> extends BinaryTree<K, V, R>
438
452
 
439
453
 
440
454
 
455
+
456
+
457
+
458
+
459
+
460
+
461
+
462
+
463
+
464
+
465
+
466
+
467
+
468
+
441
469
 
442
470
 
443
471
 
@@ -513,6 +541,20 @@ export declare class BST<K = any, V = any, R = any> extends BinaryTree<K, V, R>
513
541
 
514
542
 
515
543
 
544
+
545
+
546
+
547
+
548
+
549
+
550
+
551
+
552
+
553
+
554
+
555
+
556
+
557
+
516
558
 
517
559
 
518
560
 
@@ -532,7 +574,7 @@ export declare class BST<K = any, V = any, R = any> extends BinaryTree<K, V, R>
532
574
  * // Level-order grouping
533
575
  * const bst = new BST<number>([5, 3, 7, 1, 4]);
534
576
  * const levels = bst.listLevels(node => node.key);
535
- * console.log(levels.length); // > 0;
577
+ * console.log(levels); // toBeInstanceOf;
536
578
  * console.log(levels[0].length); // 1; // root level has 1 node
537
579
  * const allKeys = levels.flat().sort((a, b) => a - b);
538
580
  * console.log(allKeys); // [1, 3, 4, 5, 7];
@@ -599,6 +641,20 @@ export declare class BST<K = any, V = any, R = any> extends BinaryTree<K, V, R>
599
641
 
600
642
 
601
643
 
644
+
645
+
646
+
647
+
648
+
649
+
650
+
651
+
652
+
653
+
654
+
655
+
656
+
657
+
602
658
 
603
659
 
604
660
 
@@ -669,6 +725,20 @@ export declare class BST<K = any, V = any, R = any> extends BinaryTree<K, V, R>
669
725
 
670
726
 
671
727
 
728
+
729
+
730
+
731
+
732
+
733
+
734
+
735
+
736
+
737
+
738
+
739
+
740
+
741
+
672
742
 
673
743
 
674
744
 
@@ -721,6 +791,13 @@ export declare class BST<K = any, V = any, R = any> extends BinaryTree<K, V, R>
721
791
 
722
792
 
723
793
 
794
+
795
+
796
+
797
+
798
+
799
+
800
+
724
801
 
725
802
 
726
803
 
@@ -882,6 +959,27 @@ export declare class BST<K = any, V = any, R = any> extends BinaryTree<K, V, R>
882
959
 
883
960
 
884
961
 
962
+
963
+
964
+
965
+
966
+
967
+
968
+
969
+
970
+
971
+
972
+
973
+
974
+
975
+
976
+
977
+
978
+
979
+
980
+
981
+
982
+
885
983
 
886
984
 
887
985
 
@@ -966,6 +1064,20 @@ export declare class BST<K = any, V = any, R = any> extends BinaryTree<K, V, R>
966
1064
 
967
1065
 
968
1066
 
1067
+
1068
+
1069
+
1070
+
1071
+
1072
+
1073
+
1074
+
1075
+
1076
+
1077
+
1078
+
1079
+
1080
+
969
1081
 
970
1082
 
971
1083
 
@@ -1021,6 +1133,13 @@ export declare class BST<K = any, V = any, R = any> extends BinaryTree<K, V, R>
1021
1133
 
1022
1134
 
1023
1135
 
1136
+
1137
+
1138
+
1139
+
1140
+
1141
+
1142
+
1024
1143
 
1025
1144
 
1026
1145
 
@@ -1075,6 +1194,13 @@ export declare class BST<K = any, V = any, R = any> extends BinaryTree<K, V, R>
1075
1194
 
1076
1195
 
1077
1196
 
1197
+
1198
+
1199
+
1200
+
1201
+
1202
+
1203
+
1078
1204
 
1079
1205
 
1080
1206
 
@@ -1128,6 +1254,13 @@ export declare class BST<K = any, V = any, R = any> extends BinaryTree<K, V, R>
1128
1254
 
1129
1255
 
1130
1256
 
1257
+
1258
+
1259
+
1260
+
1261
+
1262
+
1263
+
1131
1264
 
1132
1265
 
1133
1266
 
@@ -1182,6 +1315,13 @@ export declare class BST<K = any, V = any, R = any> extends BinaryTree<K, V, R>
1182
1315
 
1183
1316
 
1184
1317
 
1318
+
1319
+
1320
+
1321
+
1322
+
1323
+
1324
+
1185
1325
 
1186
1326
 
1187
1327
 
@@ -1236,6 +1376,13 @@ export declare class BST<K = any, V = any, R = any> extends BinaryTree<K, V, R>
1236
1376
 
1237
1377
 
1238
1378
 
1379
+
1380
+
1381
+
1382
+
1383
+
1384
+
1385
+
1239
1386
 
1240
1387
 
1241
1388
 
@@ -1285,6 +1432,13 @@ export declare class BST<K = any, V = any, R = any> extends BinaryTree<K, V, R>
1285
1432
 
1286
1433
 
1287
1434
 
1435
+
1436
+
1437
+
1438
+
1439
+
1440
+
1441
+
1288
1442
 
1289
1443
 
1290
1444
 
@@ -1363,6 +1517,20 @@ export declare class BST<K = any, V = any, R = any> extends BinaryTree<K, V, R>
1363
1517
 
1364
1518
 
1365
1519
 
1520
+
1521
+
1522
+
1523
+
1524
+
1525
+
1526
+
1527
+
1528
+
1529
+
1530
+
1531
+
1532
+
1533
+
1366
1534
 
1367
1535
 
1368
1536
 
@@ -1421,7 +1589,7 @@ export declare class BST<K = any, V = any, R = any> extends BinaryTree<K, V, R>
1421
1589
  * - Value: true if the deletion succeeded, false if it failed (e.g., key not found during deletion phase).
1422
1590
  * - If no nodes match the search criteria, the returned map is empty.
1423
1591
  */
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>>[];
1592
+ 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
1593
  /**
1426
1594
  * (Protected) Creates the default comparator function for keys that don't have a custom comparator.
1427
1595
  * @remarks Time O(1) Space O(1)