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.
- package/.husky/pre-commit +3 -0
- package/CHANGELOG.md +3 -1
- package/MIGRATION.md +217 -0
- package/README.md +80 -8
- package/README_CN.md +569 -143
- package/SPECIFICATION.md +44 -14
- package/SPECIFICATION.zh-CN.md +44 -14
- package/dist/cjs/binary-tree.cjs +5841 -1678
- package/dist/cjs/graph.cjs +422 -14
- package/dist/cjs/hash.cjs +95 -7
- package/dist/cjs/heap.cjs +174 -16
- package/dist/cjs/index.cjs +7751 -2449
- package/dist/cjs/linked-list.cjs +443 -2
- package/dist/cjs/matrix.cjs +56 -0
- package/dist/cjs/priority-queue.cjs +172 -14
- package/dist/cjs/queue.cjs +435 -0
- package/dist/cjs/stack.cjs +103 -4
- package/dist/cjs/trie.cjs +106 -0
- package/dist/cjs-legacy/binary-tree.cjs +5933 -1772
- package/dist/cjs-legacy/graph.cjs +422 -14
- package/dist/cjs-legacy/hash.cjs +95 -7
- package/dist/cjs-legacy/heap.cjs +174 -16
- package/dist/cjs-legacy/index.cjs +8154 -2854
- package/dist/cjs-legacy/linked-list.cjs +443 -2
- package/dist/cjs-legacy/matrix.cjs +56 -0
- package/dist/cjs-legacy/priority-queue.cjs +172 -14
- package/dist/cjs-legacy/queue.cjs +435 -0
- package/dist/cjs-legacy/stack.cjs +103 -4
- package/dist/cjs-legacy/trie.cjs +106 -0
- package/dist/esm/binary-tree.mjs +5841 -1678
- package/dist/esm/graph.mjs +422 -14
- package/dist/esm/hash.mjs +95 -7
- package/dist/esm/heap.mjs +174 -16
- package/dist/esm/index.mjs +7751 -2449
- package/dist/esm/linked-list.mjs +443 -2
- package/dist/esm/matrix.mjs +56 -0
- package/dist/esm/priority-queue.mjs +172 -14
- package/dist/esm/queue.mjs +435 -0
- package/dist/esm/stack.mjs +103 -4
- package/dist/esm/trie.mjs +106 -0
- package/dist/esm-legacy/binary-tree.mjs +5933 -1772
- package/dist/esm-legacy/graph.mjs +422 -14
- package/dist/esm-legacy/hash.mjs +95 -7
- package/dist/esm-legacy/heap.mjs +174 -16
- package/dist/esm-legacy/index.mjs +8154 -2854
- package/dist/esm-legacy/linked-list.mjs +443 -2
- package/dist/esm-legacy/matrix.mjs +56 -0
- package/dist/esm-legacy/priority-queue.mjs +172 -14
- package/dist/esm-legacy/queue.mjs +435 -0
- package/dist/esm-legacy/stack.mjs +103 -4
- package/dist/esm-legacy/trie.mjs +106 -0
- package/dist/types/data-structures/base/iterable-element-base.d.ts +17 -0
- package/dist/types/data-structures/base/linear-base.d.ts +6 -0
- package/dist/types/data-structures/binary-tree/avl-tree.d.ts +86 -2
- package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +98 -0
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +191 -15
- package/dist/types/data-structures/binary-tree/bst.d.ts +171 -3
- package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +136 -8
- package/dist/types/data-structures/binary-tree/segment-tree.d.ts +42 -0
- package/dist/types/data-structures/binary-tree/tree-map.d.ts +1061 -167
- package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +1232 -355
- package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +916 -194
- package/dist/types/data-structures/binary-tree/tree-set.d.ts +1078 -141
- package/dist/types/data-structures/graph/directed-graph.d.ts +70 -0
- package/dist/types/data-structures/graph/undirected-graph.d.ts +63 -0
- package/dist/types/data-structures/hash/hash-map.d.ts +84 -6
- package/dist/types/data-structures/heap/heap.d.ts +140 -12
- package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +150 -2
- package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +106 -1
- package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +126 -0
- package/dist/types/data-structures/matrix/matrix.d.ts +56 -0
- package/dist/types/data-structures/queue/deque.d.ts +171 -0
- package/dist/types/data-structures/queue/queue.d.ts +97 -0
- package/dist/types/data-structures/stack/stack.d.ts +72 -2
- package/dist/types/data-structures/trie/trie.d.ts +84 -0
- package/dist/types/interfaces/binary-tree.d.ts +2 -3
- package/dist/umd/data-structure-typed.js +7784 -2484
- package/dist/umd/data-structure-typed.min.js +4 -4
- package/docs-site-docusaurus/docs/api/classes/AVLTree.md +188 -200
- package/docs-site-docusaurus/docs/api/classes/AVLTreeNode.md +11 -11
- package/docs-site-docusaurus/docs/api/classes/AbstractGraph.md +62 -62
- package/docs-site-docusaurus/docs/api/classes/BST.md +183 -195
- package/docs-site-docusaurus/docs/api/classes/BSTNode.md +13 -13
- package/docs-site-docusaurus/docs/api/classes/BinaryIndexedTree.md +15 -15
- package/docs-site-docusaurus/docs/api/classes/BinaryTree.md +143 -155
- package/docs-site-docusaurus/docs/api/classes/BinaryTreeNode.md +13 -13
- package/docs-site-docusaurus/docs/api/classes/Deque.md +99 -85
- package/docs-site-docusaurus/docs/api/classes/DirectedGraph.md +73 -73
- package/docs-site-docusaurus/docs/api/classes/DoublyLinkedList.md +100 -70
- package/docs-site-docusaurus/docs/api/classes/DoublyLinkedListNode.md +8 -8
- package/docs-site-docusaurus/docs/api/classes/FibonacciHeap.md +12 -12
- package/docs-site-docusaurus/docs/api/classes/FibonacciHeapNode.md +1 -1
- package/docs-site-docusaurus/docs/api/classes/HashMap.md +38 -38
- package/docs-site-docusaurus/docs/api/classes/Heap.md +96 -85
- package/docs-site-docusaurus/docs/api/classes/IterableElementBase.md +25 -25
- package/docs-site-docusaurus/docs/api/classes/IterableEntryBase.md +23 -23
- package/docs-site-docusaurus/docs/api/classes/LinearBase.md +48 -48
- package/docs-site-docusaurus/docs/api/classes/LinearLinkedBase.md +52 -52
- package/docs-site-docusaurus/docs/api/classes/LinkedHashMap.md +46 -42
- package/docs-site-docusaurus/docs/api/classes/LinkedListNode.md +6 -6
- package/docs-site-docusaurus/docs/api/classes/LinkedListQueue.md +74 -74
- package/docs-site-docusaurus/docs/api/classes/MapGraph.md +73 -73
- package/docs-site-docusaurus/docs/api/classes/Matrix.md +31 -31
- package/docs-site-docusaurus/docs/api/classes/MaxHeap.md +104 -89
- package/docs-site-docusaurus/docs/api/classes/MaxPriorityQueue.md +104 -89
- package/docs-site-docusaurus/docs/api/classes/MinHeap.md +104 -89
- package/docs-site-docusaurus/docs/api/classes/MinPriorityQueue.md +104 -89
- package/docs-site-docusaurus/docs/api/classes/Navigator.md +5 -5
- package/docs-site-docusaurus/docs/api/classes/PriorityQueue.md +103 -88
- package/docs-site-docusaurus/docs/api/classes/Queue.md +111 -59
- package/docs-site-docusaurus/docs/api/classes/RedBlackTree.md +200 -212
- package/docs-site-docusaurus/docs/api/classes/SegmentTree.md +10 -10
- package/docs-site-docusaurus/docs/api/classes/SinglyLinkedList.md +75 -75
- package/docs-site-docusaurus/docs/api/classes/SinglyLinkedListNode.md +6 -6
- package/docs-site-docusaurus/docs/api/classes/SkipList.md +37 -37
- package/docs-site-docusaurus/docs/api/classes/Stack.md +42 -42
- package/docs-site-docusaurus/docs/api/classes/TreeMap.md +107 -36
- package/docs-site-docusaurus/docs/api/classes/TreeMultiMap.md +43 -43
- package/docs-site-docusaurus/docs/api/classes/TreeSet.md +106 -35
- package/docs-site-docusaurus/docs/api/classes/Trie.md +43 -43
- package/docs-site-docusaurus/docs/api/classes/TrieNode.md +8 -8
- package/docs-site-docusaurus/docs/api/classes/UndirectedGraph.md +72 -72
- package/docs-site-docusaurus/docs/guide/architecture.md +75 -7
- package/docs-site-docusaurus/docs/guide/concepts.md +53 -34
- package/docs-site-docusaurus/docs/guide/faq.md +53 -0
- package/docs-site-docusaurus/docs/guide/guides.md +8 -9
- package/docs-site-docusaurus/docs/guide/integrations.md +74 -177
- package/docs-site-docusaurus/docs/guide/overview.md +131 -17
- package/docs-site-docusaurus/src/pages/index.tsx +4 -0
- package/docs-site-docusaurus/typedoc.json +1 -0
- package/jest.integration.config.js +1 -2
- package/package.json +10 -7
- package/src/data-structures/base/iterable-element-base.ts +32 -0
- package/src/data-structures/base/linear-base.ts +11 -0
- package/src/data-structures/binary-tree/avl-tree.ts +88 -5
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +98 -0
- package/src/data-structures/binary-tree/binary-tree.ts +242 -81
- package/src/data-structures/binary-tree/bst.ts +173 -7
- package/src/data-structures/binary-tree/red-black-tree.ts +139 -15
- package/src/data-structures/binary-tree/segment-tree.ts +42 -0
- package/src/data-structures/binary-tree/tree-map.ts +948 -36
- package/src/data-structures/binary-tree/tree-multi-map.ts +893 -13
- package/src/data-structures/binary-tree/tree-multi-set.ts +761 -33
- package/src/data-structures/binary-tree/tree-set.ts +1260 -251
- package/src/data-structures/graph/directed-graph.ts +71 -1
- package/src/data-structures/graph/undirected-graph.ts +64 -1
- package/src/data-structures/hash/hash-map.ts +100 -12
- package/src/data-structures/heap/heap.ts +149 -19
- package/src/data-structures/linked-list/doubly-linked-list.ts +178 -2
- package/src/data-structures/linked-list/singly-linked-list.ts +106 -1
- package/src/data-structures/linked-list/skip-linked-list.ts +126 -0
- package/src/data-structures/matrix/matrix.ts +56 -0
- package/src/data-structures/queue/deque.ts +187 -0
- package/src/data-structures/queue/queue.ts +109 -0
- package/src/data-structures/stack/stack.ts +75 -5
- package/src/data-structures/trie/trie.ts +84 -0
- package/src/interfaces/binary-tree.ts +1 -9
- package/.vitepress/cache/deps_temp_51f5f1b0/chunk-7OIKW5WK.js +0 -12984
- package/.vitepress/cache/deps_temp_51f5f1b0/package.json +0 -3
- package/.vitepress/cache/deps_temp_51f5f1b0/vitepress___@vue_devtools-api.js +0 -4505
- package/.vitepress/cache/deps_temp_51f5f1b0/vitepress___@vueuse_core.js +0 -9731
- package/.vitepress/cache/deps_temp_51f5f1b0/vue.js +0 -347
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
# Class: AVLTree\<K, V, R\>
|
|
8
8
|
|
|
9
|
-
Defined in: [data-structures/binary-tree/avl-tree.ts:
|
|
9
|
+
Defined in: [data-structures/binary-tree/avl-tree.ts:311](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/avl-tree.ts#L311)
|
|
10
10
|
|
|
11
11
|
Represents a self-balancing AVL (Adelson-Velsky and Landis) Tree.
|
|
12
12
|
This tree extends BST and performs rotations on set/delete to maintain balance.
|
|
@@ -182,7 +182,7 @@ The type of the raw data object (if using `toEntryFn`).
|
|
|
182
182
|
new AVLTree<K, V, R>(keysNodesEntriesOrRaws?, options?): AVLTree<K, V, R>;
|
|
183
183
|
```
|
|
184
184
|
|
|
185
|
-
Defined in: [data-structures/binary-tree/avl-tree.ts:
|
|
185
|
+
Defined in: [data-structures/binary-tree/avl-tree.ts:319](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/avl-tree.ts#L319)
|
|
186
186
|
|
|
187
187
|
Creates an instance of AVLTree.
|
|
188
188
|
|
|
@@ -228,7 +228,7 @@ Time O(N log N) (from `setMany` with balanced set). Space O(N).
|
|
|
228
228
|
get comparator(): Comparator<K>;
|
|
229
229
|
```
|
|
230
230
|
|
|
231
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
231
|
+
Defined in: [data-structures/binary-tree/bst.ts:384](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L384)
|
|
232
232
|
|
|
233
233
|
Gets the comparator function used by the tree.
|
|
234
234
|
|
|
@@ -256,7 +256,7 @@ The comparator function.
|
|
|
256
256
|
get isDuplicate(): boolean;
|
|
257
257
|
```
|
|
258
258
|
|
|
259
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:322](https://github.com/zrwusa/data-structure-typed/blob/
|
|
259
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:322](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L322)
|
|
260
260
|
|
|
261
261
|
Gets whether the tree allows duplicate keys.
|
|
262
262
|
|
|
@@ -290,7 +290,7 @@ IBinaryTree.isDuplicate
|
|
|
290
290
|
get isMapMode(): boolean;
|
|
291
291
|
```
|
|
292
292
|
|
|
293
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:310](https://github.com/zrwusa/data-structure-typed/blob/
|
|
293
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:310](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L310)
|
|
294
294
|
|
|
295
295
|
Gets whether the tree is in Map mode.
|
|
296
296
|
|
|
@@ -324,7 +324,7 @@ IBinaryTree.isMapMode
|
|
|
324
324
|
get NIL(): BinaryTreeNode<K, V>;
|
|
325
325
|
```
|
|
326
326
|
|
|
327
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:373](https://github.com/zrwusa/data-structure-typed/blob/
|
|
327
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:373](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L373)
|
|
328
328
|
|
|
329
329
|
Gets the sentinel NIL node (used in self-balancing trees like Red-Black Tree).
|
|
330
330
|
|
|
@@ -358,7 +358,7 @@ IBinaryTree.NIL
|
|
|
358
358
|
get root(): OptNode<BSTNode<K, V>>;
|
|
359
359
|
```
|
|
360
360
|
|
|
361
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
361
|
+
Defined in: [data-structures/binary-tree/bst.ts:367](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L367)
|
|
362
362
|
|
|
363
363
|
Gets the root node of the tree.
|
|
364
364
|
|
|
@@ -392,7 +392,7 @@ IBinaryTree.root
|
|
|
392
392
|
get size(): number;
|
|
393
393
|
```
|
|
394
394
|
|
|
395
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:361](https://github.com/zrwusa/data-structure-typed/blob/
|
|
395
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:361](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L361)
|
|
396
396
|
|
|
397
397
|
Gets the number of nodes in the tree.
|
|
398
398
|
|
|
@@ -426,7 +426,7 @@ IBinaryTree.size
|
|
|
426
426
|
get store(): Map<K, BinaryTreeNode<K, V>>;
|
|
427
427
|
```
|
|
428
428
|
|
|
429
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:337](https://github.com/zrwusa/data-structure-typed/blob/
|
|
429
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:337](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L337)
|
|
430
430
|
|
|
431
431
|
Gets the external value store (used in Map mode).
|
|
432
432
|
|
|
@@ -460,7 +460,7 @@ IBinaryTree.store
|
|
|
460
460
|
get toEntryFn(): ToEntryFn<K, V, R> | undefined;
|
|
461
461
|
```
|
|
462
462
|
|
|
463
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:385](https://github.com/zrwusa/data-structure-typed/blob/
|
|
463
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:385](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L385)
|
|
464
464
|
|
|
465
465
|
Gets the function used to convert raw data objects (R) into [key, value] entries.
|
|
466
466
|
|
|
@@ -492,7 +492,7 @@ IBinaryTree.toEntryFn
|
|
|
492
492
|
iterator: IterableIterator<[K, V | undefined]>;
|
|
493
493
|
```
|
|
494
494
|
|
|
495
|
-
Defined in: [data-structures/base/iterable-entry-base.ts:22](https://github.com/zrwusa/data-structure-typed/blob/
|
|
495
|
+
Defined in: [data-structures/base/iterable-entry-base.ts:22](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-entry-base.ts#L22)
|
|
496
496
|
|
|
497
497
|
Default iterator yielding `[key, value]` entries.
|
|
498
498
|
|
|
@@ -530,7 +530,7 @@ IBinaryTree.[iterator]
|
|
|
530
530
|
add(keyNodeOrEntry): boolean;
|
|
531
531
|
```
|
|
532
532
|
|
|
533
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
533
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:612](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L612)
|
|
534
534
|
|
|
535
535
|
Adds a new node to the tree.
|
|
536
536
|
|
|
@@ -556,7 +556,7 @@ True if the addition was successful, false otherwise.
|
|
|
556
556
|
|
|
557
557
|
#### Remarks
|
|
558
558
|
|
|
559
|
-
Time O(
|
|
559
|
+
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).
|
|
560
560
|
|
|
561
561
|
#### Example
|
|
562
562
|
|
|
@@ -588,7 +588,7 @@ IBinaryTree.add
|
|
|
588
588
|
addMany(keysNodesEntriesOrRaws): boolean[];
|
|
589
589
|
```
|
|
590
590
|
|
|
591
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
591
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:793](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L793)
|
|
592
592
|
|
|
593
593
|
Adds multiple items to the tree.
|
|
594
594
|
|
|
@@ -669,7 +669,7 @@ The traversal method.
|
|
|
669
669
|
bfs(): (K | undefined)[];
|
|
670
670
|
```
|
|
671
671
|
|
|
672
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
672
|
+
Defined in: [data-structures/binary-tree/bst.ts:635](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L635)
|
|
673
673
|
|
|
674
674
|
BinaryTree level-order traversal
|
|
675
675
|
|
|
@@ -707,7 +707,7 @@ bfs<C>(
|
|
|
707
707
|
iterationType?): ReturnType<C>[];
|
|
708
708
|
```
|
|
709
709
|
|
|
710
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
710
|
+
Defined in: [data-structures/binary-tree/bst.ts:636](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L636)
|
|
711
711
|
|
|
712
712
|
BinaryTree level-order traversal
|
|
713
713
|
|
|
@@ -769,7 +769,7 @@ IBinaryTree.bfs
|
|
|
769
769
|
ceiling(keyNodeEntryOrPredicate): K | undefined;
|
|
770
770
|
```
|
|
771
771
|
|
|
772
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
772
|
+
Defined in: [data-structures/binary-tree/bst.ts:1849](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L1849)
|
|
773
773
|
|
|
774
774
|
Returns the first key with a value >= target.
|
|
775
775
|
Equivalent to Java TreeMap.ceiling.
|
|
@@ -816,7 +816,7 @@ ceiling<C>(
|
|
|
816
816
|
iterationType?): ReturnType<C>;
|
|
817
817
|
```
|
|
818
818
|
|
|
819
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
819
|
+
Defined in: [data-structures/binary-tree/bst.ts:1864](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L1864)
|
|
820
820
|
|
|
821
821
|
Returns the first node with a key >= target and applies callback.
|
|
822
822
|
Time Complexity: O(log n) average, O(h) worst case.
|
|
@@ -863,7 +863,7 @@ Space Complexity: O(h) for recursion, O(1) for iteration.
|
|
|
863
863
|
clear(): void;
|
|
864
864
|
```
|
|
865
865
|
|
|
866
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
866
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1543](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L1543)
|
|
867
867
|
|
|
868
868
|
Clears the tree of all nodes and values.
|
|
869
869
|
|
|
@@ -904,7 +904,7 @@ IBinaryTree.clear
|
|
|
904
904
|
clone(): this;
|
|
905
905
|
```
|
|
906
906
|
|
|
907
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
907
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:2771](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L2771)
|
|
908
908
|
|
|
909
909
|
Clones the tree.
|
|
910
910
|
|
|
@@ -948,7 +948,7 @@ IBinaryTree.clone
|
|
|
948
948
|
createNode(key, value?): AVLTreeNode<K, V>;
|
|
949
949
|
```
|
|
950
950
|
|
|
951
|
-
Defined in: [data-structures/binary-tree/avl-tree.ts:
|
|
951
|
+
Defined in: [data-structures/binary-tree/avl-tree.ts:338](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/avl-tree.ts#L338)
|
|
952
952
|
|
|
953
953
|
(Protected) Creates a new AVL tree node.
|
|
954
954
|
|
|
@@ -994,7 +994,7 @@ IBinaryTree.createNode
|
|
|
994
994
|
createTree(options?): this;
|
|
995
995
|
```
|
|
996
996
|
|
|
997
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:408](https://github.com/zrwusa/data-structure-typed/blob/
|
|
997
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:408](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L408)
|
|
998
998
|
|
|
999
999
|
Creates a new, empty tree of the same type and configuration.
|
|
1000
1000
|
|
|
@@ -1031,10 +1031,10 @@ IBinaryTree.createTree
|
|
|
1031
1031
|
### delete()
|
|
1032
1032
|
|
|
1033
1033
|
```ts
|
|
1034
|
-
delete(keyNodeOrEntry):
|
|
1034
|
+
delete(keyNodeOrEntry): boolean;
|
|
1035
1035
|
```
|
|
1036
1036
|
|
|
1037
|
-
Defined in: [data-structures/binary-tree/avl-tree.ts:
|
|
1037
|
+
Defined in: [data-structures/binary-tree/avl-tree.ts:658](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/avl-tree.ts#L658)
|
|
1038
1038
|
|
|
1039
1039
|
Deletes a node from the AVL tree and re-balances the tree.
|
|
1040
1040
|
|
|
@@ -1052,7 +1052,7 @@ The node to delete.
|
|
|
1052
1052
|
|
|
1053
1053
|
#### Returns
|
|
1054
1054
|
|
|
1055
|
-
`
|
|
1055
|
+
`boolean`
|
|
1056
1056
|
|
|
1057
1057
|
An array containing deletion results.
|
|
1058
1058
|
|
|
@@ -1091,10 +1091,10 @@ deleteWhere(
|
|
|
1091
1091
|
keyNodeEntryOrPredicate,
|
|
1092
1092
|
onlyOne?,
|
|
1093
1093
|
startNode?,
|
|
1094
|
-
iterationType?):
|
|
1094
|
+
iterationType?): boolean;
|
|
1095
1095
|
```
|
|
1096
1096
|
|
|
1097
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
1097
|
+
Defined in: [data-structures/binary-tree/bst.ts:2692](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L2692)
|
|
1098
1098
|
|
|
1099
1099
|
Deletes nodes that match a key, node, entry, predicate, or range.
|
|
1100
1100
|
|
|
@@ -1149,7 +1149,7 @@ Controls the internal traversal implementation:
|
|
|
1149
1149
|
|
|
1150
1150
|
#### Returns
|
|
1151
1151
|
|
|
1152
|
-
`
|
|
1152
|
+
`boolean`
|
|
1153
1153
|
|
|
1154
1154
|
A Map<K, boolean> containing the deletion results:
|
|
1155
1155
|
- Key: the matched node's key.
|
|
@@ -1205,7 +1205,7 @@ The traversal method.
|
|
|
1205
1205
|
dfs(): (K | undefined)[];
|
|
1206
1206
|
```
|
|
1207
1207
|
|
|
1208
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
1208
|
+
Defined in: [data-structures/binary-tree/bst.ts:525](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L525)
|
|
1209
1209
|
|
|
1210
1210
|
Depth-first search traversal
|
|
1211
1211
|
|
|
@@ -1245,7 +1245,7 @@ dfs<C>(
|
|
|
1245
1245
|
iterationType?): ReturnType<C>[];
|
|
1246
1246
|
```
|
|
1247
1247
|
|
|
1248
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
1248
|
+
Defined in: [data-structures/binary-tree/bst.ts:527](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L527)
|
|
1249
1249
|
|
|
1250
1250
|
Depth-first search traversal
|
|
1251
1251
|
|
|
@@ -1313,7 +1313,7 @@ IBinaryTree.dfs
|
|
|
1313
1313
|
ensureNode(keyNodeOrEntry, iterationType?): OptNode<BSTNode<K, V>>;
|
|
1314
1314
|
```
|
|
1315
1315
|
|
|
1316
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
1316
|
+
Defined in: [data-structures/binary-tree/bst.ts:408](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L408)
|
|
1317
1317
|
|
|
1318
1318
|
Ensures the input is a node. If it's a key or entry, it searches for the node.
|
|
1319
1319
|
|
|
@@ -1357,7 +1357,7 @@ Time O(log N) (height of the tree), O(N) worst-case.
|
|
|
1357
1357
|
entries(): IterableIterator<[K, V | undefined]>;
|
|
1358
1358
|
```
|
|
1359
1359
|
|
|
1360
|
-
Defined in: [data-structures/base/iterable-entry-base.ts:31](https://github.com/zrwusa/data-structure-typed/blob/
|
|
1360
|
+
Defined in: [data-structures/base/iterable-entry-base.ts:31](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-entry-base.ts#L31)
|
|
1361
1361
|
|
|
1362
1362
|
Iterate over `[key, value]` pairs (may yield `undefined` values).
|
|
1363
1363
|
|
|
@@ -1389,7 +1389,7 @@ IBinaryTree.entries
|
|
|
1389
1389
|
every(predicate, thisArg?): boolean;
|
|
1390
1390
|
```
|
|
1391
1391
|
|
|
1392
|
-
Defined in: [data-structures/base/iterable-entry-base.ts:66](https://github.com/zrwusa/data-structure-typed/blob/
|
|
1392
|
+
Defined in: [data-structures/base/iterable-entry-base.ts:66](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-entry-base.ts#L66)
|
|
1393
1393
|
|
|
1394
1394
|
Test whether all entries satisfy the predicate.
|
|
1395
1395
|
|
|
@@ -1435,7 +1435,7 @@ IBinaryTree.every
|
|
|
1435
1435
|
filter(predicate, thisArg?): this;
|
|
1436
1436
|
```
|
|
1437
1437
|
|
|
1438
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
1438
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:2827](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L2827)
|
|
1439
1439
|
|
|
1440
1440
|
Creates a new tree containing only the entries that satisfy the predicate.
|
|
1441
1441
|
|
|
@@ -1492,7 +1492,7 @@ IBinaryTree.filter
|
|
|
1492
1492
|
find(callbackfn, thisArg?): [K, V | undefined] | undefined;
|
|
1493
1493
|
```
|
|
1494
1494
|
|
|
1495
|
-
Defined in: [data-structures/base/iterable-entry-base.ts:114](https://github.com/zrwusa/data-structure-typed/blob/
|
|
1495
|
+
Defined in: [data-structures/base/iterable-entry-base.ts:114](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-entry-base.ts#L114)
|
|
1496
1496
|
|
|
1497
1497
|
Find the first entry that matches a predicate.
|
|
1498
1498
|
|
|
@@ -1540,7 +1540,7 @@ IBinaryTree.find
|
|
|
1540
1540
|
floor(keyNodeEntryOrPredicate): K | undefined;
|
|
1541
1541
|
```
|
|
1542
1542
|
|
|
1543
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
1543
|
+
Defined in: [data-structures/binary-tree/bst.ts:2068](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L2068)
|
|
1544
1544
|
|
|
1545
1545
|
Returns the first key with a value <= target.
|
|
1546
1546
|
Equivalent to Java TreeMap.floor.
|
|
@@ -1587,7 +1587,7 @@ floor<C>(
|
|
|
1587
1587
|
iterationType?): ReturnType<C>;
|
|
1588
1588
|
```
|
|
1589
1589
|
|
|
1590
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
1590
|
+
Defined in: [data-structures/binary-tree/bst.ts:2083](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L2083)
|
|
1591
1591
|
|
|
1592
1592
|
Returns the first node with a key <= target and applies callback.
|
|
1593
1593
|
Time Complexity: O(log n) average, O(h) worst case.
|
|
@@ -1634,7 +1634,7 @@ Space Complexity: O(h) for recursion, O(1) for iteration.
|
|
|
1634
1634
|
forEach(callbackfn, thisArg?): void;
|
|
1635
1635
|
```
|
|
1636
1636
|
|
|
1637
|
-
Defined in: [data-structures/base/iterable-entry-base.ts:99](https://github.com/zrwusa/data-structure-typed/blob/
|
|
1637
|
+
Defined in: [data-structures/base/iterable-entry-base.ts:99](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-entry-base.ts#L99)
|
|
1638
1638
|
|
|
1639
1639
|
Visit each entry, left-to-right.
|
|
1640
1640
|
|
|
@@ -1681,7 +1681,7 @@ get(
|
|
|
1681
1681
|
iterationType?): V | undefined;
|
|
1682
1682
|
```
|
|
1683
1683
|
|
|
1684
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
1684
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1375](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L1375)
|
|
1685
1685
|
|
|
1686
1686
|
Gets the value associated with a key.
|
|
1687
1687
|
|
|
@@ -1722,7 +1722,7 @@ The associated value, or undefined.
|
|
|
1722
1722
|
|
|
1723
1723
|
#### Remarks
|
|
1724
1724
|
|
|
1725
|
-
Time O(
|
|
1725
|
+
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).
|
|
1726
1726
|
|
|
1727
1727
|
#### Example
|
|
1728
1728
|
|
|
@@ -1753,7 +1753,7 @@ IBinaryTree.get
|
|
|
1753
1753
|
getByRank(k): K | undefined;
|
|
1754
1754
|
```
|
|
1755
1755
|
|
|
1756
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
1756
|
+
Defined in: [data-structures/binary-tree/bst.ts:1240](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L1240)
|
|
1757
1757
|
|
|
1758
1758
|
Returns the element at the k-th position in tree order (0-indexed).
|
|
1759
1759
|
|
|
@@ -1800,7 +1800,7 @@ getByRank<C>(
|
|
|
1800
1800
|
iterationType?): ReturnType<C> | undefined;
|
|
1801
1801
|
```
|
|
1802
1802
|
|
|
1803
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
1803
|
+
Defined in: [data-structures/binary-tree/bst.ts:1251](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L1251)
|
|
1804
1804
|
|
|
1805
1805
|
Returns the element at the k-th position in tree order and applies a callback.
|
|
1806
1806
|
|
|
@@ -1852,7 +1852,7 @@ Time O(log n), Space O(1) iterative / O(log n) recursive. Requires `enableOrderS
|
|
|
1852
1852
|
getDepth(dist, startNode?): number;
|
|
1853
1853
|
```
|
|
1854
1854
|
|
|
1855
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
1855
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1756](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L1756)
|
|
1856
1856
|
|
|
1857
1857
|
Gets the depth of a node (distance from `startNode`).
|
|
1858
1858
|
|
|
@@ -1916,7 +1916,7 @@ IBinaryTree.getDepth
|
|
|
1916
1916
|
getHeight(startNode?, iterationType?): number;
|
|
1917
1917
|
```
|
|
1918
1918
|
|
|
1919
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
1919
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1824](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L1824)
|
|
1920
1920
|
|
|
1921
1921
|
Gets the maximum height of the tree (longest path from startNode to a leaf).
|
|
1922
1922
|
|
|
@@ -1999,7 +1999,7 @@ The traversal method.
|
|
|
1999
1999
|
getLeftMost(): K | undefined;
|
|
2000
2000
|
```
|
|
2001
2001
|
|
|
2002
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
2002
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1951](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L1951)
|
|
2003
2003
|
|
|
2004
2004
|
##### Returns
|
|
2005
2005
|
|
|
@@ -2024,7 +2024,7 @@ getLeftMost<C>(
|
|
|
2024
2024
|
iterationType?): ReturnType<C>;
|
|
2025
2025
|
```
|
|
2026
2026
|
|
|
2027
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
2027
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1953](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L1953)
|
|
2028
2028
|
|
|
2029
2029
|
##### Type Parameters
|
|
2030
2030
|
|
|
@@ -2071,7 +2071,7 @@ IBinaryTree.getLeftMost
|
|
|
2071
2071
|
getMinHeight(startNode?, iterationType?): number;
|
|
2072
2072
|
```
|
|
2073
2073
|
|
|
2074
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
2074
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1866](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L1866)
|
|
2075
2075
|
|
|
2076
2076
|
Gets the minimum height of the tree (shortest path from startNode to a leaf).
|
|
2077
2077
|
|
|
@@ -2123,7 +2123,7 @@ getNode(
|
|
|
2123
2123
|
iterationType?): OptNode<BSTNode<K, V>>;
|
|
2124
2124
|
```
|
|
2125
2125
|
|
|
2126
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
2126
|
+
Defined in: [data-structures/binary-tree/bst.ts:860](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L860)
|
|
2127
2127
|
|
|
2128
2128
|
Gets the first node matching a predicate.
|
|
2129
2129
|
|
|
@@ -2196,7 +2196,7 @@ getNodes(
|
|
|
2196
2196
|
iterationType?): BinaryTreeNode<K, V>[];
|
|
2197
2197
|
```
|
|
2198
2198
|
|
|
2199
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
2199
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1223](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L1223)
|
|
2200
2200
|
|
|
2201
2201
|
Gets all nodes matching a predicate.
|
|
2202
2202
|
|
|
@@ -2291,7 +2291,7 @@ If true, returns the path from root-to-node.
|
|
|
2291
2291
|
getPathToRoot(beginNode): (K | undefined)[];
|
|
2292
2292
|
```
|
|
2293
2293
|
|
|
2294
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
2294
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1913](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L1913)
|
|
2295
2295
|
|
|
2296
2296
|
##### Parameters
|
|
2297
2297
|
|
|
@@ -2326,7 +2326,7 @@ getPathToRoot<C>(
|
|
|
2326
2326
|
isReverse?): ReturnType<C>[];
|
|
2327
2327
|
```
|
|
2328
2328
|
|
|
2329
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
2329
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1917](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L1917)
|
|
2330
2330
|
|
|
2331
2331
|
##### Type Parameters
|
|
2332
2332
|
|
|
@@ -2374,7 +2374,7 @@ IBinaryTree.getPathToRoot
|
|
|
2374
2374
|
getPredecessor(node): BinaryTreeNode<K, V>;
|
|
2375
2375
|
```
|
|
2376
2376
|
|
|
2377
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
2377
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:2051](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L2051)
|
|
2378
2378
|
|
|
2379
2379
|
Gets the Morris traversal predecessor (rightmost node in the left subtree, or node itself).
|
|
2380
2380
|
|
|
@@ -2410,7 +2410,7 @@ This is primarily a helper for Morris traversal. Time O(H), where H is the heigh
|
|
|
2410
2410
|
getRank(keyNodeEntryOrPredicate): number;
|
|
2411
2411
|
```
|
|
2412
2412
|
|
|
2413
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
2413
|
+
Defined in: [data-structures/binary-tree/bst.ts:1295](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L1295)
|
|
2414
2414
|
|
|
2415
2415
|
Returns the 0-based rank of a key (number of elements that precede it in tree order).
|
|
2416
2416
|
|
|
@@ -2448,7 +2448,7 @@ Tree order is defined by the comparator. When the key is not found, returns the
|
|
|
2448
2448
|
getRank(keyNodeEntryOrPredicate, iterationType): number;
|
|
2449
2449
|
```
|
|
2450
2450
|
|
|
2451
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
2451
|
+
Defined in: [data-structures/binary-tree/bst.ts:1313](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L1313)
|
|
2452
2452
|
|
|
2453
2453
|
Returns the 0-based rank (number of preceding elements in tree order) with explicit iteration type.
|
|
2454
2454
|
|
|
@@ -2517,7 +2517,7 @@ The traversal method.
|
|
|
2517
2517
|
getRightMost(): K | undefined;
|
|
2518
2518
|
```
|
|
2519
2519
|
|
|
2520
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
2520
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1998](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L1998)
|
|
2521
2521
|
|
|
2522
2522
|
##### Returns
|
|
2523
2523
|
|
|
@@ -2542,7 +2542,7 @@ getRightMost<C>(
|
|
|
2542
2542
|
iterationType?): ReturnType<C>;
|
|
2543
2543
|
```
|
|
2544
2544
|
|
|
2545
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
2545
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:2000](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L2000)
|
|
2546
2546
|
|
|
2547
2547
|
##### Type Parameters
|
|
2548
2548
|
|
|
@@ -2589,7 +2589,7 @@ IBinaryTree.getRightMost
|
|
|
2589
2589
|
getSuccessor(x?): BinaryTreeNode<K, V> | null | undefined;
|
|
2590
2590
|
```
|
|
2591
2591
|
|
|
2592
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
2592
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:2072](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L2072)
|
|
2593
2593
|
|
|
2594
2594
|
Gets the in-order successor of a node in a BST.
|
|
2595
2595
|
|
|
@@ -2626,7 +2626,7 @@ has(
|
|
|
2626
2626
|
iterationType?): boolean;
|
|
2627
2627
|
```
|
|
2628
2628
|
|
|
2629
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
2629
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1464](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L1464)
|
|
2630
2630
|
|
|
2631
2631
|
Checks if a node matching the predicate exists in the tree.
|
|
2632
2632
|
|
|
@@ -2667,7 +2667,7 @@ True if a matching node exists, false otherwise.
|
|
|
2667
2667
|
|
|
2668
2668
|
#### Remarks
|
|
2669
2669
|
|
|
2670
|
-
Time O(
|
|
2670
|
+
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.
|
|
2671
2671
|
|
|
2672
2672
|
#### Example
|
|
2673
2673
|
|
|
@@ -2719,7 +2719,7 @@ IBinaryTree.has
|
|
|
2719
2719
|
hasValue(value): boolean;
|
|
2720
2720
|
```
|
|
2721
2721
|
|
|
2722
|
-
Defined in: [data-structures/base/iterable-entry-base.ts:143](https://github.com/zrwusa/data-structure-typed/blob/
|
|
2722
|
+
Defined in: [data-structures/base/iterable-entry-base.ts:143](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-entry-base.ts#L143)
|
|
2723
2723
|
|
|
2724
2724
|
Whether there exists an entry with the given value.
|
|
2725
2725
|
|
|
@@ -2761,7 +2761,7 @@ IBinaryTree.hasValue
|
|
|
2761
2761
|
higher(keyNodeEntryOrPredicate): K | undefined;
|
|
2762
2762
|
```
|
|
2763
2763
|
|
|
2764
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
2764
|
+
Defined in: [data-structures/binary-tree/bst.ts:1958](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L1958)
|
|
2765
2765
|
|
|
2766
2766
|
Returns the first key with a value > target.
|
|
2767
2767
|
Equivalent to Java TreeMap.higher.
|
|
@@ -2807,7 +2807,7 @@ higher<C>(
|
|
|
2807
2807
|
iterationType?): ReturnType<C>;
|
|
2808
2808
|
```
|
|
2809
2809
|
|
|
2810
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
2810
|
+
Defined in: [data-structures/binary-tree/bst.ts:1973](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L1973)
|
|
2811
2811
|
|
|
2812
2812
|
Returns the first node with a key > target and applies callback.
|
|
2813
2813
|
Time Complexity: O(log n) average, O(h) worst case.
|
|
@@ -2854,7 +2854,7 @@ Space Complexity: O(h) for recursion, O(1) for iteration.
|
|
|
2854
2854
|
isAVLBalanced(iterationType?): boolean;
|
|
2855
2855
|
```
|
|
2856
2856
|
|
|
2857
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
2857
|
+
Defined in: [data-structures/binary-tree/bst.ts:2505](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L2505)
|
|
2858
2858
|
|
|
2859
2859
|
Checks if the tree meets the AVL balance condition (height difference <= 1).
|
|
2860
2860
|
|
|
@@ -2898,7 +2898,7 @@ Time O(N), as it must visit every node to compute height. Space O(log N) for rec
|
|
|
2898
2898
|
isBST(startNode?, iterationType?): boolean;
|
|
2899
2899
|
```
|
|
2900
2900
|
|
|
2901
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
2901
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1661](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L1661)
|
|
2902
2902
|
|
|
2903
2903
|
Checks if the tree is a valid Binary Search Tree (BST).
|
|
2904
2904
|
|
|
@@ -2958,7 +2958,7 @@ IBinaryTree.isBST
|
|
|
2958
2958
|
isEmpty(): boolean;
|
|
2959
2959
|
```
|
|
2960
2960
|
|
|
2961
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
2961
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1594](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L1594)
|
|
2962
2962
|
|
|
2963
2963
|
Checks if the tree is empty.
|
|
2964
2964
|
|
|
@@ -2999,7 +2999,7 @@ IBinaryTree.isEmpty
|
|
|
2999
2999
|
isEntry(keyNodeOrEntry): keyNodeOrEntry is BTNEntry<K, V>;
|
|
3000
3000
|
```
|
|
3001
3001
|
|
|
3002
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:545](https://github.com/zrwusa/data-structure-typed/blob/
|
|
3002
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:545](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L545)
|
|
3003
3003
|
|
|
3004
3004
|
Checks if the given item is a [key, value] entry pair.
|
|
3005
3005
|
|
|
@@ -3037,7 +3037,7 @@ Time O(1), Space O(1)
|
|
|
3037
3037
|
isLeaf(keyNodeOrEntry): boolean;
|
|
3038
3038
|
```
|
|
3039
3039
|
|
|
3040
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:531](https://github.com/zrwusa/data-structure-typed/blob/
|
|
3040
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:531](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L531)
|
|
3041
3041
|
|
|
3042
3042
|
Checks if a node is a leaf (has no real children).
|
|
3043
3043
|
|
|
@@ -3075,7 +3075,7 @@ Time O(N) if a key/entry is passed (due to `ensureNode`). O(1) if a node is pass
|
|
|
3075
3075
|
isNIL(keyNodeOrEntry): boolean;
|
|
3076
3076
|
```
|
|
3077
3077
|
|
|
3078
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:500](https://github.com/zrwusa/data-structure-typed/blob/
|
|
3078
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:500](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L500)
|
|
3079
3079
|
|
|
3080
3080
|
Checks if the given item is the sentinel NIL node.
|
|
3081
3081
|
|
|
@@ -3113,7 +3113,7 @@ Time O(1), Space O(1)
|
|
|
3113
3113
|
isNode(keyNodeOrEntry): keyNodeOrEntry is AVLTreeNode<K, V>;
|
|
3114
3114
|
```
|
|
3115
3115
|
|
|
3116
|
-
Defined in: [data-structures/binary-tree/avl-tree.ts:
|
|
3116
|
+
Defined in: [data-structures/binary-tree/avl-tree.ts:349](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/avl-tree.ts#L349)
|
|
3117
3117
|
|
|
3118
3118
|
Checks if the given item is an `AVLTreeNode` instance.
|
|
3119
3119
|
|
|
@@ -3151,7 +3151,7 @@ Time O(1), Space O(1)
|
|
|
3151
3151
|
isPerfectlyBalanced(startNode?): boolean;
|
|
3152
3152
|
```
|
|
3153
3153
|
|
|
3154
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
3154
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1605](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L1605)
|
|
3155
3155
|
|
|
3156
3156
|
Checks if the tree is perfectly balanced.
|
|
3157
3157
|
|
|
@@ -3194,7 +3194,7 @@ IBinaryTree.isPerfectlyBalanced
|
|
|
3194
3194
|
isRange(keyNodeEntryOrPredicate): keyNodeEntryOrPredicate is Range<K>;
|
|
3195
3195
|
```
|
|
3196
3196
|
|
|
3197
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:511](https://github.com/zrwusa/data-structure-typed/blob/
|
|
3197
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:511](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L511)
|
|
3198
3198
|
|
|
3199
3199
|
Checks if the given item is a `Range` object.
|
|
3200
3200
|
|
|
@@ -3234,7 +3234,7 @@ Time O(1), Space O(1)
|
|
|
3234
3234
|
isRaw(keyNodeEntryOrRaw): keyNodeEntryOrRaw is R;
|
|
3235
3235
|
```
|
|
3236
3236
|
|
|
3237
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:460](https://github.com/zrwusa/data-structure-typed/blob/
|
|
3237
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:460](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L460)
|
|
3238
3238
|
|
|
3239
3239
|
Checks if the given item is a raw data object (R) that needs conversion via `toEntryFn`.
|
|
3240
3240
|
|
|
@@ -3273,7 +3273,7 @@ Time O(1), Space O(1)
|
|
|
3273
3273
|
isRealNode(keyNodeOrEntry): keyNodeOrEntry is BinaryTreeNode<K, V>;
|
|
3274
3274
|
```
|
|
3275
3275
|
|
|
3276
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:473](https://github.com/zrwusa/data-structure-typed/blob/
|
|
3276
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:473](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L473)
|
|
3277
3277
|
|
|
3278
3278
|
Checks if the given item is a "real" node (i.e., not null, undefined, or NIL).
|
|
3279
3279
|
|
|
@@ -3311,7 +3311,7 @@ Time O(1), Space O(1)
|
|
|
3311
3311
|
isRealNodeOrNull(keyNodeOrEntry): keyNodeOrEntry is BinaryTreeNode<K, V> | null;
|
|
3312
3312
|
```
|
|
3313
3313
|
|
|
3314
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:487](https://github.com/zrwusa/data-structure-typed/blob/
|
|
3314
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:487](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L487)
|
|
3315
3315
|
|
|
3316
3316
|
Checks if the given item is either a "real" node or null.
|
|
3317
3317
|
|
|
@@ -3349,7 +3349,7 @@ Time O(1), Space O(1)
|
|
|
3349
3349
|
isValidKey(key): key is K;
|
|
3350
3350
|
```
|
|
3351
3351
|
|
|
3352
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
3352
|
+
Defined in: [data-structures/binary-tree/bst.ts:435](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L435)
|
|
3353
3353
|
|
|
3354
3354
|
Checks if the given key is valid (comparable).
|
|
3355
3355
|
|
|
@@ -3383,7 +3383,7 @@ Time O(1)
|
|
|
3383
3383
|
keys(): IterableIterator<K>;
|
|
3384
3384
|
```
|
|
3385
3385
|
|
|
3386
|
-
Defined in: [data-structures/base/iterable-entry-base.ts:42](https://github.com/zrwusa/data-structure-typed/blob/
|
|
3386
|
+
Defined in: [data-structures/base/iterable-entry-base.ts:42](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-entry-base.ts#L42)
|
|
3387
3387
|
|
|
3388
3388
|
Iterate over keys only.
|
|
3389
3389
|
|
|
@@ -3439,7 +3439,7 @@ The traversal method.
|
|
|
3439
3439
|
leaves(): (K | undefined)[];
|
|
3440
3440
|
```
|
|
3441
3441
|
|
|
3442
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
3442
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:2378](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L2378)
|
|
3443
3443
|
|
|
3444
3444
|
Get leaf nodes
|
|
3445
3445
|
|
|
@@ -3477,7 +3477,7 @@ leaves<C>(
|
|
|
3477
3477
|
iterationType?): ReturnType<C>[];
|
|
3478
3478
|
```
|
|
3479
3479
|
|
|
3480
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
3480
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:2380](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L2380)
|
|
3481
3481
|
|
|
3482
3482
|
Get leaf nodes
|
|
3483
3483
|
|
|
@@ -3565,7 +3565,7 @@ The traversal method.
|
|
|
3565
3565
|
lesserOrGreaterTraverse(): (K | undefined)[];
|
|
3566
3566
|
```
|
|
3567
3567
|
|
|
3568
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
3568
|
+
Defined in: [data-structures/binary-tree/bst.ts:2323](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L2323)
|
|
3569
3569
|
|
|
3570
3570
|
##### Returns
|
|
3571
3571
|
|
|
@@ -3585,7 +3585,7 @@ lesserOrGreaterTraverse<C>(
|
|
|
3585
3585
|
iterationType?): ReturnType<C>[];
|
|
3586
3586
|
```
|
|
3587
3587
|
|
|
3588
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
3588
|
+
Defined in: [data-structures/binary-tree/bst.ts:2325](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L2325)
|
|
3589
3589
|
|
|
3590
3590
|
##### Type Parameters
|
|
3591
3591
|
|
|
@@ -3654,7 +3654,7 @@ The traversal method.
|
|
|
3654
3654
|
listLevels(): (K | undefined)[][];
|
|
3655
3655
|
```
|
|
3656
3656
|
|
|
3657
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
3657
|
+
Defined in: [data-structures/binary-tree/bst.ts:744](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L744)
|
|
3658
3658
|
|
|
3659
3659
|
Level-order grouping
|
|
3660
3660
|
|
|
@@ -3670,7 +3670,7 @@ Level-order grouping
|
|
|
3670
3670
|
// Level-order grouping
|
|
3671
3671
|
const bst = new BST<number>([5, 3, 7, 1, 4]);
|
|
3672
3672
|
const levels = bst.listLevels(node => node.key);
|
|
3673
|
-
console.log(levels
|
|
3673
|
+
console.log(levels); // toBeInstanceOf;
|
|
3674
3674
|
console.log(levels[0].length); // 1; // root level has 1 node
|
|
3675
3675
|
const allKeys = levels.flat().sort((a, b) => a - b);
|
|
3676
3676
|
console.log(allKeys); // [1, 3, 4, 5, 7];
|
|
@@ -3695,7 +3695,7 @@ listLevels<C>(
|
|
|
3695
3695
|
iterationType?): ReturnType<C>[][];
|
|
3696
3696
|
```
|
|
3697
3697
|
|
|
3698
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
3698
|
+
Defined in: [data-structures/binary-tree/bst.ts:746](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L746)
|
|
3699
3699
|
|
|
3700
3700
|
Level-order grouping
|
|
3701
3701
|
|
|
@@ -3734,7 +3734,7 @@ Level-order grouping
|
|
|
3734
3734
|
// Level-order grouping
|
|
3735
3735
|
const bst = new BST<number>([5, 3, 7, 1, 4]);
|
|
3736
3736
|
const levels = bst.listLevels(node => node.key);
|
|
3737
|
-
console.log(levels
|
|
3737
|
+
console.log(levels); // toBeInstanceOf;
|
|
3738
3738
|
console.log(levels[0].length); // 1; // root level has 1 node
|
|
3739
3739
|
const allKeys = levels.flat().sort((a, b) => a - b);
|
|
3740
3740
|
console.log(allKeys); // [1, 3, 4, 5, 7];
|
|
@@ -3760,7 +3760,7 @@ IBinaryTree.listLevels
|
|
|
3760
3760
|
lower(keyNodeEntryOrPredicate): K | undefined;
|
|
3761
3761
|
```
|
|
3762
3762
|
|
|
3763
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
3763
|
+
Defined in: [data-structures/binary-tree/bst.ts:2220](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L2220)
|
|
3764
3764
|
|
|
3765
3765
|
Returns the first key with a value < target.
|
|
3766
3766
|
Equivalent to Java TreeMap.lower.
|
|
@@ -3806,7 +3806,7 @@ lower<C>(
|
|
|
3806
3806
|
iterationType?): ReturnType<C>;
|
|
3807
3807
|
```
|
|
3808
3808
|
|
|
3809
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
3809
|
+
Defined in: [data-structures/binary-tree/bst.ts:2235](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L2235)
|
|
3810
3810
|
|
|
3811
3811
|
Returns the first node with a key < target and applies callback.
|
|
3812
3812
|
Time Complexity: O(log n) average, O(h) worst case.
|
|
@@ -3856,7 +3856,7 @@ map<MK, MV, MR>(
|
|
|
3856
3856
|
thisArg?): AVLTree<MK, MV, MR>;
|
|
3857
3857
|
```
|
|
3858
3858
|
|
|
3859
|
-
Defined in: [data-structures/binary-tree/avl-tree.ts:
|
|
3859
|
+
Defined in: [data-structures/binary-tree/avl-tree.ts:907](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/avl-tree.ts#L907)
|
|
3860
3860
|
|
|
3861
3861
|
Creates a new AVLTree by mapping each [key, value] pair.
|
|
3862
3862
|
|
|
@@ -3939,7 +3939,7 @@ IBinaryTree.map
|
|
|
3939
3939
|
merge(anotherTree): void;
|
|
3940
3940
|
```
|
|
3941
3941
|
|
|
3942
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
3942
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:922](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L922)
|
|
3943
3943
|
|
|
3944
3944
|
Merges another tree into this one by seting all its nodes.
|
|
3945
3945
|
|
|
@@ -4013,7 +4013,7 @@ The node to start from.
|
|
|
4013
4013
|
morris(): (K | undefined)[];
|
|
4014
4014
|
```
|
|
4015
4015
|
|
|
4016
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
4016
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:2604](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L2604)
|
|
4017
4017
|
|
|
4018
4018
|
Morris traversal (O(1) space)
|
|
4019
4019
|
|
|
@@ -4051,7 +4051,7 @@ morris<C>(
|
|
|
4051
4051
|
startNode?): ReturnType<C>[];
|
|
4052
4052
|
```
|
|
4053
4053
|
|
|
4054
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
4054
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:2606](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L2606)
|
|
4055
4055
|
|
|
4056
4056
|
Morris traversal (O(1) space)
|
|
4057
4057
|
|
|
@@ -4111,7 +4111,7 @@ IBinaryTree.morris
|
|
|
4111
4111
|
perfectlyBalance(iterationType?): boolean;
|
|
4112
4112
|
```
|
|
4113
4113
|
|
|
4114
|
-
Defined in: [data-structures/binary-tree/avl-tree.ts:
|
|
4114
|
+
Defined in: [data-structures/binary-tree/avl-tree.ts:755](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/avl-tree.ts#L755)
|
|
4115
4115
|
|
|
4116
4116
|
Rebuilds the tree to be perfectly balanced.
|
|
4117
4117
|
|
|
@@ -4160,7 +4160,7 @@ Time O(N) (O(N) for DFS, O(N) for sorted build). Space O(N) for node array and r
|
|
|
4160
4160
|
print(options?, startNode?): void;
|
|
4161
4161
|
```
|
|
4162
4162
|
|
|
4163
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
4163
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:2981](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L2981)
|
|
4164
4164
|
|
|
4165
4165
|
Prints a visual representation of the tree to the console.
|
|
4166
4166
|
|
|
@@ -4213,7 +4213,7 @@ Time O(N) (via `toVisual`). Space O(N*H) or O(N^2) (via `toVisual`).
|
|
|
4213
4213
|
rangeByRank(start, end): (K | undefined)[];
|
|
4214
4214
|
```
|
|
4215
4215
|
|
|
4216
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
4216
|
+
Defined in: [data-structures/binary-tree/bst.ts:1375](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L1375)
|
|
4217
4217
|
|
|
4218
4218
|
Returns elements by position range in tree order (0-indexed, inclusive on both ends).
|
|
4219
4219
|
|
|
@@ -4255,7 +4255,7 @@ rangeByRank<C>(
|
|
|
4255
4255
|
iterationType?): ReturnType<C>[];
|
|
4256
4256
|
```
|
|
4257
4257
|
|
|
4258
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
4258
|
+
Defined in: [data-structures/binary-tree/bst.ts:1387](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L1387)
|
|
4259
4259
|
|
|
4260
4260
|
Returns elements by position range in tree order with callback and optional iteration type.
|
|
4261
4261
|
|
|
@@ -4341,7 +4341,7 @@ The traversal method.
|
|
|
4341
4341
|
rangeSearch(range): (K | undefined)[];
|
|
4342
4342
|
```
|
|
4343
4343
|
|
|
4344
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
4344
|
+
Defined in: [data-structures/binary-tree/bst.ts:1194](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L1194)
|
|
4345
4345
|
|
|
4346
4346
|
Find all keys in a range
|
|
4347
4347
|
|
|
@@ -4379,7 +4379,7 @@ rangeSearch<C>(
|
|
|
4379
4379
|
iterationType?): ReturnType<C>[];
|
|
4380
4380
|
```
|
|
4381
4381
|
|
|
4382
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
4382
|
+
Defined in: [data-structures/binary-tree/bst.ts:1196](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L1196)
|
|
4383
4383
|
|
|
4384
4384
|
Find all keys in a range
|
|
4385
4385
|
|
|
@@ -4436,7 +4436,7 @@ Find all keys in a range
|
|
|
4436
4436
|
reduce<U>(callbackfn, initialValue): U;
|
|
4437
4437
|
```
|
|
4438
4438
|
|
|
4439
|
-
Defined in: [data-structures/base/iterable-entry-base.ts:171](https://github.com/zrwusa/data-structure-typed/blob/
|
|
4439
|
+
Defined in: [data-structures/base/iterable-entry-base.ts:171](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-entry-base.ts#L171)
|
|
4440
4440
|
|
|
4441
4441
|
Reduce entries into a single accumulator.
|
|
4442
4442
|
|
|
@@ -4482,56 +4482,6 @@ IBinaryTree.reduce
|
|
|
4482
4482
|
|
|
4483
4483
|
***
|
|
4484
4484
|
|
|
4485
|
-
### refill()
|
|
4486
|
-
|
|
4487
|
-
```ts
|
|
4488
|
-
refill(keysNodesEntriesOrRaws, values?): void;
|
|
4489
|
-
```
|
|
4490
|
-
|
|
4491
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:913](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/binary-tree.ts#L913)
|
|
4492
|
-
|
|
4493
|
-
Clears the tree and refills it with new items.
|
|
4494
|
-
|
|
4495
|
-
#### Parameters
|
|
4496
|
-
|
|
4497
|
-
##### keysNodesEntriesOrRaws
|
|
4498
|
-
|
|
4499
|
-
`Iterable`\<
|
|
4500
|
-
\| `K`
|
|
4501
|
-
\| `R`
|
|
4502
|
-
\| \[`K` \| `null` \| `undefined`, `V` \| `undefined`\]
|
|
4503
|
-
\| [`BinaryTreeNode`](BinaryTreeNode.md)\<`K`, `V`\>
|
|
4504
|
-
\| `null`
|
|
4505
|
-
\| `undefined`\>
|
|
4506
|
-
|
|
4507
|
-
An iterable of items to set.
|
|
4508
|
-
|
|
4509
|
-
##### values?
|
|
4510
|
-
|
|
4511
|
-
`Iterable`\<`V` \| `undefined`, `any`, `any`\>
|
|
4512
|
-
|
|
4513
|
-
An optional parallel iterable of values.
|
|
4514
|
-
|
|
4515
|
-
#### Returns
|
|
4516
|
-
|
|
4517
|
-
`void`
|
|
4518
|
-
|
|
4519
|
-
#### Remarks
|
|
4520
|
-
|
|
4521
|
-
Time O(N) (for `clear`) + O(N * M) (for `setMany`) = O(N * M). Space O(M) (from `setMany`).
|
|
4522
|
-
|
|
4523
|
-
#### Implementation of
|
|
4524
|
-
|
|
4525
|
-
```ts
|
|
4526
|
-
IBinaryTree.refill
|
|
4527
|
-
```
|
|
4528
|
-
|
|
4529
|
-
#### Inherited from
|
|
4530
|
-
|
|
4531
|
-
[`BST`](BST.md).[`refill`](BST.md#refill)
|
|
4532
|
-
|
|
4533
|
-
***
|
|
4534
|
-
|
|
4535
4485
|
### search()
|
|
4536
4486
|
|
|
4537
4487
|
Searches the tree for nodes matching a predicate, key, or range.
|
|
@@ -4572,7 +4522,7 @@ Whether to use 'RECURSIVE' or 'ITERATIVE' search.
|
|
|
4572
4522
|
search(keyNodeEntryOrPredicate, onlyOne?): (K | undefined)[];
|
|
4573
4523
|
```
|
|
4574
4524
|
|
|
4575
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
4525
|
+
Defined in: [data-structures/binary-tree/bst.ts:996](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L996)
|
|
4576
4526
|
|
|
4577
4527
|
Search nodes by predicate
|
|
4578
4528
|
|
|
@@ -4628,7 +4578,7 @@ search<C>(
|
|
|
4628
4578
|
iterationType?): ReturnType<C>[];
|
|
4629
4579
|
```
|
|
4630
4580
|
|
|
4631
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
4581
|
+
Defined in: [data-structures/binary-tree/bst.ts:1008](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L1008)
|
|
4632
4582
|
|
|
4633
4583
|
Search nodes by predicate
|
|
4634
4584
|
|
|
@@ -4702,7 +4652,7 @@ IBinaryTree.search
|
|
|
4702
4652
|
set(keyNodeOrEntry, value?): boolean;
|
|
4703
4653
|
```
|
|
4704
4654
|
|
|
4705
|
-
Defined in: [data-structures/binary-tree/avl-tree.ts:
|
|
4655
|
+
Defined in: [data-structures/binary-tree/avl-tree.ts:517](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/avl-tree.ts#L517)
|
|
4706
4656
|
|
|
4707
4657
|
Sets a new node to the AVL tree and balances the tree path.
|
|
4708
4658
|
|
|
@@ -4768,7 +4718,7 @@ setMany(
|
|
|
4768
4718
|
iterationType?): boolean[];
|
|
4769
4719
|
```
|
|
4770
4720
|
|
|
4771
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
4721
|
+
Defined in: [data-structures/binary-tree/bst.ts:1706](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L1706)
|
|
4772
4722
|
|
|
4773
4723
|
Adds multiple items to the tree.
|
|
4774
4724
|
|
|
@@ -4834,7 +4784,7 @@ Space O(N) for sorting and recursion/iteration stack.
|
|
|
4834
4784
|
some(predicate, thisArg?): boolean;
|
|
4835
4785
|
```
|
|
4836
4786
|
|
|
4837
|
-
Defined in: [data-structures/base/iterable-entry-base.ts:83](https://github.com/zrwusa/data-structure-typed/blob/
|
|
4787
|
+
Defined in: [data-structures/base/iterable-entry-base.ts:83](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-entry-base.ts#L83)
|
|
4838
4788
|
|
|
4839
4789
|
Test whether any entry satisfies the predicate.
|
|
4840
4790
|
|
|
@@ -4880,7 +4830,7 @@ IBinaryTree.some
|
|
|
4880
4830
|
toArray(): [K, V | undefined][];
|
|
4881
4831
|
```
|
|
4882
4832
|
|
|
4883
|
-
Defined in: [data-structures/base/iterable-entry-base.ts:186](https://github.com/zrwusa/data-structure-typed/blob/
|
|
4833
|
+
Defined in: [data-structures/base/iterable-entry-base.ts:186](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-entry-base.ts#L186)
|
|
4884
4834
|
|
|
4885
4835
|
Converts data structure to `[key, value]` pairs.
|
|
4886
4836
|
|
|
@@ -4906,7 +4856,7 @@ Time O(n), Space O(n)
|
|
|
4906
4856
|
toVisual(startNode?, options?): string;
|
|
4907
4857
|
```
|
|
4908
4858
|
|
|
4909
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
4859
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:2907](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L2907)
|
|
4910
4860
|
|
|
4911
4861
|
Generates a string representation of the tree for visualization.
|
|
4912
4862
|
|
|
@@ -4949,7 +4899,7 @@ Time O(N), visits every node. Space O(N*H) or O(N^2) in the worst case, as the s
|
|
|
4949
4899
|
values(): IterableIterator<V | undefined>;
|
|
4950
4900
|
```
|
|
4951
4901
|
|
|
4952
|
-
Defined in: [data-structures/base/iterable-entry-base.ts:53](https://github.com/zrwusa/data-structure-typed/blob/
|
|
4902
|
+
Defined in: [data-structures/base/iterable-entry-base.ts:53](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/base/iterable-entry-base.ts#L53)
|
|
4953
4903
|
|
|
4954
4904
|
Iterate over values only.
|
|
4955
4905
|
|
|
@@ -4984,7 +4934,7 @@ IBinaryTree.values
|
|
|
4984
4934
|
protected readonly _comparator: Comparator<K>;
|
|
4985
4935
|
```
|
|
4986
4936
|
|
|
4987
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
4937
|
+
Defined in: [data-structures/binary-tree/bst.ts:376](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L376)
|
|
4988
4938
|
|
|
4989
4939
|
The comparator function used to determine the order of keys in the tree.
|
|
4990
4940
|
|
|
@@ -5004,7 +4954,7 @@ Time O(1) Space O(1)
|
|
|
5004
4954
|
protected readonly _DEFAULT_NODE_CALLBACK: NodeCallback<BinaryTreeNode<K, V> | null | undefined, K | undefined>;
|
|
5005
4955
|
```
|
|
5006
4956
|
|
|
5007
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
4957
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:3177](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L3177)
|
|
5008
4958
|
|
|
5009
4959
|
(Protected) Default callback function, returns the node's key.
|
|
5010
4960
|
|
|
@@ -5032,7 +4982,7 @@ The node's key or undefined.
|
|
|
5032
4982
|
protected _balanceFactor(node): number;
|
|
5033
4983
|
```
|
|
5034
4984
|
|
|
5035
|
-
Defined in: [data-structures/binary-tree/avl-tree.ts:
|
|
4985
|
+
Defined in: [data-structures/binary-tree/avl-tree.ts:1005](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/avl-tree.ts#L1005)
|
|
5036
4986
|
|
|
5037
4987
|
(Protected) Calculates the balance factor (height(right) - height(left)).
|
|
5038
4988
|
|
|
@@ -5062,7 +5012,7 @@ Time O(1) (assumes heights are stored).
|
|
|
5062
5012
|
protected _balanceLL(A): void;
|
|
5063
5013
|
```
|
|
5064
5014
|
|
|
5065
|
-
Defined in: [data-structures/binary-tree/avl-tree.ts:
|
|
5015
|
+
Defined in: [data-structures/binary-tree/avl-tree.ts:1029](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/avl-tree.ts#L1029)
|
|
5066
5016
|
|
|
5067
5017
|
(Protected) Performs a Left-Left (LL) rotation (a single right rotation).
|
|
5068
5018
|
|
|
@@ -5090,7 +5040,7 @@ Time O(1), Space O(1)
|
|
|
5090
5040
|
protected _balanceLR(A): void;
|
|
5091
5041
|
```
|
|
5092
5042
|
|
|
5093
|
-
Defined in: [data-structures/binary-tree/avl-tree.ts:
|
|
5043
|
+
Defined in: [data-structures/binary-tree/avl-tree.ts:1066](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/avl-tree.ts#L1066)
|
|
5094
5044
|
|
|
5095
5045
|
(Protected) Performs a Left-Right (LR) double rotation.
|
|
5096
5046
|
|
|
@@ -5118,7 +5068,7 @@ Time O(1), Space O(1)
|
|
|
5118
5068
|
protected _balancePath(node): void;
|
|
5119
5069
|
```
|
|
5120
5070
|
|
|
5121
|
-
Defined in: [data-structures/binary-tree/avl-tree.ts:
|
|
5071
|
+
Defined in: [data-structures/binary-tree/avl-tree.ts:1216](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/avl-tree.ts#L1216)
|
|
5122
5072
|
|
|
5123
5073
|
(Protected) Traverses up the tree from the specified node, updating heights and performing rotations as needed.
|
|
5124
5074
|
|
|
@@ -5150,7 +5100,7 @@ Time O(log N) (O(H)), as it traverses the path to root. Space O(H) for the path
|
|
|
5150
5100
|
protected _balanceRL(A): void;
|
|
5151
5101
|
```
|
|
5152
5102
|
|
|
5153
|
-
Defined in: [data-structures/binary-tree/avl-tree.ts:
|
|
5103
|
+
Defined in: [data-structures/binary-tree/avl-tree.ts:1162](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/avl-tree.ts#L1162)
|
|
5154
5104
|
|
|
5155
5105
|
(Protected) Performs a Right-Left (RL) double rotation.
|
|
5156
5106
|
|
|
@@ -5178,7 +5128,7 @@ Time O(1), Space O(1)
|
|
|
5178
5128
|
protected _balanceRR(A): void;
|
|
5179
5129
|
```
|
|
5180
5130
|
|
|
5181
|
-
Defined in: [data-structures/binary-tree/avl-tree.ts:
|
|
5131
|
+
Defined in: [data-structures/binary-tree/avl-tree.ts:1121](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/avl-tree.ts#L1121)
|
|
5182
5132
|
|
|
5183
5133
|
(Protected) Performs a Right-Right (RR) rotation (a single left rotation).
|
|
5184
5134
|
|
|
@@ -5209,7 +5159,7 @@ protected _bound(
|
|
|
5209
5159
|
iterationType): BSTNode<K, V> | undefined;
|
|
5210
5160
|
```
|
|
5211
5161
|
|
|
5212
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
5162
|
+
Defined in: [data-structures/binary-tree/bst.ts:2993](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L2993)
|
|
5213
5163
|
|
|
5214
5164
|
(Protected) Core bound search implementation supporting all parameter types.
|
|
5215
5165
|
Unified logic for both lowerBound and upperBound.
|
|
@@ -5261,7 +5211,7 @@ protected _boundByKey(
|
|
|
5261
5211
|
iterationType): BSTNode<K, V> | undefined;
|
|
5262
5212
|
```
|
|
5263
5213
|
|
|
5264
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
5214
|
+
Defined in: [data-structures/binary-tree/bst.ts:3050](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L3050)
|
|
5265
5215
|
|
|
5266
5216
|
(Protected) Binary search for bound by key with pruning optimization.
|
|
5267
5217
|
Performs standard BST binary search, choosing left or right subtree based on comparator result.
|
|
@@ -5306,7 +5256,7 @@ The first node matching the bound condition, or undefined if none exists.
|
|
|
5306
5256
|
protected _boundByPredicate(predicate, iterationType): BSTNode<K, V> | undefined;
|
|
5307
5257
|
```
|
|
5308
5258
|
|
|
5309
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
5259
|
+
Defined in: [data-structures/binary-tree/bst.ts:3105](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L3105)
|
|
5310
5260
|
|
|
5311
5261
|
(Protected) In-order traversal search by predicate.
|
|
5312
5262
|
Falls back to linear in-order traversal when predicate-based search is required.
|
|
@@ -5346,7 +5296,7 @@ The first node satisfying predicate, or undefined if none found.
|
|
|
5346
5296
|
protected _clearNodes(): void;
|
|
5347
5297
|
```
|
|
5348
5298
|
|
|
5349
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
5299
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:3611](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L3611)
|
|
5350
5300
|
|
|
5351
5301
|
(Protected) Clears all nodes from the tree.
|
|
5352
5302
|
|
|
@@ -5370,7 +5320,7 @@ Time O(1)
|
|
|
5370
5320
|
protected _clearValues(): void;
|
|
5371
5321
|
```
|
|
5372
5322
|
|
|
5373
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
5323
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:3620](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L3620)
|
|
5374
5324
|
|
|
5375
5325
|
(Protected) Clears all values from the external store.
|
|
5376
5326
|
|
|
@@ -5394,7 +5344,7 @@ Time O(N)
|
|
|
5394
5344
|
protected _clone(cloned): void;
|
|
5395
5345
|
```
|
|
5396
5346
|
|
|
5397
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
5347
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:3270](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L3270)
|
|
5398
5348
|
|
|
5399
5349
|
(Protected) Helper for cloning. Performs a BFS and sets all nodes to the new tree.
|
|
5400
5350
|
|
|
@@ -5426,7 +5376,7 @@ Time O(N * M) (O(N) BFS + O(M) `set` for each node).
|
|
|
5426
5376
|
protected _compare(a, b): number;
|
|
5427
5377
|
```
|
|
5428
5378
|
|
|
5429
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
5379
|
+
Defined in: [data-structures/binary-tree/bst.ts:3369](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L3369)
|
|
5430
5380
|
|
|
5431
5381
|
(Protected) Compares two keys using the tree's comparator and reverse setting.
|
|
5432
5382
|
|
|
@@ -5466,7 +5416,7 @@ Time O(1) Space O(1)
|
|
|
5466
5416
|
protected _createDefaultComparator(): Comparator<K>;
|
|
5467
5417
|
```
|
|
5468
5418
|
|
|
5469
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
5419
|
+
Defined in: [data-structures/binary-tree/bst.ts:2720](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L2720)
|
|
5470
5420
|
|
|
5471
5421
|
(Protected) Creates the default comparator function for keys that don't have a custom comparator.
|
|
5472
5422
|
|
|
@@ -5492,7 +5442,7 @@ Time O(1) Space O(1)
|
|
|
5492
5442
|
protected _createInstance<TK, TV, TR>(options?): this;
|
|
5493
5443
|
```
|
|
5494
5444
|
|
|
5495
|
-
Defined in: [data-structures/binary-tree/avl-tree.ts:
|
|
5445
|
+
Defined in: [data-structures/binary-tree/avl-tree.ts:931](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/avl-tree.ts#L931)
|
|
5496
5446
|
|
|
5497
5447
|
(Protected) Creates a new, empty instance of the same AVLTree constructor.
|
|
5498
5448
|
|
|
@@ -5540,7 +5490,7 @@ Time O(1)
|
|
|
5540
5490
|
protected _createLike<TK, TV, TR>(iter?, options?): AVLTree<TK, TV, TR>;
|
|
5541
5491
|
```
|
|
5542
5492
|
|
|
5543
|
-
Defined in: [data-structures/binary-tree/avl-tree.ts:
|
|
5493
|
+
Defined in: [data-structures/binary-tree/avl-tree.ts:948](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/avl-tree.ts#L948)
|
|
5544
5494
|
|
|
5545
5495
|
(Protected) Creates a new instance of the same AVLTree constructor, potentially with different generic types.
|
|
5546
5496
|
|
|
@@ -5600,7 +5550,7 @@ Time O(N log N) (from constructor) due to processing the iterable.
|
|
|
5600
5550
|
protected _deleteByKey(key): boolean;
|
|
5601
5551
|
```
|
|
5602
5552
|
|
|
5603
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
5553
|
+
Defined in: [data-structures/binary-tree/bst.ts:3380](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L3380)
|
|
5604
5554
|
|
|
5605
5555
|
(Private) Deletes a node by its key.
|
|
5606
5556
|
|
|
@@ -5628,6 +5578,44 @@ Standard BST deletion algorithm. Time O(log N), O(N) worst-case. Space O(1).
|
|
|
5628
5578
|
|
|
5629
5579
|
***
|
|
5630
5580
|
|
|
5581
|
+
### \_deleteInternal()
|
|
5582
|
+
|
|
5583
|
+
```ts
|
|
5584
|
+
protected _deleteInternal(keyNodeEntryRawOrPredicate): BinaryTreeDeleteResult<BinaryTreeNode<K, V>>[];
|
|
5585
|
+
```
|
|
5586
|
+
|
|
5587
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:934](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L934)
|
|
5588
|
+
|
|
5589
|
+
**`Internal`**
|
|
5590
|
+
|
|
5591
|
+
Deletes a node from the tree (internal, returns balancing metadata).
|
|
5592
|
+
|
|
5593
|
+
#### Parameters
|
|
5594
|
+
|
|
5595
|
+
##### keyNodeEntryRawOrPredicate
|
|
5596
|
+
|
|
5597
|
+
\| `BTNRep`\<`K`, `V`, [`BinaryTreeNode`](BinaryTreeNode.md)\<`K`, `V`\>\>
|
|
5598
|
+
\| `NodePredicate`\<[`BinaryTreeNode`](BinaryTreeNode.md)\<`K`, `V`\> \| `null`\>
|
|
5599
|
+
|
|
5600
|
+
The node to delete.
|
|
5601
|
+
|
|
5602
|
+
#### Returns
|
|
5603
|
+
|
|
5604
|
+
`BinaryTreeDeleteResult`\<[`BinaryTreeNode`](BinaryTreeNode.md)\<`K`, `V`\>\>[]
|
|
5605
|
+
|
|
5606
|
+
An array containing deletion results with balancing metadata.
|
|
5607
|
+
|
|
5608
|
+
#### Remarks
|
|
5609
|
+
|
|
5610
|
+
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).
|
|
5611
|
+
Used by AVL/BST subclasses that need balancing metadata after deletion.
|
|
5612
|
+
|
|
5613
|
+
#### Inherited from
|
|
5614
|
+
|
|
5615
|
+
[`BST`](BST.md).[`_deleteInternal`](BST.md#_deleteinternal)
|
|
5616
|
+
|
|
5617
|
+
***
|
|
5618
|
+
|
|
5631
5619
|
### \_dfs()
|
|
5632
5620
|
|
|
5633
5621
|
```ts
|
|
@@ -5644,7 +5632,7 @@ protected _dfs<C>(
|
|
|
5644
5632
|
shouldProcessRoot?): ReturnType<C>[];
|
|
5645
5633
|
```
|
|
5646
5634
|
|
|
5647
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
5635
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:2988](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L2988)
|
|
5648
5636
|
|
|
5649
5637
|
#### Type Parameters
|
|
5650
5638
|
|
|
@@ -5737,7 +5725,7 @@ Array of callback results.
|
|
|
5737
5725
|
protected _displayAux(node, options): NodeDisplayLayout;
|
|
5738
5726
|
```
|
|
5739
5727
|
|
|
5740
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
5728
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:3294](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L3294)
|
|
5741
5729
|
|
|
5742
5730
|
(Protected) Recursive helper for `toVisual`.
|
|
5743
5731
|
|
|
@@ -5777,7 +5765,7 @@ Time O(N), Space O(N*H) or O(N^2)
|
|
|
5777
5765
|
protected _ensurePredicate(keyNodeEntryOrPredicate): NodePredicate<BinaryTreeNode<K, V>>;
|
|
5778
5766
|
```
|
|
5779
5767
|
|
|
5780
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
5768
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:3517](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L3517)
|
|
5781
5769
|
|
|
5782
5770
|
(Protected) Converts a key, node, entry, or predicate into a standardized predicate function.
|
|
5783
5771
|
|
|
@@ -5816,7 +5804,7 @@ Time O(1)
|
|
|
5816
5804
|
protected _extractKey(keyNodeOrEntry): K | null | undefined;
|
|
5817
5805
|
```
|
|
5818
5806
|
|
|
5819
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
5807
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:3577](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L3577)
|
|
5820
5808
|
|
|
5821
5809
|
(Protected) Extracts the key from a key, node, or entry.
|
|
5822
5810
|
|
|
@@ -5854,7 +5842,7 @@ Time O(1)
|
|
|
5854
5842
|
protected _floorByKey(key, iterationType): BSTNode<K, V> | undefined;
|
|
5855
5843
|
```
|
|
5856
5844
|
|
|
5857
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
5845
|
+
Defined in: [data-structures/binary-tree/bst.ts:2758](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L2758)
|
|
5858
5846
|
|
|
5859
5847
|
(Protected) Binary search for floor by key with pruning optimization.
|
|
5860
5848
|
Performs standard BST binary search, choosing left or right subtree based on comparator result.
|
|
@@ -5896,7 +5884,7 @@ Time O(h) where h is tree height.
|
|
|
5896
5884
|
protected _floorByPredicate(predicate, iterationType): BSTNode<K, V> | undefined;
|
|
5897
5885
|
```
|
|
5898
5886
|
|
|
5899
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
5887
|
+
Defined in: [data-structures/binary-tree/bst.ts:2811](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L2811)
|
|
5900
5888
|
|
|
5901
5889
|
(Protected) In-order traversal search for floor by predicate.
|
|
5902
5890
|
Falls back to linear in-order traversal when predicate-based search is required.
|
|
@@ -5939,7 +5927,7 @@ Space Complexity: O(h) for recursion, O(h) for iterative stack.
|
|
|
5939
5927
|
protected _getByRankIterative(node, k): BSTNode<K, V> | undefined;
|
|
5940
5928
|
```
|
|
5941
5929
|
|
|
5942
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
5930
|
+
Defined in: [data-structures/binary-tree/bst.ts:3261](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L3261)
|
|
5943
5931
|
|
|
5944
5932
|
(Protected) Finds the node at position k in tree order (iterative).
|
|
5945
5933
|
|
|
@@ -5973,7 +5961,7 @@ Time O(log n), Space O(1)
|
|
|
5973
5961
|
protected _getByRankRecursive(node, k): BSTNode<K, V> | undefined;
|
|
5974
5962
|
```
|
|
5975
5963
|
|
|
5976
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
5964
|
+
Defined in: [data-structures/binary-tree/bst.ts:3282](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L3282)
|
|
5977
5965
|
|
|
5978
5966
|
(Protected) Finds the node at position k in tree order (recursive).
|
|
5979
5967
|
|
|
@@ -6007,7 +5995,7 @@ Time O(log n), Space O(log n) call stack
|
|
|
6007
5995
|
protected _getIterator(node?): IterableIterator<[K, V | undefined]>;
|
|
6008
5996
|
```
|
|
6009
5997
|
|
|
6010
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
5998
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:3133](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L3133)
|
|
6011
5999
|
|
|
6012
6000
|
(Protected) Gets the iterator for the tree (default in-order).
|
|
6013
6001
|
|
|
@@ -6041,7 +6029,7 @@ Time O(N) for full iteration. O(H) to get the first element. Space O(H) for the
|
|
|
6041
6029
|
protected _getRankIterative(node, key): number;
|
|
6042
6030
|
```
|
|
6043
6031
|
|
|
6044
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
6032
|
+
Defined in: [data-structures/binary-tree/bst.ts:3294](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L3294)
|
|
6045
6033
|
|
|
6046
6034
|
(Protected) Computes the rank of a key iteratively.
|
|
6047
6035
|
|
|
@@ -6075,7 +6063,7 @@ Time O(log n), Space O(1)
|
|
|
6075
6063
|
protected _getRankRecursive(node, key): number;
|
|
6076
6064
|
```
|
|
6077
6065
|
|
|
6078
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
6066
|
+
Defined in: [data-structures/binary-tree/bst.ts:3320](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L3320)
|
|
6079
6067
|
|
|
6080
6068
|
(Protected) Computes the rank of a key recursively.
|
|
6081
6069
|
|
|
@@ -6109,7 +6097,7 @@ Time O(log n), Space O(log n) call stack
|
|
|
6109
6097
|
protected _isDisplayLeaf(node, options): boolean;
|
|
6110
6098
|
```
|
|
6111
6099
|
|
|
6112
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
6100
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:3389](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L3389)
|
|
6113
6101
|
|
|
6114
6102
|
Check if a node is a display leaf (empty, null, undefined, NIL, or real leaf).
|
|
6115
6103
|
|
|
@@ -6139,7 +6127,7 @@ Check if a node is a display leaf (empty, null, undefined, NIL, or real leaf).
|
|
|
6139
6127
|
protected _isPredicate(p): p is NodePredicate<BinaryTreeNode<K, V>>;
|
|
6140
6128
|
```
|
|
6141
6129
|
|
|
6142
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
6130
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:3566](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L3566)
|
|
6143
6131
|
|
|
6144
6132
|
(Protected) Checks if an item is a predicate function.
|
|
6145
6133
|
|
|
@@ -6173,7 +6161,7 @@ Time O(1)
|
|
|
6173
6161
|
protected _keyValueNodeOrEntryToNodeAndValue(keyNodeOrEntry, value?): [OptNode<BSTNode<K, V>>, V | undefined];
|
|
6174
6162
|
```
|
|
6175
6163
|
|
|
6176
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
6164
|
+
Defined in: [data-structures/binary-tree/bst.ts:3218](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L3218)
|
|
6177
6165
|
|
|
6178
6166
|
(Protected) Converts a key, node, or entry into a standardized [node, value] tuple.
|
|
6179
6167
|
|
|
@@ -6217,7 +6205,7 @@ Time O(1)
|
|
|
6217
6205
|
protected _lowerByKey(key, iterationType): BSTNode<K, V> | undefined;
|
|
6218
6206
|
```
|
|
6219
6207
|
|
|
6220
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
6208
|
+
Defined in: [data-structures/binary-tree/bst.ts:2876](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L2876)
|
|
6221
6209
|
|
|
6222
6210
|
(Protected) Binary search for lower by key with pruning optimization.
|
|
6223
6211
|
Performs standard BST binary search, choosing left or right subtree based on comparator result.
|
|
@@ -6259,7 +6247,7 @@ Time O(h) where h is tree height.
|
|
|
6259
6247
|
protected _lowerByPredicate(predicate, iterationType): BSTNode<K, V> | undefined;
|
|
6260
6248
|
```
|
|
6261
6249
|
|
|
6262
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
6250
|
+
Defined in: [data-structures/binary-tree/bst.ts:2929](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L2929)
|
|
6263
6251
|
|
|
6264
6252
|
(Protected) In-order traversal search for lower by predicate.
|
|
6265
6253
|
Falls back to linear in-order traversal when predicate-based search is required.
|
|
@@ -6302,7 +6290,7 @@ Space Complexity: O(h) for recursion, O(h) for iterative stack.
|
|
|
6302
6290
|
protected _next(node): BSTNode<K, V> | undefined;
|
|
6303
6291
|
```
|
|
6304
6292
|
|
|
6305
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
6293
|
+
Defined in: [data-structures/binary-tree/bst.ts:3337](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L3337)
|
|
6306
6294
|
|
|
6307
6295
|
(Protected) Finds the in-order successor of a node.
|
|
6308
6296
|
|
|
@@ -6332,7 +6320,7 @@ Time O(log n), Space O(1)
|
|
|
6332
6320
|
protected _replaceNode(oldNode, newNode): AVLTreeNode<K, V>;
|
|
6333
6321
|
```
|
|
6334
6322
|
|
|
6335
|
-
Defined in: [data-structures/binary-tree/avl-tree.ts:
|
|
6323
|
+
Defined in: [data-structures/binary-tree/avl-tree.ts:1264](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/avl-tree.ts#L1264)
|
|
6336
6324
|
|
|
6337
6325
|
(Protected) Replaces a node, ensuring height is copied.
|
|
6338
6326
|
|
|
@@ -6375,7 +6363,7 @@ protected _resolveDisplayLeaf(
|
|
|
6375
6363
|
emptyDisplayLayout): NodeDisplayLayout;
|
|
6376
6364
|
```
|
|
6377
6365
|
|
|
6378
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
6366
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:3419](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L3419)
|
|
6379
6367
|
|
|
6380
6368
|
Resolve a display leaf node to its layout.
|
|
6381
6369
|
|
|
@@ -6409,7 +6397,7 @@ Resolve a display leaf node to its layout.
|
|
|
6409
6397
|
protected _setRoot(v): void;
|
|
6410
6398
|
```
|
|
6411
6399
|
|
|
6412
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
6400
|
+
Defined in: [data-structures/binary-tree/bst.ts:3356](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L3356)
|
|
6413
6401
|
|
|
6414
6402
|
(Protected) Sets the root node and clears its parent reference.
|
|
6415
6403
|
|
|
@@ -6441,7 +6429,7 @@ Time O(1)
|
|
|
6441
6429
|
protected _setValue(key, value): boolean;
|
|
6442
6430
|
```
|
|
6443
6431
|
|
|
6444
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
6432
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:3598](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L3598)
|
|
6445
6433
|
|
|
6446
6434
|
(Protected) Sets a value in the external store (Map mode).
|
|
6447
6435
|
|
|
@@ -6481,7 +6469,7 @@ Time O(1) (average for Map.set).
|
|
|
6481
6469
|
protected _snapshotOptions<TK, TV, TR>(): BSTOptions<TK, TV, TR>;
|
|
6482
6470
|
```
|
|
6483
6471
|
|
|
6484
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
6472
|
+
Defined in: [data-structures/binary-tree/bst.ts:3202](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L3202)
|
|
6485
6473
|
|
|
6486
6474
|
(Protected) Snapshots the current BST's configuration options.
|
|
6487
6475
|
|
|
@@ -6521,7 +6509,7 @@ Time O(1)
|
|
|
6521
6509
|
protected _swapProperties(srcNode, destNode): AVLTreeNode<K, V> | undefined;
|
|
6522
6510
|
```
|
|
6523
6511
|
|
|
6524
|
-
Defined in: [data-structures/binary-tree/avl-tree.ts:
|
|
6512
|
+
Defined in: [data-structures/binary-tree/avl-tree.ts:967](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/avl-tree.ts#L967)
|
|
6525
6513
|
|
|
6526
6514
|
(Protected) Swaps properties of two nodes, including height.
|
|
6527
6515
|
|
|
@@ -6561,7 +6549,7 @@ Time O(H) (due to `ensureNode`), but O(1) if nodes are passed directly.
|
|
|
6561
6549
|
protected _updateCount(node): void;
|
|
6562
6550
|
```
|
|
6563
6551
|
|
|
6564
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
6552
|
+
Defined in: [data-structures/binary-tree/bst.ts:3237](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L3237)
|
|
6565
6553
|
|
|
6566
6554
|
(Protected) Recalculates the subtree count for a single node.
|
|
6567
6555
|
|
|
@@ -6591,7 +6579,7 @@ Time O(1). Only active when enableOrderStatistic is true.
|
|
|
6591
6579
|
protected _updateCountAlongPath(node): void;
|
|
6592
6580
|
```
|
|
6593
6581
|
|
|
6594
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
6582
|
+
Defined in: [data-structures/binary-tree/bst.ts:3248](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L3248)
|
|
6595
6583
|
|
|
6596
6584
|
(Protected) Updates subtree counts from a node up to the root.
|
|
6597
6585
|
|
|
@@ -6621,7 +6609,7 @@ Time O(log n). Only active when enableOrderStatistic is true.
|
|
|
6621
6609
|
protected _updateHeight(node): void;
|
|
6622
6610
|
```
|
|
6623
6611
|
|
|
6624
|
-
Defined in: [data-structures/binary-tree/avl-tree.ts:
|
|
6612
|
+
Defined in: [data-structures/binary-tree/avl-tree.ts:1017](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/avl-tree.ts#L1017)
|
|
6625
6613
|
|
|
6626
6614
|
(Protected) Recalculates and updates the height of a node based on its children's heights.
|
|
6627
6615
|
|