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: BST\<K, V, R\>
|
|
8
8
|
|
|
9
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
9
|
+
Defined in: [data-structures/binary-tree/bst.ts:326](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L326)
|
|
10
10
|
|
|
11
11
|
Represents a Binary Search Tree (BST).
|
|
12
12
|
Keys are ordered, allowing for faster search operations compared to a standard Binary Tree.
|
|
@@ -188,7 +188,7 @@ The type of the raw data object (if using `toEntryFn`).
|
|
|
188
188
|
new BST<K, V, R>(keysNodesEntriesOrRaws?, options?): BST<K, V, R>;
|
|
189
189
|
```
|
|
190
190
|
|
|
191
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
191
|
+
Defined in: [data-structures/binary-tree/bst.ts:334](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L334)
|
|
192
192
|
|
|
193
193
|
Creates an instance of BST.
|
|
194
194
|
|
|
@@ -234,7 +234,7 @@ Time O(N log N) or O(N^2) depending on `isBalanceAdd` in `addMany` and input ord
|
|
|
234
234
|
get comparator(): Comparator<K>;
|
|
235
235
|
```
|
|
236
236
|
|
|
237
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
237
|
+
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)
|
|
238
238
|
|
|
239
239
|
Gets the comparator function used by the tree.
|
|
240
240
|
|
|
@@ -258,7 +258,7 @@ The comparator function.
|
|
|
258
258
|
get isDuplicate(): boolean;
|
|
259
259
|
```
|
|
260
260
|
|
|
261
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:322](https://github.com/zrwusa/data-structure-typed/blob/
|
|
261
|
+
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)
|
|
262
262
|
|
|
263
263
|
Gets whether the tree allows duplicate keys.
|
|
264
264
|
|
|
@@ -292,7 +292,7 @@ IBinaryTree.isDuplicate
|
|
|
292
292
|
get isMapMode(): boolean;
|
|
293
293
|
```
|
|
294
294
|
|
|
295
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:310](https://github.com/zrwusa/data-structure-typed/blob/
|
|
295
|
+
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)
|
|
296
296
|
|
|
297
297
|
Gets whether the tree is in Map mode.
|
|
298
298
|
|
|
@@ -326,7 +326,7 @@ IBinaryTree.isMapMode
|
|
|
326
326
|
get NIL(): BinaryTreeNode<K, V>;
|
|
327
327
|
```
|
|
328
328
|
|
|
329
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:373](https://github.com/zrwusa/data-structure-typed/blob/
|
|
329
|
+
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)
|
|
330
330
|
|
|
331
331
|
Gets the sentinel NIL node (used in self-balancing trees like Red-Black Tree).
|
|
332
332
|
|
|
@@ -360,7 +360,7 @@ IBinaryTree.NIL
|
|
|
360
360
|
get root(): OptNode<BSTNode<K, V>>;
|
|
361
361
|
```
|
|
362
362
|
|
|
363
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
363
|
+
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)
|
|
364
364
|
|
|
365
365
|
Gets the root node of the tree.
|
|
366
366
|
|
|
@@ -394,7 +394,7 @@ IBinaryTree.root
|
|
|
394
394
|
get size(): number;
|
|
395
395
|
```
|
|
396
396
|
|
|
397
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:361](https://github.com/zrwusa/data-structure-typed/blob/
|
|
397
|
+
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)
|
|
398
398
|
|
|
399
399
|
Gets the number of nodes in the tree.
|
|
400
400
|
|
|
@@ -428,7 +428,7 @@ IBinaryTree.size
|
|
|
428
428
|
get store(): Map<K, BinaryTreeNode<K, V>>;
|
|
429
429
|
```
|
|
430
430
|
|
|
431
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:337](https://github.com/zrwusa/data-structure-typed/blob/
|
|
431
|
+
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)
|
|
432
432
|
|
|
433
433
|
Gets the external value store (used in Map mode).
|
|
434
434
|
|
|
@@ -462,7 +462,7 @@ IBinaryTree.store
|
|
|
462
462
|
get toEntryFn(): ToEntryFn<K, V, R> | undefined;
|
|
463
463
|
```
|
|
464
464
|
|
|
465
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:385](https://github.com/zrwusa/data-structure-typed/blob/
|
|
465
|
+
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)
|
|
466
466
|
|
|
467
467
|
Gets the function used to convert raw data objects (R) into [key, value] entries.
|
|
468
468
|
|
|
@@ -494,7 +494,7 @@ IBinaryTree.toEntryFn
|
|
|
494
494
|
iterator: IterableIterator<[K, V | undefined]>;
|
|
495
495
|
```
|
|
496
496
|
|
|
497
|
-
Defined in: [data-structures/base/iterable-entry-base.ts:22](https://github.com/zrwusa/data-structure-typed/blob/
|
|
497
|
+
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)
|
|
498
498
|
|
|
499
499
|
Default iterator yielding `[key, value]` entries.
|
|
500
500
|
|
|
@@ -532,7 +532,7 @@ IBinaryTree.[iterator]
|
|
|
532
532
|
add(keyNodeOrEntry): boolean;
|
|
533
533
|
```
|
|
534
534
|
|
|
535
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
535
|
+
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)
|
|
536
536
|
|
|
537
537
|
Adds a new node to the tree.
|
|
538
538
|
|
|
@@ -558,7 +558,7 @@ True if the addition was successful, false otherwise.
|
|
|
558
558
|
|
|
559
559
|
#### Remarks
|
|
560
560
|
|
|
561
|
-
Time O(
|
|
561
|
+
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).
|
|
562
562
|
|
|
563
563
|
#### Example
|
|
564
564
|
|
|
@@ -590,7 +590,7 @@ IBinaryTree.add
|
|
|
590
590
|
addMany(keysNodesEntriesOrRaws): boolean[];
|
|
591
591
|
```
|
|
592
592
|
|
|
593
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
593
|
+
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)
|
|
594
594
|
|
|
595
595
|
Adds multiple items to the tree.
|
|
596
596
|
|
|
@@ -671,7 +671,7 @@ The traversal method.
|
|
|
671
671
|
bfs(): (K | undefined)[];
|
|
672
672
|
```
|
|
673
673
|
|
|
674
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
674
|
+
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)
|
|
675
675
|
|
|
676
676
|
BinaryTree level-order traversal
|
|
677
677
|
|
|
@@ -709,7 +709,7 @@ bfs<C>(
|
|
|
709
709
|
iterationType?): ReturnType<C>[];
|
|
710
710
|
```
|
|
711
711
|
|
|
712
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
712
|
+
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)
|
|
713
713
|
|
|
714
714
|
BinaryTree level-order traversal
|
|
715
715
|
|
|
@@ -771,7 +771,7 @@ IBinaryTree.bfs
|
|
|
771
771
|
ceiling(keyNodeEntryOrPredicate): K | undefined;
|
|
772
772
|
```
|
|
773
773
|
|
|
774
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
774
|
+
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)
|
|
775
775
|
|
|
776
776
|
Returns the first key with a value >= target.
|
|
777
777
|
Equivalent to Java TreeMap.ceiling.
|
|
@@ -814,7 +814,7 @@ ceiling<C>(
|
|
|
814
814
|
iterationType?): ReturnType<C>;
|
|
815
815
|
```
|
|
816
816
|
|
|
817
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
817
|
+
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)
|
|
818
818
|
|
|
819
819
|
Returns the first node with a key >= target and applies callback.
|
|
820
820
|
Time Complexity: O(log n) average, O(h) worst case.
|
|
@@ -857,7 +857,7 @@ Space Complexity: O(h) for recursion, O(1) for iteration.
|
|
|
857
857
|
clear(): void;
|
|
858
858
|
```
|
|
859
859
|
|
|
860
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
860
|
+
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)
|
|
861
861
|
|
|
862
862
|
Clears the tree of all nodes and values.
|
|
863
863
|
|
|
@@ -898,7 +898,7 @@ IBinaryTree.clear
|
|
|
898
898
|
clone(): this;
|
|
899
899
|
```
|
|
900
900
|
|
|
901
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
901
|
+
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)
|
|
902
902
|
|
|
903
903
|
Clones the tree.
|
|
904
904
|
|
|
@@ -942,7 +942,7 @@ IBinaryTree.clone
|
|
|
942
942
|
createNode(key, value?): BSTNode<K, V>;
|
|
943
943
|
```
|
|
944
944
|
|
|
945
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
945
|
+
Defined in: [data-structures/binary-tree/bst.ts:396](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L396)
|
|
946
946
|
|
|
947
947
|
(Protected) Creates a new BST node.
|
|
948
948
|
|
|
@@ -988,7 +988,7 @@ IBinaryTree.createNode
|
|
|
988
988
|
createTree(options?): this;
|
|
989
989
|
```
|
|
990
990
|
|
|
991
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:408](https://github.com/zrwusa/data-structure-typed/blob/
|
|
991
|
+
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)
|
|
992
992
|
|
|
993
993
|
Creates a new, empty tree of the same type and configuration.
|
|
994
994
|
|
|
@@ -1025,10 +1025,10 @@ IBinaryTree.createTree
|
|
|
1025
1025
|
### delete()
|
|
1026
1026
|
|
|
1027
1027
|
```ts
|
|
1028
|
-
delete(keyNodeEntryRawOrPredicate):
|
|
1028
|
+
delete(keyNodeEntryRawOrPredicate): boolean;
|
|
1029
1029
|
```
|
|
1030
1030
|
|
|
1031
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
1031
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1039](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L1039)
|
|
1032
1032
|
|
|
1033
1033
|
Deletes a node from the tree.
|
|
1034
1034
|
|
|
@@ -1043,15 +1043,15 @@ The node to delete.
|
|
|
1043
1043
|
|
|
1044
1044
|
#### Returns
|
|
1045
1045
|
|
|
1046
|
-
`
|
|
1046
|
+
`boolean`
|
|
1047
1047
|
|
|
1048
|
-
|
|
1048
|
+
True if the node was found and deleted, false otherwise.
|
|
1049
1049
|
|
|
1050
1050
|
*
|
|
1051
1051
|
|
|
1052
1052
|
#### Remarks
|
|
1053
1053
|
|
|
1054
|
-
Time O(
|
|
1054
|
+
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).
|
|
1055
1055
|
|
|
1056
1056
|
#### Example
|
|
1057
1057
|
|
|
@@ -1082,10 +1082,10 @@ deleteWhere(
|
|
|
1082
1082
|
keyNodeEntryOrPredicate,
|
|
1083
1083
|
onlyOne?,
|
|
1084
1084
|
startNode?,
|
|
1085
|
-
iterationType?):
|
|
1085
|
+
iterationType?): boolean;
|
|
1086
1086
|
```
|
|
1087
1087
|
|
|
1088
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
1088
|
+
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)
|
|
1089
1089
|
|
|
1090
1090
|
Deletes nodes that match a key, node, entry, predicate, or range.
|
|
1091
1091
|
|
|
@@ -1140,7 +1140,7 @@ Controls the internal traversal implementation:
|
|
|
1140
1140
|
|
|
1141
1141
|
#### Returns
|
|
1142
1142
|
|
|
1143
|
-
`
|
|
1143
|
+
`boolean`
|
|
1144
1144
|
|
|
1145
1145
|
A Map<K, boolean> containing the deletion results:
|
|
1146
1146
|
- Key: the matched node's key.
|
|
@@ -1192,7 +1192,7 @@ The traversal method.
|
|
|
1192
1192
|
dfs(): (K | undefined)[];
|
|
1193
1193
|
```
|
|
1194
1194
|
|
|
1195
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
1195
|
+
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)
|
|
1196
1196
|
|
|
1197
1197
|
Depth-first search traversal
|
|
1198
1198
|
|
|
@@ -1232,7 +1232,7 @@ dfs<C>(
|
|
|
1232
1232
|
iterationType?): ReturnType<C>[];
|
|
1233
1233
|
```
|
|
1234
1234
|
|
|
1235
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
1235
|
+
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)
|
|
1236
1236
|
|
|
1237
1237
|
Depth-first search traversal
|
|
1238
1238
|
|
|
@@ -1300,7 +1300,7 @@ IBinaryTree.dfs
|
|
|
1300
1300
|
ensureNode(keyNodeOrEntry, iterationType?): OptNode<BSTNode<K, V>>;
|
|
1301
1301
|
```
|
|
1302
1302
|
|
|
1303
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
1303
|
+
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)
|
|
1304
1304
|
|
|
1305
1305
|
Ensures the input is a node. If it's a key or entry, it searches for the node.
|
|
1306
1306
|
|
|
@@ -1344,7 +1344,7 @@ Time O(log N) (height of the tree), O(N) worst-case.
|
|
|
1344
1344
|
entries(): IterableIterator<[K, V | undefined]>;
|
|
1345
1345
|
```
|
|
1346
1346
|
|
|
1347
|
-
Defined in: [data-structures/base/iterable-entry-base.ts:31](https://github.com/zrwusa/data-structure-typed/blob/
|
|
1347
|
+
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)
|
|
1348
1348
|
|
|
1349
1349
|
Iterate over `[key, value]` pairs (may yield `undefined` values).
|
|
1350
1350
|
|
|
@@ -1376,7 +1376,7 @@ IBinaryTree.entries
|
|
|
1376
1376
|
every(predicate, thisArg?): boolean;
|
|
1377
1377
|
```
|
|
1378
1378
|
|
|
1379
|
-
Defined in: [data-structures/base/iterable-entry-base.ts:66](https://github.com/zrwusa/data-structure-typed/blob/
|
|
1379
|
+
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)
|
|
1380
1380
|
|
|
1381
1381
|
Test whether all entries satisfy the predicate.
|
|
1382
1382
|
|
|
@@ -1422,7 +1422,7 @@ IBinaryTree.every
|
|
|
1422
1422
|
filter(predicate, thisArg?): this;
|
|
1423
1423
|
```
|
|
1424
1424
|
|
|
1425
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
1425
|
+
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)
|
|
1426
1426
|
|
|
1427
1427
|
Creates a new tree containing only the entries that satisfy the predicate.
|
|
1428
1428
|
|
|
@@ -1479,7 +1479,7 @@ IBinaryTree.filter
|
|
|
1479
1479
|
find(callbackfn, thisArg?): [K, V | undefined] | undefined;
|
|
1480
1480
|
```
|
|
1481
1481
|
|
|
1482
|
-
Defined in: [data-structures/base/iterable-entry-base.ts:114](https://github.com/zrwusa/data-structure-typed/blob/
|
|
1482
|
+
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)
|
|
1483
1483
|
|
|
1484
1484
|
Find the first entry that matches a predicate.
|
|
1485
1485
|
|
|
@@ -1527,7 +1527,7 @@ IBinaryTree.find
|
|
|
1527
1527
|
floor(keyNodeEntryOrPredicate): K | undefined;
|
|
1528
1528
|
```
|
|
1529
1529
|
|
|
1530
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
1530
|
+
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)
|
|
1531
1531
|
|
|
1532
1532
|
Returns the first key with a value <= target.
|
|
1533
1533
|
Equivalent to Java TreeMap.floor.
|
|
@@ -1570,7 +1570,7 @@ floor<C>(
|
|
|
1570
1570
|
iterationType?): ReturnType<C>;
|
|
1571
1571
|
```
|
|
1572
1572
|
|
|
1573
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
1573
|
+
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)
|
|
1574
1574
|
|
|
1575
1575
|
Returns the first node with a key <= target and applies callback.
|
|
1576
1576
|
Time Complexity: O(log n) average, O(h) worst case.
|
|
@@ -1613,7 +1613,7 @@ Space Complexity: O(h) for recursion, O(1) for iteration.
|
|
|
1613
1613
|
forEach(callbackfn, thisArg?): void;
|
|
1614
1614
|
```
|
|
1615
1615
|
|
|
1616
|
-
Defined in: [data-structures/base/iterable-entry-base.ts:99](https://github.com/zrwusa/data-structure-typed/blob/
|
|
1616
|
+
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)
|
|
1617
1617
|
|
|
1618
1618
|
Visit each entry, left-to-right.
|
|
1619
1619
|
|
|
@@ -1660,7 +1660,7 @@ get(
|
|
|
1660
1660
|
iterationType?): V | undefined;
|
|
1661
1661
|
```
|
|
1662
1662
|
|
|
1663
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
1663
|
+
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)
|
|
1664
1664
|
|
|
1665
1665
|
Gets the value associated with a key.
|
|
1666
1666
|
|
|
@@ -1701,7 +1701,7 @@ The associated value, or undefined.
|
|
|
1701
1701
|
|
|
1702
1702
|
#### Remarks
|
|
1703
1703
|
|
|
1704
|
-
Time O(
|
|
1704
|
+
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).
|
|
1705
1705
|
|
|
1706
1706
|
#### Example
|
|
1707
1707
|
|
|
@@ -1732,7 +1732,7 @@ IBinaryTree.get
|
|
|
1732
1732
|
getByRank(k): K | undefined;
|
|
1733
1733
|
```
|
|
1734
1734
|
|
|
1735
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
1735
|
+
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)
|
|
1736
1736
|
|
|
1737
1737
|
Returns the element at the k-th position in tree order (0-indexed).
|
|
1738
1738
|
|
|
@@ -1775,7 +1775,7 @@ getByRank<C>(
|
|
|
1775
1775
|
iterationType?): ReturnType<C> | undefined;
|
|
1776
1776
|
```
|
|
1777
1777
|
|
|
1778
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
1778
|
+
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)
|
|
1779
1779
|
|
|
1780
1780
|
Returns the element at the k-th position in tree order and applies a callback.
|
|
1781
1781
|
|
|
@@ -1823,7 +1823,7 @@ Time O(log n), Space O(1) iterative / O(log n) recursive. Requires `enableOrderS
|
|
|
1823
1823
|
getDepth(dist, startNode?): number;
|
|
1824
1824
|
```
|
|
1825
1825
|
|
|
1826
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
1826
|
+
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)
|
|
1827
1827
|
|
|
1828
1828
|
Gets the depth of a node (distance from `startNode`).
|
|
1829
1829
|
|
|
@@ -1887,7 +1887,7 @@ IBinaryTree.getDepth
|
|
|
1887
1887
|
getHeight(startNode?, iterationType?): number;
|
|
1888
1888
|
```
|
|
1889
1889
|
|
|
1890
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
1890
|
+
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)
|
|
1891
1891
|
|
|
1892
1892
|
Gets the maximum height of the tree (longest path from startNode to a leaf).
|
|
1893
1893
|
|
|
@@ -1970,7 +1970,7 @@ The traversal method.
|
|
|
1970
1970
|
getLeftMost(): K | undefined;
|
|
1971
1971
|
```
|
|
1972
1972
|
|
|
1973
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
1973
|
+
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)
|
|
1974
1974
|
|
|
1975
1975
|
##### Returns
|
|
1976
1976
|
|
|
@@ -1995,7 +1995,7 @@ getLeftMost<C>(
|
|
|
1995
1995
|
iterationType?): ReturnType<C>;
|
|
1996
1996
|
```
|
|
1997
1997
|
|
|
1998
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
1998
|
+
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)
|
|
1999
1999
|
|
|
2000
2000
|
##### Type Parameters
|
|
2001
2001
|
|
|
@@ -2042,7 +2042,7 @@ IBinaryTree.getLeftMost
|
|
|
2042
2042
|
getMinHeight(startNode?, iterationType?): number;
|
|
2043
2043
|
```
|
|
2044
2044
|
|
|
2045
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
2045
|
+
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)
|
|
2046
2046
|
|
|
2047
2047
|
Gets the minimum height of the tree (shortest path from startNode to a leaf).
|
|
2048
2048
|
|
|
@@ -2094,7 +2094,7 @@ getNode(
|
|
|
2094
2094
|
iterationType?): OptNode<BSTNode<K, V>>;
|
|
2095
2095
|
```
|
|
2096
2096
|
|
|
2097
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
2097
|
+
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)
|
|
2098
2098
|
|
|
2099
2099
|
Gets the first node matching a predicate.
|
|
2100
2100
|
|
|
@@ -2167,7 +2167,7 @@ getNodes(
|
|
|
2167
2167
|
iterationType?): BinaryTreeNode<K, V>[];
|
|
2168
2168
|
```
|
|
2169
2169
|
|
|
2170
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
2170
|
+
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)
|
|
2171
2171
|
|
|
2172
2172
|
Gets all nodes matching a predicate.
|
|
2173
2173
|
|
|
@@ -2262,7 +2262,7 @@ If true, returns the path from root-to-node.
|
|
|
2262
2262
|
getPathToRoot(beginNode): (K | undefined)[];
|
|
2263
2263
|
```
|
|
2264
2264
|
|
|
2265
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
2265
|
+
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)
|
|
2266
2266
|
|
|
2267
2267
|
##### Parameters
|
|
2268
2268
|
|
|
@@ -2297,7 +2297,7 @@ getPathToRoot<C>(
|
|
|
2297
2297
|
isReverse?): ReturnType<C>[];
|
|
2298
2298
|
```
|
|
2299
2299
|
|
|
2300
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
2300
|
+
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)
|
|
2301
2301
|
|
|
2302
2302
|
##### Type Parameters
|
|
2303
2303
|
|
|
@@ -2345,7 +2345,7 @@ IBinaryTree.getPathToRoot
|
|
|
2345
2345
|
getPredecessor(node): BinaryTreeNode<K, V>;
|
|
2346
2346
|
```
|
|
2347
2347
|
|
|
2348
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
2348
|
+
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)
|
|
2349
2349
|
|
|
2350
2350
|
Gets the Morris traversal predecessor (rightmost node in the left subtree, or node itself).
|
|
2351
2351
|
|
|
@@ -2381,7 +2381,7 @@ This is primarily a helper for Morris traversal. Time O(H), where H is the heigh
|
|
|
2381
2381
|
getRank(keyNodeEntryOrPredicate): number;
|
|
2382
2382
|
```
|
|
2383
2383
|
|
|
2384
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
2384
|
+
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)
|
|
2385
2385
|
|
|
2386
2386
|
Returns the 0-based rank of a key (number of elements that precede it in tree order).
|
|
2387
2387
|
|
|
@@ -2415,7 +2415,7 @@ Tree order is defined by the comparator. When the key is not found, returns the
|
|
|
2415
2415
|
getRank(keyNodeEntryOrPredicate, iterationType): number;
|
|
2416
2416
|
```
|
|
2417
2417
|
|
|
2418
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
2418
|
+
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)
|
|
2419
2419
|
|
|
2420
2420
|
Returns the 0-based rank (number of preceding elements in tree order) with explicit iteration type.
|
|
2421
2421
|
|
|
@@ -2480,7 +2480,7 @@ The traversal method.
|
|
|
2480
2480
|
getRightMost(): K | undefined;
|
|
2481
2481
|
```
|
|
2482
2482
|
|
|
2483
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
2483
|
+
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)
|
|
2484
2484
|
|
|
2485
2485
|
##### Returns
|
|
2486
2486
|
|
|
@@ -2505,7 +2505,7 @@ getRightMost<C>(
|
|
|
2505
2505
|
iterationType?): ReturnType<C>;
|
|
2506
2506
|
```
|
|
2507
2507
|
|
|
2508
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
2508
|
+
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)
|
|
2509
2509
|
|
|
2510
2510
|
##### Type Parameters
|
|
2511
2511
|
|
|
@@ -2552,7 +2552,7 @@ IBinaryTree.getRightMost
|
|
|
2552
2552
|
getSuccessor(x?): BinaryTreeNode<K, V> | null | undefined;
|
|
2553
2553
|
```
|
|
2554
2554
|
|
|
2555
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
2555
|
+
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)
|
|
2556
2556
|
|
|
2557
2557
|
Gets the in-order successor of a node in a BST.
|
|
2558
2558
|
|
|
@@ -2589,7 +2589,7 @@ has(
|
|
|
2589
2589
|
iterationType?): boolean;
|
|
2590
2590
|
```
|
|
2591
2591
|
|
|
2592
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
2592
|
+
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)
|
|
2593
2593
|
|
|
2594
2594
|
Checks if a node matching the predicate exists in the tree.
|
|
2595
2595
|
|
|
@@ -2630,7 +2630,7 @@ True if a matching node exists, false otherwise.
|
|
|
2630
2630
|
|
|
2631
2631
|
#### Remarks
|
|
2632
2632
|
|
|
2633
|
-
Time O(
|
|
2633
|
+
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.
|
|
2634
2634
|
|
|
2635
2635
|
#### Example
|
|
2636
2636
|
|
|
@@ -2682,7 +2682,7 @@ IBinaryTree.has
|
|
|
2682
2682
|
hasValue(value): boolean;
|
|
2683
2683
|
```
|
|
2684
2684
|
|
|
2685
|
-
Defined in: [data-structures/base/iterable-entry-base.ts:143](https://github.com/zrwusa/data-structure-typed/blob/
|
|
2685
|
+
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)
|
|
2686
2686
|
|
|
2687
2687
|
Whether there exists an entry with the given value.
|
|
2688
2688
|
|
|
@@ -2724,7 +2724,7 @@ IBinaryTree.hasValue
|
|
|
2724
2724
|
higher(keyNodeEntryOrPredicate): K | undefined;
|
|
2725
2725
|
```
|
|
2726
2726
|
|
|
2727
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
2727
|
+
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)
|
|
2728
2728
|
|
|
2729
2729
|
Returns the first key with a value > target.
|
|
2730
2730
|
Equivalent to Java TreeMap.higher.
|
|
@@ -2766,7 +2766,7 @@ higher<C>(
|
|
|
2766
2766
|
iterationType?): ReturnType<C>;
|
|
2767
2767
|
```
|
|
2768
2768
|
|
|
2769
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
2769
|
+
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)
|
|
2770
2770
|
|
|
2771
2771
|
Returns the first node with a key > target and applies callback.
|
|
2772
2772
|
Time Complexity: O(log n) average, O(h) worst case.
|
|
@@ -2809,7 +2809,7 @@ Space Complexity: O(h) for recursion, O(1) for iteration.
|
|
|
2809
2809
|
isAVLBalanced(iterationType?): boolean;
|
|
2810
2810
|
```
|
|
2811
2811
|
|
|
2812
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
2812
|
+
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)
|
|
2813
2813
|
|
|
2814
2814
|
Checks if the tree meets the AVL balance condition (height difference <= 1).
|
|
2815
2815
|
|
|
@@ -2849,7 +2849,7 @@ Time O(N), as it must visit every node to compute height. Space O(log N) for rec
|
|
|
2849
2849
|
isBST(startNode?, iterationType?): boolean;
|
|
2850
2850
|
```
|
|
2851
2851
|
|
|
2852
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
2852
|
+
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)
|
|
2853
2853
|
|
|
2854
2854
|
Checks if the tree is a valid Binary Search Tree (BST).
|
|
2855
2855
|
|
|
@@ -2909,7 +2909,7 @@ IBinaryTree.isBST
|
|
|
2909
2909
|
isEmpty(): boolean;
|
|
2910
2910
|
```
|
|
2911
2911
|
|
|
2912
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
2912
|
+
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)
|
|
2913
2913
|
|
|
2914
2914
|
Checks if the tree is empty.
|
|
2915
2915
|
|
|
@@ -2950,7 +2950,7 @@ IBinaryTree.isEmpty
|
|
|
2950
2950
|
isEntry(keyNodeOrEntry): keyNodeOrEntry is BTNEntry<K, V>;
|
|
2951
2951
|
```
|
|
2952
2952
|
|
|
2953
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:545](https://github.com/zrwusa/data-structure-typed/blob/
|
|
2953
|
+
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)
|
|
2954
2954
|
|
|
2955
2955
|
Checks if the given item is a [key, value] entry pair.
|
|
2956
2956
|
|
|
@@ -2988,7 +2988,7 @@ Time O(1), Space O(1)
|
|
|
2988
2988
|
isLeaf(keyNodeOrEntry): boolean;
|
|
2989
2989
|
```
|
|
2990
2990
|
|
|
2991
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:531](https://github.com/zrwusa/data-structure-typed/blob/
|
|
2991
|
+
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)
|
|
2992
2992
|
|
|
2993
2993
|
Checks if a node is a leaf (has no real children).
|
|
2994
2994
|
|
|
@@ -3026,7 +3026,7 @@ Time O(N) if a key/entry is passed (due to `ensureNode`). O(1) if a node is pass
|
|
|
3026
3026
|
isNIL(keyNodeOrEntry): boolean;
|
|
3027
3027
|
```
|
|
3028
3028
|
|
|
3029
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:500](https://github.com/zrwusa/data-structure-typed/blob/
|
|
3029
|
+
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)
|
|
3030
3030
|
|
|
3031
3031
|
Checks if the given item is the sentinel NIL node.
|
|
3032
3032
|
|
|
@@ -3064,7 +3064,7 @@ Time O(1), Space O(1)
|
|
|
3064
3064
|
isNode(keyNodeOrEntry): keyNodeOrEntry is BSTNode<K, V>;
|
|
3065
3065
|
```
|
|
3066
3066
|
|
|
3067
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
3067
|
+
Defined in: [data-structures/binary-tree/bst.ts:422](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L422)
|
|
3068
3068
|
|
|
3069
3069
|
Checks if the given item is a `BSTNode` instance.
|
|
3070
3070
|
|
|
@@ -3102,7 +3102,7 @@ Time O(1), Space O(1)
|
|
|
3102
3102
|
isPerfectlyBalanced(startNode?): boolean;
|
|
3103
3103
|
```
|
|
3104
3104
|
|
|
3105
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
3105
|
+
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)
|
|
3106
3106
|
|
|
3107
3107
|
Checks if the tree is perfectly balanced.
|
|
3108
3108
|
|
|
@@ -3145,7 +3145,7 @@ IBinaryTree.isPerfectlyBalanced
|
|
|
3145
3145
|
isRange(keyNodeEntryOrPredicate): keyNodeEntryOrPredicate is Range<K>;
|
|
3146
3146
|
```
|
|
3147
3147
|
|
|
3148
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:511](https://github.com/zrwusa/data-structure-typed/blob/
|
|
3148
|
+
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)
|
|
3149
3149
|
|
|
3150
3150
|
Checks if the given item is a `Range` object.
|
|
3151
3151
|
|
|
@@ -3185,7 +3185,7 @@ Time O(1), Space O(1)
|
|
|
3185
3185
|
isRaw(keyNodeEntryOrRaw): keyNodeEntryOrRaw is R;
|
|
3186
3186
|
```
|
|
3187
3187
|
|
|
3188
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:460](https://github.com/zrwusa/data-structure-typed/blob/
|
|
3188
|
+
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)
|
|
3189
3189
|
|
|
3190
3190
|
Checks if the given item is a raw data object (R) that needs conversion via `toEntryFn`.
|
|
3191
3191
|
|
|
@@ -3224,7 +3224,7 @@ Time O(1), Space O(1)
|
|
|
3224
3224
|
isRealNode(keyNodeOrEntry): keyNodeOrEntry is BinaryTreeNode<K, V>;
|
|
3225
3225
|
```
|
|
3226
3226
|
|
|
3227
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:473](https://github.com/zrwusa/data-structure-typed/blob/
|
|
3227
|
+
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)
|
|
3228
3228
|
|
|
3229
3229
|
Checks if the given item is a "real" node (i.e., not null, undefined, or NIL).
|
|
3230
3230
|
|
|
@@ -3262,7 +3262,7 @@ Time O(1), Space O(1)
|
|
|
3262
3262
|
isRealNodeOrNull(keyNodeOrEntry): keyNodeOrEntry is BinaryTreeNode<K, V> | null;
|
|
3263
3263
|
```
|
|
3264
3264
|
|
|
3265
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:487](https://github.com/zrwusa/data-structure-typed/blob/
|
|
3265
|
+
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)
|
|
3266
3266
|
|
|
3267
3267
|
Checks if the given item is either a "real" node or null.
|
|
3268
3268
|
|
|
@@ -3300,7 +3300,7 @@ Time O(1), Space O(1)
|
|
|
3300
3300
|
isValidKey(key): key is K;
|
|
3301
3301
|
```
|
|
3302
3302
|
|
|
3303
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
3303
|
+
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)
|
|
3304
3304
|
|
|
3305
3305
|
Checks if the given key is valid (comparable).
|
|
3306
3306
|
|
|
@@ -3334,7 +3334,7 @@ Time O(1)
|
|
|
3334
3334
|
keys(): IterableIterator<K>;
|
|
3335
3335
|
```
|
|
3336
3336
|
|
|
3337
|
-
Defined in: [data-structures/base/iterable-entry-base.ts:42](https://github.com/zrwusa/data-structure-typed/blob/
|
|
3337
|
+
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)
|
|
3338
3338
|
|
|
3339
3339
|
Iterate over keys only.
|
|
3340
3340
|
|
|
@@ -3390,7 +3390,7 @@ The traversal method.
|
|
|
3390
3390
|
leaves(): (K | undefined)[];
|
|
3391
3391
|
```
|
|
3392
3392
|
|
|
3393
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
3393
|
+
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)
|
|
3394
3394
|
|
|
3395
3395
|
Get leaf nodes
|
|
3396
3396
|
|
|
@@ -3428,7 +3428,7 @@ leaves<C>(
|
|
|
3428
3428
|
iterationType?): ReturnType<C>[];
|
|
3429
3429
|
```
|
|
3430
3430
|
|
|
3431
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
3431
|
+
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)
|
|
3432
3432
|
|
|
3433
3433
|
Get leaf nodes
|
|
3434
3434
|
|
|
@@ -3516,7 +3516,7 @@ The traversal method.
|
|
|
3516
3516
|
lesserOrGreaterTraverse(): (K | undefined)[];
|
|
3517
3517
|
```
|
|
3518
3518
|
|
|
3519
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
3519
|
+
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)
|
|
3520
3520
|
|
|
3521
3521
|
##### Returns
|
|
3522
3522
|
|
|
@@ -3532,7 +3532,7 @@ lesserOrGreaterTraverse<C>(
|
|
|
3532
3532
|
iterationType?): ReturnType<C>[];
|
|
3533
3533
|
```
|
|
3534
3534
|
|
|
3535
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
3535
|
+
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)
|
|
3536
3536
|
|
|
3537
3537
|
##### Type Parameters
|
|
3538
3538
|
|
|
@@ -3597,7 +3597,7 @@ The traversal method.
|
|
|
3597
3597
|
listLevels(): (K | undefined)[][];
|
|
3598
3598
|
```
|
|
3599
3599
|
|
|
3600
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
3600
|
+
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)
|
|
3601
3601
|
|
|
3602
3602
|
Level-order grouping
|
|
3603
3603
|
|
|
@@ -3613,7 +3613,7 @@ Level-order grouping
|
|
|
3613
3613
|
// Level-order grouping
|
|
3614
3614
|
const bst = new BST<number>([5, 3, 7, 1, 4]);
|
|
3615
3615
|
const levels = bst.listLevels(node => node.key);
|
|
3616
|
-
console.log(levels
|
|
3616
|
+
console.log(levels); // toBeInstanceOf;
|
|
3617
3617
|
console.log(levels[0].length); // 1; // root level has 1 node
|
|
3618
3618
|
const allKeys = levels.flat().sort((a, b) => a - b);
|
|
3619
3619
|
console.log(allKeys); // [1, 3, 4, 5, 7];
|
|
@@ -3638,7 +3638,7 @@ listLevels<C>(
|
|
|
3638
3638
|
iterationType?): ReturnType<C>[][];
|
|
3639
3639
|
```
|
|
3640
3640
|
|
|
3641
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
3641
|
+
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)
|
|
3642
3642
|
|
|
3643
3643
|
Level-order grouping
|
|
3644
3644
|
|
|
@@ -3677,7 +3677,7 @@ Level-order grouping
|
|
|
3677
3677
|
// Level-order grouping
|
|
3678
3678
|
const bst = new BST<number>([5, 3, 7, 1, 4]);
|
|
3679
3679
|
const levels = bst.listLevels(node => node.key);
|
|
3680
|
-
console.log(levels
|
|
3680
|
+
console.log(levels); // toBeInstanceOf;
|
|
3681
3681
|
console.log(levels[0].length); // 1; // root level has 1 node
|
|
3682
3682
|
const allKeys = levels.flat().sort((a, b) => a - b);
|
|
3683
3683
|
console.log(allKeys); // [1, 3, 4, 5, 7];
|
|
@@ -3703,7 +3703,7 @@ IBinaryTree.listLevels
|
|
|
3703
3703
|
lower(keyNodeEntryOrPredicate): K | undefined;
|
|
3704
3704
|
```
|
|
3705
3705
|
|
|
3706
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
3706
|
+
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)
|
|
3707
3707
|
|
|
3708
3708
|
Returns the first key with a value < target.
|
|
3709
3709
|
Equivalent to Java TreeMap.lower.
|
|
@@ -3745,7 +3745,7 @@ lower<C>(
|
|
|
3745
3745
|
iterationType?): ReturnType<C>;
|
|
3746
3746
|
```
|
|
3747
3747
|
|
|
3748
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
3748
|
+
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)
|
|
3749
3749
|
|
|
3750
3750
|
Returns the first node with a key < target and applies callback.
|
|
3751
3751
|
Time Complexity: O(log n) average, O(h) worst case.
|
|
@@ -3791,7 +3791,7 @@ map<MK, MV, MR>(
|
|
|
3791
3791
|
thisArg?): BST<MK, MV, MR>;
|
|
3792
3792
|
```
|
|
3793
3793
|
|
|
3794
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
3794
|
+
Defined in: [data-structures/binary-tree/bst.ts:2642](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L2642)
|
|
3795
3795
|
|
|
3796
3796
|
Creates a new BST by mapping each [key, value] pair to a new entry.
|
|
3797
3797
|
|
|
@@ -3875,7 +3875,7 @@ IBinaryTree.map
|
|
|
3875
3875
|
merge(anotherTree): void;
|
|
3876
3876
|
```
|
|
3877
3877
|
|
|
3878
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
3878
|
+
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)
|
|
3879
3879
|
|
|
3880
3880
|
Merges another tree into this one by seting all its nodes.
|
|
3881
3881
|
|
|
@@ -3949,7 +3949,7 @@ The node to start from.
|
|
|
3949
3949
|
morris(): (K | undefined)[];
|
|
3950
3950
|
```
|
|
3951
3951
|
|
|
3952
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
3952
|
+
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)
|
|
3953
3953
|
|
|
3954
3954
|
Morris traversal (O(1) space)
|
|
3955
3955
|
|
|
@@ -3987,7 +3987,7 @@ morris<C>(
|
|
|
3987
3987
|
startNode?): ReturnType<C>[];
|
|
3988
3988
|
```
|
|
3989
3989
|
|
|
3990
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
3990
|
+
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)
|
|
3991
3991
|
|
|
3992
3992
|
Morris traversal (O(1) space)
|
|
3993
3993
|
|
|
@@ -4047,7 +4047,7 @@ IBinaryTree.morris
|
|
|
4047
4047
|
perfectlyBalance(iterationType?): boolean;
|
|
4048
4048
|
```
|
|
4049
4049
|
|
|
4050
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
4050
|
+
Defined in: [data-structures/binary-tree/bst.ts:2432](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L2432)
|
|
4051
4051
|
|
|
4052
4052
|
Rebuilds the tree to be perfectly balanced.
|
|
4053
4053
|
|
|
@@ -4091,7 +4091,7 @@ Time O(N) (O(N) for DFS, O(N) for sorted build). Space O(N) for node array and r
|
|
|
4091
4091
|
print(options?, startNode?): void;
|
|
4092
4092
|
```
|
|
4093
4093
|
|
|
4094
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
4094
|
+
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)
|
|
4095
4095
|
|
|
4096
4096
|
Prints a visual representation of the tree to the console.
|
|
4097
4097
|
|
|
@@ -4144,7 +4144,7 @@ Time O(N) (via `toVisual`). Space O(N*H) or O(N^2) (via `toVisual`).
|
|
|
4144
4144
|
rangeByRank(start, end): (K | undefined)[];
|
|
4145
4145
|
```
|
|
4146
4146
|
|
|
4147
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
4147
|
+
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)
|
|
4148
4148
|
|
|
4149
4149
|
Returns elements by position range in tree order (0-indexed, inclusive on both ends).
|
|
4150
4150
|
|
|
@@ -4182,7 +4182,7 @@ rangeByRank<C>(
|
|
|
4182
4182
|
iterationType?): ReturnType<C>[];
|
|
4183
4183
|
```
|
|
4184
4184
|
|
|
4185
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
4185
|
+
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)
|
|
4186
4186
|
|
|
4187
4187
|
Returns elements by position range in tree order with callback and optional iteration type.
|
|
4188
4188
|
|
|
@@ -4264,7 +4264,7 @@ The traversal method.
|
|
|
4264
4264
|
rangeSearch(range): (K | undefined)[];
|
|
4265
4265
|
```
|
|
4266
4266
|
|
|
4267
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
4267
|
+
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)
|
|
4268
4268
|
|
|
4269
4269
|
Find all keys in a range
|
|
4270
4270
|
|
|
@@ -4298,7 +4298,7 @@ rangeSearch<C>(
|
|
|
4298
4298
|
iterationType?): ReturnType<C>[];
|
|
4299
4299
|
```
|
|
4300
4300
|
|
|
4301
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
4301
|
+
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)
|
|
4302
4302
|
|
|
4303
4303
|
Find all keys in a range
|
|
4304
4304
|
|
|
@@ -4351,7 +4351,7 @@ Find all keys in a range
|
|
|
4351
4351
|
reduce<U>(callbackfn, initialValue): U;
|
|
4352
4352
|
```
|
|
4353
4353
|
|
|
4354
|
-
Defined in: [data-structures/base/iterable-entry-base.ts:171](https://github.com/zrwusa/data-structure-typed/blob/
|
|
4354
|
+
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)
|
|
4355
4355
|
|
|
4356
4356
|
Reduce entries into a single accumulator.
|
|
4357
4357
|
|
|
@@ -4397,56 +4397,6 @@ IBinaryTree.reduce
|
|
|
4397
4397
|
|
|
4398
4398
|
***
|
|
4399
4399
|
|
|
4400
|
-
### refill()
|
|
4401
|
-
|
|
4402
|
-
```ts
|
|
4403
|
-
refill(keysNodesEntriesOrRaws, values?): void;
|
|
4404
|
-
```
|
|
4405
|
-
|
|
4406
|
-
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)
|
|
4407
|
-
|
|
4408
|
-
Clears the tree and refills it with new items.
|
|
4409
|
-
|
|
4410
|
-
#### Parameters
|
|
4411
|
-
|
|
4412
|
-
##### keysNodesEntriesOrRaws
|
|
4413
|
-
|
|
4414
|
-
`Iterable`\<
|
|
4415
|
-
\| `K`
|
|
4416
|
-
\| `R`
|
|
4417
|
-
\| [`BinaryTreeNode`](BinaryTreeNode.md)\<`K`, `V`\>
|
|
4418
|
-
\| \[`K` \| `null` \| `undefined`, `V` \| `undefined`\]
|
|
4419
|
-
\| `null`
|
|
4420
|
-
\| `undefined`\>
|
|
4421
|
-
|
|
4422
|
-
An iterable of items to set.
|
|
4423
|
-
|
|
4424
|
-
##### values?
|
|
4425
|
-
|
|
4426
|
-
`Iterable`\<`V` \| `undefined`, `any`, `any`\>
|
|
4427
|
-
|
|
4428
|
-
An optional parallel iterable of values.
|
|
4429
|
-
|
|
4430
|
-
#### Returns
|
|
4431
|
-
|
|
4432
|
-
`void`
|
|
4433
|
-
|
|
4434
|
-
#### Remarks
|
|
4435
|
-
|
|
4436
|
-
Time O(N) (for `clear`) + O(N * M) (for `setMany`) = O(N * M). Space O(M) (from `setMany`).
|
|
4437
|
-
|
|
4438
|
-
#### Implementation of
|
|
4439
|
-
|
|
4440
|
-
```ts
|
|
4441
|
-
IBinaryTree.refill
|
|
4442
|
-
```
|
|
4443
|
-
|
|
4444
|
-
#### Inherited from
|
|
4445
|
-
|
|
4446
|
-
[`BinaryTree`](BinaryTree.md).[`refill`](BinaryTree.md#refill)
|
|
4447
|
-
|
|
4448
|
-
***
|
|
4449
|
-
|
|
4450
4400
|
### search()
|
|
4451
4401
|
|
|
4452
4402
|
Searches the tree for nodes matching a predicate, key, or range.
|
|
@@ -4487,7 +4437,7 @@ Whether to use 'RECURSIVE' or 'ITERATIVE' search.
|
|
|
4487
4437
|
search(keyNodeEntryOrPredicate, onlyOne?): (K | undefined)[];
|
|
4488
4438
|
```
|
|
4489
4439
|
|
|
4490
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
4440
|
+
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)
|
|
4491
4441
|
|
|
4492
4442
|
Search nodes by predicate
|
|
4493
4443
|
|
|
@@ -4543,7 +4493,7 @@ search<C>(
|
|
|
4543
4493
|
iterationType?): ReturnType<C>[];
|
|
4544
4494
|
```
|
|
4545
4495
|
|
|
4546
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
4496
|
+
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)
|
|
4547
4497
|
|
|
4548
4498
|
Search nodes by predicate
|
|
4549
4499
|
|
|
@@ -4617,7 +4567,7 @@ IBinaryTree.search
|
|
|
4617
4567
|
set(keyNodeOrEntry, value?): boolean;
|
|
4618
4568
|
```
|
|
4619
4569
|
|
|
4620
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
4570
|
+
Defined in: [data-structures/binary-tree/bst.ts:1573](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L1573)
|
|
4621
4571
|
|
|
4622
4572
|
Adds a new node to the BST based on key comparison.
|
|
4623
4573
|
|
|
@@ -4683,7 +4633,7 @@ setMany(
|
|
|
4683
4633
|
iterationType?): boolean[];
|
|
4684
4634
|
```
|
|
4685
4635
|
|
|
4686
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
4636
|
+
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)
|
|
4687
4637
|
|
|
4688
4638
|
Adds multiple items to the tree.
|
|
4689
4639
|
|
|
@@ -4749,7 +4699,7 @@ Space O(N) for sorting and recursion/iteration stack.
|
|
|
4749
4699
|
some(predicate, thisArg?): boolean;
|
|
4750
4700
|
```
|
|
4751
4701
|
|
|
4752
|
-
Defined in: [data-structures/base/iterable-entry-base.ts:83](https://github.com/zrwusa/data-structure-typed/blob/
|
|
4702
|
+
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)
|
|
4753
4703
|
|
|
4754
4704
|
Test whether any entry satisfies the predicate.
|
|
4755
4705
|
|
|
@@ -4795,7 +4745,7 @@ IBinaryTree.some
|
|
|
4795
4745
|
toArray(): [K, V | undefined][];
|
|
4796
4746
|
```
|
|
4797
4747
|
|
|
4798
|
-
Defined in: [data-structures/base/iterable-entry-base.ts:186](https://github.com/zrwusa/data-structure-typed/blob/
|
|
4748
|
+
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)
|
|
4799
4749
|
|
|
4800
4750
|
Converts data structure to `[key, value]` pairs.
|
|
4801
4751
|
|
|
@@ -4821,7 +4771,7 @@ Time O(n), Space O(n)
|
|
|
4821
4771
|
toVisual(startNode?, options?): string;
|
|
4822
4772
|
```
|
|
4823
4773
|
|
|
4824
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
4774
|
+
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)
|
|
4825
4775
|
|
|
4826
4776
|
Generates a string representation of the tree for visualization.
|
|
4827
4777
|
|
|
@@ -4864,7 +4814,7 @@ Time O(N), visits every node. Space O(N*H) or O(N^2) in the worst case, as the s
|
|
|
4864
4814
|
values(): IterableIterator<V | undefined>;
|
|
4865
4815
|
```
|
|
4866
4816
|
|
|
4867
|
-
Defined in: [data-structures/base/iterable-entry-base.ts:53](https://github.com/zrwusa/data-structure-typed/blob/
|
|
4817
|
+
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)
|
|
4868
4818
|
|
|
4869
4819
|
Iterate over values only.
|
|
4870
4820
|
|
|
@@ -4899,7 +4849,7 @@ IBinaryTree.values
|
|
|
4899
4849
|
protected readonly _comparator: Comparator<K>;
|
|
4900
4850
|
```
|
|
4901
4851
|
|
|
4902
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
4852
|
+
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)
|
|
4903
4853
|
|
|
4904
4854
|
The comparator function used to determine the order of keys in the tree.
|
|
4905
4855
|
|
|
@@ -4915,7 +4865,7 @@ Time O(1) Space O(1)
|
|
|
4915
4865
|
protected readonly _DEFAULT_NODE_CALLBACK: NodeCallback<BinaryTreeNode<K, V> | null | undefined, K | undefined>;
|
|
4916
4866
|
```
|
|
4917
4867
|
|
|
4918
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
4868
|
+
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)
|
|
4919
4869
|
|
|
4920
4870
|
(Protected) Default callback function, returns the node's key.
|
|
4921
4871
|
|
|
@@ -4946,7 +4896,7 @@ protected _bound(
|
|
|
4946
4896
|
iterationType): BSTNode<K, V> | undefined;
|
|
4947
4897
|
```
|
|
4948
4898
|
|
|
4949
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
4899
|
+
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)
|
|
4950
4900
|
|
|
4951
4901
|
(Protected) Core bound search implementation supporting all parameter types.
|
|
4952
4902
|
Unified logic for both lowerBound and upperBound.
|
|
@@ -4994,7 +4944,7 @@ protected _boundByKey(
|
|
|
4994
4944
|
iterationType): BSTNode<K, V> | undefined;
|
|
4995
4945
|
```
|
|
4996
4946
|
|
|
4997
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
4947
|
+
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)
|
|
4998
4948
|
|
|
4999
4949
|
(Protected) Binary search for bound by key with pruning optimization.
|
|
5000
4950
|
Performs standard BST binary search, choosing left or right subtree based on comparator result.
|
|
@@ -5035,7 +4985,7 @@ The first node matching the bound condition, or undefined if none exists.
|
|
|
5035
4985
|
protected _boundByPredicate(predicate, iterationType): BSTNode<K, V> | undefined;
|
|
5036
4986
|
```
|
|
5037
4987
|
|
|
5038
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
4988
|
+
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)
|
|
5039
4989
|
|
|
5040
4990
|
(Protected) In-order traversal search by predicate.
|
|
5041
4991
|
Falls back to linear in-order traversal when predicate-based search is required.
|
|
@@ -5071,7 +5021,7 @@ The first node satisfying predicate, or undefined if none found.
|
|
|
5071
5021
|
protected _clearNodes(): void;
|
|
5072
5022
|
```
|
|
5073
5023
|
|
|
5074
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
5024
|
+
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)
|
|
5075
5025
|
|
|
5076
5026
|
(Protected) Clears all nodes from the tree.
|
|
5077
5027
|
|
|
@@ -5095,7 +5045,7 @@ Time O(1)
|
|
|
5095
5045
|
protected _clearValues(): void;
|
|
5096
5046
|
```
|
|
5097
5047
|
|
|
5098
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
5048
|
+
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)
|
|
5099
5049
|
|
|
5100
5050
|
(Protected) Clears all values from the external store.
|
|
5101
5051
|
|
|
@@ -5119,7 +5069,7 @@ Time O(N)
|
|
|
5119
5069
|
protected _clone(cloned): void;
|
|
5120
5070
|
```
|
|
5121
5071
|
|
|
5122
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
5072
|
+
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)
|
|
5123
5073
|
|
|
5124
5074
|
(Protected) Helper for cloning. Performs a BFS and sets all nodes to the new tree.
|
|
5125
5075
|
|
|
@@ -5151,7 +5101,7 @@ Time O(N * M) (O(N) BFS + O(M) `set` for each node).
|
|
|
5151
5101
|
protected _compare(a, b): number;
|
|
5152
5102
|
```
|
|
5153
5103
|
|
|
5154
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
5104
|
+
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)
|
|
5155
5105
|
|
|
5156
5106
|
(Protected) Compares two keys using the tree's comparator and reverse setting.
|
|
5157
5107
|
|
|
@@ -5187,7 +5137,7 @@ Time O(1) Space O(1)
|
|
|
5187
5137
|
protected _createDefaultComparator(): Comparator<K>;
|
|
5188
5138
|
```
|
|
5189
5139
|
|
|
5190
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
5140
|
+
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)
|
|
5191
5141
|
|
|
5192
5142
|
(Protected) Creates the default comparator function for keys that don't have a custom comparator.
|
|
5193
5143
|
|
|
@@ -5209,7 +5159,7 @@ Time O(1) Space O(1)
|
|
|
5209
5159
|
protected _createInstance<TK, TV, TR>(options?): this;
|
|
5210
5160
|
```
|
|
5211
5161
|
|
|
5212
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
5162
|
+
Defined in: [data-structures/binary-tree/bst.ts:3167](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L3167)
|
|
5213
5163
|
|
|
5214
5164
|
(Protected) Creates a new, empty instance of the same BST constructor.
|
|
5215
5165
|
|
|
@@ -5257,7 +5207,7 @@ Time O(1)
|
|
|
5257
5207
|
protected _createLike<TK, TV, TR>(iter?, options?): BST<TK, TV, TR>;
|
|
5258
5208
|
```
|
|
5259
5209
|
|
|
5260
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
5210
|
+
Defined in: [data-structures/binary-tree/bst.ts:3184](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L3184)
|
|
5261
5211
|
|
|
5262
5212
|
(Protected) Creates a new instance of the same BST constructor, potentially with different generic types.
|
|
5263
5213
|
|
|
@@ -5317,7 +5267,7 @@ Time O(N log N) or O(N^2) (from constructor) due to processing the iterable.
|
|
|
5317
5267
|
protected _deleteByKey(key): boolean;
|
|
5318
5268
|
```
|
|
5319
5269
|
|
|
5320
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
5270
|
+
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)
|
|
5321
5271
|
|
|
5322
5272
|
(Private) Deletes a node by its key.
|
|
5323
5273
|
|
|
@@ -5341,6 +5291,44 @@ Standard BST deletion algorithm. Time O(log N), O(N) worst-case. Space O(1).
|
|
|
5341
5291
|
|
|
5342
5292
|
***
|
|
5343
5293
|
|
|
5294
|
+
### \_deleteInternal()
|
|
5295
|
+
|
|
5296
|
+
```ts
|
|
5297
|
+
protected _deleteInternal(keyNodeEntryRawOrPredicate): BinaryTreeDeleteResult<BinaryTreeNode<K, V>>[];
|
|
5298
|
+
```
|
|
5299
|
+
|
|
5300
|
+
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)
|
|
5301
|
+
|
|
5302
|
+
**`Internal`**
|
|
5303
|
+
|
|
5304
|
+
Deletes a node from the tree (internal, returns balancing metadata).
|
|
5305
|
+
|
|
5306
|
+
#### Parameters
|
|
5307
|
+
|
|
5308
|
+
##### keyNodeEntryRawOrPredicate
|
|
5309
|
+
|
|
5310
|
+
\| `NodePredicate`\<[`BinaryTreeNode`](BinaryTreeNode.md)\<`K`, `V`\> \| `null`\>
|
|
5311
|
+
\| `BTNRep`\<`K`, `V`, [`BinaryTreeNode`](BinaryTreeNode.md)\<`K`, `V`\>\>
|
|
5312
|
+
|
|
5313
|
+
The node to delete.
|
|
5314
|
+
|
|
5315
|
+
#### Returns
|
|
5316
|
+
|
|
5317
|
+
`BinaryTreeDeleteResult`\<[`BinaryTreeNode`](BinaryTreeNode.md)\<`K`, `V`\>\>[]
|
|
5318
|
+
|
|
5319
|
+
An array containing deletion results with balancing metadata.
|
|
5320
|
+
|
|
5321
|
+
#### Remarks
|
|
5322
|
+
|
|
5323
|
+
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).
|
|
5324
|
+
Used by AVL/BST subclasses that need balancing metadata after deletion.
|
|
5325
|
+
|
|
5326
|
+
#### Inherited from
|
|
5327
|
+
|
|
5328
|
+
[`BinaryTree`](BinaryTree.md).[`_deleteInternal`](BinaryTree.md#_deleteinternal)
|
|
5329
|
+
|
|
5330
|
+
***
|
|
5331
|
+
|
|
5344
5332
|
### \_dfs()
|
|
5345
5333
|
|
|
5346
5334
|
```ts
|
|
@@ -5357,7 +5345,7 @@ protected _dfs<C>(
|
|
|
5357
5345
|
shouldProcessRoot?): ReturnType<C>[];
|
|
5358
5346
|
```
|
|
5359
5347
|
|
|
5360
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
5348
|
+
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)
|
|
5361
5349
|
|
|
5362
5350
|
#### Type Parameters
|
|
5363
5351
|
|
|
@@ -5450,7 +5438,7 @@ Array of callback results.
|
|
|
5450
5438
|
protected _displayAux(node, options): NodeDisplayLayout;
|
|
5451
5439
|
```
|
|
5452
5440
|
|
|
5453
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
5441
|
+
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)
|
|
5454
5442
|
|
|
5455
5443
|
(Protected) Recursive helper for `toVisual`.
|
|
5456
5444
|
|
|
@@ -5490,7 +5478,7 @@ Time O(N), Space O(N*H) or O(N^2)
|
|
|
5490
5478
|
protected _ensurePredicate(keyNodeEntryOrPredicate): NodePredicate<BinaryTreeNode<K, V>>;
|
|
5491
5479
|
```
|
|
5492
5480
|
|
|
5493
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
5481
|
+
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)
|
|
5494
5482
|
|
|
5495
5483
|
(Protected) Converts a key, node, entry, or predicate into a standardized predicate function.
|
|
5496
5484
|
|
|
@@ -5529,7 +5517,7 @@ Time O(1)
|
|
|
5529
5517
|
protected _extractKey(keyNodeOrEntry): K | null | undefined;
|
|
5530
5518
|
```
|
|
5531
5519
|
|
|
5532
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
5520
|
+
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)
|
|
5533
5521
|
|
|
5534
5522
|
(Protected) Extracts the key from a key, node, or entry.
|
|
5535
5523
|
|
|
@@ -5567,7 +5555,7 @@ Time O(1)
|
|
|
5567
5555
|
protected _floorByKey(key, iterationType): BSTNode<K, V> | undefined;
|
|
5568
5556
|
```
|
|
5569
5557
|
|
|
5570
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
5558
|
+
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)
|
|
5571
5559
|
|
|
5572
5560
|
(Protected) Binary search for floor by key with pruning optimization.
|
|
5573
5561
|
Performs standard BST binary search, choosing left or right subtree based on comparator result.
|
|
@@ -5605,7 +5593,7 @@ Time O(h) where h is tree height.
|
|
|
5605
5593
|
protected _floorByPredicate(predicate, iterationType): BSTNode<K, V> | undefined;
|
|
5606
5594
|
```
|
|
5607
5595
|
|
|
5608
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
5596
|
+
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)
|
|
5609
5597
|
|
|
5610
5598
|
(Protected) In-order traversal search for floor by predicate.
|
|
5611
5599
|
Falls back to linear in-order traversal when predicate-based search is required.
|
|
@@ -5644,7 +5632,7 @@ Space Complexity: O(h) for recursion, O(h) for iterative stack.
|
|
|
5644
5632
|
protected _getByRankIterative(node, k): BSTNode<K, V> | undefined;
|
|
5645
5633
|
```
|
|
5646
5634
|
|
|
5647
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
5635
|
+
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)
|
|
5648
5636
|
|
|
5649
5637
|
(Protected) Finds the node at position k in tree order (iterative).
|
|
5650
5638
|
|
|
@@ -5674,7 +5662,7 @@ Time O(log n), Space O(1)
|
|
|
5674
5662
|
protected _getByRankRecursive(node, k): BSTNode<K, V> | undefined;
|
|
5675
5663
|
```
|
|
5676
5664
|
|
|
5677
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
5665
|
+
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)
|
|
5678
5666
|
|
|
5679
5667
|
(Protected) Finds the node at position k in tree order (recursive).
|
|
5680
5668
|
|
|
@@ -5704,7 +5692,7 @@ Time O(log n), Space O(log n) call stack
|
|
|
5704
5692
|
protected _getIterator(node?): IterableIterator<[K, V | undefined]>;
|
|
5705
5693
|
```
|
|
5706
5694
|
|
|
5707
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
5695
|
+
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)
|
|
5708
5696
|
|
|
5709
5697
|
(Protected) Gets the iterator for the tree (default in-order).
|
|
5710
5698
|
|
|
@@ -5738,7 +5726,7 @@ Time O(N) for full iteration. O(H) to get the first element. Space O(H) for the
|
|
|
5738
5726
|
protected _getRankIterative(node, key): number;
|
|
5739
5727
|
```
|
|
5740
5728
|
|
|
5741
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
5729
|
+
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)
|
|
5742
5730
|
|
|
5743
5731
|
(Protected) Computes the rank of a key iteratively.
|
|
5744
5732
|
|
|
@@ -5768,7 +5756,7 @@ Time O(log n), Space O(1)
|
|
|
5768
5756
|
protected _getRankRecursive(node, key): number;
|
|
5769
5757
|
```
|
|
5770
5758
|
|
|
5771
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
5759
|
+
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)
|
|
5772
5760
|
|
|
5773
5761
|
(Protected) Computes the rank of a key recursively.
|
|
5774
5762
|
|
|
@@ -5798,7 +5786,7 @@ Time O(log n), Space O(log n) call stack
|
|
|
5798
5786
|
protected _isDisplayLeaf(node, options): boolean;
|
|
5799
5787
|
```
|
|
5800
5788
|
|
|
5801
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
5789
|
+
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)
|
|
5802
5790
|
|
|
5803
5791
|
Check if a node is a display leaf (empty, null, undefined, NIL, or real leaf).
|
|
5804
5792
|
|
|
@@ -5828,7 +5816,7 @@ Check if a node is a display leaf (empty, null, undefined, NIL, or real leaf).
|
|
|
5828
5816
|
protected _isPredicate(p): p is NodePredicate<BinaryTreeNode<K, V>>;
|
|
5829
5817
|
```
|
|
5830
5818
|
|
|
5831
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
5819
|
+
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)
|
|
5832
5820
|
|
|
5833
5821
|
(Protected) Checks if an item is a predicate function.
|
|
5834
5822
|
|
|
@@ -5862,7 +5850,7 @@ Time O(1)
|
|
|
5862
5850
|
protected _keyValueNodeOrEntryToNodeAndValue(keyNodeOrEntry, value?): [OptNode<BSTNode<K, V>>, V | undefined];
|
|
5863
5851
|
```
|
|
5864
5852
|
|
|
5865
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
5853
|
+
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)
|
|
5866
5854
|
|
|
5867
5855
|
(Protected) Converts a key, node, or entry into a standardized [node, value] tuple.
|
|
5868
5856
|
|
|
@@ -5906,7 +5894,7 @@ Time O(1)
|
|
|
5906
5894
|
protected _lowerByKey(key, iterationType): BSTNode<K, V> | undefined;
|
|
5907
5895
|
```
|
|
5908
5896
|
|
|
5909
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
5897
|
+
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)
|
|
5910
5898
|
|
|
5911
5899
|
(Protected) Binary search for lower by key with pruning optimization.
|
|
5912
5900
|
Performs standard BST binary search, choosing left or right subtree based on comparator result.
|
|
@@ -5944,7 +5932,7 @@ Time O(h) where h is tree height.
|
|
|
5944
5932
|
protected _lowerByPredicate(predicate, iterationType): BSTNode<K, V> | undefined;
|
|
5945
5933
|
```
|
|
5946
5934
|
|
|
5947
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
5935
|
+
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)
|
|
5948
5936
|
|
|
5949
5937
|
(Protected) In-order traversal search for lower by predicate.
|
|
5950
5938
|
Falls back to linear in-order traversal when predicate-based search is required.
|
|
@@ -5983,7 +5971,7 @@ Space Complexity: O(h) for recursion, O(h) for iterative stack.
|
|
|
5983
5971
|
protected _next(node): BSTNode<K, V> | undefined;
|
|
5984
5972
|
```
|
|
5985
5973
|
|
|
5986
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
5974
|
+
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)
|
|
5987
5975
|
|
|
5988
5976
|
(Protected) Finds the in-order successor of a node.
|
|
5989
5977
|
|
|
@@ -6009,7 +5997,7 @@ Time O(log n), Space O(1)
|
|
|
6009
5997
|
protected _replaceNode(oldNode, newNode): BinaryTreeNode<K, V>;
|
|
6010
5998
|
```
|
|
6011
5999
|
|
|
6012
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
6000
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:3479](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L3479)
|
|
6013
6001
|
|
|
6014
6002
|
(Protected) Replaces a node in the tree with a new node, maintaining children and parent links.
|
|
6015
6003
|
|
|
@@ -6052,7 +6040,7 @@ protected _resolveDisplayLeaf(
|
|
|
6052
6040
|
emptyDisplayLayout): NodeDisplayLayout;
|
|
6053
6041
|
```
|
|
6054
6042
|
|
|
6055
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
6043
|
+
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)
|
|
6056
6044
|
|
|
6057
6045
|
Resolve a display leaf node to its layout.
|
|
6058
6046
|
|
|
@@ -6086,7 +6074,7 @@ Resolve a display leaf node to its layout.
|
|
|
6086
6074
|
protected _setRoot(v): void;
|
|
6087
6075
|
```
|
|
6088
6076
|
|
|
6089
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
6077
|
+
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)
|
|
6090
6078
|
|
|
6091
6079
|
(Protected) Sets the root node and clears its parent reference.
|
|
6092
6080
|
|
|
@@ -6118,7 +6106,7 @@ Time O(1)
|
|
|
6118
6106
|
protected _setValue(key, value): boolean;
|
|
6119
6107
|
```
|
|
6120
6108
|
|
|
6121
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
6109
|
+
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)
|
|
6122
6110
|
|
|
6123
6111
|
(Protected) Sets a value in the external store (Map mode).
|
|
6124
6112
|
|
|
@@ -6158,7 +6146,7 @@ Time O(1) (average for Map.set).
|
|
|
6158
6146
|
protected _snapshotOptions<TK, TV, TR>(): BSTOptions<TK, TV, TR>;
|
|
6159
6147
|
```
|
|
6160
6148
|
|
|
6161
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
6149
|
+
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)
|
|
6162
6150
|
|
|
6163
6151
|
(Protected) Snapshots the current BST's configuration options.
|
|
6164
6152
|
|
|
@@ -6198,7 +6186,7 @@ Time O(1)
|
|
|
6198
6186
|
protected _swapProperties(srcNode, destNode): BinaryTreeNode<K, V> | undefined;
|
|
6199
6187
|
```
|
|
6200
6188
|
|
|
6201
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
6189
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:3445](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L3445)
|
|
6202
6190
|
|
|
6203
6191
|
(Protected) Swaps the key/value properties of two nodes.
|
|
6204
6192
|
|
|
@@ -6246,7 +6234,7 @@ Time O(1)
|
|
|
6246
6234
|
protected _updateCount(node): void;
|
|
6247
6235
|
```
|
|
6248
6236
|
|
|
6249
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
6237
|
+
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)
|
|
6250
6238
|
|
|
6251
6239
|
(Protected) Recalculates the subtree count for a single node.
|
|
6252
6240
|
|
|
@@ -6272,7 +6260,7 @@ Time O(1). Only active when enableOrderStatistic is true.
|
|
|
6272
6260
|
protected _updateCountAlongPath(node): void;
|
|
6273
6261
|
```
|
|
6274
6262
|
|
|
6275
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
6263
|
+
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)
|
|
6276
6264
|
|
|
6277
6265
|
(Protected) Updates subtree counts from a node up to the root.
|
|
6278
6266
|
|