data-structure-typed 2.5.2 → 2.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +3 -1
- package/MIGRATION.md +169 -0
- package/README.md +60 -6
- package/README_CN.md +551 -143
- package/SPECIFICATION.md +20 -14
- package/SPECIFICATION.zh-CN.md +20 -14
- package/dist/cjs/binary-tree.cjs +2417 -132
- package/dist/cjs/graph.cjs +248 -14
- package/dist/cjs/hash.cjs +62 -7
- package/dist/cjs/heap.cjs +103 -16
- package/dist/cjs/index.cjs +3046 -124
- package/dist/cjs/linked-list.cjs +219 -0
- package/dist/cjs/matrix.cjs +32 -0
- package/dist/cjs/priority-queue.cjs +101 -14
- package/dist/cjs/queue.cjs +215 -0
- package/dist/cjs/stack.cjs +44 -4
- package/dist/cjs/trie.cjs +44 -0
- package/dist/cjs-legacy/binary-tree.cjs +2406 -123
- package/dist/cjs-legacy/graph.cjs +248 -14
- package/dist/cjs-legacy/hash.cjs +62 -7
- package/dist/cjs-legacy/heap.cjs +103 -16
- package/dist/cjs-legacy/index.cjs +3105 -185
- package/dist/cjs-legacy/linked-list.cjs +219 -0
- package/dist/cjs-legacy/matrix.cjs +32 -0
- package/dist/cjs-legacy/priority-queue.cjs +101 -14
- package/dist/cjs-legacy/queue.cjs +215 -0
- package/dist/cjs-legacy/stack.cjs +44 -4
- package/dist/cjs-legacy/trie.cjs +44 -0
- package/dist/esm/binary-tree.mjs +2417 -132
- package/dist/esm/graph.mjs +248 -14
- package/dist/esm/hash.mjs +62 -7
- package/dist/esm/heap.mjs +103 -16
- package/dist/esm/index.mjs +3046 -124
- package/dist/esm/linked-list.mjs +219 -0
- package/dist/esm/matrix.mjs +32 -0
- package/dist/esm/priority-queue.mjs +101 -14
- package/dist/esm/queue.mjs +215 -0
- package/dist/esm/stack.mjs +44 -4
- package/dist/esm/trie.mjs +44 -0
- package/dist/esm-legacy/binary-tree.mjs +2406 -123
- package/dist/esm-legacy/graph.mjs +248 -14
- package/dist/esm-legacy/hash.mjs +62 -7
- package/dist/esm-legacy/heap.mjs +103 -16
- package/dist/esm-legacy/index.mjs +3105 -185
- package/dist/esm-legacy/linked-list.mjs +219 -0
- package/dist/esm-legacy/matrix.mjs +32 -0
- package/dist/esm-legacy/priority-queue.mjs +101 -14
- package/dist/esm-legacy/queue.mjs +215 -0
- package/dist/esm-legacy/stack.mjs +44 -4
- package/dist/esm-legacy/trie.mjs +44 -0
- package/dist/types/data-structures/binary-tree/avl-tree.d.ts +50 -2
- package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +56 -0
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +116 -15
- package/dist/types/data-structures/binary-tree/bst.d.ts +99 -3
- package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +79 -8
- package/dist/types/data-structures/binary-tree/segment-tree.d.ts +24 -0
- package/dist/types/data-structures/binary-tree/tree-map.d.ts +520 -1
- package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +489 -1
- package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +393 -1
- package/dist/types/data-structures/binary-tree/tree-set.d.ts +500 -1
- package/dist/types/data-structures/graph/directed-graph.d.ts +40 -0
- package/dist/types/data-structures/graph/undirected-graph.d.ts +36 -0
- package/dist/types/data-structures/hash/hash-map.d.ts +51 -6
- package/dist/types/data-structures/heap/heap.d.ts +98 -12
- package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +75 -0
- package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +61 -1
- package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +72 -0
- package/dist/types/data-structures/matrix/matrix.d.ts +32 -0
- package/dist/types/data-structures/queue/deque.d.ts +82 -0
- package/dist/types/data-structures/queue/queue.d.ts +61 -0
- package/dist/types/data-structures/stack/stack.d.ts +42 -2
- package/dist/types/data-structures/trie/trie.d.ts +48 -0
- package/dist/types/interfaces/binary-tree.d.ts +2 -3
- package/dist/umd/data-structure-typed.js +3105 -185
- 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 +42 -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/package.json +7 -6
- package/src/data-structures/binary-tree/avl-tree.ts +52 -5
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +56 -0
- package/src/data-structures/binary-tree/binary-tree.ts +167 -81
- package/src/data-structures/binary-tree/bst.ts +101 -7
- package/src/data-structures/binary-tree/red-black-tree.ts +82 -15
- package/src/data-structures/binary-tree/segment-tree.ts +24 -0
- package/src/data-structures/binary-tree/tree-map.ts +540 -3
- package/src/data-structures/binary-tree/tree-multi-map.ts +490 -2
- package/src/data-structures/binary-tree/tree-multi-set.ts +393 -1
- package/src/data-structures/binary-tree/tree-set.ts +520 -3
- package/src/data-structures/graph/directed-graph.ts +41 -1
- package/src/data-structures/graph/undirected-graph.ts +37 -1
- package/src/data-structures/hash/hash-map.ts +67 -12
- package/src/data-structures/heap/heap.ts +107 -19
- package/src/data-structures/linked-list/doubly-linked-list.ts +88 -0
- package/src/data-structures/linked-list/singly-linked-list.ts +61 -1
- package/src/data-structures/linked-list/skip-linked-list.ts +72 -0
- package/src/data-structures/matrix/matrix.ts +32 -0
- package/src/data-structures/queue/deque.ts +85 -0
- package/src/data-structures/queue/queue.ts +73 -0
- package/src/data-structures/stack/stack.ts +45 -5
- package/src/data-structures/trie/trie.ts +48 -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: RedBlackTree\<K, V, R\>
|
|
8
8
|
|
|
9
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:254](https://github.com/zrwusa/data-structure-typed/blob/
|
|
9
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:254](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/red-black-tree.ts#L254)
|
|
10
10
|
|
|
11
11
|
Represents a Red-Black Tree (self-balancing BST) supporting map-like mode and stable O(log n) updates.
|
|
12
12
|
|
|
@@ -132,7 +132,7 @@ Operation complexity depends on the method; see each method's docs.
|
|
|
132
132
|
get comparator(): Comparator<K>;
|
|
133
133
|
```
|
|
134
134
|
|
|
135
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
135
|
+
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)
|
|
136
136
|
|
|
137
137
|
Gets the comparator function used by the tree.
|
|
138
138
|
|
|
@@ -160,7 +160,7 @@ The comparator function.
|
|
|
160
160
|
get isDuplicate(): boolean;
|
|
161
161
|
```
|
|
162
162
|
|
|
163
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:322](https://github.com/zrwusa/data-structure-typed/blob/
|
|
163
|
+
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)
|
|
164
164
|
|
|
165
165
|
Gets whether the tree allows duplicate keys.
|
|
166
166
|
|
|
@@ -194,7 +194,7 @@ IBinaryTree.isDuplicate
|
|
|
194
194
|
get isMapMode(): boolean;
|
|
195
195
|
```
|
|
196
196
|
|
|
197
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:310](https://github.com/zrwusa/data-structure-typed/blob/
|
|
197
|
+
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)
|
|
198
198
|
|
|
199
199
|
Gets whether the tree is in Map mode.
|
|
200
200
|
|
|
@@ -228,7 +228,7 @@ IBinaryTree.isMapMode
|
|
|
228
228
|
get NIL(): BinaryTreeNode<K, V>;
|
|
229
229
|
```
|
|
230
230
|
|
|
231
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:373](https://github.com/zrwusa/data-structure-typed/blob/
|
|
231
|
+
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)
|
|
232
232
|
|
|
233
233
|
Gets the sentinel NIL node (used in self-balancing trees like Red-Black Tree).
|
|
234
234
|
|
|
@@ -262,7 +262,7 @@ IBinaryTree.NIL
|
|
|
262
262
|
get root(): RedBlackTreeNode<K, V> | undefined;
|
|
263
263
|
```
|
|
264
264
|
|
|
265
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:305](https://github.com/zrwusa/data-structure-typed/blob/
|
|
265
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:305](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/red-black-tree.ts#L305)
|
|
266
266
|
|
|
267
267
|
Get the current root node.
|
|
268
268
|
|
|
@@ -296,7 +296,7 @@ IBinaryTree.root
|
|
|
296
296
|
get size(): number;
|
|
297
297
|
```
|
|
298
298
|
|
|
299
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:361](https://github.com/zrwusa/data-structure-typed/blob/
|
|
299
|
+
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)
|
|
300
300
|
|
|
301
301
|
Gets the number of nodes in the tree.
|
|
302
302
|
|
|
@@ -330,7 +330,7 @@ IBinaryTree.size
|
|
|
330
330
|
get store(): Map<K, BinaryTreeNode<K, V>>;
|
|
331
331
|
```
|
|
332
332
|
|
|
333
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:337](https://github.com/zrwusa/data-structure-typed/blob/
|
|
333
|
+
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)
|
|
334
334
|
|
|
335
335
|
Gets the external value store (used in Map mode).
|
|
336
336
|
|
|
@@ -364,7 +364,7 @@ IBinaryTree.store
|
|
|
364
364
|
get toEntryFn(): ToEntryFn<K, V, R> | undefined;
|
|
365
365
|
```
|
|
366
366
|
|
|
367
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:385](https://github.com/zrwusa/data-structure-typed/blob/
|
|
367
|
+
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)
|
|
368
368
|
|
|
369
369
|
Gets the function used to convert raw data objects (R) into [key, value] entries.
|
|
370
370
|
|
|
@@ -396,7 +396,7 @@ IBinaryTree.toEntryFn
|
|
|
396
396
|
iterator: IterableIterator<[K, V | undefined]>;
|
|
397
397
|
```
|
|
398
398
|
|
|
399
|
-
Defined in: [data-structures/base/iterable-entry-base.ts:22](https://github.com/zrwusa/data-structure-typed/blob/
|
|
399
|
+
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)
|
|
400
400
|
|
|
401
401
|
Default iterator yielding `[key, value]` entries.
|
|
402
402
|
|
|
@@ -434,7 +434,7 @@ IBinaryTree.[iterator]
|
|
|
434
434
|
add(keyNodeOrEntry): boolean;
|
|
435
435
|
```
|
|
436
436
|
|
|
437
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
437
|
+
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)
|
|
438
438
|
|
|
439
439
|
Adds a new node to the tree.
|
|
440
440
|
|
|
@@ -460,7 +460,7 @@ True if the addition was successful, false otherwise.
|
|
|
460
460
|
|
|
461
461
|
#### Remarks
|
|
462
462
|
|
|
463
|
-
Time O(
|
|
463
|
+
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).
|
|
464
464
|
|
|
465
465
|
#### Example
|
|
466
466
|
|
|
@@ -492,7 +492,7 @@ IBinaryTree.add
|
|
|
492
492
|
addMany(keysNodesEntriesOrRaws): boolean[];
|
|
493
493
|
```
|
|
494
494
|
|
|
495
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
495
|
+
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)
|
|
496
496
|
|
|
497
497
|
Adds multiple items to the tree.
|
|
498
498
|
|
|
@@ -573,7 +573,7 @@ The traversal method.
|
|
|
573
573
|
bfs(): (K | undefined)[];
|
|
574
574
|
```
|
|
575
575
|
|
|
576
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
576
|
+
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)
|
|
577
577
|
|
|
578
578
|
BinaryTree level-order traversal
|
|
579
579
|
|
|
@@ -611,7 +611,7 @@ bfs<C>(
|
|
|
611
611
|
iterationType?): ReturnType<C>[];
|
|
612
612
|
```
|
|
613
613
|
|
|
614
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
614
|
+
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)
|
|
615
615
|
|
|
616
616
|
BinaryTree level-order traversal
|
|
617
617
|
|
|
@@ -673,7 +673,7 @@ IBinaryTree.bfs
|
|
|
673
673
|
ceiling(keyNodeEntryOrPredicate): K | undefined;
|
|
674
674
|
```
|
|
675
675
|
|
|
676
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
676
|
+
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)
|
|
677
677
|
|
|
678
678
|
Returns the first key with a value >= target.
|
|
679
679
|
Equivalent to Java TreeMap.ceiling.
|
|
@@ -720,7 +720,7 @@ ceiling<C>(
|
|
|
720
720
|
iterationType?): ReturnType<C>;
|
|
721
721
|
```
|
|
722
722
|
|
|
723
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
723
|
+
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)
|
|
724
724
|
|
|
725
725
|
Returns the first node with a key >= target and applies callback.
|
|
726
726
|
Time Complexity: O(log n) average, O(h) worst case.
|
|
@@ -767,9 +767,9 @@ Space Complexity: O(h) for recursion, O(1) for iteration.
|
|
|
767
767
|
clear(): void;
|
|
768
768
|
```
|
|
769
769
|
|
|
770
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:
|
|
770
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:490](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/red-black-tree.ts#L490)
|
|
771
771
|
|
|
772
|
-
Remove all nodes and
|
|
772
|
+
Remove all nodes, clear the key→value store (if in map mode) and internal caches.
|
|
773
773
|
|
|
774
774
|
#### Returns
|
|
775
775
|
|
|
@@ -777,7 +777,7 @@ Remove all nodes and clear internal caches.
|
|
|
777
777
|
|
|
778
778
|
#### Remarks
|
|
779
779
|
|
|
780
|
-
Time O(n)
|
|
780
|
+
Time O(n), Space O(1)
|
|
781
781
|
|
|
782
782
|
*
|
|
783
783
|
|
|
@@ -808,7 +808,7 @@ IBinaryTree.clear
|
|
|
808
808
|
clone(): this;
|
|
809
809
|
```
|
|
810
810
|
|
|
811
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
811
|
+
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)
|
|
812
812
|
|
|
813
813
|
Clones the tree.
|
|
814
814
|
|
|
@@ -855,7 +855,7 @@ createNode(
|
|
|
855
855
|
color?): RedBlackTreeNode<K, V>;
|
|
856
856
|
```
|
|
857
857
|
|
|
858
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:317](https://github.com/zrwusa/data-structure-typed/blob/
|
|
858
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:317](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/red-black-tree.ts#L317)
|
|
859
859
|
|
|
860
860
|
Create a red-black node for the given key/value (value ignored in map mode).
|
|
861
861
|
|
|
@@ -907,7 +907,7 @@ IBinaryTree.createNode
|
|
|
907
907
|
createTree(options?): this;
|
|
908
908
|
```
|
|
909
909
|
|
|
910
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:408](https://github.com/zrwusa/data-structure-typed/blob/
|
|
910
|
+
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)
|
|
911
911
|
|
|
912
912
|
Creates a new, empty tree of the same type and configuration.
|
|
913
913
|
|
|
@@ -944,10 +944,10 @@ IBinaryTree.createTree
|
|
|
944
944
|
### delete()
|
|
945
945
|
|
|
946
946
|
```ts
|
|
947
|
-
delete(keyNodeEntryRawOrPredicate):
|
|
947
|
+
delete(keyNodeEntryRawOrPredicate): boolean;
|
|
948
948
|
```
|
|
949
949
|
|
|
950
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:
|
|
950
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:1267](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/red-black-tree.ts#L1267)
|
|
951
951
|
|
|
952
952
|
Delete a node by key/node/entry and rebalance as needed.
|
|
953
953
|
|
|
@@ -962,7 +962,7 @@ Key, node, or [key, value] entry identifying the node to delete.
|
|
|
962
962
|
|
|
963
963
|
#### Returns
|
|
964
964
|
|
|
965
|
-
`
|
|
965
|
+
`boolean`
|
|
966
966
|
|
|
967
967
|
Array with deletion metadata (removed node, rebalancing hint if any).
|
|
968
968
|
|
|
@@ -1001,10 +1001,10 @@ deleteWhere(
|
|
|
1001
1001
|
keyNodeEntryOrPredicate,
|
|
1002
1002
|
onlyOne?,
|
|
1003
1003
|
startNode?,
|
|
1004
|
-
iterationType?):
|
|
1004
|
+
iterationType?): boolean;
|
|
1005
1005
|
```
|
|
1006
1006
|
|
|
1007
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
1007
|
+
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)
|
|
1008
1008
|
|
|
1009
1009
|
Deletes nodes that match a key, node, entry, predicate, or range.
|
|
1010
1010
|
|
|
@@ -1059,7 +1059,7 @@ Controls the internal traversal implementation:
|
|
|
1059
1059
|
|
|
1060
1060
|
#### Returns
|
|
1061
1061
|
|
|
1062
|
-
`
|
|
1062
|
+
`boolean`
|
|
1063
1063
|
|
|
1064
1064
|
A Map<K, boolean> containing the deletion results:
|
|
1065
1065
|
- Key: the matched node's key.
|
|
@@ -1115,7 +1115,7 @@ The traversal method.
|
|
|
1115
1115
|
dfs(): (K | undefined)[];
|
|
1116
1116
|
```
|
|
1117
1117
|
|
|
1118
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
1118
|
+
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)
|
|
1119
1119
|
|
|
1120
1120
|
Depth-first search traversal
|
|
1121
1121
|
|
|
@@ -1155,7 +1155,7 @@ dfs<C>(
|
|
|
1155
1155
|
iterationType?): ReturnType<C>[];
|
|
1156
1156
|
```
|
|
1157
1157
|
|
|
1158
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
1158
|
+
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)
|
|
1159
1159
|
|
|
1160
1160
|
Depth-first search traversal
|
|
1161
1161
|
|
|
@@ -1223,7 +1223,7 @@ IBinaryTree.dfs
|
|
|
1223
1223
|
ensureNode(keyNodeOrEntry, iterationType?): OptNode<BSTNode<K, V>>;
|
|
1224
1224
|
```
|
|
1225
1225
|
|
|
1226
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
1226
|
+
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)
|
|
1227
1227
|
|
|
1228
1228
|
Ensures the input is a node. If it's a key or entry, it searches for the node.
|
|
1229
1229
|
|
|
@@ -1267,7 +1267,7 @@ Time O(log N) (height of the tree), O(N) worst-case.
|
|
|
1267
1267
|
entries(): IterableIterator<[K, V | undefined]>;
|
|
1268
1268
|
```
|
|
1269
1269
|
|
|
1270
|
-
Defined in: [data-structures/base/iterable-entry-base.ts:31](https://github.com/zrwusa/data-structure-typed/blob/
|
|
1270
|
+
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)
|
|
1271
1271
|
|
|
1272
1272
|
Iterate over `[key, value]` pairs (may yield `undefined` values).
|
|
1273
1273
|
|
|
@@ -1299,7 +1299,7 @@ IBinaryTree.entries
|
|
|
1299
1299
|
every(predicate, thisArg?): boolean;
|
|
1300
1300
|
```
|
|
1301
1301
|
|
|
1302
|
-
Defined in: [data-structures/base/iterable-entry-base.ts:66](https://github.com/zrwusa/data-structure-typed/blob/
|
|
1302
|
+
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)
|
|
1303
1303
|
|
|
1304
1304
|
Test whether all entries satisfy the predicate.
|
|
1305
1305
|
|
|
@@ -1345,7 +1345,7 @@ IBinaryTree.every
|
|
|
1345
1345
|
filter(predicate, thisArg?): this;
|
|
1346
1346
|
```
|
|
1347
1347
|
|
|
1348
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
1348
|
+
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)
|
|
1349
1349
|
|
|
1350
1350
|
Creates a new tree containing only the entries that satisfy the predicate.
|
|
1351
1351
|
|
|
@@ -1402,7 +1402,7 @@ IBinaryTree.filter
|
|
|
1402
1402
|
find(callbackfn, thisArg?): [K, V | undefined] | undefined;
|
|
1403
1403
|
```
|
|
1404
1404
|
|
|
1405
|
-
Defined in: [data-structures/base/iterable-entry-base.ts:114](https://github.com/zrwusa/data-structure-typed/blob/
|
|
1405
|
+
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)
|
|
1406
1406
|
|
|
1407
1407
|
Find the first entry that matches a predicate.
|
|
1408
1408
|
|
|
@@ -1450,7 +1450,7 @@ IBinaryTree.find
|
|
|
1450
1450
|
floor(keyNodeEntryOrPredicate): K | undefined;
|
|
1451
1451
|
```
|
|
1452
1452
|
|
|
1453
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
1453
|
+
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)
|
|
1454
1454
|
|
|
1455
1455
|
Returns the first key with a value <= target.
|
|
1456
1456
|
Equivalent to Java TreeMap.floor.
|
|
@@ -1497,7 +1497,7 @@ floor<C>(
|
|
|
1497
1497
|
iterationType?): ReturnType<C>;
|
|
1498
1498
|
```
|
|
1499
1499
|
|
|
1500
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
1500
|
+
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)
|
|
1501
1501
|
|
|
1502
1502
|
Returns the first node with a key <= target and applies callback.
|
|
1503
1503
|
Time Complexity: O(log n) average, O(h) worst case.
|
|
@@ -1544,7 +1544,7 @@ Space Complexity: O(h) for recursion, O(1) for iteration.
|
|
|
1544
1544
|
forEach(callbackfn, thisArg?): void;
|
|
1545
1545
|
```
|
|
1546
1546
|
|
|
1547
|
-
Defined in: [data-structures/base/iterable-entry-base.ts:99](https://github.com/zrwusa/data-structure-typed/blob/
|
|
1547
|
+
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)
|
|
1548
1548
|
|
|
1549
1549
|
Visit each entry, left-to-right.
|
|
1550
1550
|
|
|
@@ -1591,7 +1591,7 @@ get(
|
|
|
1591
1591
|
iterationType?): V | undefined;
|
|
1592
1592
|
```
|
|
1593
1593
|
|
|
1594
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
1594
|
+
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)
|
|
1595
1595
|
|
|
1596
1596
|
Gets the value associated with a key.
|
|
1597
1597
|
|
|
@@ -1632,7 +1632,7 @@ The associated value, or undefined.
|
|
|
1632
1632
|
|
|
1633
1633
|
#### Remarks
|
|
1634
1634
|
|
|
1635
|
-
Time O(
|
|
1635
|
+
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).
|
|
1636
1636
|
|
|
1637
1637
|
#### Example
|
|
1638
1638
|
|
|
@@ -1663,7 +1663,7 @@ IBinaryTree.get
|
|
|
1663
1663
|
getByRank(k): K | undefined;
|
|
1664
1664
|
```
|
|
1665
1665
|
|
|
1666
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
1666
|
+
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)
|
|
1667
1667
|
|
|
1668
1668
|
Returns the element at the k-th position in tree order (0-indexed).
|
|
1669
1669
|
|
|
@@ -1710,7 +1710,7 @@ getByRank<C>(
|
|
|
1710
1710
|
iterationType?): ReturnType<C> | undefined;
|
|
1711
1711
|
```
|
|
1712
1712
|
|
|
1713
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
1713
|
+
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)
|
|
1714
1714
|
|
|
1715
1715
|
Returns the element at the k-th position in tree order and applies a callback.
|
|
1716
1716
|
|
|
@@ -1762,7 +1762,7 @@ Time O(log n), Space O(1) iterative / O(log n) recursive. Requires `enableOrderS
|
|
|
1762
1762
|
getDepth(dist, startNode?): number;
|
|
1763
1763
|
```
|
|
1764
1764
|
|
|
1765
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
1765
|
+
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)
|
|
1766
1766
|
|
|
1767
1767
|
Gets the depth of a node (distance from `startNode`).
|
|
1768
1768
|
|
|
@@ -1826,7 +1826,7 @@ IBinaryTree.getDepth
|
|
|
1826
1826
|
getHeight(startNode?, iterationType?): number;
|
|
1827
1827
|
```
|
|
1828
1828
|
|
|
1829
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
1829
|
+
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)
|
|
1830
1830
|
|
|
1831
1831
|
Gets the maximum height of the tree (longest path from startNode to a leaf).
|
|
1832
1832
|
|
|
@@ -1909,7 +1909,7 @@ The traversal method.
|
|
|
1909
1909
|
getLeftMost(): K | undefined;
|
|
1910
1910
|
```
|
|
1911
1911
|
|
|
1912
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
1912
|
+
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)
|
|
1913
1913
|
|
|
1914
1914
|
##### Returns
|
|
1915
1915
|
|
|
@@ -1934,7 +1934,7 @@ getLeftMost<C>(
|
|
|
1934
1934
|
iterationType?): ReturnType<C>;
|
|
1935
1935
|
```
|
|
1936
1936
|
|
|
1937
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
1937
|
+
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)
|
|
1938
1938
|
|
|
1939
1939
|
##### Type Parameters
|
|
1940
1940
|
|
|
@@ -1981,7 +1981,7 @@ IBinaryTree.getLeftMost
|
|
|
1981
1981
|
getMinHeight(startNode?, iterationType?): number;
|
|
1982
1982
|
```
|
|
1983
1983
|
|
|
1984
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
1984
|
+
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)
|
|
1985
1985
|
|
|
1986
1986
|
Gets the minimum height of the tree (shortest path from startNode to a leaf).
|
|
1987
1987
|
|
|
@@ -2033,7 +2033,7 @@ getNode(
|
|
|
2033
2033
|
iterationType?): OptNode<BSTNode<K, V>>;
|
|
2034
2034
|
```
|
|
2035
2035
|
|
|
2036
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
2036
|
+
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)
|
|
2037
2037
|
|
|
2038
2038
|
Gets the first node matching a predicate.
|
|
2039
2039
|
|
|
@@ -2106,7 +2106,7 @@ getNodes(
|
|
|
2106
2106
|
iterationType?): BinaryTreeNode<K, V>[];
|
|
2107
2107
|
```
|
|
2108
2108
|
|
|
2109
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
2109
|
+
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)
|
|
2110
2110
|
|
|
2111
2111
|
Gets all nodes matching a predicate.
|
|
2112
2112
|
|
|
@@ -2201,7 +2201,7 @@ If true, returns the path from root-to-node.
|
|
|
2201
2201
|
getPathToRoot(beginNode): (K | undefined)[];
|
|
2202
2202
|
```
|
|
2203
2203
|
|
|
2204
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
2204
|
+
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)
|
|
2205
2205
|
|
|
2206
2206
|
##### Parameters
|
|
2207
2207
|
|
|
@@ -2236,7 +2236,7 @@ getPathToRoot<C>(
|
|
|
2236
2236
|
isReverse?): ReturnType<C>[];
|
|
2237
2237
|
```
|
|
2238
2238
|
|
|
2239
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
2239
|
+
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)
|
|
2240
2240
|
|
|
2241
2241
|
##### Type Parameters
|
|
2242
2242
|
|
|
@@ -2284,7 +2284,7 @@ IBinaryTree.getPathToRoot
|
|
|
2284
2284
|
getPredecessor(node): BinaryTreeNode<K, V>;
|
|
2285
2285
|
```
|
|
2286
2286
|
|
|
2287
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
2287
|
+
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)
|
|
2288
2288
|
|
|
2289
2289
|
Gets the Morris traversal predecessor (rightmost node in the left subtree, or node itself).
|
|
2290
2290
|
|
|
@@ -2320,7 +2320,7 @@ This is primarily a helper for Morris traversal. Time O(H), where H is the heigh
|
|
|
2320
2320
|
getRank(keyNodeEntryOrPredicate): number;
|
|
2321
2321
|
```
|
|
2322
2322
|
|
|
2323
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
2323
|
+
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)
|
|
2324
2324
|
|
|
2325
2325
|
Returns the 0-based rank of a key (number of elements that precede it in tree order).
|
|
2326
2326
|
|
|
@@ -2358,7 +2358,7 @@ Tree order is defined by the comparator. When the key is not found, returns the
|
|
|
2358
2358
|
getRank(keyNodeEntryOrPredicate, iterationType): number;
|
|
2359
2359
|
```
|
|
2360
2360
|
|
|
2361
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
2361
|
+
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)
|
|
2362
2362
|
|
|
2363
2363
|
Returns the 0-based rank (number of preceding elements in tree order) with explicit iteration type.
|
|
2364
2364
|
|
|
@@ -2427,7 +2427,7 @@ The traversal method.
|
|
|
2427
2427
|
getRightMost(): K | undefined;
|
|
2428
2428
|
```
|
|
2429
2429
|
|
|
2430
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
2430
|
+
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)
|
|
2431
2431
|
|
|
2432
2432
|
##### Returns
|
|
2433
2433
|
|
|
@@ -2452,7 +2452,7 @@ getRightMost<C>(
|
|
|
2452
2452
|
iterationType?): ReturnType<C>;
|
|
2453
2453
|
```
|
|
2454
2454
|
|
|
2455
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
2455
|
+
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)
|
|
2456
2456
|
|
|
2457
2457
|
##### Type Parameters
|
|
2458
2458
|
|
|
@@ -2499,7 +2499,7 @@ IBinaryTree.getRightMost
|
|
|
2499
2499
|
getSuccessor(x?): BinaryTreeNode<K, V> | null | undefined;
|
|
2500
2500
|
```
|
|
2501
2501
|
|
|
2502
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
2502
|
+
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)
|
|
2503
2503
|
|
|
2504
2504
|
Gets the in-order successor of a node in a BST.
|
|
2505
2505
|
|
|
@@ -2536,7 +2536,7 @@ has(
|
|
|
2536
2536
|
iterationType?): boolean;
|
|
2537
2537
|
```
|
|
2538
2538
|
|
|
2539
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
2539
|
+
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)
|
|
2540
2540
|
|
|
2541
2541
|
Checks if a node matching the predicate exists in the tree.
|
|
2542
2542
|
|
|
@@ -2577,7 +2577,7 @@ True if a matching node exists, false otherwise.
|
|
|
2577
2577
|
|
|
2578
2578
|
#### Remarks
|
|
2579
2579
|
|
|
2580
|
-
Time O(
|
|
2580
|
+
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.
|
|
2581
2581
|
|
|
2582
2582
|
#### Example
|
|
2583
2583
|
|
|
@@ -2629,7 +2629,7 @@ IBinaryTree.has
|
|
|
2629
2629
|
hasValue(value): boolean;
|
|
2630
2630
|
```
|
|
2631
2631
|
|
|
2632
|
-
Defined in: [data-structures/base/iterable-entry-base.ts:143](https://github.com/zrwusa/data-structure-typed/blob/
|
|
2632
|
+
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)
|
|
2633
2633
|
|
|
2634
2634
|
Whether there exists an entry with the given value.
|
|
2635
2635
|
|
|
@@ -2671,7 +2671,7 @@ IBinaryTree.hasValue
|
|
|
2671
2671
|
higher(keyNodeEntryOrPredicate): K | undefined;
|
|
2672
2672
|
```
|
|
2673
2673
|
|
|
2674
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
2674
|
+
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)
|
|
2675
2675
|
|
|
2676
2676
|
Returns the first key with a value > target.
|
|
2677
2677
|
Equivalent to Java TreeMap.higher.
|
|
@@ -2717,7 +2717,7 @@ higher<C>(
|
|
|
2717
2717
|
iterationType?): ReturnType<C>;
|
|
2718
2718
|
```
|
|
2719
2719
|
|
|
2720
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
2720
|
+
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)
|
|
2721
2721
|
|
|
2722
2722
|
Returns the first node with a key > target and applies callback.
|
|
2723
2723
|
Time Complexity: O(log n) average, O(h) worst case.
|
|
@@ -2764,7 +2764,7 @@ Space Complexity: O(h) for recursion, O(1) for iteration.
|
|
|
2764
2764
|
isAVLBalanced(iterationType?): boolean;
|
|
2765
2765
|
```
|
|
2766
2766
|
|
|
2767
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
2767
|
+
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)
|
|
2768
2768
|
|
|
2769
2769
|
Checks if the tree meets the AVL balance condition (height difference <= 1).
|
|
2770
2770
|
|
|
@@ -2808,7 +2808,7 @@ Time O(N), as it must visit every node to compute height. Space O(log N) for rec
|
|
|
2808
2808
|
isBST(startNode?, iterationType?): boolean;
|
|
2809
2809
|
```
|
|
2810
2810
|
|
|
2811
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
2811
|
+
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)
|
|
2812
2812
|
|
|
2813
2813
|
Checks if the tree is a valid Binary Search Tree (BST).
|
|
2814
2814
|
|
|
@@ -2868,7 +2868,7 @@ IBinaryTree.isBST
|
|
|
2868
2868
|
isEmpty(): boolean;
|
|
2869
2869
|
```
|
|
2870
2870
|
|
|
2871
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
2871
|
+
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)
|
|
2872
2872
|
|
|
2873
2873
|
Checks if the tree is empty.
|
|
2874
2874
|
|
|
@@ -2909,7 +2909,7 @@ IBinaryTree.isEmpty
|
|
|
2909
2909
|
isEntry(keyNodeOrEntry): keyNodeOrEntry is BTNEntry<K, V>;
|
|
2910
2910
|
```
|
|
2911
2911
|
|
|
2912
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:545](https://github.com/zrwusa/data-structure-typed/blob/
|
|
2912
|
+
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)
|
|
2913
2913
|
|
|
2914
2914
|
Checks if the given item is a [key, value] entry pair.
|
|
2915
2915
|
|
|
@@ -2947,7 +2947,7 @@ Time O(1), Space O(1)
|
|
|
2947
2947
|
isLeaf(keyNodeOrEntry): boolean;
|
|
2948
2948
|
```
|
|
2949
2949
|
|
|
2950
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:531](https://github.com/zrwusa/data-structure-typed/blob/
|
|
2950
|
+
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)
|
|
2951
2951
|
|
|
2952
2952
|
Checks if a node is a leaf (has no real children).
|
|
2953
2953
|
|
|
@@ -2985,7 +2985,7 @@ Time O(N) if a key/entry is passed (due to `ensureNode`). O(1) if a node is pass
|
|
|
2985
2985
|
isNIL(keyNodeOrEntry): boolean;
|
|
2986
2986
|
```
|
|
2987
2987
|
|
|
2988
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:500](https://github.com/zrwusa/data-structure-typed/blob/
|
|
2988
|
+
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)
|
|
2989
2989
|
|
|
2990
2990
|
Checks if the given item is the sentinel NIL node.
|
|
2991
2991
|
|
|
@@ -3023,7 +3023,7 @@ Time O(1), Space O(1)
|
|
|
3023
3023
|
isNode(keyNodeOrEntry): keyNodeOrEntry is RedBlackTreeNode<K, V>;
|
|
3024
3024
|
```
|
|
3025
3025
|
|
|
3026
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:328](https://github.com/zrwusa/data-structure-typed/blob/
|
|
3026
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:328](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/red-black-tree.ts#L328)
|
|
3027
3027
|
|
|
3028
3028
|
Type guard: check whether the input is a RedBlackTreeNode.
|
|
3029
3029
|
|
|
@@ -3061,7 +3061,7 @@ Time O(1), Space O(1)
|
|
|
3061
3061
|
isPerfectlyBalanced(startNode?): boolean;
|
|
3062
3062
|
```
|
|
3063
3063
|
|
|
3064
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
3064
|
+
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)
|
|
3065
3065
|
|
|
3066
3066
|
Checks if the tree is perfectly balanced.
|
|
3067
3067
|
|
|
@@ -3104,7 +3104,7 @@ IBinaryTree.isPerfectlyBalanced
|
|
|
3104
3104
|
isRange(keyNodeEntryOrPredicate): keyNodeEntryOrPredicate is Range<K>;
|
|
3105
3105
|
```
|
|
3106
3106
|
|
|
3107
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:511](https://github.com/zrwusa/data-structure-typed/blob/
|
|
3107
|
+
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)
|
|
3108
3108
|
|
|
3109
3109
|
Checks if the given item is a `Range` object.
|
|
3110
3110
|
|
|
@@ -3144,7 +3144,7 @@ Time O(1), Space O(1)
|
|
|
3144
3144
|
isRaw(keyNodeEntryOrRaw): keyNodeEntryOrRaw is R;
|
|
3145
3145
|
```
|
|
3146
3146
|
|
|
3147
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:460](https://github.com/zrwusa/data-structure-typed/blob/
|
|
3147
|
+
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)
|
|
3148
3148
|
|
|
3149
3149
|
Checks if the given item is a raw data object (R) that needs conversion via `toEntryFn`.
|
|
3150
3150
|
|
|
@@ -3183,7 +3183,7 @@ Time O(1), Space O(1)
|
|
|
3183
3183
|
isRealNode(keyNodeOrEntry): keyNodeOrEntry is BinaryTreeNode<K, V>;
|
|
3184
3184
|
```
|
|
3185
3185
|
|
|
3186
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:473](https://github.com/zrwusa/data-structure-typed/blob/
|
|
3186
|
+
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)
|
|
3187
3187
|
|
|
3188
3188
|
Checks if the given item is a "real" node (i.e., not null, undefined, or NIL).
|
|
3189
3189
|
|
|
@@ -3221,7 +3221,7 @@ Time O(1), Space O(1)
|
|
|
3221
3221
|
isRealNodeOrNull(keyNodeOrEntry): keyNodeOrEntry is BinaryTreeNode<K, V> | null;
|
|
3222
3222
|
```
|
|
3223
3223
|
|
|
3224
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:487](https://github.com/zrwusa/data-structure-typed/blob/
|
|
3224
|
+
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)
|
|
3225
3225
|
|
|
3226
3226
|
Checks if the given item is either a "real" node or null.
|
|
3227
3227
|
|
|
@@ -3259,7 +3259,7 @@ Time O(1), Space O(1)
|
|
|
3259
3259
|
isValidKey(key): key is K;
|
|
3260
3260
|
```
|
|
3261
3261
|
|
|
3262
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
3262
|
+
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)
|
|
3263
3263
|
|
|
3264
3264
|
Checks if the given key is valid (comparable).
|
|
3265
3265
|
|
|
@@ -3293,7 +3293,7 @@ Time O(1)
|
|
|
3293
3293
|
keys(): IterableIterator<K>;
|
|
3294
3294
|
```
|
|
3295
3295
|
|
|
3296
|
-
Defined in: [data-structures/base/iterable-entry-base.ts:42](https://github.com/zrwusa/data-structure-typed/blob/
|
|
3296
|
+
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)
|
|
3297
3297
|
|
|
3298
3298
|
Iterate over keys only.
|
|
3299
3299
|
|
|
@@ -3349,7 +3349,7 @@ The traversal method.
|
|
|
3349
3349
|
leaves(): (K | undefined)[];
|
|
3350
3350
|
```
|
|
3351
3351
|
|
|
3352
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
3352
|
+
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)
|
|
3353
3353
|
|
|
3354
3354
|
Get leaf nodes
|
|
3355
3355
|
|
|
@@ -3387,7 +3387,7 @@ leaves<C>(
|
|
|
3387
3387
|
iterationType?): ReturnType<C>[];
|
|
3388
3388
|
```
|
|
3389
3389
|
|
|
3390
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
3390
|
+
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)
|
|
3391
3391
|
|
|
3392
3392
|
Get leaf nodes
|
|
3393
3393
|
|
|
@@ -3475,7 +3475,7 @@ The traversal method.
|
|
|
3475
3475
|
lesserOrGreaterTraverse(): (K | undefined)[];
|
|
3476
3476
|
```
|
|
3477
3477
|
|
|
3478
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
3478
|
+
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)
|
|
3479
3479
|
|
|
3480
3480
|
##### Returns
|
|
3481
3481
|
|
|
@@ -3495,7 +3495,7 @@ lesserOrGreaterTraverse<C>(
|
|
|
3495
3495
|
iterationType?): ReturnType<C>[];
|
|
3496
3496
|
```
|
|
3497
3497
|
|
|
3498
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
3498
|
+
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)
|
|
3499
3499
|
|
|
3500
3500
|
##### Type Parameters
|
|
3501
3501
|
|
|
@@ -3564,7 +3564,7 @@ The traversal method.
|
|
|
3564
3564
|
listLevels(): (K | undefined)[][];
|
|
3565
3565
|
```
|
|
3566
3566
|
|
|
3567
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
3567
|
+
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)
|
|
3568
3568
|
|
|
3569
3569
|
Level-order grouping
|
|
3570
3570
|
|
|
@@ -3580,7 +3580,7 @@ Level-order grouping
|
|
|
3580
3580
|
// Level-order grouping
|
|
3581
3581
|
const bst = new BST<number>([5, 3, 7, 1, 4]);
|
|
3582
3582
|
const levels = bst.listLevels(node => node.key);
|
|
3583
|
-
console.log(levels
|
|
3583
|
+
console.log(levels); // toBeInstanceOf;
|
|
3584
3584
|
console.log(levels[0].length); // 1; // root level has 1 node
|
|
3585
3585
|
const allKeys = levels.flat().sort((a, b) => a - b);
|
|
3586
3586
|
console.log(allKeys); // [1, 3, 4, 5, 7];
|
|
@@ -3605,7 +3605,7 @@ listLevels<C>(
|
|
|
3605
3605
|
iterationType?): ReturnType<C>[][];
|
|
3606
3606
|
```
|
|
3607
3607
|
|
|
3608
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
3608
|
+
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)
|
|
3609
3609
|
|
|
3610
3610
|
Level-order grouping
|
|
3611
3611
|
|
|
@@ -3644,7 +3644,7 @@ Level-order grouping
|
|
|
3644
3644
|
// Level-order grouping
|
|
3645
3645
|
const bst = new BST<number>([5, 3, 7, 1, 4]);
|
|
3646
3646
|
const levels = bst.listLevels(node => node.key);
|
|
3647
|
-
console.log(levels
|
|
3647
|
+
console.log(levels); // toBeInstanceOf;
|
|
3648
3648
|
console.log(levels[0].length); // 1; // root level has 1 node
|
|
3649
3649
|
const allKeys = levels.flat().sort((a, b) => a - b);
|
|
3650
3650
|
console.log(allKeys); // [1, 3, 4, 5, 7];
|
|
@@ -3670,7 +3670,7 @@ IBinaryTree.listLevels
|
|
|
3670
3670
|
lower(keyNodeEntryOrPredicate): K | undefined;
|
|
3671
3671
|
```
|
|
3672
3672
|
|
|
3673
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
3673
|
+
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)
|
|
3674
3674
|
|
|
3675
3675
|
Returns the first key with a value < target.
|
|
3676
3676
|
Equivalent to Java TreeMap.lower.
|
|
@@ -3716,7 +3716,7 @@ lower<C>(
|
|
|
3716
3716
|
iterationType?): ReturnType<C>;
|
|
3717
3717
|
```
|
|
3718
3718
|
|
|
3719
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
3719
|
+
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)
|
|
3720
3720
|
|
|
3721
3721
|
Returns the first node with a key < target and applies callback.
|
|
3722
3722
|
Time Complexity: O(log n) average, O(h) worst case.
|
|
@@ -3766,7 +3766,7 @@ map<MK, MV, MR>(
|
|
|
3766
3766
|
thisArg?): RedBlackTree<MK, MV, MR>;
|
|
3767
3767
|
```
|
|
3768
3768
|
|
|
3769
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:
|
|
3769
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:1652](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/red-black-tree.ts#L1652)
|
|
3770
3770
|
|
|
3771
3771
|
Transform to new tree
|
|
3772
3772
|
|
|
@@ -3831,7 +3831,7 @@ IBinaryTree.map
|
|
|
3831
3831
|
merge(anotherTree): void;
|
|
3832
3832
|
```
|
|
3833
3833
|
|
|
3834
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
3834
|
+
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)
|
|
3835
3835
|
|
|
3836
3836
|
Merges another tree into this one by seting all its nodes.
|
|
3837
3837
|
|
|
@@ -3905,7 +3905,7 @@ The node to start from.
|
|
|
3905
3905
|
morris(): (K | undefined)[];
|
|
3906
3906
|
```
|
|
3907
3907
|
|
|
3908
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
3908
|
+
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)
|
|
3909
3909
|
|
|
3910
3910
|
Morris traversal (O(1) space)
|
|
3911
3911
|
|
|
@@ -3943,7 +3943,7 @@ morris<C>(
|
|
|
3943
3943
|
startNode?): ReturnType<C>[];
|
|
3944
3944
|
```
|
|
3945
3945
|
|
|
3946
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
3946
|
+
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)
|
|
3947
3947
|
|
|
3948
3948
|
Morris traversal (O(1) space)
|
|
3949
3949
|
|
|
@@ -4003,7 +4003,7 @@ IBinaryTree.morris
|
|
|
4003
4003
|
perfectlyBalance(_iterationType?): boolean;
|
|
4004
4004
|
```
|
|
4005
4005
|
|
|
4006
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:
|
|
4006
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:1483](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/red-black-tree.ts#L1483)
|
|
4007
4007
|
|
|
4008
4008
|
Red-Black trees are self-balancing — `perfectlyBalance` rebuilds via
|
|
4009
4009
|
sorted bulk insert, which naturally produces a balanced RBT.
|
|
@@ -4045,7 +4045,7 @@ Time O(N), Space O(N)
|
|
|
4045
4045
|
print(options?, startNode?): void;
|
|
4046
4046
|
```
|
|
4047
4047
|
|
|
4048
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
4048
|
+
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)
|
|
4049
4049
|
|
|
4050
4050
|
Prints a visual representation of the tree to the console.
|
|
4051
4051
|
|
|
@@ -4098,7 +4098,7 @@ Time O(N) (via `toVisual`). Space O(N*H) or O(N^2) (via `toVisual`).
|
|
|
4098
4098
|
rangeByRank(start, end): (K | undefined)[];
|
|
4099
4099
|
```
|
|
4100
4100
|
|
|
4101
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
4101
|
+
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)
|
|
4102
4102
|
|
|
4103
4103
|
Returns elements by position range in tree order (0-indexed, inclusive on both ends).
|
|
4104
4104
|
|
|
@@ -4140,7 +4140,7 @@ rangeByRank<C>(
|
|
|
4140
4140
|
iterationType?): ReturnType<C>[];
|
|
4141
4141
|
```
|
|
4142
4142
|
|
|
4143
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
4143
|
+
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)
|
|
4144
4144
|
|
|
4145
4145
|
Returns elements by position range in tree order with callback and optional iteration type.
|
|
4146
4146
|
|
|
@@ -4226,7 +4226,7 @@ The traversal method.
|
|
|
4226
4226
|
rangeSearch(range): (K | undefined)[];
|
|
4227
4227
|
```
|
|
4228
4228
|
|
|
4229
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
4229
|
+
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)
|
|
4230
4230
|
|
|
4231
4231
|
Find all keys in a range
|
|
4232
4232
|
|
|
@@ -4264,7 +4264,7 @@ rangeSearch<C>(
|
|
|
4264
4264
|
iterationType?): ReturnType<C>[];
|
|
4265
4265
|
```
|
|
4266
4266
|
|
|
4267
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
4267
|
+
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)
|
|
4268
4268
|
|
|
4269
4269
|
Find all keys in a range
|
|
4270
4270
|
|
|
@@ -4321,7 +4321,7 @@ Find all keys in a range
|
|
|
4321
4321
|
reduce<U>(callbackfn, initialValue): U;
|
|
4322
4322
|
```
|
|
4323
4323
|
|
|
4324
|
-
Defined in: [data-structures/base/iterable-entry-base.ts:171](https://github.com/zrwusa/data-structure-typed/blob/
|
|
4324
|
+
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)
|
|
4325
4325
|
|
|
4326
4326
|
Reduce entries into a single accumulator.
|
|
4327
4327
|
|
|
@@ -4367,56 +4367,6 @@ IBinaryTree.reduce
|
|
|
4367
4367
|
|
|
4368
4368
|
***
|
|
4369
4369
|
|
|
4370
|
-
### refill()
|
|
4371
|
-
|
|
4372
|
-
```ts
|
|
4373
|
-
refill(keysNodesEntriesOrRaws, values?): void;
|
|
4374
|
-
```
|
|
4375
|
-
|
|
4376
|
-
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)
|
|
4377
|
-
|
|
4378
|
-
Clears the tree and refills it with new items.
|
|
4379
|
-
|
|
4380
|
-
#### Parameters
|
|
4381
|
-
|
|
4382
|
-
##### keysNodesEntriesOrRaws
|
|
4383
|
-
|
|
4384
|
-
`Iterable`\<
|
|
4385
|
-
\| `K`
|
|
4386
|
-
\| `R`
|
|
4387
|
-
\| \[`K` \| `null` \| `undefined`, `V` \| `undefined`\]
|
|
4388
|
-
\| [`BinaryTreeNode`](BinaryTreeNode.md)\<`K`, `V`\>
|
|
4389
|
-
\| `null`
|
|
4390
|
-
\| `undefined`\>
|
|
4391
|
-
|
|
4392
|
-
An iterable of items to set.
|
|
4393
|
-
|
|
4394
|
-
##### values?
|
|
4395
|
-
|
|
4396
|
-
`Iterable`\<`V` \| `undefined`, `any`, `any`\>
|
|
4397
|
-
|
|
4398
|
-
An optional parallel iterable of values.
|
|
4399
|
-
|
|
4400
|
-
#### Returns
|
|
4401
|
-
|
|
4402
|
-
`void`
|
|
4403
|
-
|
|
4404
|
-
#### Remarks
|
|
4405
|
-
|
|
4406
|
-
Time O(N) (for `clear`) + O(N * M) (for `setMany`) = O(N * M). Space O(M) (from `setMany`).
|
|
4407
|
-
|
|
4408
|
-
#### Implementation of
|
|
4409
|
-
|
|
4410
|
-
```ts
|
|
4411
|
-
IBinaryTree.refill
|
|
4412
|
-
```
|
|
4413
|
-
|
|
4414
|
-
#### Inherited from
|
|
4415
|
-
|
|
4416
|
-
[`BST`](BST.md).[`refill`](BST.md#refill)
|
|
4417
|
-
|
|
4418
|
-
***
|
|
4419
|
-
|
|
4420
4370
|
### search()
|
|
4421
4371
|
|
|
4422
4372
|
Searches the tree for nodes matching a predicate, key, or range.
|
|
@@ -4457,7 +4407,7 @@ Whether to use 'RECURSIVE' or 'ITERATIVE' search.
|
|
|
4457
4407
|
search(keyNodeEntryOrPredicate, onlyOne?): (K | undefined)[];
|
|
4458
4408
|
```
|
|
4459
4409
|
|
|
4460
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
4410
|
+
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)
|
|
4461
4411
|
|
|
4462
4412
|
Search nodes by predicate
|
|
4463
4413
|
|
|
@@ -4513,7 +4463,7 @@ search<C>(
|
|
|
4513
4463
|
iterationType?): ReturnType<C>[];
|
|
4514
4464
|
```
|
|
4515
4465
|
|
|
4516
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
4466
|
+
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)
|
|
4517
4467
|
|
|
4518
4468
|
Search nodes by predicate
|
|
4519
4469
|
|
|
@@ -4587,7 +4537,7 @@ IBinaryTree.search
|
|
|
4587
4537
|
set(keyNodeOrEntry, value?): boolean;
|
|
4588
4538
|
```
|
|
4589
4539
|
|
|
4590
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:
|
|
4540
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:1050](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/red-black-tree.ts#L1050)
|
|
4591
4541
|
|
|
4592
4542
|
Insert or update a key/value (map mode) or key-only (set mode).
|
|
4593
4543
|
|
|
@@ -4662,7 +4612,7 @@ setMany(
|
|
|
4662
4612
|
iterationType?): boolean[];
|
|
4663
4613
|
```
|
|
4664
4614
|
|
|
4665
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
4615
|
+
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)
|
|
4666
4616
|
|
|
4667
4617
|
Adds multiple items to the tree.
|
|
4668
4618
|
|
|
@@ -4731,7 +4681,7 @@ setWithHint(
|
|
|
4731
4681
|
hint?): boolean;
|
|
4732
4682
|
```
|
|
4733
4683
|
|
|
4734
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:
|
|
4684
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:872](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/red-black-tree.ts#L872)
|
|
4735
4685
|
|
|
4736
4686
|
Boolean wrapper for setWithHintNode.
|
|
4737
4687
|
|
|
@@ -4768,7 +4718,7 @@ setWithHintNode(
|
|
|
4768
4718
|
hint?): RedBlackTreeNode<K, V> | undefined;
|
|
4769
4719
|
```
|
|
4770
4720
|
|
|
4771
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:
|
|
4721
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:772](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/red-black-tree.ts#L772)
|
|
4772
4722
|
|
|
4773
4723
|
Insert/update using a hint node to speed up nearby insertions.
|
|
4774
4724
|
|
|
@@ -4809,7 +4759,7 @@ Time O(log n) average, Space O(1)
|
|
|
4809
4759
|
some(predicate, thisArg?): boolean;
|
|
4810
4760
|
```
|
|
4811
4761
|
|
|
4812
|
-
Defined in: [data-structures/base/iterable-entry-base.ts:83](https://github.com/zrwusa/data-structure-typed/blob/
|
|
4762
|
+
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)
|
|
4813
4763
|
|
|
4814
4764
|
Test whether any entry satisfies the predicate.
|
|
4815
4765
|
|
|
@@ -4855,7 +4805,7 @@ IBinaryTree.some
|
|
|
4855
4805
|
toArray(): [K, V | undefined][];
|
|
4856
4806
|
```
|
|
4857
4807
|
|
|
4858
|
-
Defined in: [data-structures/base/iterable-entry-base.ts:186](https://github.com/zrwusa/data-structure-typed/blob/
|
|
4808
|
+
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)
|
|
4859
4809
|
|
|
4860
4810
|
Converts data structure to `[key, value]` pairs.
|
|
4861
4811
|
|
|
@@ -4881,7 +4831,7 @@ Time O(n), Space O(n)
|
|
|
4881
4831
|
toVisual(startNode?, options?): string;
|
|
4882
4832
|
```
|
|
4883
4833
|
|
|
4884
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
4834
|
+
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)
|
|
4885
4835
|
|
|
4886
4836
|
Generates a string representation of the tree for visualization.
|
|
4887
4837
|
|
|
@@ -4924,7 +4874,7 @@ Time O(N), visits every node. Space O(N*H) or O(N^2) in the worst case, as the s
|
|
|
4924
4874
|
values(): IterableIterator<V | undefined>;
|
|
4925
4875
|
```
|
|
4926
4876
|
|
|
4927
|
-
Defined in: [data-structures/base/iterable-entry-base.ts:53](https://github.com/zrwusa/data-structure-typed/blob/
|
|
4877
|
+
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)
|
|
4928
4878
|
|
|
4929
4879
|
Iterate over values only.
|
|
4930
4880
|
|
|
@@ -4959,7 +4909,7 @@ IBinaryTree.values
|
|
|
4959
4909
|
protected readonly _comparator: Comparator<K>;
|
|
4960
4910
|
```
|
|
4961
4911
|
|
|
4962
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
4912
|
+
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)
|
|
4963
4913
|
|
|
4964
4914
|
The comparator function used to determine the order of keys in the tree.
|
|
4965
4915
|
|
|
@@ -4979,7 +4929,7 @@ Time O(1) Space O(1)
|
|
|
4979
4929
|
protected readonly _DEFAULT_NODE_CALLBACK: NodeCallback<BinaryTreeNode<K, V> | null | undefined, K | undefined>;
|
|
4980
4930
|
```
|
|
4981
4931
|
|
|
4982
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
4932
|
+
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)
|
|
4983
4933
|
|
|
4984
4934
|
(Protected) Default callback function, returns the node's key.
|
|
4985
4935
|
|
|
@@ -5007,7 +4957,7 @@ The node's key or undefined.
|
|
|
5007
4957
|
protected _header: RedBlackTreeNode<K, V>;
|
|
5008
4958
|
```
|
|
5009
4959
|
|
|
5010
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:291](https://github.com/zrwusa/data-structure-typed/blob/
|
|
4960
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:291](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/red-black-tree.ts#L291)
|
|
5011
4961
|
|
|
5012
4962
|
(Internal) Header sentinel:
|
|
5013
4963
|
- header.parent -> root
|
|
@@ -5027,7 +4977,7 @@ IMPORTANT:
|
|
|
5027
4977
|
protected _minNode: RedBlackTreeNode<K, V> | undefined;
|
|
5028
4978
|
```
|
|
5029
4979
|
|
|
5030
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:297](https://github.com/zrwusa/data-structure-typed/blob/
|
|
4980
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:297](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/red-black-tree.ts#L297)
|
|
5031
4981
|
|
|
5032
4982
|
(Internal) Cache of the current minimum and maximum nodes.
|
|
5033
4983
|
Used for fast-path insert/update when keys are monotonic or near-boundary.
|
|
@@ -5043,7 +4993,7 @@ protected _attachNewNode(
|
|
|
5043
4993
|
node): void;
|
|
5044
4994
|
```
|
|
5045
4995
|
|
|
5046
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:
|
|
4996
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:571](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/red-black-tree.ts#L571)
|
|
5047
4997
|
|
|
5048
4998
|
(Internal) Attach a new node directly under a known parent/side (no search).
|
|
5049
4999
|
|
|
@@ -5088,7 +5038,7 @@ protected _bound(
|
|
|
5088
5038
|
iterationType): BSTNode<K, V> | undefined;
|
|
5089
5039
|
```
|
|
5090
5040
|
|
|
5091
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
5041
|
+
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)
|
|
5092
5042
|
|
|
5093
5043
|
(Protected) Core bound search implementation supporting all parameter types.
|
|
5094
5044
|
Unified logic for both lowerBound and upperBound.
|
|
@@ -5140,7 +5090,7 @@ protected _boundByKey(
|
|
|
5140
5090
|
iterationType): BSTNode<K, V> | undefined;
|
|
5141
5091
|
```
|
|
5142
5092
|
|
|
5143
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
5093
|
+
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)
|
|
5144
5094
|
|
|
5145
5095
|
(Protected) Binary search for bound by key with pruning optimization.
|
|
5146
5096
|
Performs standard BST binary search, choosing left or right subtree based on comparator result.
|
|
@@ -5185,7 +5135,7 @@ The first node matching the bound condition, or undefined if none exists.
|
|
|
5185
5135
|
protected _boundByPredicate(predicate, iterationType): BSTNode<K, V> | undefined;
|
|
5186
5136
|
```
|
|
5187
5137
|
|
|
5188
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
5138
|
+
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)
|
|
5189
5139
|
|
|
5190
5140
|
(Protected) In-order traversal search by predicate.
|
|
5191
5141
|
Falls back to linear in-order traversal when predicate-based search is required.
|
|
@@ -5225,7 +5175,7 @@ The first node satisfying predicate, or undefined if none found.
|
|
|
5225
5175
|
protected _clearNodes(): void;
|
|
5226
5176
|
```
|
|
5227
5177
|
|
|
5228
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
5178
|
+
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)
|
|
5229
5179
|
|
|
5230
5180
|
(Protected) Clears all nodes from the tree.
|
|
5231
5181
|
|
|
@@ -5249,7 +5199,7 @@ Time O(1)
|
|
|
5249
5199
|
protected _clearValues(): void;
|
|
5250
5200
|
```
|
|
5251
5201
|
|
|
5252
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
5202
|
+
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)
|
|
5253
5203
|
|
|
5254
5204
|
(Protected) Clears all values from the external store.
|
|
5255
5205
|
|
|
@@ -5273,7 +5223,7 @@ Time O(N)
|
|
|
5273
5223
|
protected _clone(cloned): void;
|
|
5274
5224
|
```
|
|
5275
5225
|
|
|
5276
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
5226
|
+
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)
|
|
5277
5227
|
|
|
5278
5228
|
(Protected) Helper for cloning. Performs a BFS and sets all nodes to the new tree.
|
|
5279
5229
|
|
|
@@ -5305,7 +5255,7 @@ Time O(N * M) (O(N) BFS + O(M) `set` for each node).
|
|
|
5305
5255
|
protected _compare(a, b): number;
|
|
5306
5256
|
```
|
|
5307
5257
|
|
|
5308
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
5258
|
+
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)
|
|
5309
5259
|
|
|
5310
5260
|
(Protected) Compares two keys using the tree's comparator and reverse setting.
|
|
5311
5261
|
|
|
@@ -5345,7 +5295,7 @@ Time O(1) Space O(1)
|
|
|
5345
5295
|
protected _createDefaultComparator(): Comparator<K>;
|
|
5346
5296
|
```
|
|
5347
5297
|
|
|
5348
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
5298
|
+
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)
|
|
5349
5299
|
|
|
5350
5300
|
(Protected) Creates the default comparator function for keys that don't have a custom comparator.
|
|
5351
5301
|
|
|
@@ -5371,7 +5321,7 @@ Time O(1) Space O(1)
|
|
|
5371
5321
|
protected _createInstance<TK, TV, TR>(options?): this;
|
|
5372
5322
|
```
|
|
5373
5323
|
|
|
5374
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:
|
|
5324
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:1670](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/red-black-tree.ts#L1670)
|
|
5375
5325
|
|
|
5376
5326
|
(Internal) Create an empty instance of the same concrete tree type.
|
|
5377
5327
|
|
|
@@ -5415,7 +5365,7 @@ Time O(1) average, Space O(1)
|
|
|
5415
5365
|
protected _createLike<TK, TV, TR>(iter?, options?): RedBlackTree<TK, TV, TR>;
|
|
5416
5366
|
```
|
|
5417
5367
|
|
|
5418
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:
|
|
5368
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:1682](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/red-black-tree.ts#L1682)
|
|
5419
5369
|
|
|
5420
5370
|
(Internal) Create a like-kind tree (same concrete class) populated from an iterable.
|
|
5421
5371
|
|
|
@@ -5469,7 +5419,7 @@ Time O(m log m) average (m = iterable length), Space O(m)
|
|
|
5469
5419
|
protected _deleteByKey(key): boolean;
|
|
5470
5420
|
```
|
|
5471
5421
|
|
|
5472
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
5422
|
+
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)
|
|
5473
5423
|
|
|
5474
5424
|
(Private) Deletes a node by its key.
|
|
5475
5425
|
|
|
@@ -5503,7 +5453,7 @@ Standard BST deletion algorithm. Time O(log N), O(N) worst-case. Space O(1).
|
|
|
5503
5453
|
protected _deleteFixup(node): void;
|
|
5504
5454
|
```
|
|
5505
5455
|
|
|
5506
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:
|
|
5456
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:1867](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/red-black-tree.ts#L1867)
|
|
5507
5457
|
|
|
5508
5458
|
(Protected) Restore red-black properties after deletion (recolor/rotate).
|
|
5509
5459
|
|
|
@@ -5527,6 +5477,44 @@ Time O(log n) average, Space O(1)
|
|
|
5527
5477
|
|
|
5528
5478
|
***
|
|
5529
5479
|
|
|
5480
|
+
### \_deleteInternal()
|
|
5481
|
+
|
|
5482
|
+
```ts
|
|
5483
|
+
protected _deleteInternal(keyNodeEntryRawOrPredicate): BinaryTreeDeleteResult<BinaryTreeNode<K, V>>[];
|
|
5484
|
+
```
|
|
5485
|
+
|
|
5486
|
+
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)
|
|
5487
|
+
|
|
5488
|
+
**`Internal`**
|
|
5489
|
+
|
|
5490
|
+
Deletes a node from the tree (internal, returns balancing metadata).
|
|
5491
|
+
|
|
5492
|
+
#### Parameters
|
|
5493
|
+
|
|
5494
|
+
##### keyNodeEntryRawOrPredicate
|
|
5495
|
+
|
|
5496
|
+
\| `BTNRep`\<`K`, `V`, [`BinaryTreeNode`](BinaryTreeNode.md)\<`K`, `V`\>\>
|
|
5497
|
+
\| `NodePredicate`\<[`BinaryTreeNode`](BinaryTreeNode.md)\<`K`, `V`\> \| `null`\>
|
|
5498
|
+
|
|
5499
|
+
The node to delete.
|
|
5500
|
+
|
|
5501
|
+
#### Returns
|
|
5502
|
+
|
|
5503
|
+
`BinaryTreeDeleteResult`\<[`BinaryTreeNode`](BinaryTreeNode.md)\<`K`, `V`\>\>[]
|
|
5504
|
+
|
|
5505
|
+
An array containing deletion results with balancing metadata.
|
|
5506
|
+
|
|
5507
|
+
#### Remarks
|
|
5508
|
+
|
|
5509
|
+
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).
|
|
5510
|
+
Used by AVL/BST subclasses that need balancing metadata after deletion.
|
|
5511
|
+
|
|
5512
|
+
#### Inherited from
|
|
5513
|
+
|
|
5514
|
+
[`BST`](BST.md).[`_deleteInternal`](BST.md#_deleteinternal)
|
|
5515
|
+
|
|
5516
|
+
***
|
|
5517
|
+
|
|
5530
5518
|
### \_dfs()
|
|
5531
5519
|
|
|
5532
5520
|
```ts
|
|
@@ -5543,7 +5531,7 @@ protected _dfs<C>(
|
|
|
5543
5531
|
shouldProcessRoot?): ReturnType<C>[];
|
|
5544
5532
|
```
|
|
5545
5533
|
|
|
5546
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
5534
|
+
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)
|
|
5547
5535
|
|
|
5548
5536
|
#### Type Parameters
|
|
5549
5537
|
|
|
@@ -5636,7 +5624,7 @@ Array of callback results.
|
|
|
5636
5624
|
protected _displayAux(node, options): NodeDisplayLayout;
|
|
5637
5625
|
```
|
|
5638
5626
|
|
|
5639
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
5627
|
+
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)
|
|
5640
5628
|
|
|
5641
5629
|
(Protected) Recursive helper for `toVisual`.
|
|
5642
5630
|
|
|
@@ -5676,7 +5664,7 @@ Time O(N), Space O(N*H) or O(N^2)
|
|
|
5676
5664
|
protected _ensurePredicate(keyNodeEntryOrPredicate): NodePredicate<BinaryTreeNode<K, V>>;
|
|
5677
5665
|
```
|
|
5678
5666
|
|
|
5679
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
5667
|
+
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)
|
|
5680
5668
|
|
|
5681
5669
|
(Protected) Converts a key, node, entry, or predicate into a standardized predicate function.
|
|
5682
5670
|
|
|
@@ -5715,7 +5703,7 @@ Time O(1)
|
|
|
5715
5703
|
protected _extractKey(keyNodeOrEntry): K | null | undefined;
|
|
5716
5704
|
```
|
|
5717
5705
|
|
|
5718
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
5706
|
+
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)
|
|
5719
5707
|
|
|
5720
5708
|
(Protected) Extracts the key from a key, node, or entry.
|
|
5721
5709
|
|
|
@@ -5753,7 +5741,7 @@ Time O(1)
|
|
|
5753
5741
|
protected _findNodeByKey(key): RedBlackTreeNode<K, V> | undefined;
|
|
5754
5742
|
```
|
|
5755
5743
|
|
|
5756
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:
|
|
5744
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:505](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/red-black-tree.ts#L505)
|
|
5757
5745
|
|
|
5758
5746
|
(Internal) Find a node by key using a tight BST walk (no allocations).
|
|
5759
5747
|
|
|
@@ -5781,7 +5769,7 @@ Time O(log n) average, Space O(1)
|
|
|
5781
5769
|
protected _floorByKey(key, iterationType): BSTNode<K, V> | undefined;
|
|
5782
5770
|
```
|
|
5783
5771
|
|
|
5784
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
5772
|
+
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)
|
|
5785
5773
|
|
|
5786
5774
|
(Protected) Binary search for floor by key with pruning optimization.
|
|
5787
5775
|
Performs standard BST binary search, choosing left or right subtree based on comparator result.
|
|
@@ -5823,7 +5811,7 @@ Time O(h) where h is tree height.
|
|
|
5823
5811
|
protected _floorByPredicate(predicate, iterationType): BSTNode<K, V> | undefined;
|
|
5824
5812
|
```
|
|
5825
5813
|
|
|
5826
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
5814
|
+
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)
|
|
5827
5815
|
|
|
5828
5816
|
(Protected) In-order traversal search for floor by predicate.
|
|
5829
5817
|
Falls back to linear in-order traversal when predicate-based search is required.
|
|
@@ -5866,7 +5854,7 @@ Space Complexity: O(h) for recursion, O(h) for iterative stack.
|
|
|
5866
5854
|
protected _getByRankIterative(node, k): BSTNode<K, V> | undefined;
|
|
5867
5855
|
```
|
|
5868
5856
|
|
|
5869
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
5857
|
+
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)
|
|
5870
5858
|
|
|
5871
5859
|
(Protected) Finds the node at position k in tree order (iterative).
|
|
5872
5860
|
|
|
@@ -5900,7 +5888,7 @@ Time O(log n), Space O(1)
|
|
|
5900
5888
|
protected _getByRankRecursive(node, k): BSTNode<K, V> | undefined;
|
|
5901
5889
|
```
|
|
5902
5890
|
|
|
5903
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
5891
|
+
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)
|
|
5904
5892
|
|
|
5905
5893
|
(Protected) Finds the node at position k in tree order (recursive).
|
|
5906
5894
|
|
|
@@ -5934,7 +5922,7 @@ Time O(log n), Space O(log n) call stack
|
|
|
5934
5922
|
protected _getIterator(node?): IterableIterator<[K, V | undefined]>;
|
|
5935
5923
|
```
|
|
5936
5924
|
|
|
5937
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
5925
|
+
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)
|
|
5938
5926
|
|
|
5939
5927
|
(Protected) Gets the iterator for the tree (default in-order).
|
|
5940
5928
|
|
|
@@ -5968,7 +5956,7 @@ Time O(N) for full iteration. O(H) to get the first element. Space O(H) for the
|
|
|
5968
5956
|
protected _getRankIterative(node, key): number;
|
|
5969
5957
|
```
|
|
5970
5958
|
|
|
5971
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
5959
|
+
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)
|
|
5972
5960
|
|
|
5973
5961
|
(Protected) Computes the rank of a key iteratively.
|
|
5974
5962
|
|
|
@@ -6002,7 +5990,7 @@ Time O(log n), Space O(1)
|
|
|
6002
5990
|
protected _getRankRecursive(node, key): number;
|
|
6003
5991
|
```
|
|
6004
5992
|
|
|
6005
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
5993
|
+
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)
|
|
6006
5994
|
|
|
6007
5995
|
(Protected) Computes the rank of a key recursively.
|
|
6008
5996
|
|
|
@@ -6036,7 +6024,7 @@ Time O(log n), Space O(log n) call stack
|
|
|
6036
6024
|
protected _insert(node): CRUD;
|
|
6037
6025
|
```
|
|
6038
6026
|
|
|
6039
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:
|
|
6027
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:1729](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/red-black-tree.ts#L1729)
|
|
6040
6028
|
|
|
6041
6029
|
(Protected) Standard BST insert followed by red-black fix-up.
|
|
6042
6030
|
|
|
@@ -6066,7 +6054,7 @@ Time O(log n) average, Space O(1)
|
|
|
6066
6054
|
protected _insertFixup(z): void;
|
|
6067
6055
|
```
|
|
6068
6056
|
|
|
6069
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:
|
|
6057
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:1798](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/red-black-tree.ts#L1798)
|
|
6070
6058
|
|
|
6071
6059
|
(Protected) Restore red-black properties after insertion (recolor/rotate).
|
|
6072
6060
|
|
|
@@ -6096,7 +6084,7 @@ Time O(log n) average, Space O(1)
|
|
|
6096
6084
|
protected _isDisplayLeaf(node, options): boolean;
|
|
6097
6085
|
```
|
|
6098
6086
|
|
|
6099
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
6087
|
+
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)
|
|
6100
6088
|
|
|
6101
6089
|
Check if a node is a display leaf (empty, null, undefined, NIL, or real leaf).
|
|
6102
6090
|
|
|
@@ -6126,7 +6114,7 @@ Check if a node is a display leaf (empty, null, undefined, NIL, or real leaf).
|
|
|
6126
6114
|
protected _isPredicate(p): p is NodePredicate<BinaryTreeNode<K, V>>;
|
|
6127
6115
|
```
|
|
6128
6116
|
|
|
6129
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
6117
|
+
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)
|
|
6130
6118
|
|
|
6131
6119
|
(Protected) Checks if an item is a predicate function.
|
|
6132
6120
|
|
|
@@ -6160,7 +6148,7 @@ Time O(1)
|
|
|
6160
6148
|
protected _keyValueNodeOrEntryToNodeAndValue(keyNodeOrEntry, value?): [OptNode<BSTNode<K, V>>, V | undefined];
|
|
6161
6149
|
```
|
|
6162
6150
|
|
|
6163
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
6151
|
+
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)
|
|
6164
6152
|
|
|
6165
6153
|
(Protected) Converts a key, node, or entry into a standardized [node, value] tuple.
|
|
6166
6154
|
|
|
@@ -6204,7 +6192,7 @@ Time O(1)
|
|
|
6204
6192
|
protected _leftRotate(x): void;
|
|
6205
6193
|
```
|
|
6206
6194
|
|
|
6207
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:
|
|
6195
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:1946](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/red-black-tree.ts#L1946)
|
|
6208
6196
|
|
|
6209
6197
|
(Protected) Perform a left rotation around x.
|
|
6210
6198
|
|
|
@@ -6234,7 +6222,7 @@ Time O(1), Space O(1)
|
|
|
6234
6222
|
protected _lowerByKey(key, iterationType): BSTNode<K, V> | undefined;
|
|
6235
6223
|
```
|
|
6236
6224
|
|
|
6237
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
6225
|
+
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)
|
|
6238
6226
|
|
|
6239
6227
|
(Protected) Binary search for lower by key with pruning optimization.
|
|
6240
6228
|
Performs standard BST binary search, choosing left or right subtree based on comparator result.
|
|
@@ -6276,7 +6264,7 @@ Time O(h) where h is tree height.
|
|
|
6276
6264
|
protected _lowerByPredicate(predicate, iterationType): BSTNode<K, V> | undefined;
|
|
6277
6265
|
```
|
|
6278
6266
|
|
|
6279
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
6267
|
+
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)
|
|
6280
6268
|
|
|
6281
6269
|
(Protected) In-order traversal search for lower by predicate.
|
|
6282
6270
|
Falls back to linear in-order traversal when predicate-based search is required.
|
|
@@ -6319,7 +6307,7 @@ Space Complexity: O(h) for recursion, O(h) for iterative stack.
|
|
|
6319
6307
|
protected _next(node): BSTNode<K, V> | undefined;
|
|
6320
6308
|
```
|
|
6321
6309
|
|
|
6322
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
6310
|
+
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)
|
|
6323
6311
|
|
|
6324
6312
|
(Protected) Finds the in-order successor of a node.
|
|
6325
6313
|
|
|
@@ -6349,7 +6337,7 @@ Time O(log n), Space O(1)
|
|
|
6349
6337
|
protected _predecessorOf(node): RedBlackTreeNode<K, V> | undefined;
|
|
6350
6338
|
```
|
|
6351
6339
|
|
|
6352
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:
|
|
6340
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:523](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/red-black-tree.ts#L523)
|
|
6353
6341
|
|
|
6354
6342
|
(Internal) In-order predecessor of a node in a BST.
|
|
6355
6343
|
|
|
@@ -6375,7 +6363,7 @@ Time O(log n) average, Space O(1)
|
|
|
6375
6363
|
protected _replaceNode(oldNode, newNode): RedBlackTreeNode<K, V>;
|
|
6376
6364
|
```
|
|
6377
6365
|
|
|
6378
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:
|
|
6366
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:1714](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/red-black-tree.ts#L1714)
|
|
6379
6367
|
|
|
6380
6368
|
(Internal) Replace a node in place while preserving its color.
|
|
6381
6369
|
|
|
@@ -6412,7 +6400,7 @@ protected _resolveDisplayLeaf(
|
|
|
6412
6400
|
emptyDisplayLayout): NodeDisplayLayout;
|
|
6413
6401
|
```
|
|
6414
6402
|
|
|
6415
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
6403
|
+
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)
|
|
6416
6404
|
|
|
6417
6405
|
Resolve a display leaf node to its layout.
|
|
6418
6406
|
|
|
@@ -6446,7 +6434,7 @@ Resolve a display leaf node to its layout.
|
|
|
6446
6434
|
protected _rightRotate(y): void;
|
|
6447
6435
|
```
|
|
6448
6436
|
|
|
6449
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:
|
|
6437
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:1982](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/red-black-tree.ts#L1982)
|
|
6450
6438
|
|
|
6451
6439
|
(Protected) Perform a right rotation around y.
|
|
6452
6440
|
|
|
@@ -6476,7 +6464,7 @@ Time O(1), Space O(1)
|
|
|
6476
6464
|
protected _setKV(key, nextValue?): boolean;
|
|
6477
6465
|
```
|
|
6478
6466
|
|
|
6479
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:
|
|
6467
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:748](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/red-black-tree.ts#L748)
|
|
6480
6468
|
|
|
6481
6469
|
(Internal) Boolean wrapper around `_setKVNode`.
|
|
6482
6470
|
|
|
@@ -6517,7 +6505,7 @@ protected _setKVNode(key, nextValue?):
|
|
|
6517
6505
|
| undefined;
|
|
6518
6506
|
```
|
|
6519
6507
|
|
|
6520
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:
|
|
6508
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:621](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/red-black-tree.ts#L621)
|
|
6521
6509
|
|
|
6522
6510
|
(Internal) Core set implementation returning the affected node.
|
|
6523
6511
|
|
|
@@ -6561,7 +6549,7 @@ Time O(log n) average, Space O(1)
|
|
|
6561
6549
|
protected _setMaxCache(node): void;
|
|
6562
6550
|
```
|
|
6563
6551
|
|
|
6564
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:
|
|
6552
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:602](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/red-black-tree.ts#L602)
|
|
6565
6553
|
|
|
6566
6554
|
(Internal) Update max cache pointers (header._right is the canonical max pointer).
|
|
6567
6555
|
|
|
@@ -6587,7 +6575,7 @@ Time O(1), Space O(1)
|
|
|
6587
6575
|
protected _setMinCache(node): void;
|
|
6588
6576
|
```
|
|
6589
6577
|
|
|
6590
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:
|
|
6578
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:593](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/red-black-tree.ts#L593)
|
|
6591
6579
|
|
|
6592
6580
|
(Internal) Update min cache pointers (header._left is the canonical min pointer).
|
|
6593
6581
|
|
|
@@ -6613,7 +6601,7 @@ Time O(1), Space O(1)
|
|
|
6613
6601
|
protected _setRoot(v): void;
|
|
6614
6602
|
```
|
|
6615
6603
|
|
|
6616
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:
|
|
6604
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:1699](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/red-black-tree.ts#L1699)
|
|
6617
6605
|
|
|
6618
6606
|
(Internal) Set the root pointer and keep header.parent in sync.
|
|
6619
6607
|
|
|
@@ -6643,7 +6631,7 @@ Time O(1), Space O(1)
|
|
|
6643
6631
|
protected _setValue(key, value): boolean;
|
|
6644
6632
|
```
|
|
6645
6633
|
|
|
6646
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
6634
|
+
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)
|
|
6647
6635
|
|
|
6648
6636
|
(Protected) Sets a value in the external store (Map mode).
|
|
6649
6637
|
|
|
@@ -6683,7 +6671,7 @@ Time O(1) (average for Map.set).
|
|
|
6683
6671
|
protected _snapshotOptions<TK, TV, TR>(): BSTOptions<TK, TV, TR>;
|
|
6684
6672
|
```
|
|
6685
6673
|
|
|
6686
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
6674
|
+
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)
|
|
6687
6675
|
|
|
6688
6676
|
(Protected) Snapshots the current BST's configuration options.
|
|
6689
6677
|
|
|
@@ -6723,7 +6711,7 @@ Time O(1)
|
|
|
6723
6711
|
protected _successorOf(node): RedBlackTreeNode<K, V> | undefined;
|
|
6724
6712
|
```
|
|
6725
6713
|
|
|
6726
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:
|
|
6714
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:543](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/red-black-tree.ts#L543)
|
|
6727
6715
|
|
|
6728
6716
|
(Internal) In-order successor of a node in a BST.
|
|
6729
6717
|
|
|
@@ -6749,7 +6737,7 @@ Time O(log n) average, Space O(1)
|
|
|
6749
6737
|
protected _swapProperties(srcNode, destNode): BinaryTreeNode<K, V> | undefined;
|
|
6750
6738
|
```
|
|
6751
6739
|
|
|
6752
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
6740
|
+
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)
|
|
6753
6741
|
|
|
6754
6742
|
(Protected) Swaps the key/value properties of two nodes.
|
|
6755
6743
|
|
|
@@ -6797,7 +6785,7 @@ Time O(1)
|
|
|
6797
6785
|
protected _transplant(u, v): void;
|
|
6798
6786
|
```
|
|
6799
6787
|
|
|
6800
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:
|
|
6788
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:1778](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/red-black-tree.ts#L1778)
|
|
6801
6789
|
|
|
6802
6790
|
(Protected) Transplant a subtree in place of another during deletion.
|
|
6803
6791
|
|
|
@@ -6833,7 +6821,7 @@ Time O(1), Space O(1)
|
|
|
6833
6821
|
protected _updateCount(node): void;
|
|
6834
6822
|
```
|
|
6835
6823
|
|
|
6836
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
6824
|
+
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)
|
|
6837
6825
|
|
|
6838
6826
|
(Protected) Recalculates the subtree count for a single node.
|
|
6839
6827
|
|
|
@@ -6863,7 +6851,7 @@ Time O(1). Only active when enableOrderStatistic is true.
|
|
|
6863
6851
|
protected _updateCountAlongPath(node): void;
|
|
6864
6852
|
```
|
|
6865
6853
|
|
|
6866
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
6854
|
+
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)
|
|
6867
6855
|
|
|
6868
6856
|
(Protected) Updates subtree counts from a node up to the root.
|
|
6869
6857
|
|