data-structure-typed 2.6.0 → 2.6.2
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/.github/workflows/ci.yml +7 -2
- package/.github/workflows/release-package.yml +9 -2
- package/CHANGELOG.md +9 -1
- package/dist/cjs/binary-tree.cjs +2927 -23688
- package/dist/cjs/graph.cjs +845 -2634
- package/dist/cjs/hash.cjs +185 -616
- package/dist/cjs/heap.cjs +266 -818
- package/dist/cjs/index.cjs +5116 -31358
- package/dist/cjs/linked-list.cjs +644 -2615
- package/dist/cjs/matrix.cjs +220 -535
- package/dist/cjs/priority-queue.cjs +266 -818
- package/dist/cjs/queue.cjs +637 -2343
- package/dist/cjs/stack.cjs +124 -530
- package/dist/cjs/trie.cjs +145 -592
- package/dist/cjs-legacy/binary-tree.cjs +4352 -25113
- package/dist/cjs-legacy/graph.cjs +847 -2636
- package/dist/cjs-legacy/hash.cjs +181 -612
- package/dist/cjs-legacy/heap.cjs +266 -818
- package/dist/cjs-legacy/index.cjs +6657 -32899
- package/dist/cjs-legacy/linked-list.cjs +640 -2611
- package/dist/cjs-legacy/matrix.cjs +220 -535
- package/dist/cjs-legacy/priority-queue.cjs +266 -818
- package/dist/cjs-legacy/queue.cjs +634 -2340
- package/dist/cjs-legacy/stack.cjs +124 -530
- package/dist/cjs-legacy/trie.cjs +145 -592
- package/dist/esm/binary-tree.mjs +2927 -23688
- package/dist/esm/graph.mjs +845 -2634
- package/dist/esm/hash.mjs +185 -616
- package/dist/esm/heap.mjs +266 -818
- package/dist/esm/index.mjs +5116 -31358
- package/dist/esm/linked-list.mjs +644 -2615
- package/dist/esm/matrix.mjs +220 -535
- package/dist/esm/priority-queue.mjs +266 -818
- package/dist/esm/queue.mjs +637 -2343
- package/dist/esm/stack.mjs +124 -530
- package/dist/esm/trie.mjs +145 -592
- package/dist/esm-legacy/binary-tree.mjs +4352 -25113
- package/dist/esm-legacy/graph.mjs +847 -2636
- package/dist/esm-legacy/hash.mjs +181 -612
- package/dist/esm-legacy/heap.mjs +266 -818
- package/dist/esm-legacy/index.mjs +6657 -32899
- package/dist/esm-legacy/linked-list.mjs +640 -2611
- package/dist/esm-legacy/matrix.mjs +220 -535
- package/dist/esm-legacy/priority-queue.mjs +266 -818
- package/dist/esm-legacy/queue.mjs +634 -2340
- package/dist/esm-legacy/stack.mjs +124 -530
- package/dist/esm-legacy/trie.mjs +145 -592
- package/dist/types/data-structures/binary-tree/avl-tree.d.ts +29 -500
- package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +38 -563
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +230 -1212
- package/dist/types/data-structures/binary-tree/bst.d.ts +124 -1063
- package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +99 -854
- package/dist/types/data-structures/binary-tree/segment-tree.d.ts +62 -314
- package/dist/types/data-structures/binary-tree/tree-map.d.ts +366 -5057
- package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +277 -4885
- package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +253 -3929
- package/dist/types/data-structures/binary-tree/tree-set.d.ts +261 -4782
- package/dist/types/data-structures/graph/abstract-graph.d.ts +44 -44
- package/dist/types/data-structures/graph/directed-graph.d.ts +130 -527
- package/dist/types/data-structures/graph/undirected-graph.d.ts +125 -482
- package/dist/types/data-structures/hash/hash-map.d.ts +132 -562
- package/dist/types/data-structures/heap/heap.d.ts +194 -746
- package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +120 -809
- package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +121 -733
- package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +193 -863
- package/dist/types/data-structures/matrix/matrix.d.ts +159 -474
- package/dist/types/data-structures/priority-queue/max-priority-queue.d.ts +1 -6
- package/dist/types/data-structures/priority-queue/min-priority-queue.d.ts +6 -11
- package/dist/types/data-structures/priority-queue/priority-queue.d.ts +1 -1
- package/dist/types/data-structures/queue/deque.d.ts +196 -804
- package/dist/types/data-structures/queue/queue.d.ts +99 -585
- package/dist/types/data-structures/stack/stack.d.ts +75 -481
- package/dist/types/data-structures/trie/trie.d.ts +98 -584
- package/dist/umd/data-structure-typed.js +6580 -32822
- package/dist/umd/data-structure-typed.min.js +3 -3
- package/docs-site-docusaurus/docs/api/classes/AVLTree.md +162 -215
- package/docs-site-docusaurus/docs/api/classes/AVLTreeNode.md +9 -9
- package/docs-site-docusaurus/docs/api/classes/AbstractGraph.md +47 -47
- package/docs-site-docusaurus/docs/api/classes/BST.md +155 -208
- package/docs-site-docusaurus/docs/api/classes/BSTNode.md +7 -7
- package/docs-site-docusaurus/docs/api/classes/BinaryIndexedTree.md +13 -29
- package/docs-site-docusaurus/docs/api/classes/BinaryTree.md +104 -158
- package/docs-site-docusaurus/docs/api/classes/BinaryTreeNode.md +13 -13
- package/docs-site-docusaurus/docs/api/classes/Deque.md +253 -101
- package/docs-site-docusaurus/docs/api/classes/DirectedGraph.md +60 -80
- package/docs-site-docusaurus/docs/api/classes/DoublyLinkedList.md +244 -114
- package/docs-site-docusaurus/docs/api/classes/DoublyLinkedListNode.md +6 -6
- package/docs-site-docusaurus/docs/api/classes/FibonacciHeap.md +9 -9
- package/docs-site-docusaurus/docs/api/classes/FibonacciHeapNode.md +1 -1
- package/docs-site-docusaurus/docs/api/classes/HashMap.md +52 -48
- package/docs-site-docusaurus/docs/api/classes/Heap.md +119 -64
- package/docs-site-docusaurus/docs/api/classes/IterableElementBase.md +84 -14
- package/docs-site-docusaurus/docs/api/classes/LinearBase.md +138 -34
- package/docs-site-docusaurus/docs/api/classes/LinearLinkedBase.md +149 -41
- package/docs-site-docusaurus/docs/api/classes/LinkedHashMap.md +23 -23
- package/docs-site-docusaurus/docs/api/classes/LinkedListQueue.md +172 -92
- package/docs-site-docusaurus/docs/api/classes/MapGraph.md +60 -80
- package/docs-site-docusaurus/docs/api/classes/Matrix.md +57 -52
- package/docs-site-docusaurus/docs/api/classes/MaxHeap.md +117 -62
- package/docs-site-docusaurus/docs/api/classes/MaxPriorityQueue.md +120 -70
- package/docs-site-docusaurus/docs/api/classes/MinHeap.md +117 -62
- package/docs-site-docusaurus/docs/api/classes/MinPriorityQueue.md +125 -75
- package/docs-site-docusaurus/docs/api/classes/PriorityQueue.md +119 -64
- package/docs-site-docusaurus/docs/api/classes/Queue.md +158 -74
- package/docs-site-docusaurus/docs/api/classes/RedBlackTree.md +171 -225
- package/docs-site-docusaurus/docs/api/classes/SegmentTree.md +10 -22
- package/docs-site-docusaurus/docs/api/classes/SinglyLinkedList.md +172 -94
- package/docs-site-docusaurus/docs/api/classes/SinglyLinkedListNode.md +4 -4
- package/docs-site-docusaurus/docs/api/classes/SkipList.md +98 -75
- package/docs-site-docusaurus/docs/api/classes/Stack.md +112 -50
- package/docs-site-docusaurus/docs/api/classes/TreeMap.md +104 -129
- package/docs-site-docusaurus/docs/api/classes/TreeMultiMap.md +90 -121
- package/docs-site-docusaurus/docs/api/classes/TreeSet.md +298 -107
- package/docs-site-docusaurus/docs/api/classes/Trie.md +116 -58
- package/docs-site-docusaurus/docs/api/classes/TrieNode.md +8 -8
- package/docs-site-docusaurus/docs/api/classes/UndirectedGraph.md +59 -77
- package/package.json +45 -46
- package/src/common/error.ts +15 -32
- package/src/common/index.ts +0 -3
- package/src/data-structures/base/iterable-element-base.ts +0 -3
- package/src/data-structures/base/linear-base.ts +2 -36
- package/src/data-structures/binary-tree/avl-tree.ts +31 -529
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +47 -572
- package/src/data-structures/binary-tree/binary-tree.ts +326 -1311
- package/src/data-structures/binary-tree/bst.ts +158 -1082
- package/src/data-structures/binary-tree/red-black-tree.ts +451 -1290
- package/src/data-structures/binary-tree/segment-tree.ts +73 -351
- package/src/data-structures/binary-tree/tree-map.ts +462 -5124
- package/src/data-structures/binary-tree/tree-multi-map.ts +302 -4914
- package/src/data-structures/binary-tree/tree-multi-set.ts +299 -3983
- package/src/data-structures/binary-tree/tree-set.ts +338 -4836
- package/src/data-structures/graph/abstract-graph.ts +98 -167
- package/src/data-structures/graph/directed-graph.ts +137 -562
- package/src/data-structures/graph/map-graph.ts +0 -3
- package/src/data-structures/graph/undirected-graph.ts +132 -511
- package/src/data-structures/hash/hash-map.ts +154 -582
- package/src/data-structures/heap/heap.ts +200 -795
- package/src/data-structures/linked-list/doubly-linked-list.ts +121 -865
- package/src/data-structures/linked-list/singly-linked-list.ts +122 -794
- package/src/data-structures/linked-list/skip-linked-list.ts +211 -918
- package/src/data-structures/matrix/matrix.ts +179 -518
- package/src/data-structures/matrix/navigator.ts +0 -1
- package/src/data-structures/priority-queue/max-priority-queue.ts +1 -6
- package/src/data-structures/priority-queue/min-priority-queue.ts +6 -11
- package/src/data-structures/priority-queue/priority-queue.ts +1 -2
- package/src/data-structures/queue/deque.ts +214 -882
- package/src/data-structures/queue/queue.ts +102 -625
- package/src/data-structures/stack/stack.ts +76 -505
- package/src/data-structures/trie/trie.ts +98 -628
- package/src/types/common.ts +0 -10
- package/src/types/data-structures/binary-tree/bst.ts +0 -7
- package/src/types/data-structures/binary-tree/red-black-tree.ts +0 -1
- package/src/types/data-structures/graph/abstract-graph.ts +0 -2
- package/src/types/data-structures/hash/hash-map.ts +0 -3
- package/src/types/data-structures/hash/index.ts +0 -1
- package/src/types/data-structures/matrix/navigator.ts +0 -2
- package/src/types/utils/utils.ts +0 -7
- package/src/types/utils/validate-type.ts +0 -7
- package/src/utils/number.ts +0 -2
- package/src/utils/utils.ts +0 -5
|
@@ -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:
|
|
9
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:248](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/red-black-tree.ts#L248)
|
|
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:390](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L390)
|
|
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:
|
|
163
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:326](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L326)
|
|
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:
|
|
197
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:316](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L316)
|
|
198
198
|
|
|
199
199
|
Gets whether the tree is in Map mode.
|
|
200
200
|
|
|
@@ -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:
|
|
265
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:295](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/red-black-tree.ts#L295)
|
|
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:
|
|
299
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:363](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L363)
|
|
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:
|
|
333
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:339](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L339)
|
|
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:
|
|
367
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:383](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L383)
|
|
368
368
|
|
|
369
369
|
Gets the function used to convert raw data objects (R) into [key, value] entries.
|
|
370
370
|
|
|
@@ -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:609](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L609)
|
|
438
438
|
|
|
439
439
|
Adds a new node to the tree.
|
|
440
440
|
|
|
@@ -456,8 +456,6 @@ The key, node, or entry to add.
|
|
|
456
456
|
|
|
457
457
|
True if the addition was successful, false otherwise.
|
|
458
458
|
|
|
459
|
-
*
|
|
460
|
-
|
|
461
459
|
#### Remarks
|
|
462
460
|
|
|
463
461
|
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).
|
|
@@ -492,7 +490,7 @@ IBinaryTree.add
|
|
|
492
490
|
addMany(keysNodesEntriesOrRaws): boolean[];
|
|
493
491
|
```
|
|
494
492
|
|
|
495
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
493
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:711](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L711)
|
|
496
494
|
|
|
497
495
|
Adds multiple items to the tree.
|
|
498
496
|
|
|
@@ -516,8 +514,6 @@ An iterable of items to set.
|
|
|
516
514
|
|
|
517
515
|
An array of booleans indicating the success of each individual `set` operation.
|
|
518
516
|
|
|
519
|
-
*
|
|
520
|
-
|
|
521
517
|
#### Remarks
|
|
522
518
|
|
|
523
519
|
Time O(N * M), where N is the number of items to set and M is the size of the tree at insertion (due to O(M) `set` operation). Space O(M) (from `set`) + O(N) (for the `inserted` array).
|
|
@@ -573,12 +569,10 @@ The traversal method.
|
|
|
573
569
|
bfs(): (K | undefined)[];
|
|
574
570
|
```
|
|
575
571
|
|
|
576
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
572
|
+
Defined in: [data-structures/binary-tree/bst.ts:493](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L493)
|
|
577
573
|
|
|
578
574
|
BinaryTree level-order traversal
|
|
579
575
|
|
|
580
|
-
*
|
|
581
|
-
|
|
582
576
|
##### Returns
|
|
583
577
|
|
|
584
578
|
(`K` \| `undefined`)[]
|
|
@@ -611,12 +605,10 @@ bfs<C>(
|
|
|
611
605
|
iterationType?): ReturnType<C>[];
|
|
612
606
|
```
|
|
613
607
|
|
|
614
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
608
|
+
Defined in: [data-structures/binary-tree/bst.ts:494](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L494)
|
|
615
609
|
|
|
616
610
|
BinaryTree level-order traversal
|
|
617
611
|
|
|
618
|
-
*
|
|
619
|
-
|
|
620
612
|
##### Type Parameters
|
|
621
613
|
|
|
622
614
|
###### C
|
|
@@ -673,15 +665,13 @@ IBinaryTree.bfs
|
|
|
673
665
|
ceiling(keyNodeEntryOrPredicate): K | undefined;
|
|
674
666
|
```
|
|
675
667
|
|
|
676
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
668
|
+
Defined in: [data-structures/binary-tree/bst.ts:1253](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L1253)
|
|
677
669
|
|
|
678
670
|
Returns the first key with a value >= target.
|
|
679
671
|
Equivalent to Java TreeMap.ceiling.
|
|
680
672
|
Time Complexity: O(log n) average, O(h) worst case.
|
|
681
673
|
Space Complexity: O(h) for recursion, O(1) for iteration.
|
|
682
674
|
|
|
683
|
-
*
|
|
684
|
-
|
|
685
675
|
##### Parameters
|
|
686
676
|
|
|
687
677
|
###### keyNodeEntryOrPredicate
|
|
@@ -720,7 +710,7 @@ ceiling<C>(
|
|
|
720
710
|
iterationType?): ReturnType<C>;
|
|
721
711
|
```
|
|
722
712
|
|
|
723
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
713
|
+
Defined in: [data-structures/binary-tree/bst.ts:1268](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L1268)
|
|
724
714
|
|
|
725
715
|
Returns the first node with a key >= target and applies callback.
|
|
726
716
|
Time Complexity: O(log n) average, O(h) worst case.
|
|
@@ -767,7 +757,7 @@ Space Complexity: O(h) for recursion, O(1) for iteration.
|
|
|
767
757
|
clear(): void;
|
|
768
758
|
```
|
|
769
759
|
|
|
770
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:
|
|
760
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:332](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/red-black-tree.ts#L332)
|
|
771
761
|
|
|
772
762
|
Remove all nodes, clear the key→value store (if in map mode) and internal caches.
|
|
773
763
|
|
|
@@ -779,8 +769,6 @@ Remove all nodes, clear the key→value store (if in map mode) and internal cach
|
|
|
779
769
|
|
|
780
770
|
Time O(n), Space O(1)
|
|
781
771
|
|
|
782
|
-
*
|
|
783
|
-
|
|
784
772
|
#### Example
|
|
785
773
|
|
|
786
774
|
```ts
|
|
@@ -808,7 +796,7 @@ IBinaryTree.clear
|
|
|
808
796
|
clone(): this;
|
|
809
797
|
```
|
|
810
798
|
|
|
811
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
799
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1939](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L1939)
|
|
812
800
|
|
|
813
801
|
Clones the tree.
|
|
814
802
|
|
|
@@ -818,8 +806,6 @@ Clones the tree.
|
|
|
818
806
|
|
|
819
807
|
A new, cloned instance of the tree.
|
|
820
808
|
|
|
821
|
-
*
|
|
822
|
-
|
|
823
809
|
#### Remarks
|
|
824
810
|
|
|
825
811
|
Time O(N * M), where N is the number of nodes and M is the tree size during insertion (due to `bfs` + `set`, and `set` is O(M)). Space O(N) for the new tree and the BFS queue.
|
|
@@ -855,7 +841,7 @@ createNode(
|
|
|
855
841
|
color?): RedBlackTreeNode<K, V>;
|
|
856
842
|
```
|
|
857
843
|
|
|
858
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:
|
|
844
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:307](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/red-black-tree.ts#L307)
|
|
859
845
|
|
|
860
846
|
Create a red-black node for the given key/value (value ignored in map mode).
|
|
861
847
|
|
|
@@ -907,7 +893,7 @@ IBinaryTree.createNode
|
|
|
907
893
|
createTree(options?): this;
|
|
908
894
|
```
|
|
909
895
|
|
|
910
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
896
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:439](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L439)
|
|
911
897
|
|
|
912
898
|
Creates a new, empty tree of the same type and configuration.
|
|
913
899
|
|
|
@@ -947,7 +933,7 @@ IBinaryTree.createTree
|
|
|
947
933
|
delete(keyNodeEntryRawOrPredicate): boolean;
|
|
948
934
|
```
|
|
949
935
|
|
|
950
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:
|
|
936
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:534](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/red-black-tree.ts#L534)
|
|
951
937
|
|
|
952
938
|
Delete a node by key/node/entry and rebalance as needed.
|
|
953
939
|
|
|
@@ -966,8 +952,6 @@ Key, node, or [key, value] entry identifying the node to delete.
|
|
|
966
952
|
|
|
967
953
|
Array with deletion metadata (removed node, rebalancing hint if any).
|
|
968
954
|
|
|
969
|
-
*
|
|
970
|
-
|
|
971
955
|
#### Remarks
|
|
972
956
|
|
|
973
957
|
Time O(log n) average, Space O(1)
|
|
@@ -1004,7 +988,7 @@ deleteWhere(
|
|
|
1004
988
|
iterationType?): boolean;
|
|
1005
989
|
```
|
|
1006
990
|
|
|
1007
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
991
|
+
Defined in: [data-structures/binary-tree/bst.ts:1838](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L1838)
|
|
1008
992
|
|
|
1009
993
|
Deletes nodes that match a key, node, entry, predicate, or range.
|
|
1010
994
|
|
|
@@ -1115,12 +1099,10 @@ The traversal method.
|
|
|
1115
1099
|
dfs(): (K | undefined)[];
|
|
1116
1100
|
```
|
|
1117
1101
|
|
|
1118
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
1102
|
+
Defined in: [data-structures/binary-tree/bst.ts:453](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L453)
|
|
1119
1103
|
|
|
1120
1104
|
Depth-first search traversal
|
|
1121
1105
|
|
|
1122
|
-
*
|
|
1123
|
-
|
|
1124
1106
|
##### Returns
|
|
1125
1107
|
|
|
1126
1108
|
(`K` \| `undefined`)[]
|
|
@@ -1155,12 +1137,10 @@ dfs<C>(
|
|
|
1155
1137
|
iterationType?): ReturnType<C>[];
|
|
1156
1138
|
```
|
|
1157
1139
|
|
|
1158
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
1140
|
+
Defined in: [data-structures/binary-tree/bst.ts:455](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L455)
|
|
1159
1141
|
|
|
1160
1142
|
Depth-first search traversal
|
|
1161
1143
|
|
|
1162
|
-
*
|
|
1163
|
-
|
|
1164
1144
|
##### Type Parameters
|
|
1165
1145
|
|
|
1166
1146
|
###### C
|
|
@@ -1223,7 +1203,7 @@ IBinaryTree.dfs
|
|
|
1223
1203
|
ensureNode(keyNodeOrEntry, iterationType?): OptNode<BSTNode<K, V>>;
|
|
1224
1204
|
```
|
|
1225
1205
|
|
|
1226
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
1206
|
+
Defined in: [data-structures/binary-tree/bst.ts:414](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L414)
|
|
1227
1207
|
|
|
1228
1208
|
Ensures the input is a node. If it's a key or entry, it searches for the node.
|
|
1229
1209
|
|
|
@@ -1345,7 +1325,7 @@ IBinaryTree.every
|
|
|
1345
1325
|
filter(predicate, thisArg?): this;
|
|
1346
1326
|
```
|
|
1347
1327
|
|
|
1348
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
1328
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1958](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L1958)
|
|
1349
1329
|
|
|
1350
1330
|
Creates a new tree containing only the entries that satisfy the predicate.
|
|
1351
1331
|
|
|
@@ -1369,8 +1349,6 @@ A function to test each [key, value] pair.
|
|
|
1369
1349
|
|
|
1370
1350
|
A new, filtered tree.
|
|
1371
1351
|
|
|
1372
|
-
*
|
|
1373
|
-
|
|
1374
1352
|
#### Remarks
|
|
1375
1353
|
|
|
1376
1354
|
Time O(N * M), where N is nodes in this tree, and M is size of the new tree during insertion (O(N) iteration + O(M) `set` for each item). Space O(N) for the new tree.
|
|
@@ -1450,15 +1428,13 @@ IBinaryTree.find
|
|
|
1450
1428
|
floor(keyNodeEntryOrPredicate): K | undefined;
|
|
1451
1429
|
```
|
|
1452
1430
|
|
|
1453
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
1431
|
+
Defined in: [data-structures/binary-tree/bst.ts:1394](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L1394)
|
|
1454
1432
|
|
|
1455
1433
|
Returns the first key with a value <= target.
|
|
1456
1434
|
Equivalent to Java TreeMap.floor.
|
|
1457
1435
|
Time Complexity: O(log n) average, O(h) worst case.
|
|
1458
1436
|
Space Complexity: O(h) for recursion, O(1) for iteration.
|
|
1459
1437
|
|
|
1460
|
-
*
|
|
1461
|
-
|
|
1462
1438
|
##### Parameters
|
|
1463
1439
|
|
|
1464
1440
|
###### keyNodeEntryOrPredicate
|
|
@@ -1497,7 +1473,7 @@ floor<C>(
|
|
|
1497
1473
|
iterationType?): ReturnType<C>;
|
|
1498
1474
|
```
|
|
1499
1475
|
|
|
1500
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
1476
|
+
Defined in: [data-structures/binary-tree/bst.ts:1409](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L1409)
|
|
1501
1477
|
|
|
1502
1478
|
Returns the first node with a key <= target and applies callback.
|
|
1503
1479
|
Time Complexity: O(log n) average, O(h) worst case.
|
|
@@ -1591,7 +1567,7 @@ get(
|
|
|
1591
1567
|
iterationType?): V | undefined;
|
|
1592
1568
|
```
|
|
1593
1569
|
|
|
1594
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
1570
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:995](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L995)
|
|
1595
1571
|
|
|
1596
1572
|
Gets the value associated with a key.
|
|
1597
1573
|
|
|
@@ -1628,8 +1604,6 @@ The traversal method (if not in Map mode).
|
|
|
1628
1604
|
|
|
1629
1605
|
The associated value, or undefined.
|
|
1630
1606
|
|
|
1631
|
-
*
|
|
1632
|
-
|
|
1633
1607
|
#### Remarks
|
|
1634
1608
|
|
|
1635
1609
|
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).
|
|
@@ -1638,7 +1612,11 @@ Time O(1) in Map mode, O(N) otherwise (via `getNode`). Space O(1) in Map mode, O
|
|
|
1638
1612
|
|
|
1639
1613
|
```ts
|
|
1640
1614
|
// Retrieve value by key
|
|
1641
|
-
const tree = new BinaryTree<number, string>([
|
|
1615
|
+
const tree = new BinaryTree<number, string>([
|
|
1616
|
+
[1, 'root'],
|
|
1617
|
+
[2, 'left'],
|
|
1618
|
+
[3, 'right']
|
|
1619
|
+
]);
|
|
1642
1620
|
console.log(tree.get(2)); // 'left';
|
|
1643
1621
|
console.log(tree.get(99)); // undefined;
|
|
1644
1622
|
```
|
|
@@ -1663,7 +1641,7 @@ IBinaryTree.get
|
|
|
1663
1641
|
getByRank(k): K | undefined;
|
|
1664
1642
|
```
|
|
1665
1643
|
|
|
1666
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
1644
|
+
Defined in: [data-structures/binary-tree/bst.ts:853](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L853)
|
|
1667
1645
|
|
|
1668
1646
|
Returns the element at the k-th position in tree order (0-indexed).
|
|
1669
1647
|
|
|
@@ -1680,7 +1658,6 @@ The 0-based position in tree order (0 = first element).
|
|
|
1680
1658
|
`K` \| `undefined`
|
|
1681
1659
|
|
|
1682
1660
|
The key at position k, or `undefined` if out of bounds.
|
|
1683
|
-
*
|
|
1684
1661
|
|
|
1685
1662
|
##### Remarks
|
|
1686
1663
|
|
|
@@ -1710,7 +1687,7 @@ getByRank<C>(
|
|
|
1710
1687
|
iterationType?): ReturnType<C> | undefined;
|
|
1711
1688
|
```
|
|
1712
1689
|
|
|
1713
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
1690
|
+
Defined in: [data-structures/binary-tree/bst.ts:864](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L864)
|
|
1714
1691
|
|
|
1715
1692
|
Returns the element at the k-th position in tree order and applies a callback.
|
|
1716
1693
|
|
|
@@ -1762,7 +1739,7 @@ Time O(log n), Space O(1) iterative / O(log n) recursive. Requires `enableOrderS
|
|
|
1762
1739
|
getDepth(dist, startNode?): number;
|
|
1763
1740
|
```
|
|
1764
1741
|
|
|
1765
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
1742
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1187](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L1187)
|
|
1766
1743
|
|
|
1767
1744
|
Gets the depth of a node (distance from `startNode`).
|
|
1768
1745
|
|
|
@@ -1793,8 +1770,6 @@ The node to measure depth from (defaults to root).
|
|
|
1793
1770
|
|
|
1794
1771
|
The depth (0 if `dist` is `startNode`).
|
|
1795
1772
|
|
|
1796
|
-
*
|
|
1797
|
-
|
|
1798
1773
|
#### Remarks
|
|
1799
1774
|
|
|
1800
1775
|
Time O(H), where H is the depth of the `dist` node relative to `startNode`. O(N) worst-case. Space O(1).
|
|
@@ -1826,7 +1801,7 @@ IBinaryTree.getDepth
|
|
|
1826
1801
|
getHeight(startNode?, iterationType?): number;
|
|
1827
1802
|
```
|
|
1828
1803
|
|
|
1829
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
1804
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1216](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L1216)
|
|
1830
1805
|
|
|
1831
1806
|
Gets the maximum height of the tree (longest path from startNode to a leaf).
|
|
1832
1807
|
|
|
@@ -1853,8 +1828,6 @@ The traversal method.
|
|
|
1853
1828
|
|
|
1854
1829
|
The height ( -1 for an empty tree, 0 for a single-node tree).
|
|
1855
1830
|
|
|
1856
|
-
*
|
|
1857
|
-
|
|
1858
1831
|
#### Remarks
|
|
1859
1832
|
|
|
1860
1833
|
Time O(N), as it must visit every node. Space O(H) for recursive stack (O(N) worst-case) or O(N) for iterative stack (storing node + depth).
|
|
@@ -1909,7 +1882,7 @@ The traversal method.
|
|
|
1909
1882
|
getLeftMost(): K | undefined;
|
|
1910
1883
|
```
|
|
1911
1884
|
|
|
1912
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
1885
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1343](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L1343)
|
|
1913
1886
|
|
|
1914
1887
|
##### Returns
|
|
1915
1888
|
|
|
@@ -1934,7 +1907,7 @@ getLeftMost<C>(
|
|
|
1934
1907
|
iterationType?): ReturnType<C>;
|
|
1935
1908
|
```
|
|
1936
1909
|
|
|
1937
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
1910
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1345](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L1345)
|
|
1938
1911
|
|
|
1939
1912
|
##### Type Parameters
|
|
1940
1913
|
|
|
@@ -1981,7 +1954,7 @@ IBinaryTree.getLeftMost
|
|
|
1981
1954
|
getMinHeight(startNode?, iterationType?): number;
|
|
1982
1955
|
```
|
|
1983
1956
|
|
|
1984
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
1957
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1258](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L1258)
|
|
1985
1958
|
|
|
1986
1959
|
Gets the minimum height of the tree (shortest path from startNode to a leaf).
|
|
1987
1960
|
|
|
@@ -2033,7 +2006,7 @@ getNode(
|
|
|
2033
2006
|
iterationType?): OptNode<BSTNode<K, V>>;
|
|
2034
2007
|
```
|
|
2035
2008
|
|
|
2036
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
2009
|
+
Defined in: [data-structures/binary-tree/bst.ts:574](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L574)
|
|
2037
2010
|
|
|
2038
2011
|
Gets the first node matching a predicate.
|
|
2039
2012
|
|
|
@@ -2068,8 +2041,6 @@ The traversal method.
|
|
|
2068
2041
|
|
|
2069
2042
|
The first matching node, or undefined if not found.
|
|
2070
2043
|
|
|
2071
|
-
*
|
|
2072
|
-
|
|
2073
2044
|
#### Remarks
|
|
2074
2045
|
|
|
2075
2046
|
Time O(log N) if searching by key, O(N) if searching by predicate. Space O(log N) or O(N).
|
|
@@ -2078,7 +2049,11 @@ Time O(log N) if searching by key, O(N) if searching by predicate. Space O(log N
|
|
|
2078
2049
|
|
|
2079
2050
|
```ts
|
|
2080
2051
|
// Get node object by key
|
|
2081
|
-
const bst = new BST<number, string>([
|
|
2052
|
+
const bst = new BST<number, string>([
|
|
2053
|
+
[5, 'root'],
|
|
2054
|
+
[3, 'left'],
|
|
2055
|
+
[7, 'right']
|
|
2056
|
+
]);
|
|
2082
2057
|
const node = bst.getNode(3);
|
|
2083
2058
|
console.log(node?.key); // 3;
|
|
2084
2059
|
console.log(node?.value); // 'left';
|
|
@@ -2106,7 +2081,7 @@ getNodes(
|
|
|
2106
2081
|
iterationType?): BinaryTreeNode<K, V>[];
|
|
2107
2082
|
```
|
|
2108
2083
|
|
|
2109
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
2084
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:912](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L912)
|
|
2110
2085
|
|
|
2111
2086
|
Gets all nodes matching a predicate.
|
|
2112
2087
|
|
|
@@ -2150,8 +2125,6 @@ The traversal method.
|
|
|
2150
2125
|
|
|
2151
2126
|
An array of matching nodes.
|
|
2152
2127
|
|
|
2153
|
-
*
|
|
2154
|
-
|
|
2155
2128
|
#### Remarks
|
|
2156
2129
|
|
|
2157
2130
|
Time O(N) (via `search`). Space O(H) or O(N) (via `search`).
|
|
@@ -2201,7 +2174,7 @@ If true, returns the path from root-to-node.
|
|
|
2201
2174
|
getPathToRoot(beginNode): (K | undefined)[];
|
|
2202
2175
|
```
|
|
2203
2176
|
|
|
2204
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
2177
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1305](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L1305)
|
|
2205
2178
|
|
|
2206
2179
|
##### Parameters
|
|
2207
2180
|
|
|
@@ -2236,7 +2209,7 @@ getPathToRoot<C>(
|
|
|
2236
2209
|
isReverse?): ReturnType<C>[];
|
|
2237
2210
|
```
|
|
2238
2211
|
|
|
2239
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
2212
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1309](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L1309)
|
|
2240
2213
|
|
|
2241
2214
|
##### Type Parameters
|
|
2242
2215
|
|
|
@@ -2284,7 +2257,7 @@ IBinaryTree.getPathToRoot
|
|
|
2284
2257
|
getPredecessor(node): BinaryTreeNode<K, V>;
|
|
2285
2258
|
```
|
|
2286
2259
|
|
|
2287
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
2260
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1443](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L1443)
|
|
2288
2261
|
|
|
2289
2262
|
Gets the Morris traversal predecessor (rightmost node in the left subtree, or node itself).
|
|
2290
2263
|
|
|
@@ -2320,7 +2293,7 @@ This is primarily a helper for Morris traversal. Time O(H), where H is the heigh
|
|
|
2320
2293
|
getRank(keyNodeEntryOrPredicate): number;
|
|
2321
2294
|
```
|
|
2322
2295
|
|
|
2323
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
2296
|
+
Defined in: [data-structures/binary-tree/bst.ts:909](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L909)
|
|
2324
2297
|
|
|
2325
2298
|
Returns the 0-based rank of a key (number of elements that precede it in tree order).
|
|
2326
2299
|
|
|
@@ -2358,7 +2331,7 @@ Tree order is defined by the comparator. When the key is not found, returns the
|
|
|
2358
2331
|
getRank(keyNodeEntryOrPredicate, iterationType): number;
|
|
2359
2332
|
```
|
|
2360
2333
|
|
|
2361
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
2334
|
+
Defined in: [data-structures/binary-tree/bst.ts:927](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L927)
|
|
2362
2335
|
|
|
2363
2336
|
Returns the 0-based rank (number of preceding elements in tree order) with explicit iteration type.
|
|
2364
2337
|
|
|
@@ -2427,7 +2400,7 @@ The traversal method.
|
|
|
2427
2400
|
getRightMost(): K | undefined;
|
|
2428
2401
|
```
|
|
2429
2402
|
|
|
2430
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
2403
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1390](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L1390)
|
|
2431
2404
|
|
|
2432
2405
|
##### Returns
|
|
2433
2406
|
|
|
@@ -2452,7 +2425,7 @@ getRightMost<C>(
|
|
|
2452
2425
|
iterationType?): ReturnType<C>;
|
|
2453
2426
|
```
|
|
2454
2427
|
|
|
2455
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
2428
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1392](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L1392)
|
|
2456
2429
|
|
|
2457
2430
|
##### Type Parameters
|
|
2458
2431
|
|
|
@@ -2499,7 +2472,7 @@ IBinaryTree.getRightMost
|
|
|
2499
2472
|
getSuccessor(x?): BinaryTreeNode<K, V> | null | undefined;
|
|
2500
2473
|
```
|
|
2501
2474
|
|
|
2502
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
2475
|
+
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)
|
|
2503
2476
|
|
|
2504
2477
|
Gets the in-order successor of a node in a BST.
|
|
2505
2478
|
|
|
@@ -2536,7 +2509,7 @@ has(
|
|
|
2536
2509
|
iterationType?): boolean;
|
|
2537
2510
|
```
|
|
2538
2511
|
|
|
2539
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
2512
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1045](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L1045)
|
|
2540
2513
|
|
|
2541
2514
|
Checks if a node matching the predicate exists in the tree.
|
|
2542
2515
|
|
|
@@ -2573,8 +2546,6 @@ The traversal method.
|
|
|
2573
2546
|
|
|
2574
2547
|
True if a matching node exists, false otherwise.
|
|
2575
2548
|
|
|
2576
|
-
*
|
|
2577
|
-
|
|
2578
2549
|
#### Remarks
|
|
2579
2550
|
|
|
2580
2551
|
Time O(N) via `search`. Space O(H) or O(N). BST/Red-Black Tree/AVL Tree subclasses override to O(log N) for key lookups.
|
|
@@ -2671,15 +2642,13 @@ IBinaryTree.hasValue
|
|
|
2671
2642
|
higher(keyNodeEntryOrPredicate): K | undefined;
|
|
2672
2643
|
```
|
|
2673
2644
|
|
|
2674
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
2645
|
+
Defined in: [data-structures/binary-tree/bst.ts:1323](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L1323)
|
|
2675
2646
|
|
|
2676
2647
|
Returns the first key with a value > target.
|
|
2677
2648
|
Equivalent to Java TreeMap.higher.
|
|
2678
2649
|
Time Complexity: O(log n) average, O(h) worst case.
|
|
2679
2650
|
Space Complexity: O(h) for recursion, O(1) for iteration.
|
|
2680
2651
|
|
|
2681
|
-
*
|
|
2682
|
-
|
|
2683
2652
|
##### Parameters
|
|
2684
2653
|
|
|
2685
2654
|
###### keyNodeEntryOrPredicate
|
|
@@ -2717,7 +2686,7 @@ higher<C>(
|
|
|
2717
2686
|
iterationType?): ReturnType<C>;
|
|
2718
2687
|
```
|
|
2719
2688
|
|
|
2720
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
2689
|
+
Defined in: [data-structures/binary-tree/bst.ts:1338](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L1338)
|
|
2721
2690
|
|
|
2722
2691
|
Returns the first node with a key > target and applies callback.
|
|
2723
2692
|
Time Complexity: O(log n) average, O(h) worst case.
|
|
@@ -2764,7 +2733,7 @@ Space Complexity: O(h) for recursion, O(1) for iteration.
|
|
|
2764
2733
|
isAVLBalanced(iterationType?): boolean;
|
|
2765
2734
|
```
|
|
2766
2735
|
|
|
2767
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
2736
|
+
Defined in: [data-structures/binary-tree/bst.ts:1722](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L1722)
|
|
2768
2737
|
|
|
2769
2738
|
Checks if the tree meets the AVL balance condition (height difference <= 1).
|
|
2770
2739
|
|
|
@@ -2782,8 +2751,6 @@ The traversal method.
|
|
|
2782
2751
|
|
|
2783
2752
|
True if the tree is AVL balanced, false otherwise.
|
|
2784
2753
|
|
|
2785
|
-
*
|
|
2786
|
-
|
|
2787
2754
|
#### Remarks
|
|
2788
2755
|
|
|
2789
2756
|
Time O(N), as it must visit every node to compute height. Space O(log N) for recursion or O(N) for iterative map.
|
|
@@ -2808,7 +2775,7 @@ Time O(N), as it must visit every node to compute height. Space O(log N) for rec
|
|
|
2808
2775
|
isBST(startNode?, iterationType?): boolean;
|
|
2809
2776
|
```
|
|
2810
2777
|
|
|
2811
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
2778
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1131](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L1131)
|
|
2812
2779
|
|
|
2813
2780
|
Checks if the tree is a valid Binary Search Tree (BST).
|
|
2814
2781
|
|
|
@@ -2835,8 +2802,6 @@ The traversal method.
|
|
|
2835
2802
|
|
|
2836
2803
|
True if it's a valid BST, false otherwise.
|
|
2837
2804
|
|
|
2838
|
-
*
|
|
2839
|
-
|
|
2840
2805
|
#### Remarks
|
|
2841
2806
|
|
|
2842
2807
|
Time O(N), as it must visit every node. Space O(H) for the call stack (recursive) or explicit stack (iterative), where H is the tree height (O(N) worst-case).
|
|
@@ -2868,7 +2833,7 @@ IBinaryTree.isBST
|
|
|
2868
2833
|
isEmpty(): boolean;
|
|
2869
2834
|
```
|
|
2870
2835
|
|
|
2871
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
2836
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1101](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L1101)
|
|
2872
2837
|
|
|
2873
2838
|
Checks if the tree is empty.
|
|
2874
2839
|
|
|
@@ -2878,8 +2843,6 @@ Checks if the tree is empty.
|
|
|
2878
2843
|
|
|
2879
2844
|
True if the tree has no nodes, false otherwise.
|
|
2880
2845
|
|
|
2881
|
-
*
|
|
2882
|
-
|
|
2883
2846
|
#### Remarks
|
|
2884
2847
|
|
|
2885
2848
|
Time O(1), Space O(1)
|
|
@@ -2909,7 +2872,7 @@ IBinaryTree.isEmpty
|
|
|
2909
2872
|
isEntry(keyNodeOrEntry): keyNodeOrEntry is BTNEntry<K, V>;
|
|
2910
2873
|
```
|
|
2911
2874
|
|
|
2912
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
2875
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:576](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L576)
|
|
2913
2876
|
|
|
2914
2877
|
Checks if the given item is a [key, value] entry pair.
|
|
2915
2878
|
|
|
@@ -2947,7 +2910,7 @@ Time O(1), Space O(1)
|
|
|
2947
2910
|
isLeaf(keyNodeOrEntry): boolean;
|
|
2948
2911
|
```
|
|
2949
2912
|
|
|
2950
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
2913
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:562](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L562)
|
|
2951
2914
|
|
|
2952
2915
|
Checks if a node is a leaf (has no real children).
|
|
2953
2916
|
|
|
@@ -2985,7 +2948,7 @@ Time O(N) if a key/entry is passed (due to `ensureNode`). O(1) if a node is pass
|
|
|
2985
2948
|
isNIL(keyNodeOrEntry): boolean;
|
|
2986
2949
|
```
|
|
2987
2950
|
|
|
2988
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
2951
|
+
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)
|
|
2989
2952
|
|
|
2990
2953
|
Checks if the given item is the sentinel NIL node.
|
|
2991
2954
|
|
|
@@ -3023,7 +2986,7 @@ Time O(1), Space O(1)
|
|
|
3023
2986
|
isNode(keyNodeOrEntry): keyNodeOrEntry is RedBlackTreeNode<K, V>;
|
|
3024
2987
|
```
|
|
3025
2988
|
|
|
3026
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:
|
|
2989
|
+
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)
|
|
3027
2990
|
|
|
3028
2991
|
Type guard: check whether the input is a RedBlackTreeNode.
|
|
3029
2992
|
|
|
@@ -3061,7 +3024,7 @@ Time O(1), Space O(1)
|
|
|
3061
3024
|
isPerfectlyBalanced(startNode?): boolean;
|
|
3062
3025
|
```
|
|
3063
3026
|
|
|
3064
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
3027
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1112](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L1112)
|
|
3065
3028
|
|
|
3066
3029
|
Checks if the tree is perfectly balanced.
|
|
3067
3030
|
|
|
@@ -3104,7 +3067,7 @@ IBinaryTree.isPerfectlyBalanced
|
|
|
3104
3067
|
isRange(keyNodeEntryOrPredicate): keyNodeEntryOrPredicate is Range<K>;
|
|
3105
3068
|
```
|
|
3106
3069
|
|
|
3107
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
3070
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:542](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L542)
|
|
3108
3071
|
|
|
3109
3072
|
Checks if the given item is a `Range` object.
|
|
3110
3073
|
|
|
@@ -3144,7 +3107,7 @@ Time O(1), Space O(1)
|
|
|
3144
3107
|
isRaw(keyNodeEntryOrRaw): keyNodeEntryOrRaw is R;
|
|
3145
3108
|
```
|
|
3146
3109
|
|
|
3147
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
3110
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:491](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L491)
|
|
3148
3111
|
|
|
3149
3112
|
Checks if the given item is a raw data object (R) that needs conversion via `toEntryFn`.
|
|
3150
3113
|
|
|
@@ -3183,7 +3146,7 @@ Time O(1), Space O(1)
|
|
|
3183
3146
|
isRealNode(keyNodeOrEntry): keyNodeOrEntry is BinaryTreeNode<K, V>;
|
|
3184
3147
|
```
|
|
3185
3148
|
|
|
3186
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
3149
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:504](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L504)
|
|
3187
3150
|
|
|
3188
3151
|
Checks if the given item is a "real" node (i.e., not null, undefined, or NIL).
|
|
3189
3152
|
|
|
@@ -3221,7 +3184,7 @@ Time O(1), Space O(1)
|
|
|
3221
3184
|
isRealNodeOrNull(keyNodeOrEntry): keyNodeOrEntry is BinaryTreeNode<K, V> | null;
|
|
3222
3185
|
```
|
|
3223
3186
|
|
|
3224
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
3187
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:518](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L518)
|
|
3225
3188
|
|
|
3226
3189
|
Checks if the given item is either a "real" node or null.
|
|
3227
3190
|
|
|
@@ -3259,7 +3222,7 @@ Time O(1), Space O(1)
|
|
|
3259
3222
|
isValidKey(key): key is K;
|
|
3260
3223
|
```
|
|
3261
3224
|
|
|
3262
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
3225
|
+
Defined in: [data-structures/binary-tree/bst.ts:441](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L441)
|
|
3263
3226
|
|
|
3264
3227
|
Checks if the given key is valid (comparable).
|
|
3265
3228
|
|
|
@@ -3349,12 +3312,10 @@ The traversal method.
|
|
|
3349
3312
|
leaves(): (K | undefined)[];
|
|
3350
3313
|
```
|
|
3351
3314
|
|
|
3352
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
3315
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1655](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L1655)
|
|
3353
3316
|
|
|
3354
3317
|
Get leaf nodes
|
|
3355
3318
|
|
|
3356
|
-
*
|
|
3357
|
-
|
|
3358
3319
|
##### Returns
|
|
3359
3320
|
|
|
3360
3321
|
(`K` \| `undefined`)[]
|
|
@@ -3387,12 +3348,10 @@ leaves<C>(
|
|
|
3387
3348
|
iterationType?): ReturnType<C>[];
|
|
3388
3349
|
```
|
|
3389
3350
|
|
|
3390
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
3351
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1657](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L1657)
|
|
3391
3352
|
|
|
3392
3353
|
Get leaf nodes
|
|
3393
3354
|
|
|
3394
|
-
*
|
|
3395
|
-
|
|
3396
3355
|
##### Type Parameters
|
|
3397
3356
|
|
|
3398
3357
|
###### C
|
|
@@ -3475,7 +3434,7 @@ The traversal method.
|
|
|
3475
3434
|
lesserOrGreaterTraverse(): (K | undefined)[];
|
|
3476
3435
|
```
|
|
3477
3436
|
|
|
3478
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
3437
|
+
Defined in: [data-structures/binary-tree/bst.ts:1614](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L1614)
|
|
3479
3438
|
|
|
3480
3439
|
##### Returns
|
|
3481
3440
|
|
|
@@ -3495,7 +3454,7 @@ lesserOrGreaterTraverse<C>(
|
|
|
3495
3454
|
iterationType?): ReturnType<C>[];
|
|
3496
3455
|
```
|
|
3497
3456
|
|
|
3498
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
3457
|
+
Defined in: [data-structures/binary-tree/bst.ts:1616](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L1616)
|
|
3499
3458
|
|
|
3500
3459
|
##### Type Parameters
|
|
3501
3460
|
|
|
@@ -3564,12 +3523,10 @@ The traversal method.
|
|
|
3564
3523
|
listLevels(): (K | undefined)[][];
|
|
3565
3524
|
```
|
|
3566
3525
|
|
|
3567
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
3526
|
+
Defined in: [data-structures/binary-tree/bst.ts:529](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L529)
|
|
3568
3527
|
|
|
3569
3528
|
Level-order grouping
|
|
3570
3529
|
|
|
3571
|
-
*
|
|
3572
|
-
|
|
3573
3530
|
##### Returns
|
|
3574
3531
|
|
|
3575
3532
|
(`K` \| `undefined`)[][]
|
|
@@ -3605,12 +3562,10 @@ listLevels<C>(
|
|
|
3605
3562
|
iterationType?): ReturnType<C>[][];
|
|
3606
3563
|
```
|
|
3607
3564
|
|
|
3608
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
3565
|
+
Defined in: [data-structures/binary-tree/bst.ts:531](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L531)
|
|
3609
3566
|
|
|
3610
3567
|
Level-order grouping
|
|
3611
3568
|
|
|
3612
|
-
*
|
|
3613
|
-
|
|
3614
3569
|
##### Type Parameters
|
|
3615
3570
|
|
|
3616
3571
|
###### C
|
|
@@ -3670,15 +3625,13 @@ IBinaryTree.listLevels
|
|
|
3670
3625
|
lower(keyNodeEntryOrPredicate): K | undefined;
|
|
3671
3626
|
```
|
|
3672
3627
|
|
|
3673
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
3628
|
+
Defined in: [data-structures/binary-tree/bst.ts:1509](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L1509)
|
|
3674
3629
|
|
|
3675
3630
|
Returns the first key with a value < target.
|
|
3676
3631
|
Equivalent to Java TreeMap.lower.
|
|
3677
3632
|
Time Complexity: O(log n) average, O(h) worst case.
|
|
3678
3633
|
Space Complexity: O(h) for recursion, O(1) for iteration.
|
|
3679
3634
|
|
|
3680
|
-
*
|
|
3681
|
-
|
|
3682
3635
|
##### Parameters
|
|
3683
3636
|
|
|
3684
3637
|
###### keyNodeEntryOrPredicate
|
|
@@ -3716,7 +3669,7 @@ lower<C>(
|
|
|
3716
3669
|
iterationType?): ReturnType<C>;
|
|
3717
3670
|
```
|
|
3718
3671
|
|
|
3719
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
3672
|
+
Defined in: [data-structures/binary-tree/bst.ts:1524](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L1524)
|
|
3720
3673
|
|
|
3721
3674
|
Returns the first node with a key < target and applies callback.
|
|
3722
3675
|
Time Complexity: O(log n) average, O(h) worst case.
|
|
@@ -3766,12 +3719,10 @@ map<MK, MV, MR>(
|
|
|
3766
3719
|
thisArg?): RedBlackTree<MK, MV, MR>;
|
|
3767
3720
|
```
|
|
3768
3721
|
|
|
3769
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:
|
|
3722
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:658](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/red-black-tree.ts#L658)
|
|
3770
3723
|
|
|
3771
3724
|
Transform to new tree
|
|
3772
3725
|
|
|
3773
|
-
*
|
|
3774
|
-
|
|
3775
3726
|
#### Type Parameters
|
|
3776
3727
|
|
|
3777
3728
|
##### MK
|
|
@@ -3808,7 +3759,10 @@ Transform to new tree
|
|
|
3808
3759
|
|
|
3809
3760
|
```ts
|
|
3810
3761
|
// Transform to new tree
|
|
3811
|
-
const rbt = new RedBlackTree<number, number>([
|
|
3762
|
+
const rbt = new RedBlackTree<number, number>([
|
|
3763
|
+
[1, 10],
|
|
3764
|
+
[2, 20]
|
|
3765
|
+
]);
|
|
3812
3766
|
const doubled = rbt.map((v, k) => [k, (v ?? 0) * 2] as [number, number]);
|
|
3813
3767
|
console.log([...doubled.values()]); // [20, 40];
|
|
3814
3768
|
```
|
|
@@ -3831,7 +3785,7 @@ IBinaryTree.map
|
|
|
3831
3785
|
merge(anotherTree): void;
|
|
3832
3786
|
```
|
|
3833
3787
|
|
|
3834
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
3788
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:777](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L777)
|
|
3835
3789
|
|
|
3836
3790
|
Merges another tree into this one by seting all its nodes.
|
|
3837
3791
|
|
|
@@ -3843,8 +3797,6 @@ Merges another tree into this one by seting all its nodes.
|
|
|
3843
3797
|
|
|
3844
3798
|
The tree to merge.
|
|
3845
3799
|
|
|
3846
|
-
*
|
|
3847
|
-
|
|
3848
3800
|
#### Returns
|
|
3849
3801
|
|
|
3850
3802
|
`void`
|
|
@@ -3905,12 +3857,10 @@ The node to start from.
|
|
|
3905
3857
|
morris(): (K | undefined)[];
|
|
3906
3858
|
```
|
|
3907
3859
|
|
|
3908
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
3860
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1809](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L1809)
|
|
3909
3861
|
|
|
3910
3862
|
Morris traversal (O(1) space)
|
|
3911
3863
|
|
|
3912
|
-
*
|
|
3913
|
-
|
|
3914
3864
|
##### Returns
|
|
3915
3865
|
|
|
3916
3866
|
(`K` \| `undefined`)[]
|
|
@@ -3943,12 +3893,10 @@ morris<C>(
|
|
|
3943
3893
|
startNode?): ReturnType<C>[];
|
|
3944
3894
|
```
|
|
3945
3895
|
|
|
3946
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
3896
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1811](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L1811)
|
|
3947
3897
|
|
|
3948
3898
|
Morris traversal (O(1) space)
|
|
3949
3899
|
|
|
3950
|
-
*
|
|
3951
|
-
|
|
3952
3900
|
##### Type Parameters
|
|
3953
3901
|
|
|
3954
3902
|
###### C
|
|
@@ -4003,7 +3951,7 @@ IBinaryTree.morris
|
|
|
4003
3951
|
perfectlyBalance(_iterationType?): boolean;
|
|
4004
3952
|
```
|
|
4005
3953
|
|
|
4006
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:
|
|
3954
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:633](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/red-black-tree.ts#L633)
|
|
4007
3955
|
|
|
4008
3956
|
Red-Black trees are self-balancing — `perfectlyBalance` rebuilds via
|
|
4009
3957
|
sorted bulk insert, which naturally produces a balanced RBT.
|
|
@@ -4022,8 +3970,6 @@ sorted bulk insert, which naturally produces a balanced RBT.
|
|
|
4022
3970
|
|
|
4023
3971
|
Time O(N), Space O(N)
|
|
4024
3972
|
|
|
4025
|
-
*
|
|
4026
|
-
|
|
4027
3973
|
#### Example
|
|
4028
3974
|
|
|
4029
3975
|
```ts
|
|
@@ -4045,7 +3991,7 @@ Time O(N), Space O(N)
|
|
|
4045
3991
|
print(options?, startNode?): void;
|
|
4046
3992
|
```
|
|
4047
3993
|
|
|
4048
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
3994
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:2041](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L2041)
|
|
4049
3995
|
|
|
4050
3996
|
Prints a visual representation of the tree to the console.
|
|
4051
3997
|
|
|
@@ -4066,8 +4012,6 @@ Options to control the output.
|
|
|
4066
4012
|
|
|
4067
4013
|
The node to start printing from.
|
|
4068
4014
|
|
|
4069
|
-
*
|
|
4070
|
-
|
|
4071
4015
|
#### Returns
|
|
4072
4016
|
|
|
4073
4017
|
`void`
|
|
@@ -4098,7 +4042,7 @@ Time O(N) (via `toVisual`). Space O(N*H) or O(N^2) (via `toVisual`).
|
|
|
4098
4042
|
rangeByRank(start, end): (K | undefined)[];
|
|
4099
4043
|
```
|
|
4100
4044
|
|
|
4101
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
4045
|
+
Defined in: [data-structures/binary-tree/bst.ts:989](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L989)
|
|
4102
4046
|
|
|
4103
4047
|
Returns elements by position range in tree order (0-indexed, inclusive on both ends).
|
|
4104
4048
|
|
|
@@ -4140,7 +4084,7 @@ rangeByRank<C>(
|
|
|
4140
4084
|
iterationType?): ReturnType<C>[];
|
|
4141
4085
|
```
|
|
4142
4086
|
|
|
4143
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
4087
|
+
Defined in: [data-structures/binary-tree/bst.ts:1001](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L1001)
|
|
4144
4088
|
|
|
4145
4089
|
Returns elements by position range in tree order with callback and optional iteration type.
|
|
4146
4090
|
|
|
@@ -4226,12 +4170,10 @@ The traversal method.
|
|
|
4226
4170
|
rangeSearch(range): (K | undefined)[];
|
|
4227
4171
|
```
|
|
4228
4172
|
|
|
4229
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
4173
|
+
Defined in: [data-structures/binary-tree/bst.ts:807](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L807)
|
|
4230
4174
|
|
|
4231
4175
|
Find all keys in a range
|
|
4232
4176
|
|
|
4233
|
-
*
|
|
4234
|
-
|
|
4235
4177
|
##### Parameters
|
|
4236
4178
|
|
|
4237
4179
|
###### range
|
|
@@ -4264,12 +4206,10 @@ rangeSearch<C>(
|
|
|
4264
4206
|
iterationType?): ReturnType<C>[];
|
|
4265
4207
|
```
|
|
4266
4208
|
|
|
4267
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
4209
|
+
Defined in: [data-structures/binary-tree/bst.ts:809](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L809)
|
|
4268
4210
|
|
|
4269
4211
|
Find all keys in a range
|
|
4270
4212
|
|
|
4271
|
-
*
|
|
4272
|
-
|
|
4273
4213
|
##### Type Parameters
|
|
4274
4214
|
|
|
4275
4215
|
###### C
|
|
@@ -4407,12 +4347,10 @@ Whether to use 'RECURSIVE' or 'ITERATIVE' search.
|
|
|
4407
4347
|
search(keyNodeEntryOrPredicate, onlyOne?): (K | undefined)[];
|
|
4408
4348
|
```
|
|
4409
4349
|
|
|
4410
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
4350
|
+
Defined in: [data-structures/binary-tree/bst.ts:646](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L646)
|
|
4411
4351
|
|
|
4412
4352
|
Search nodes by predicate
|
|
4413
4353
|
|
|
4414
|
-
*
|
|
4415
|
-
|
|
4416
4354
|
##### Parameters
|
|
4417
4355
|
|
|
4418
4356
|
###### keyNodeEntryOrPredicate
|
|
@@ -4437,7 +4375,12 @@ Search nodes by predicate
|
|
|
4437
4375
|
|
|
4438
4376
|
```ts
|
|
4439
4377
|
// Search nodes by predicate
|
|
4440
|
-
const bst = new BST<number, string>([
|
|
4378
|
+
const bst = new BST<number, string>([
|
|
4379
|
+
[1, 'a'],
|
|
4380
|
+
[2, 'b'],
|
|
4381
|
+
[3, 'c'],
|
|
4382
|
+
[4, 'd']
|
|
4383
|
+
]);
|
|
4441
4384
|
const found = bst.search(node => node.key > 2, true);
|
|
4442
4385
|
console.log(found.length); // >= 1;
|
|
4443
4386
|
```
|
|
@@ -4463,12 +4406,10 @@ search<C>(
|
|
|
4463
4406
|
iterationType?): ReturnType<C>[];
|
|
4464
4407
|
```
|
|
4465
4408
|
|
|
4466
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
4409
|
+
Defined in: [data-structures/binary-tree/bst.ts:658](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L658)
|
|
4467
4410
|
|
|
4468
4411
|
Search nodes by predicate
|
|
4469
4412
|
|
|
4470
|
-
*
|
|
4471
|
-
|
|
4472
4413
|
##### Type Parameters
|
|
4473
4414
|
|
|
4474
4415
|
###### C
|
|
@@ -4514,7 +4455,12 @@ Search nodes by predicate
|
|
|
4514
4455
|
|
|
4515
4456
|
```ts
|
|
4516
4457
|
// Search nodes by predicate
|
|
4517
|
-
const bst = new BST<number, string>([
|
|
4458
|
+
const bst = new BST<number, string>([
|
|
4459
|
+
[1, 'a'],
|
|
4460
|
+
[2, 'b'],
|
|
4461
|
+
[3, 'c'],
|
|
4462
|
+
[4, 'd']
|
|
4463
|
+
]);
|
|
4518
4464
|
const found = bst.search(node => node.key > 2, true);
|
|
4519
4465
|
console.log(found.length); // >= 1;
|
|
4520
4466
|
```
|
|
@@ -4537,7 +4483,7 @@ IBinaryTree.search
|
|
|
4537
4483
|
set(keyNodeOrEntry, value?): boolean;
|
|
4538
4484
|
```
|
|
4539
4485
|
|
|
4540
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:
|
|
4486
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:472](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/red-black-tree.ts#L472)
|
|
4541
4487
|
|
|
4542
4488
|
Insert or update a key/value (map mode) or key-only (set mode).
|
|
4543
4489
|
|
|
@@ -4567,8 +4513,6 @@ This method is optimized for:
|
|
|
4567
4513
|
|
|
4568
4514
|
Time O(log n) average, Space O(1)
|
|
4569
4515
|
|
|
4570
|
-
*
|
|
4571
|
-
|
|
4572
4516
|
#### Example
|
|
4573
4517
|
|
|
4574
4518
|
```ts
|
|
@@ -4612,7 +4556,7 @@ setMany(
|
|
|
4612
4556
|
iterationType?): boolean[];
|
|
4613
4557
|
```
|
|
4614
4558
|
|
|
4615
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
4559
|
+
Defined in: [data-structures/binary-tree/bst.ts:1149](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L1149)
|
|
4616
4560
|
|
|
4617
4561
|
Adds multiple items to the tree.
|
|
4618
4562
|
|
|
@@ -4648,8 +4592,6 @@ The traversal method for balanced set (recursive or iterative).
|
|
|
4648
4592
|
|
|
4649
4593
|
An array of booleans indicating the success of each individual `set` operation.
|
|
4650
4594
|
|
|
4651
|
-
*
|
|
4652
|
-
|
|
4653
4595
|
#### Remarks
|
|
4654
4596
|
|
|
4655
4597
|
If `isBalanceAdd` is true, sorts the input and builds a balanced tree. Time O(N log N) (due to sort and balanced set).
|
|
@@ -4661,7 +4603,11 @@ Space O(N) for sorting and recursion/iteration stack.
|
|
|
4661
4603
|
```ts
|
|
4662
4604
|
// Set multiple key-value pairs
|
|
4663
4605
|
const bst = new BST<number, string>();
|
|
4664
|
-
bst.setMany([
|
|
4606
|
+
bst.setMany([
|
|
4607
|
+
[1, 'a'],
|
|
4608
|
+
[2, 'b'],
|
|
4609
|
+
[3, 'c']
|
|
4610
|
+
]);
|
|
4665
4611
|
console.log(bst.size); // 3;
|
|
4666
4612
|
console.log(bst.get(2)); // 'b';
|
|
4667
4613
|
```
|
|
@@ -4681,7 +4627,7 @@ setWithHint(
|
|
|
4681
4627
|
hint?): boolean;
|
|
4682
4628
|
```
|
|
4683
4629
|
|
|
4684
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:
|
|
4630
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:442](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/red-black-tree.ts#L442)
|
|
4685
4631
|
|
|
4686
4632
|
Boolean wrapper for setWithHintNode.
|
|
4687
4633
|
|
|
@@ -4718,7 +4664,7 @@ setWithHintNode(
|
|
|
4718
4664
|
hint?): RedBlackTreeNode<K, V> | undefined;
|
|
4719
4665
|
```
|
|
4720
4666
|
|
|
4721
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:
|
|
4667
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:351](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/red-black-tree.ts#L351)
|
|
4722
4668
|
|
|
4723
4669
|
Insert/update using a hint node to speed up nearby insertions.
|
|
4724
4670
|
|
|
@@ -4831,7 +4777,7 @@ Time O(n), Space O(n)
|
|
|
4831
4777
|
toVisual(startNode?, options?): string;
|
|
4832
4778
|
```
|
|
4833
4779
|
|
|
4834
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
4780
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:2004](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L2004)
|
|
4835
4781
|
|
|
4836
4782
|
Generates a string representation of the tree for visualization.
|
|
4837
4783
|
|
|
@@ -4909,7 +4855,7 @@ IBinaryTree.values
|
|
|
4909
4855
|
protected readonly _comparator: Comparator<K>;
|
|
4910
4856
|
```
|
|
4911
4857
|
|
|
4912
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
4858
|
+
Defined in: [data-structures/binary-tree/bst.ts:340](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L340)
|
|
4913
4859
|
|
|
4914
4860
|
The comparator function used to determine the order of keys in the tree.
|
|
4915
4861
|
|
|
@@ -4929,7 +4875,7 @@ Time O(1) Space O(1)
|
|
|
4929
4875
|
protected readonly _DEFAULT_NODE_CALLBACK: NodeCallback<BinaryTreeNode<K, V> | null | undefined, K | undefined>;
|
|
4930
4876
|
```
|
|
4931
4877
|
|
|
4932
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
4878
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:2298](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L2298)
|
|
4933
4879
|
|
|
4934
4880
|
(Protected) Default callback function, returns the node's key.
|
|
4935
4881
|
|
|
@@ -4957,7 +4903,7 @@ The node's key or undefined.
|
|
|
4957
4903
|
protected _header: RedBlackTreeNode<K, V>;
|
|
4958
4904
|
```
|
|
4959
4905
|
|
|
4960
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:
|
|
4906
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:260](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/red-black-tree.ts#L260)
|
|
4961
4907
|
|
|
4962
4908
|
(Internal) Header sentinel:
|
|
4963
4909
|
- header.parent -> root
|
|
@@ -4977,7 +4923,7 @@ IMPORTANT:
|
|
|
4977
4923
|
protected _minNode: RedBlackTreeNode<K, V> | undefined;
|
|
4978
4924
|
```
|
|
4979
4925
|
|
|
4980
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:
|
|
4926
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:266](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/red-black-tree.ts#L266)
|
|
4981
4927
|
|
|
4982
4928
|
(Internal) Cache of the current minimum and maximum nodes.
|
|
4983
4929
|
Used for fast-path insert/update when keys are monotonic or near-boundary.
|
|
@@ -4993,7 +4939,7 @@ protected _attachNewNode(
|
|
|
4993
4939
|
node): void;
|
|
4994
4940
|
```
|
|
4995
4941
|
|
|
4996
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:
|
|
4942
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:742](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/red-black-tree.ts#L742)
|
|
4997
4943
|
|
|
4998
4944
|
(Internal) Attach a new node directly under a known parent/side (no search).
|
|
4999
4945
|
|
|
@@ -5038,7 +4984,7 @@ protected _bound(
|
|
|
5038
4984
|
iterationType): BSTNode<K, V> | undefined;
|
|
5039
4985
|
```
|
|
5040
4986
|
|
|
5041
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
4987
|
+
Defined in: [data-structures/binary-tree/bst.ts:2139](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L2139)
|
|
5042
4988
|
|
|
5043
4989
|
(Protected) Core bound search implementation supporting all parameter types.
|
|
5044
4990
|
Unified logic for both lowerBound and upperBound.
|
|
@@ -5090,7 +5036,7 @@ protected _boundByKey(
|
|
|
5090
5036
|
iterationType): BSTNode<K, V> | undefined;
|
|
5091
5037
|
```
|
|
5092
5038
|
|
|
5093
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
5039
|
+
Defined in: [data-structures/binary-tree/bst.ts:2196](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L2196)
|
|
5094
5040
|
|
|
5095
5041
|
(Protected) Binary search for bound by key with pruning optimization.
|
|
5096
5042
|
Performs standard BST binary search, choosing left or right subtree based on comparator result.
|
|
@@ -5135,7 +5081,7 @@ The first node matching the bound condition, or undefined if none exists.
|
|
|
5135
5081
|
protected _boundByPredicate(predicate, iterationType): BSTNode<K, V> | undefined;
|
|
5136
5082
|
```
|
|
5137
5083
|
|
|
5138
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
5084
|
+
Defined in: [data-structures/binary-tree/bst.ts:2251](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L2251)
|
|
5139
5085
|
|
|
5140
5086
|
(Protected) In-order traversal search by predicate.
|
|
5141
5087
|
Falls back to linear in-order traversal when predicate-based search is required.
|
|
@@ -5175,7 +5121,7 @@ The first node satisfying predicate, or undefined if none found.
|
|
|
5175
5121
|
protected _clearNodes(): void;
|
|
5176
5122
|
```
|
|
5177
5123
|
|
|
5178
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
5124
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:2701](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L2701)
|
|
5179
5125
|
|
|
5180
5126
|
(Protected) Clears all nodes from the tree.
|
|
5181
5127
|
|
|
@@ -5199,7 +5145,7 @@ Time O(1)
|
|
|
5199
5145
|
protected _clearValues(): void;
|
|
5200
5146
|
```
|
|
5201
5147
|
|
|
5202
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
5148
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:2710](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L2710)
|
|
5203
5149
|
|
|
5204
5150
|
(Protected) Clears all values from the external store.
|
|
5205
5151
|
|
|
@@ -5223,7 +5169,7 @@ Time O(N)
|
|
|
5223
5169
|
protected _clone(cloned): void;
|
|
5224
5170
|
```
|
|
5225
5171
|
|
|
5226
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
5172
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:2392](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L2392)
|
|
5227
5173
|
|
|
5228
5174
|
(Protected) Helper for cloning. Performs a BFS and sets all nodes to the new tree.
|
|
5229
5175
|
|
|
@@ -5255,7 +5201,7 @@ Time O(N * M) (O(N) BFS + O(M) `set` for each node).
|
|
|
5255
5201
|
protected _compare(a, b): number;
|
|
5256
5202
|
```
|
|
5257
5203
|
|
|
5258
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
5204
|
+
Defined in: [data-structures/binary-tree/bst.ts:2517](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L2517)
|
|
5259
5205
|
|
|
5260
5206
|
(Protected) Compares two keys using the tree's comparator and reverse setting.
|
|
5261
5207
|
|
|
@@ -5295,7 +5241,7 @@ Time O(1) Space O(1)
|
|
|
5295
5241
|
protected _createDefaultComparator(): Comparator<K>;
|
|
5296
5242
|
```
|
|
5297
5243
|
|
|
5298
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
5244
|
+
Defined in: [data-structures/binary-tree/bst.ts:1866](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L1866)
|
|
5299
5245
|
|
|
5300
5246
|
(Protected) Creates the default comparator function for keys that don't have a custom comparator.
|
|
5301
5247
|
|
|
@@ -5321,7 +5267,7 @@ Time O(1) Space O(1)
|
|
|
5321
5267
|
protected _createInstance<TK, TV, TR>(options?): this;
|
|
5322
5268
|
```
|
|
5323
5269
|
|
|
5324
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:
|
|
5270
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:925](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/red-black-tree.ts#L925)
|
|
5325
5271
|
|
|
5326
5272
|
(Internal) Create an empty instance of the same concrete tree type.
|
|
5327
5273
|
|
|
@@ -5365,7 +5311,7 @@ Time O(1) average, Space O(1)
|
|
|
5365
5311
|
protected _createLike<TK, TV, TR>(iter?, options?): RedBlackTree<TK, TV, TR>;
|
|
5366
5312
|
```
|
|
5367
5313
|
|
|
5368
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:
|
|
5314
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:937](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/red-black-tree.ts#L937)
|
|
5369
5315
|
|
|
5370
5316
|
(Internal) Create a like-kind tree (same concrete class) populated from an iterable.
|
|
5371
5317
|
|
|
@@ -5419,7 +5365,7 @@ Time O(m log m) average (m = iterable length), Space O(m)
|
|
|
5419
5365
|
protected _deleteByKey(key): boolean;
|
|
5420
5366
|
```
|
|
5421
5367
|
|
|
5422
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
5368
|
+
Defined in: [data-structures/binary-tree/bst.ts:2528](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L2528)
|
|
5423
5369
|
|
|
5424
5370
|
(Private) Deletes a node by its key.
|
|
5425
5371
|
|
|
@@ -5453,7 +5399,7 @@ Standard BST deletion algorithm. Time O(log N), O(N) worst-case. Space O(1).
|
|
|
5453
5399
|
protected _deleteFixup(node): void;
|
|
5454
5400
|
```
|
|
5455
5401
|
|
|
5456
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:
|
|
5402
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:1104](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/red-black-tree.ts#L1104)
|
|
5457
5403
|
|
|
5458
5404
|
(Protected) Restore red-black properties after deletion (recolor/rotate).
|
|
5459
5405
|
|
|
@@ -5483,7 +5429,7 @@ Time O(log n) average, Space O(1)
|
|
|
5483
5429
|
protected _deleteInternal(keyNodeEntryRawOrPredicate): BinaryTreeDeleteResult<BinaryTreeNode<K, V>>[];
|
|
5484
5430
|
```
|
|
5485
5431
|
|
|
5486
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
5432
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:2056](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L2056)
|
|
5487
5433
|
|
|
5488
5434
|
**`Internal`**
|
|
5489
5435
|
|
|
@@ -5531,7 +5477,7 @@ protected _dfs<C>(
|
|
|
5531
5477
|
shouldProcessRoot?): ReturnType<C>[];
|
|
5532
5478
|
```
|
|
5533
5479
|
|
|
5534
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
5480
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:2109](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L2109)
|
|
5535
5481
|
|
|
5536
5482
|
#### Type Parameters
|
|
5537
5483
|
|
|
@@ -5624,7 +5570,7 @@ Array of callback results.
|
|
|
5624
5570
|
protected _displayAux(node, options): NodeDisplayLayout;
|
|
5625
5571
|
```
|
|
5626
5572
|
|
|
5627
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
5573
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:2416](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L2416)
|
|
5628
5574
|
|
|
5629
5575
|
(Protected) Recursive helper for `toVisual`.
|
|
5630
5576
|
|
|
@@ -5664,7 +5610,7 @@ Time O(N), Space O(N*H) or O(N^2)
|
|
|
5664
5610
|
protected _ensurePredicate(keyNodeEntryOrPredicate): NodePredicate<BinaryTreeNode<K, V>>;
|
|
5665
5611
|
```
|
|
5666
5612
|
|
|
5667
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
5613
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:2607](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L2607)
|
|
5668
5614
|
|
|
5669
5615
|
(Protected) Converts a key, node, entry, or predicate into a standardized predicate function.
|
|
5670
5616
|
|
|
@@ -5703,7 +5649,7 @@ Time O(1)
|
|
|
5703
5649
|
protected _extractKey(keyNodeOrEntry): K | null | undefined;
|
|
5704
5650
|
```
|
|
5705
5651
|
|
|
5706
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
5652
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:2667](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L2667)
|
|
5707
5653
|
|
|
5708
5654
|
(Protected) Extracts the key from a key, node, or entry.
|
|
5709
5655
|
|
|
@@ -5741,7 +5687,7 @@ Time O(1)
|
|
|
5741
5687
|
protected _findNodeByKey(key): RedBlackTreeNode<K, V> | undefined;
|
|
5742
5688
|
```
|
|
5743
5689
|
|
|
5744
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:
|
|
5690
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:677](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/red-black-tree.ts#L677)
|
|
5745
5691
|
|
|
5746
5692
|
(Internal) Find a node by key using a tight BST walk (no allocations).
|
|
5747
5693
|
|
|
@@ -5769,7 +5715,7 @@ Time O(log n) average, Space O(1)
|
|
|
5769
5715
|
protected _floorByKey(key, iterationType): BSTNode<K, V> | undefined;
|
|
5770
5716
|
```
|
|
5771
5717
|
|
|
5772
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
5718
|
+
Defined in: [data-structures/binary-tree/bst.ts:1904](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L1904)
|
|
5773
5719
|
|
|
5774
5720
|
(Protected) Binary search for floor by key with pruning optimization.
|
|
5775
5721
|
Performs standard BST binary search, choosing left or right subtree based on comparator result.
|
|
@@ -5811,7 +5757,7 @@ Time O(h) where h is tree height.
|
|
|
5811
5757
|
protected _floorByPredicate(predicate, iterationType): BSTNode<K, V> | undefined;
|
|
5812
5758
|
```
|
|
5813
5759
|
|
|
5814
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
5760
|
+
Defined in: [data-structures/binary-tree/bst.ts:1957](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L1957)
|
|
5815
5761
|
|
|
5816
5762
|
(Protected) In-order traversal search for floor by predicate.
|
|
5817
5763
|
Falls back to linear in-order traversal when predicate-based search is required.
|
|
@@ -5854,7 +5800,7 @@ Space Complexity: O(h) for recursion, O(h) for iterative stack.
|
|
|
5854
5800
|
protected _getByRankIterative(node, k): BSTNode<K, V> | undefined;
|
|
5855
5801
|
```
|
|
5856
5802
|
|
|
5857
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
5803
|
+
Defined in: [data-structures/binary-tree/bst.ts:2406](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L2406)
|
|
5858
5804
|
|
|
5859
5805
|
(Protected) Finds the node at position k in tree order (iterative).
|
|
5860
5806
|
|
|
@@ -5888,7 +5834,7 @@ Time O(log n), Space O(1)
|
|
|
5888
5834
|
protected _getByRankRecursive(node, k): BSTNode<K, V> | undefined;
|
|
5889
5835
|
```
|
|
5890
5836
|
|
|
5891
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
5837
|
+
Defined in: [data-structures/binary-tree/bst.ts:2427](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L2427)
|
|
5892
5838
|
|
|
5893
5839
|
(Protected) Finds the node at position k in tree order (recursive).
|
|
5894
5840
|
|
|
@@ -5922,7 +5868,7 @@ Time O(log n), Space O(log n) call stack
|
|
|
5922
5868
|
protected _getIterator(node?): IterableIterator<[K, V | undefined]>;
|
|
5923
5869
|
```
|
|
5924
5870
|
|
|
5925
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
5871
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:2254](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L2254)
|
|
5926
5872
|
|
|
5927
5873
|
(Protected) Gets the iterator for the tree (default in-order).
|
|
5928
5874
|
|
|
@@ -5956,7 +5902,7 @@ Time O(N) for full iteration. O(H) to get the first element. Space O(H) for the
|
|
|
5956
5902
|
protected _getRankIterative(node, key): number;
|
|
5957
5903
|
```
|
|
5958
5904
|
|
|
5959
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
5905
|
+
Defined in: [data-structures/binary-tree/bst.ts:2439](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L2439)
|
|
5960
5906
|
|
|
5961
5907
|
(Protected) Computes the rank of a key iteratively.
|
|
5962
5908
|
|
|
@@ -5990,7 +5936,7 @@ Time O(log n), Space O(1)
|
|
|
5990
5936
|
protected _getRankRecursive(node, key): number;
|
|
5991
5937
|
```
|
|
5992
5938
|
|
|
5993
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
5939
|
+
Defined in: [data-structures/binary-tree/bst.ts:2465](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L2465)
|
|
5994
5940
|
|
|
5995
5941
|
(Protected) Computes the rank of a key recursively.
|
|
5996
5942
|
|
|
@@ -6024,7 +5970,7 @@ Time O(log n), Space O(log n) call stack
|
|
|
6024
5970
|
protected _insert(node): CRUD;
|
|
6025
5971
|
```
|
|
6026
5972
|
|
|
6027
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:
|
|
5973
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:983](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/red-black-tree.ts#L983)
|
|
6028
5974
|
|
|
6029
5975
|
(Protected) Standard BST insert followed by red-black fix-up.
|
|
6030
5976
|
|
|
@@ -6054,7 +6000,7 @@ Time O(log n) average, Space O(1)
|
|
|
6054
6000
|
protected _insertFixup(z): void;
|
|
6055
6001
|
```
|
|
6056
6002
|
|
|
6057
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:
|
|
6003
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:1044](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/red-black-tree.ts#L1044)
|
|
6058
6004
|
|
|
6059
6005
|
(Protected) Restore red-black properties after insertion (recolor/rotate).
|
|
6060
6006
|
|
|
@@ -6084,7 +6030,7 @@ Time O(log n) average, Space O(1)
|
|
|
6084
6030
|
protected _isDisplayLeaf(node, options): boolean;
|
|
6085
6031
|
```
|
|
6086
6032
|
|
|
6087
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
6033
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:2482](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L2482)
|
|
6088
6034
|
|
|
6089
6035
|
Check if a node is a display leaf (empty, null, undefined, NIL, or real leaf).
|
|
6090
6036
|
|
|
@@ -6114,7 +6060,7 @@ Check if a node is a display leaf (empty, null, undefined, NIL, or real leaf).
|
|
|
6114
6060
|
protected _isPredicate(p): p is NodePredicate<BinaryTreeNode<K, V>>;
|
|
6115
6061
|
```
|
|
6116
6062
|
|
|
6117
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
6063
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:2656](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L2656)
|
|
6118
6064
|
|
|
6119
6065
|
(Protected) Checks if an item is a predicate function.
|
|
6120
6066
|
|
|
@@ -6148,7 +6094,7 @@ Time O(1)
|
|
|
6148
6094
|
protected _keyValueNodeOrEntryToNodeAndValue(keyNodeOrEntry, value?): [OptNode<BSTNode<K, V>>, V | undefined];
|
|
6149
6095
|
```
|
|
6150
6096
|
|
|
6151
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
6097
|
+
Defined in: [data-structures/binary-tree/bst.ts:2364](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L2364)
|
|
6152
6098
|
|
|
6153
6099
|
(Protected) Converts a key, node, or entry into a standardized [node, value] tuple.
|
|
6154
6100
|
|
|
@@ -6192,7 +6138,7 @@ Time O(1)
|
|
|
6192
6138
|
protected _leftRotate(x): void;
|
|
6193
6139
|
```
|
|
6194
6140
|
|
|
6195
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:
|
|
6141
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:1176](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/red-black-tree.ts#L1176)
|
|
6196
6142
|
|
|
6197
6143
|
(Protected) Perform a left rotation around x.
|
|
6198
6144
|
|
|
@@ -6222,7 +6168,7 @@ Time O(1), Space O(1)
|
|
|
6222
6168
|
protected _lowerByKey(key, iterationType): BSTNode<K, V> | undefined;
|
|
6223
6169
|
```
|
|
6224
6170
|
|
|
6225
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
6171
|
+
Defined in: [data-structures/binary-tree/bst.ts:2022](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L2022)
|
|
6226
6172
|
|
|
6227
6173
|
(Protected) Binary search for lower by key with pruning optimization.
|
|
6228
6174
|
Performs standard BST binary search, choosing left or right subtree based on comparator result.
|
|
@@ -6264,7 +6210,7 @@ Time O(h) where h is tree height.
|
|
|
6264
6210
|
protected _lowerByPredicate(predicate, iterationType): BSTNode<K, V> | undefined;
|
|
6265
6211
|
```
|
|
6266
6212
|
|
|
6267
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
6213
|
+
Defined in: [data-structures/binary-tree/bst.ts:2075](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L2075)
|
|
6268
6214
|
|
|
6269
6215
|
(Protected) In-order traversal search for lower by predicate.
|
|
6270
6216
|
Falls back to linear in-order traversal when predicate-based search is required.
|
|
@@ -6307,7 +6253,7 @@ Space Complexity: O(h) for recursion, O(h) for iterative stack.
|
|
|
6307
6253
|
protected _next(node): BSTNode<K, V> | undefined;
|
|
6308
6254
|
```
|
|
6309
6255
|
|
|
6310
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
6256
|
+
Defined in: [data-structures/binary-tree/bst.ts:2485](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L2485)
|
|
6311
6257
|
|
|
6312
6258
|
(Protected) Finds the in-order successor of a node.
|
|
6313
6259
|
|
|
@@ -6337,7 +6283,7 @@ Time O(log n), Space O(1)
|
|
|
6337
6283
|
protected _predecessorOf(node): RedBlackTreeNode<K, V> | undefined;
|
|
6338
6284
|
```
|
|
6339
6285
|
|
|
6340
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:
|
|
6286
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:694](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/red-black-tree.ts#L694)
|
|
6341
6287
|
|
|
6342
6288
|
(Internal) In-order predecessor of a node in a BST.
|
|
6343
6289
|
|
|
@@ -6363,7 +6309,7 @@ Time O(log n) average, Space O(1)
|
|
|
6363
6309
|
protected _replaceNode(oldNode, newNode): RedBlackTreeNode<K, V>;
|
|
6364
6310
|
```
|
|
6365
6311
|
|
|
6366
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:
|
|
6312
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:969](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/red-black-tree.ts#L969)
|
|
6367
6313
|
|
|
6368
6314
|
(Internal) Replace a node in place while preserving its color.
|
|
6369
6315
|
|
|
@@ -6400,7 +6346,7 @@ protected _resolveDisplayLeaf(
|
|
|
6400
6346
|
emptyDisplayLayout): NodeDisplayLayout;
|
|
6401
6347
|
```
|
|
6402
6348
|
|
|
6403
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
6349
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:2509](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L2509)
|
|
6404
6350
|
|
|
6405
6351
|
Resolve a display leaf node to its layout.
|
|
6406
6352
|
|
|
@@ -6434,7 +6380,7 @@ Resolve a display leaf node to its layout.
|
|
|
6434
6380
|
protected _rightRotate(y): void;
|
|
6435
6381
|
```
|
|
6436
6382
|
|
|
6437
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:
|
|
6383
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:1206](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/red-black-tree.ts#L1206)
|
|
6438
6384
|
|
|
6439
6385
|
(Protected) Perform a right rotation around y.
|
|
6440
6386
|
|
|
@@ -6464,7 +6410,7 @@ Time O(1), Space O(1)
|
|
|
6464
6410
|
protected _setKV(key, nextValue?): boolean;
|
|
6465
6411
|
```
|
|
6466
6412
|
|
|
6467
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:
|
|
6413
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:909](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/red-black-tree.ts#L909)
|
|
6468
6414
|
|
|
6469
6415
|
(Internal) Boolean wrapper around `_setKVNode`.
|
|
6470
6416
|
|
|
@@ -6505,7 +6451,7 @@ protected _setKVNode(key, nextValue?):
|
|
|
6505
6451
|
| undefined;
|
|
6506
6452
|
```
|
|
6507
6453
|
|
|
6508
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:
|
|
6454
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:792](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/red-black-tree.ts#L792)
|
|
6509
6455
|
|
|
6510
6456
|
(Internal) Core set implementation returning the affected node.
|
|
6511
6457
|
|
|
@@ -6549,7 +6495,7 @@ Time O(log n) average, Space O(1)
|
|
|
6549
6495
|
protected _setMaxCache(node): void;
|
|
6550
6496
|
```
|
|
6551
6497
|
|
|
6552
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:
|
|
6498
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:773](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/red-black-tree.ts#L773)
|
|
6553
6499
|
|
|
6554
6500
|
(Internal) Update max cache pointers (header._right is the canonical max pointer).
|
|
6555
6501
|
|
|
@@ -6575,7 +6521,7 @@ Time O(1), Space O(1)
|
|
|
6575
6521
|
protected _setMinCache(node): void;
|
|
6576
6522
|
```
|
|
6577
6523
|
|
|
6578
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:
|
|
6524
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:764](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/red-black-tree.ts#L764)
|
|
6579
6525
|
|
|
6580
6526
|
(Internal) Update min cache pointers (header._left is the canonical min pointer).
|
|
6581
6527
|
|
|
@@ -6601,7 +6547,7 @@ Time O(1), Space O(1)
|
|
|
6601
6547
|
protected _setRoot(v): void;
|
|
6602
6548
|
```
|
|
6603
6549
|
|
|
6604
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:
|
|
6550
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:954](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/red-black-tree.ts#L954)
|
|
6605
6551
|
|
|
6606
6552
|
(Internal) Set the root pointer and keep header.parent in sync.
|
|
6607
6553
|
|
|
@@ -6631,7 +6577,7 @@ Time O(1), Space O(1)
|
|
|
6631
6577
|
protected _setValue(key, value): boolean;
|
|
6632
6578
|
```
|
|
6633
6579
|
|
|
6634
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
6580
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:2688](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L2688)
|
|
6635
6581
|
|
|
6636
6582
|
(Protected) Sets a value in the external store (Map mode).
|
|
6637
6583
|
|
|
@@ -6671,7 +6617,7 @@ Time O(1) (average for Map.set).
|
|
|
6671
6617
|
protected _snapshotOptions<TK, TV, TR>(): BSTOptions<TK, TV, TR>;
|
|
6672
6618
|
```
|
|
6673
6619
|
|
|
6674
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
6620
|
+
Defined in: [data-structures/binary-tree/bst.ts:2348](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L2348)
|
|
6675
6621
|
|
|
6676
6622
|
(Protected) Snapshots the current BST's configuration options.
|
|
6677
6623
|
|
|
@@ -6711,7 +6657,7 @@ Time O(1)
|
|
|
6711
6657
|
protected _successorOf(node): RedBlackTreeNode<K, V> | undefined;
|
|
6712
6658
|
```
|
|
6713
6659
|
|
|
6714
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:
|
|
6660
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:714](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/red-black-tree.ts#L714)
|
|
6715
6661
|
|
|
6716
6662
|
(Internal) In-order successor of a node in a BST.
|
|
6717
6663
|
|
|
@@ -6737,7 +6683,7 @@ Time O(log n) average, Space O(1)
|
|
|
6737
6683
|
protected _swapProperties(srcNode, destNode): BinaryTreeNode<K, V> | undefined;
|
|
6738
6684
|
```
|
|
6739
6685
|
|
|
6740
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
6686
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:2535](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/binary-tree.ts#L2535)
|
|
6741
6687
|
|
|
6742
6688
|
(Protected) Swaps the key/value properties of two nodes.
|
|
6743
6689
|
|
|
@@ -6785,7 +6731,7 @@ Time O(1)
|
|
|
6785
6731
|
protected _transplant(u, v): void;
|
|
6786
6732
|
```
|
|
6787
6733
|
|
|
6788
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:
|
|
6734
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:1025](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/red-black-tree.ts#L1025)
|
|
6789
6735
|
|
|
6790
6736
|
(Protected) Transplant a subtree in place of another during deletion.
|
|
6791
6737
|
|
|
@@ -6821,7 +6767,7 @@ Time O(1), Space O(1)
|
|
|
6821
6767
|
protected _updateCount(node): void;
|
|
6822
6768
|
```
|
|
6823
6769
|
|
|
6824
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
6770
|
+
Defined in: [data-structures/binary-tree/bst.ts:2383](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L2383)
|
|
6825
6771
|
|
|
6826
6772
|
(Protected) Recalculates the subtree count for a single node.
|
|
6827
6773
|
|
|
@@ -6851,7 +6797,7 @@ Time O(1). Only active when enableOrderStatistic is true.
|
|
|
6851
6797
|
protected _updateCountAlongPath(node): void;
|
|
6852
6798
|
```
|
|
6853
6799
|
|
|
6854
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
6800
|
+
Defined in: [data-structures/binary-tree/bst.ts:2393](https://github.com/zrwusa/data-structure-typed/blob/main/src/data-structures/binary-tree/bst.ts#L2393)
|
|
6855
6801
|
|
|
6856
6802
|
(Protected) Updates subtree counts from a node up to the root.
|
|
6857
6803
|
|