data-structure-typed 2.5.1 → 2.5.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/CHANGELOG.md +3 -1
- package/README.md +75 -17
- package/dist/cjs/binary-tree.cjs +2723 -139
- package/dist/cjs/graph.cjs +192 -6
- package/dist/cjs/hash.cjs +63 -15
- package/dist/cjs/heap.cjs +93 -31
- package/dist/cjs/index.cjs +3514 -379
- package/dist/cjs/linked-list.cjs +237 -31
- package/dist/cjs/matrix.cjs +47 -9
- package/dist/cjs/priority-queue.cjs +92 -30
- package/dist/cjs/queue.cjs +176 -2
- package/dist/cjs/stack.cjs +48 -2
- package/dist/cjs/trie.cjs +78 -28
- package/dist/cjs-legacy/binary-tree.cjs +2725 -136
- package/dist/cjs-legacy/graph.cjs +192 -6
- package/dist/cjs-legacy/hash.cjs +63 -15
- package/dist/cjs-legacy/heap.cjs +93 -31
- package/dist/cjs-legacy/index.cjs +3389 -249
- package/dist/cjs-legacy/linked-list.cjs +237 -31
- package/dist/cjs-legacy/matrix.cjs +47 -9
- package/dist/cjs-legacy/priority-queue.cjs +92 -30
- package/dist/cjs-legacy/queue.cjs +176 -2
- package/dist/cjs-legacy/stack.cjs +48 -2
- package/dist/cjs-legacy/trie.cjs +78 -28
- package/dist/esm/binary-tree.mjs +2723 -139
- package/dist/esm/graph.mjs +192 -6
- package/dist/esm/hash.mjs +63 -15
- package/dist/esm/heap.mjs +93 -31
- package/dist/esm/index.mjs +3514 -380
- package/dist/esm/linked-list.mjs +237 -31
- package/dist/esm/matrix.mjs +47 -9
- package/dist/esm/priority-queue.mjs +92 -30
- package/dist/esm/queue.mjs +176 -2
- package/dist/esm/stack.mjs +48 -2
- package/dist/esm/trie.mjs +78 -28
- package/dist/esm-legacy/binary-tree.mjs +2725 -136
- package/dist/esm-legacy/graph.mjs +192 -6
- package/dist/esm-legacy/hash.mjs +63 -15
- package/dist/esm-legacy/heap.mjs +93 -31
- package/dist/esm-legacy/index.mjs +3389 -250
- package/dist/esm-legacy/linked-list.mjs +237 -31
- package/dist/esm-legacy/matrix.mjs +47 -9
- package/dist/esm-legacy/priority-queue.mjs +92 -30
- package/dist/esm-legacy/queue.mjs +176 -2
- package/dist/esm-legacy/stack.mjs +48 -2
- package/dist/esm-legacy/trie.mjs +78 -28
- package/dist/types/common/error.d.ts +9 -0
- package/dist/types/common/index.d.ts +1 -1
- package/dist/types/data-structures/binary-tree/avl-tree.d.ts +48 -0
- package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +56 -0
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +102 -2
- package/dist/types/data-structures/binary-tree/bst.d.ts +195 -0
- package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +76 -0
- package/dist/types/data-structures/binary-tree/segment-tree.d.ts +24 -0
- package/dist/types/data-structures/binary-tree/tree-map.d.ts +528 -0
- package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +531 -6
- package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +435 -6
- package/dist/types/data-structures/binary-tree/tree-set.d.ts +505 -0
- package/dist/types/data-structures/graph/directed-graph.d.ts +40 -0
- package/dist/types/data-structures/graph/undirected-graph.d.ts +36 -0
- package/dist/types/data-structures/hash/hash-map.d.ts +44 -0
- package/dist/types/data-structures/heap/heap.d.ts +56 -0
- package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +68 -0
- package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +60 -0
- package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +72 -0
- package/dist/types/data-structures/matrix/matrix.d.ts +32 -0
- package/dist/types/data-structures/queue/deque.d.ts +60 -0
- package/dist/types/data-structures/queue/queue.d.ts +48 -0
- package/dist/types/data-structures/stack/stack.d.ts +40 -0
- package/dist/types/data-structures/trie/trie.d.ts +48 -0
- package/dist/types/types/data-structures/binary-tree/bst.d.ts +1 -0
- package/dist/types/types/data-structures/binary-tree/tree-map.d.ts +5 -0
- package/dist/types/types/data-structures/binary-tree/tree-multi-set.d.ts +4 -0
- package/dist/types/types/data-structures/binary-tree/tree-set.d.ts +4 -0
- package/dist/umd/data-structure-typed.js +3404 -265
- package/dist/umd/data-structure-typed.min.js +5 -5
- package/docs-site-docusaurus/docs/api/classes/AVLTree.md +650 -136
- package/docs-site-docusaurus/docs/api/classes/AVLTreeNode.md +11 -11
- package/docs-site-docusaurus/docs/api/classes/AbstractGraph.md +71 -71
- package/docs-site-docusaurus/docs/api/classes/BST.md +591 -129
- package/docs-site-docusaurus/docs/api/classes/BSTNode.md +13 -13
- package/docs-site-docusaurus/docs/api/classes/BinaryIndexedTree.md +15 -15
- package/docs-site-docusaurus/docs/api/classes/BinaryTree.md +107 -107
- package/docs-site-docusaurus/docs/api/classes/BinaryTreeNode.md +13 -13
- package/docs-site-docusaurus/docs/api/classes/Deque.md +82 -82
- package/docs-site-docusaurus/docs/api/classes/DirectedGraph.md +82 -82
- package/docs-site-docusaurus/docs/api/classes/DoublyLinkedList.md +74 -74
- package/docs-site-docusaurus/docs/api/classes/DoublyLinkedListNode.md +8 -8
- 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 +47 -47
- package/docs-site-docusaurus/docs/api/classes/Heap.md +45 -45
- package/docs-site-docusaurus/docs/api/classes/IterableElementBase.md +25 -25
- package/docs-site-docusaurus/docs/api/classes/IterableEntryBase.md +33 -33
- package/docs-site-docusaurus/docs/api/classes/LinearBase.md +50 -50
- package/docs-site-docusaurus/docs/api/classes/LinearLinkedBase.md +55 -55
- package/docs-site-docusaurus/docs/api/classes/LinkedHashMap.md +49 -49
- package/docs-site-docusaurus/docs/api/classes/LinkedListNode.md +6 -6
- package/docs-site-docusaurus/docs/api/classes/LinkedListQueue.md +78 -78
- package/docs-site-docusaurus/docs/api/classes/MapGraph.md +82 -82
- package/docs-site-docusaurus/docs/api/classes/Matrix.md +31 -31
- package/docs-site-docusaurus/docs/api/classes/MaxHeap.md +45 -45
- package/docs-site-docusaurus/docs/api/classes/MaxPriorityQueue.md +45 -45
- package/docs-site-docusaurus/docs/api/classes/MinHeap.md +45 -45
- package/docs-site-docusaurus/docs/api/classes/MinPriorityQueue.md +45 -45
- package/docs-site-docusaurus/docs/api/classes/Navigator.md +5 -5
- package/docs-site-docusaurus/docs/api/classes/PriorityQueue.md +44 -44
- package/docs-site-docusaurus/docs/api/classes/Queue.md +60 -60
- package/docs-site-docusaurus/docs/api/classes/RedBlackTree.md +660 -146
- package/docs-site-docusaurus/docs/api/classes/SegmentTree.md +10 -10
- package/docs-site-docusaurus/docs/api/classes/SinglyLinkedList.md +78 -78
- package/docs-site-docusaurus/docs/api/classes/SinglyLinkedListNode.md +6 -6
- package/docs-site-docusaurus/docs/api/classes/SkipList.md +44 -44
- package/docs-site-docusaurus/docs/api/classes/Stack.md +39 -39
- package/docs-site-docusaurus/docs/api/classes/TreeMap.md +165 -33
- package/docs-site-docusaurus/docs/api/classes/TreeMultiMap.md +162 -46
- package/docs-site-docusaurus/docs/api/classes/TreeSet.md +161 -32
- package/docs-site-docusaurus/docs/api/classes/Trie.md +47 -47
- package/docs-site-docusaurus/docs/api/classes/TrieNode.md +8 -8
- package/docs-site-docusaurus/docs/api/classes/UndirectedGraph.md +81 -81
- package/docs-site-docusaurus/docs/guide/architecture.md +2 -0
- package/docs-site-docusaurus/docs/guide/concepts.md +32 -1
- package/docs-site-docusaurus/docs/guide/faq.md +180 -0
- package/docs-site-docusaurus/docs/guide/guides.md +40 -54
- package/docs-site-docusaurus/docs/guide/installation.md +2 -0
- package/docs-site-docusaurus/docs/guide/integrations.md +2 -0
- package/docs-site-docusaurus/docs/guide/overview.md +7 -0
- package/docs-site-docusaurus/docs/guide/performance.md +2 -0
- package/docs-site-docusaurus/docs/guide/quick-start.md +31 -0
- package/docs-site-docusaurus/docs/guide/use-cases/_category_.json +6 -0
- package/docs-site-docusaurus/docs/guide/use-cases/array-sort-alternative.md +158 -0
- package/docs-site-docusaurus/docs/guide/use-cases/heap-vs-sorting.md +92 -0
- package/docs-site-docusaurus/docs/guide/use-cases/map-vs-treemap.md +151 -0
- package/docs-site-docusaurus/docs/guide/use-cases/priority-queue-typescript.md +113 -0
- package/docs-site-docusaurus/docs/guide/use-cases/treemap-javascript.md +151 -0
- package/docs-site-docusaurus/docusaurus.config.ts +1 -1
- package/docs-site-docusaurus/src/pages/index.tsx +51 -2
- package/docs-site-docusaurus/static/llms.txt +37 -0
- package/llms.txt +37 -0
- package/package.json +64 -56
- package/src/common/error.ts +19 -1
- package/src/common/index.ts +1 -1
- package/src/data-structures/base/iterable-element-base.ts +3 -2
- package/src/data-structures/binary-tree/avl-tree.ts +47 -0
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +46 -4
- package/src/data-structures/binary-tree/binary-tree.ts +79 -4
- package/src/data-structures/binary-tree/bst.ts +441 -6
- package/src/data-structures/binary-tree/red-black-tree.ts +73 -0
- package/src/data-structures/binary-tree/segment-tree.ts +18 -0
- package/src/data-structures/binary-tree/tree-map.ts +434 -9
- package/src/data-structures/binary-tree/tree-multi-map.ts +426 -5
- package/src/data-structures/binary-tree/tree-multi-set.ts +350 -6
- package/src/data-structures/binary-tree/tree-set.ts +410 -8
- package/src/data-structures/graph/abstract-graph.ts +2 -2
- package/src/data-structures/graph/directed-graph.ts +30 -0
- package/src/data-structures/graph/undirected-graph.ts +27 -0
- package/src/data-structures/hash/hash-map.ts +35 -4
- package/src/data-structures/heap/heap.ts +46 -4
- package/src/data-structures/heap/max-heap.ts +2 -2
- package/src/data-structures/linked-list/doubly-linked-list.ts +51 -0
- package/src/data-structures/linked-list/singly-linked-list.ts +45 -0
- package/src/data-structures/linked-list/skip-linked-list.ts +59 -5
- package/src/data-structures/matrix/matrix.ts +33 -9
- package/src/data-structures/priority-queue/max-priority-queue.ts +2 -2
- package/src/data-structures/queue/deque.ts +45 -0
- package/src/data-structures/queue/queue.ts +36 -0
- package/src/data-structures/stack/stack.ts +30 -0
- package/src/data-structures/trie/trie.ts +38 -2
- package/src/types/data-structures/binary-tree/bst.ts +1 -0
- package/src/types/data-structures/binary-tree/tree-map.ts +6 -0
- package/src/types/data-structures/binary-tree/tree-multi-set.ts +5 -0
- package/src/types/data-structures/binary-tree/tree-set.ts +5 -0
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
# Class: RedBlackTree\<K, V, R\>
|
|
8
8
|
|
|
9
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:254](https://github.com/zrwusa/data-structure-typed/blob/
|
|
9
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:254](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/red-black-tree.ts#L254)
|
|
10
10
|
|
|
11
11
|
Represents a Red-Black Tree (self-balancing BST) supporting map-like mode and stable O(log n) updates.
|
|
12
12
|
|
|
@@ -132,7 +132,7 @@ Operation complexity depends on the method; see each method's docs.
|
|
|
132
132
|
get comparator(): Comparator<K>;
|
|
133
133
|
```
|
|
134
134
|
|
|
135
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
135
|
+
Defined in: [data-structures/binary-tree/bst.ts:385](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/bst.ts#L385)
|
|
136
136
|
|
|
137
137
|
Gets the comparator function used by the tree.
|
|
138
138
|
|
|
@@ -160,7 +160,7 @@ The comparator function.
|
|
|
160
160
|
get isDuplicate(): boolean;
|
|
161
161
|
```
|
|
162
162
|
|
|
163
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:322](https://github.com/zrwusa/data-structure-typed/blob/
|
|
163
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:322](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/binary-tree.ts#L322)
|
|
164
164
|
|
|
165
165
|
Gets whether the tree allows duplicate keys.
|
|
166
166
|
|
|
@@ -194,7 +194,7 @@ IBinaryTree.isDuplicate
|
|
|
194
194
|
get isMapMode(): boolean;
|
|
195
195
|
```
|
|
196
196
|
|
|
197
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:310](https://github.com/zrwusa/data-structure-typed/blob/
|
|
197
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:310](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/binary-tree.ts#L310)
|
|
198
198
|
|
|
199
199
|
Gets whether the tree is in Map mode.
|
|
200
200
|
|
|
@@ -228,7 +228,7 @@ IBinaryTree.isMapMode
|
|
|
228
228
|
get NIL(): BinaryTreeNode<K, V>;
|
|
229
229
|
```
|
|
230
230
|
|
|
231
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:373](https://github.com/zrwusa/data-structure-typed/blob/
|
|
231
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:373](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/binary-tree.ts#L373)
|
|
232
232
|
|
|
233
233
|
Gets the sentinel NIL node (used in self-balancing trees like Red-Black Tree).
|
|
234
234
|
|
|
@@ -262,7 +262,7 @@ IBinaryTree.NIL
|
|
|
262
262
|
get root(): RedBlackTreeNode<K, V> | undefined;
|
|
263
263
|
```
|
|
264
264
|
|
|
265
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:305](https://github.com/zrwusa/data-structure-typed/blob/
|
|
265
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:305](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/red-black-tree.ts#L305)
|
|
266
266
|
|
|
267
267
|
Get the current root node.
|
|
268
268
|
|
|
@@ -296,7 +296,7 @@ IBinaryTree.root
|
|
|
296
296
|
get size(): number;
|
|
297
297
|
```
|
|
298
298
|
|
|
299
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:361](https://github.com/zrwusa/data-structure-typed/blob/
|
|
299
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:361](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/binary-tree.ts#L361)
|
|
300
300
|
|
|
301
301
|
Gets the number of nodes in the tree.
|
|
302
302
|
|
|
@@ -330,7 +330,7 @@ IBinaryTree.size
|
|
|
330
330
|
get store(): Map<K, BinaryTreeNode<K, V>>;
|
|
331
331
|
```
|
|
332
332
|
|
|
333
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:337](https://github.com/zrwusa/data-structure-typed/blob/
|
|
333
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:337](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/binary-tree.ts#L337)
|
|
334
334
|
|
|
335
335
|
Gets the external value store (used in Map mode).
|
|
336
336
|
|
|
@@ -364,7 +364,7 @@ IBinaryTree.store
|
|
|
364
364
|
get toEntryFn(): ToEntryFn<K, V, R> | undefined;
|
|
365
365
|
```
|
|
366
366
|
|
|
367
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:385](https://github.com/zrwusa/data-structure-typed/blob/
|
|
367
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:385](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/binary-tree.ts#L385)
|
|
368
368
|
|
|
369
369
|
Gets the function used to convert raw data objects (R) into [key, value] entries.
|
|
370
370
|
|
|
@@ -396,7 +396,7 @@ IBinaryTree.toEntryFn
|
|
|
396
396
|
iterator: IterableIterator<[K, V | undefined]>;
|
|
397
397
|
```
|
|
398
398
|
|
|
399
|
-
Defined in: [data-structures/base/iterable-entry-base.ts:22](https://github.com/zrwusa/data-structure-typed/blob/
|
|
399
|
+
Defined in: [data-structures/base/iterable-entry-base.ts:22](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/iterable-entry-base.ts#L22)
|
|
400
400
|
|
|
401
401
|
Default iterator yielding `[key, value]` entries.
|
|
402
402
|
|
|
@@ -404,7 +404,7 @@ Default iterator yielding `[key, value]` entries.
|
|
|
404
404
|
|
|
405
405
|
##### args
|
|
406
406
|
|
|
407
|
-
...`
|
|
407
|
+
...`unknown`[]
|
|
408
408
|
|
|
409
409
|
#### Returns
|
|
410
410
|
|
|
@@ -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:608](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/binary-tree.ts#L608)
|
|
438
438
|
|
|
439
439
|
Adds a new node to the tree.
|
|
440
440
|
|
|
@@ -492,7 +492,7 @@ IBinaryTree.add
|
|
|
492
492
|
addMany(keysNodesEntriesOrRaws): boolean[];
|
|
493
493
|
```
|
|
494
494
|
|
|
495
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
495
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:781](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/binary-tree.ts#L781)
|
|
496
496
|
|
|
497
497
|
Adds multiple items to the tree.
|
|
498
498
|
|
|
@@ -573,7 +573,7 @@ The traversal method.
|
|
|
573
573
|
bfs(): (K | undefined)[];
|
|
574
574
|
```
|
|
575
575
|
|
|
576
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
576
|
+
Defined in: [data-structures/binary-tree/bst.ts:620](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/bst.ts#L620)
|
|
577
577
|
|
|
578
578
|
BinaryTree level-order traversal
|
|
579
579
|
|
|
@@ -611,7 +611,7 @@ bfs<C>(
|
|
|
611
611
|
iterationType?): ReturnType<C>[];
|
|
612
612
|
```
|
|
613
613
|
|
|
614
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
614
|
+
Defined in: [data-structures/binary-tree/bst.ts:621](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/bst.ts#L621)
|
|
615
615
|
|
|
616
616
|
BinaryTree level-order traversal
|
|
617
617
|
|
|
@@ -673,7 +673,7 @@ IBinaryTree.bfs
|
|
|
673
673
|
ceiling(keyNodeEntryOrPredicate): K | undefined;
|
|
674
674
|
```
|
|
675
675
|
|
|
676
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
676
|
+
Defined in: [data-structures/binary-tree/bst.ts:1782](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/bst.ts#L1782)
|
|
677
677
|
|
|
678
678
|
Returns the first key with a value >= target.
|
|
679
679
|
Equivalent to Java TreeMap.ceiling.
|
|
@@ -720,7 +720,7 @@ ceiling<C>(
|
|
|
720
720
|
iterationType?): ReturnType<C>;
|
|
721
721
|
```
|
|
722
722
|
|
|
723
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
723
|
+
Defined in: [data-structures/binary-tree/bst.ts:1797](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/bst.ts#L1797)
|
|
724
724
|
|
|
725
725
|
Returns the first node with a key >= target and applies callback.
|
|
726
726
|
Time Complexity: O(log n) average, O(h) worst case.
|
|
@@ -767,7 +767,7 @@ Space Complexity: O(h) for recursion, O(1) for iteration.
|
|
|
767
767
|
clear(): void;
|
|
768
768
|
```
|
|
769
769
|
|
|
770
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:
|
|
770
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:480](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/red-black-tree.ts#L480)
|
|
771
771
|
|
|
772
772
|
Remove all nodes and clear internal caches.
|
|
773
773
|
|
|
@@ -808,7 +808,7 @@ IBinaryTree.clear
|
|
|
808
808
|
clone(): this;
|
|
809
809
|
```
|
|
810
810
|
|
|
811
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
811
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:2697](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/binary-tree.ts#L2697)
|
|
812
812
|
|
|
813
813
|
Clones the tree.
|
|
814
814
|
|
|
@@ -855,7 +855,7 @@ createNode(
|
|
|
855
855
|
color?): RedBlackTreeNode<K, V>;
|
|
856
856
|
```
|
|
857
857
|
|
|
858
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:317](https://github.com/zrwusa/data-structure-typed/blob/
|
|
858
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:317](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/red-black-tree.ts#L317)
|
|
859
859
|
|
|
860
860
|
Create a red-black node for the given key/value (value ignored in map mode).
|
|
861
861
|
|
|
@@ -907,7 +907,7 @@ IBinaryTree.createNode
|
|
|
907
907
|
createTree(options?): this;
|
|
908
908
|
```
|
|
909
909
|
|
|
910
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:408](https://github.com/zrwusa/data-structure-typed/blob/
|
|
910
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:408](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/binary-tree.ts#L408)
|
|
911
911
|
|
|
912
912
|
Creates a new, empty tree of the same type and configuration.
|
|
913
913
|
|
|
@@ -947,7 +947,7 @@ IBinaryTree.createTree
|
|
|
947
947
|
delete(keyNodeEntryRawOrPredicate): BinaryTreeDeleteResult<RedBlackTreeNode<K, V>>[];
|
|
948
948
|
```
|
|
949
949
|
|
|
950
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:
|
|
950
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:1225](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/red-black-tree.ts#L1225)
|
|
951
951
|
|
|
952
952
|
Delete a node by key/node/entry and rebalance as needed.
|
|
953
953
|
|
|
@@ -1004,7 +1004,7 @@ deleteWhere(
|
|
|
1004
1004
|
iterationType?): BinaryTreeDeleteResult<BSTNode<K, V>>[];
|
|
1005
1005
|
```
|
|
1006
1006
|
|
|
1007
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
1007
|
+
Defined in: [data-structures/binary-tree/bst.ts:2597](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/bst.ts#L2597)
|
|
1008
1008
|
|
|
1009
1009
|
Deletes nodes that match a key, node, entry, predicate, or range.
|
|
1010
1010
|
|
|
@@ -1115,7 +1115,7 @@ The traversal method.
|
|
|
1115
1115
|
dfs(): (K | undefined)[];
|
|
1116
1116
|
```
|
|
1117
1117
|
|
|
1118
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
1118
|
+
Defined in: [data-structures/binary-tree/bst.ts:518](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/bst.ts#L518)
|
|
1119
1119
|
|
|
1120
1120
|
Depth-first search traversal
|
|
1121
1121
|
|
|
@@ -1155,7 +1155,7 @@ dfs<C>(
|
|
|
1155
1155
|
iterationType?): ReturnType<C>[];
|
|
1156
1156
|
```
|
|
1157
1157
|
|
|
1158
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
1158
|
+
Defined in: [data-structures/binary-tree/bst.ts:520](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/bst.ts#L520)
|
|
1159
1159
|
|
|
1160
1160
|
Depth-first search traversal
|
|
1161
1161
|
|
|
@@ -1223,7 +1223,7 @@ IBinaryTree.dfs
|
|
|
1223
1223
|
ensureNode(keyNodeOrEntry, iterationType?): OptNode<BSTNode<K, V>>;
|
|
1224
1224
|
```
|
|
1225
1225
|
|
|
1226
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
1226
|
+
Defined in: [data-structures/binary-tree/bst.ts:409](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/bst.ts#L409)
|
|
1227
1227
|
|
|
1228
1228
|
Ensures the input is a node. If it's a key or entry, it searches for the node.
|
|
1229
1229
|
|
|
@@ -1267,7 +1267,7 @@ Time O(log N) (height of the tree), O(N) worst-case.
|
|
|
1267
1267
|
entries(): IterableIterator<[K, V | undefined]>;
|
|
1268
1268
|
```
|
|
1269
1269
|
|
|
1270
|
-
Defined in: [data-structures/base/iterable-entry-base.ts:31](https://github.com/zrwusa/data-structure-typed/blob/
|
|
1270
|
+
Defined in: [data-structures/base/iterable-entry-base.ts:31](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/iterable-entry-base.ts#L31)
|
|
1271
1271
|
|
|
1272
1272
|
Iterate over `[key, value]` pairs (may yield `undefined` values).
|
|
1273
1273
|
|
|
@@ -1299,7 +1299,7 @@ IBinaryTree.entries
|
|
|
1299
1299
|
every(predicate, thisArg?): boolean;
|
|
1300
1300
|
```
|
|
1301
1301
|
|
|
1302
|
-
Defined in: [data-structures/base/iterable-entry-base.ts:66](https://github.com/zrwusa/data-structure-typed/blob/
|
|
1302
|
+
Defined in: [data-structures/base/iterable-entry-base.ts:66](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/iterable-entry-base.ts#L66)
|
|
1303
1303
|
|
|
1304
1304
|
Test whether all entries satisfy the predicate.
|
|
1305
1305
|
|
|
@@ -1313,7 +1313,7 @@ Test whether all entries satisfy the predicate.
|
|
|
1313
1313
|
|
|
1314
1314
|
##### thisArg?
|
|
1315
1315
|
|
|
1316
|
-
`
|
|
1316
|
+
`unknown`
|
|
1317
1317
|
|
|
1318
1318
|
Optional `this` for callback.
|
|
1319
1319
|
|
|
@@ -1345,7 +1345,7 @@ IBinaryTree.every
|
|
|
1345
1345
|
filter(predicate, thisArg?): this;
|
|
1346
1346
|
```
|
|
1347
1347
|
|
|
1348
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
1348
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:2749](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/binary-tree.ts#L2749)
|
|
1349
1349
|
|
|
1350
1350
|
Creates a new tree containing only the entries that satisfy the predicate.
|
|
1351
1351
|
|
|
@@ -1402,7 +1402,7 @@ IBinaryTree.filter
|
|
|
1402
1402
|
find(callbackfn, thisArg?): [K, V | undefined] | undefined;
|
|
1403
1403
|
```
|
|
1404
1404
|
|
|
1405
|
-
Defined in: [data-structures/base/iterable-entry-base.ts:114](https://github.com/zrwusa/data-structure-typed/blob/
|
|
1405
|
+
Defined in: [data-structures/base/iterable-entry-base.ts:114](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/iterable-entry-base.ts#L114)
|
|
1406
1406
|
|
|
1407
1407
|
Find the first entry that matches a predicate.
|
|
1408
1408
|
|
|
@@ -1416,7 +1416,7 @@ Find the first entry that matches a predicate.
|
|
|
1416
1416
|
|
|
1417
1417
|
##### thisArg?
|
|
1418
1418
|
|
|
1419
|
-
`
|
|
1419
|
+
`unknown`
|
|
1420
1420
|
|
|
1421
1421
|
Optional `this` for callback.
|
|
1422
1422
|
|
|
@@ -1450,7 +1450,7 @@ IBinaryTree.find
|
|
|
1450
1450
|
floor(keyNodeEntryOrPredicate): K | undefined;
|
|
1451
1451
|
```
|
|
1452
1452
|
|
|
1453
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
1453
|
+
Defined in: [data-structures/binary-tree/bst.ts:1993](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/bst.ts#L1993)
|
|
1454
1454
|
|
|
1455
1455
|
Returns the first key with a value <= target.
|
|
1456
1456
|
Equivalent to Java TreeMap.floor.
|
|
@@ -1497,7 +1497,7 @@ floor<C>(
|
|
|
1497
1497
|
iterationType?): ReturnType<C>;
|
|
1498
1498
|
```
|
|
1499
1499
|
|
|
1500
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
1500
|
+
Defined in: [data-structures/binary-tree/bst.ts:2008](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/bst.ts#L2008)
|
|
1501
1501
|
|
|
1502
1502
|
Returns the first node with a key <= target and applies callback.
|
|
1503
1503
|
Time Complexity: O(log n) average, O(h) worst case.
|
|
@@ -1544,7 +1544,7 @@ Space Complexity: O(h) for recursion, O(1) for iteration.
|
|
|
1544
1544
|
forEach(callbackfn, thisArg?): void;
|
|
1545
1545
|
```
|
|
1546
1546
|
|
|
1547
|
-
Defined in: [data-structures/base/iterable-entry-base.ts:99](https://github.com/zrwusa/data-structure-typed/blob/
|
|
1547
|
+
Defined in: [data-structures/base/iterable-entry-base.ts:99](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/iterable-entry-base.ts#L99)
|
|
1548
1548
|
|
|
1549
1549
|
Visit each entry, left-to-right.
|
|
1550
1550
|
|
|
@@ -1558,7 +1558,7 @@ Visit each entry, left-to-right.
|
|
|
1558
1558
|
|
|
1559
1559
|
##### thisArg?
|
|
1560
1560
|
|
|
1561
|
-
`
|
|
1561
|
+
`unknown`
|
|
1562
1562
|
|
|
1563
1563
|
Optional `this` for callback.
|
|
1564
1564
|
|
|
@@ -1591,7 +1591,7 @@ get(
|
|
|
1591
1591
|
iterationType?): V | undefined;
|
|
1592
1592
|
```
|
|
1593
1593
|
|
|
1594
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
1594
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1349](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/binary-tree.ts#L1349)
|
|
1595
1595
|
|
|
1596
1596
|
Gets the value associated with a key.
|
|
1597
1597
|
|
|
@@ -1655,13 +1655,114 @@ IBinaryTree.get
|
|
|
1655
1655
|
|
|
1656
1656
|
***
|
|
1657
1657
|
|
|
1658
|
+
### getByRank()
|
|
1659
|
+
|
|
1660
|
+
#### Call Signature
|
|
1661
|
+
|
|
1662
|
+
```ts
|
|
1663
|
+
getByRank(k): K | undefined;
|
|
1664
|
+
```
|
|
1665
|
+
|
|
1666
|
+
Defined in: [data-structures/binary-tree/bst.ts:1197](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/bst.ts#L1197)
|
|
1667
|
+
|
|
1668
|
+
Returns the element at the k-th position in tree order (0-indexed).
|
|
1669
|
+
|
|
1670
|
+
##### Parameters
|
|
1671
|
+
|
|
1672
|
+
###### k
|
|
1673
|
+
|
|
1674
|
+
`number`
|
|
1675
|
+
|
|
1676
|
+
The 0-based position in tree order (0 = first element).
|
|
1677
|
+
|
|
1678
|
+
##### Returns
|
|
1679
|
+
|
|
1680
|
+
`K` \| `undefined`
|
|
1681
|
+
|
|
1682
|
+
The key at position k, or `undefined` if out of bounds.
|
|
1683
|
+
*
|
|
1684
|
+
|
|
1685
|
+
##### Remarks
|
|
1686
|
+
|
|
1687
|
+
Time O(log n), Space O(1) iterative / O(log n) recursive. Requires `enableOrderStatistic: true`.
|
|
1688
|
+
Tree order is defined by the comparator — ascending by default, but respects custom comparators (e.g. descending).
|
|
1689
|
+
|
|
1690
|
+
##### Example
|
|
1691
|
+
|
|
1692
|
+
```ts
|
|
1693
|
+
// Order-statistic on BST
|
|
1694
|
+
const tree = new BST<number>([30, 10, 50, 20, 40], { enableOrderStatistic: true });
|
|
1695
|
+
console.log(tree.getByRank(0)); // 10;
|
|
1696
|
+
console.log(tree.getByRank(4)); // 50;
|
|
1697
|
+
console.log(tree.getRank(30)); // 2;
|
|
1698
|
+
```
|
|
1699
|
+
|
|
1700
|
+
##### Inherited from
|
|
1701
|
+
|
|
1702
|
+
[`BST`](BST.md).[`getByRank`](BST.md#getbyrank)
|
|
1703
|
+
|
|
1704
|
+
#### Call Signature
|
|
1705
|
+
|
|
1706
|
+
```ts
|
|
1707
|
+
getByRank<C>(
|
|
1708
|
+
k,
|
|
1709
|
+
callback,
|
|
1710
|
+
iterationType?): ReturnType<C> | undefined;
|
|
1711
|
+
```
|
|
1712
|
+
|
|
1713
|
+
Defined in: [data-structures/binary-tree/bst.ts:1208](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/bst.ts#L1208)
|
|
1714
|
+
|
|
1715
|
+
Returns the element at the k-th position in tree order and applies a callback.
|
|
1716
|
+
|
|
1717
|
+
##### Type Parameters
|
|
1718
|
+
|
|
1719
|
+
###### C
|
|
1720
|
+
|
|
1721
|
+
`C` *extends* `NodeCallback`\<[`BSTNode`](BSTNode.md)\<`K`, `V`\>\>
|
|
1722
|
+
|
|
1723
|
+
##### Parameters
|
|
1724
|
+
|
|
1725
|
+
###### k
|
|
1726
|
+
|
|
1727
|
+
`number`
|
|
1728
|
+
|
|
1729
|
+
The 0-based position in tree order (0 = first element).
|
|
1730
|
+
|
|
1731
|
+
###### callback
|
|
1732
|
+
|
|
1733
|
+
`C`
|
|
1734
|
+
|
|
1735
|
+
Callback to apply to the found node.
|
|
1736
|
+
|
|
1737
|
+
###### iterationType?
|
|
1738
|
+
|
|
1739
|
+
`IterationType`
|
|
1740
|
+
|
|
1741
|
+
Iteration strategy ('ITERATIVE' or 'RECURSIVE').
|
|
1742
|
+
|
|
1743
|
+
##### Returns
|
|
1744
|
+
|
|
1745
|
+
`ReturnType`\<`C`\> \| `undefined`
|
|
1746
|
+
|
|
1747
|
+
The callback result, or `undefined` if out of bounds.
|
|
1748
|
+
|
|
1749
|
+
##### Remarks
|
|
1750
|
+
|
|
1751
|
+
Time O(log n), Space O(1) iterative / O(log n) recursive. Requires `enableOrderStatistic: true`.
|
|
1752
|
+
|
|
1753
|
+
##### Inherited from
|
|
1754
|
+
|
|
1755
|
+
[`BST`](BST.md).[`getByRank`](BST.md#getbyrank)
|
|
1756
|
+
|
|
1757
|
+
***
|
|
1758
|
+
|
|
1658
1759
|
### getDepth()
|
|
1659
1760
|
|
|
1660
1761
|
```ts
|
|
1661
1762
|
getDepth(dist, startNode?): number;
|
|
1662
1763
|
```
|
|
1663
1764
|
|
|
1664
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
1765
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1710](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/binary-tree.ts#L1710)
|
|
1665
1766
|
|
|
1666
1767
|
Gets the depth of a node (distance from `startNode`).
|
|
1667
1768
|
|
|
@@ -1725,7 +1826,7 @@ IBinaryTree.getDepth
|
|
|
1725
1826
|
getHeight(startNode?, iterationType?): number;
|
|
1726
1827
|
```
|
|
1727
1828
|
|
|
1728
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
1829
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1774](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/binary-tree.ts#L1774)
|
|
1729
1830
|
|
|
1730
1831
|
Gets the maximum height of the tree (longest path from startNode to a leaf).
|
|
1731
1832
|
|
|
@@ -1808,7 +1909,7 @@ The traversal method.
|
|
|
1808
1909
|
getLeftMost(): K | undefined;
|
|
1809
1910
|
```
|
|
1810
1911
|
|
|
1811
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
1912
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1901](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/binary-tree.ts#L1901)
|
|
1812
1913
|
|
|
1813
1914
|
##### Returns
|
|
1814
1915
|
|
|
@@ -1833,7 +1934,7 @@ getLeftMost<C>(
|
|
|
1833
1934
|
iterationType?): ReturnType<C>;
|
|
1834
1935
|
```
|
|
1835
1936
|
|
|
1836
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
1937
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1903](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/binary-tree.ts#L1903)
|
|
1837
1938
|
|
|
1838
1939
|
##### Type Parameters
|
|
1839
1940
|
|
|
@@ -1880,7 +1981,7 @@ IBinaryTree.getLeftMost
|
|
|
1880
1981
|
getMinHeight(startNode?, iterationType?): number;
|
|
1881
1982
|
```
|
|
1882
1983
|
|
|
1883
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
1984
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1816](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/binary-tree.ts#L1816)
|
|
1884
1985
|
|
|
1885
1986
|
Gets the minimum height of the tree (shortest path from startNode to a leaf).
|
|
1886
1987
|
|
|
@@ -1932,7 +2033,7 @@ getNode(
|
|
|
1932
2033
|
iterationType?): OptNode<BSTNode<K, V>>;
|
|
1933
2034
|
```
|
|
1934
2035
|
|
|
1935
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
2036
|
+
Defined in: [data-structures/binary-tree/bst.ts:829](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/bst.ts#L829)
|
|
1936
2037
|
|
|
1937
2038
|
Gets the first node matching a predicate.
|
|
1938
2039
|
|
|
@@ -2005,7 +2106,7 @@ getNodes(
|
|
|
2005
2106
|
iterationType?): BinaryTreeNode<K, V>[];
|
|
2006
2107
|
```
|
|
2007
2108
|
|
|
2008
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
2109
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1205](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/binary-tree.ts#L1205)
|
|
2009
2110
|
|
|
2010
2111
|
Gets all nodes matching a predicate.
|
|
2011
2112
|
|
|
@@ -2100,7 +2201,7 @@ If true, returns the path from root-to-node.
|
|
|
2100
2201
|
getPathToRoot(beginNode): (K | undefined)[];
|
|
2101
2202
|
```
|
|
2102
2203
|
|
|
2103
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
2204
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1863](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/binary-tree.ts#L1863)
|
|
2104
2205
|
|
|
2105
2206
|
##### Parameters
|
|
2106
2207
|
|
|
@@ -2135,7 +2236,7 @@ getPathToRoot<C>(
|
|
|
2135
2236
|
isReverse?): ReturnType<C>[];
|
|
2136
2237
|
```
|
|
2137
2238
|
|
|
2138
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
2239
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1867](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/binary-tree.ts#L1867)
|
|
2139
2240
|
|
|
2140
2241
|
##### Type Parameters
|
|
2141
2242
|
|
|
@@ -2183,7 +2284,7 @@ IBinaryTree.getPathToRoot
|
|
|
2183
2284
|
getPredecessor(node): BinaryTreeNode<K, V>;
|
|
2184
2285
|
```
|
|
2185
2286
|
|
|
2186
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
2287
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:2001](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/binary-tree.ts#L2001)
|
|
2187
2288
|
|
|
2188
2289
|
Gets the Morris traversal predecessor (rightmost node in the left subtree, or node itself).
|
|
2189
2290
|
|
|
@@ -2211,6 +2312,91 @@ This is primarily a helper for Morris traversal. Time O(H), where H is the heigh
|
|
|
2211
2312
|
|
|
2212
2313
|
***
|
|
2213
2314
|
|
|
2315
|
+
### getRank()
|
|
2316
|
+
|
|
2317
|
+
#### Call Signature
|
|
2318
|
+
|
|
2319
|
+
```ts
|
|
2320
|
+
getRank(keyNodeEntryOrPredicate): number;
|
|
2321
|
+
```
|
|
2322
|
+
|
|
2323
|
+
Defined in: [data-structures/binary-tree/bst.ts:1252](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/bst.ts#L1252)
|
|
2324
|
+
|
|
2325
|
+
Returns the 0-based rank of a key (number of elements that precede it in tree order).
|
|
2326
|
+
|
|
2327
|
+
##### Parameters
|
|
2328
|
+
|
|
2329
|
+
###### keyNodeEntryOrPredicate
|
|
2330
|
+
|
|
2331
|
+
\| `K`
|
|
2332
|
+
\| [`BSTNode`](BSTNode.md)\<`K`, `V`\>
|
|
2333
|
+
\| \[`K` \| `null` \| `undefined`, `V` \| `undefined`\]
|
|
2334
|
+
\| `NodePredicate`\<[`BSTNode`](BSTNode.md)\<`K`, `V`\>\>
|
|
2335
|
+
\| `null`
|
|
2336
|
+
\| `undefined`
|
|
2337
|
+
|
|
2338
|
+
The key, node, entry `[K, V]`, or predicate to find.
|
|
2339
|
+
|
|
2340
|
+
##### Returns
|
|
2341
|
+
|
|
2342
|
+
`number`
|
|
2343
|
+
|
|
2344
|
+
The rank (0-indexed), or -1 if the tree is empty or input is invalid.
|
|
2345
|
+
|
|
2346
|
+
##### Remarks
|
|
2347
|
+
|
|
2348
|
+
Time O(log n), Space O(1) iterative / O(log n) recursive. Requires `enableOrderStatistic: true`.
|
|
2349
|
+
Tree order is defined by the comparator. When the key is not found, returns the insertion position.
|
|
2350
|
+
|
|
2351
|
+
##### Inherited from
|
|
2352
|
+
|
|
2353
|
+
[`BST`](BST.md).[`getRank`](BST.md#getrank)
|
|
2354
|
+
|
|
2355
|
+
#### Call Signature
|
|
2356
|
+
|
|
2357
|
+
```ts
|
|
2358
|
+
getRank(keyNodeEntryOrPredicate, iterationType): number;
|
|
2359
|
+
```
|
|
2360
|
+
|
|
2361
|
+
Defined in: [data-structures/binary-tree/bst.ts:1270](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/bst.ts#L1270)
|
|
2362
|
+
|
|
2363
|
+
Returns the 0-based rank (number of preceding elements in tree order) with explicit iteration type.
|
|
2364
|
+
|
|
2365
|
+
##### Parameters
|
|
2366
|
+
|
|
2367
|
+
###### keyNodeEntryOrPredicate
|
|
2368
|
+
|
|
2369
|
+
\| `K`
|
|
2370
|
+
\| [`BSTNode`](BSTNode.md)\<`K`, `V`\>
|
|
2371
|
+
\| \[`K` \| `null` \| `undefined`, `V` \| `undefined`\]
|
|
2372
|
+
\| `NodePredicate`\<[`BSTNode`](BSTNode.md)\<`K`, `V`\>\>
|
|
2373
|
+
\| `null`
|
|
2374
|
+
\| `undefined`
|
|
2375
|
+
|
|
2376
|
+
The key, node, entry, or predicate to find.
|
|
2377
|
+
|
|
2378
|
+
###### iterationType
|
|
2379
|
+
|
|
2380
|
+
`IterationType`
|
|
2381
|
+
|
|
2382
|
+
Iteration strategy ('ITERATIVE' or 'RECURSIVE').
|
|
2383
|
+
|
|
2384
|
+
##### Returns
|
|
2385
|
+
|
|
2386
|
+
`number`
|
|
2387
|
+
|
|
2388
|
+
The rank (0-indexed), or -1 if the tree is empty or input is invalid.
|
|
2389
|
+
|
|
2390
|
+
##### Remarks
|
|
2391
|
+
|
|
2392
|
+
Time O(log n), Space O(1) iterative / O(log n) recursive. Requires `enableOrderStatistic: true`.
|
|
2393
|
+
|
|
2394
|
+
##### Inherited from
|
|
2395
|
+
|
|
2396
|
+
[`BST`](BST.md).[`getRank`](BST.md#getrank)
|
|
2397
|
+
|
|
2398
|
+
***
|
|
2399
|
+
|
|
2214
2400
|
### getRightMost()
|
|
2215
2401
|
|
|
2216
2402
|
Finds the rightmost node in a subtree (the node with the largest key in a BST).
|
|
@@ -2241,7 +2427,7 @@ The traversal method.
|
|
|
2241
2427
|
getRightMost(): K | undefined;
|
|
2242
2428
|
```
|
|
2243
2429
|
|
|
2244
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
2430
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1948](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/binary-tree.ts#L1948)
|
|
2245
2431
|
|
|
2246
2432
|
##### Returns
|
|
2247
2433
|
|
|
@@ -2266,7 +2452,7 @@ getRightMost<C>(
|
|
|
2266
2452
|
iterationType?): ReturnType<C>;
|
|
2267
2453
|
```
|
|
2268
2454
|
|
|
2269
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
2455
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1950](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/binary-tree.ts#L1950)
|
|
2270
2456
|
|
|
2271
2457
|
##### Type Parameters
|
|
2272
2458
|
|
|
@@ -2313,7 +2499,7 @@ IBinaryTree.getRightMost
|
|
|
2313
2499
|
getSuccessor(x?): BinaryTreeNode<K, V> | null | undefined;
|
|
2314
2500
|
```
|
|
2315
2501
|
|
|
2316
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
2502
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:2022](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/binary-tree.ts#L2022)
|
|
2317
2503
|
|
|
2318
2504
|
Gets the in-order successor of a node in a BST.
|
|
2319
2505
|
|
|
@@ -2350,7 +2536,7 @@ has(
|
|
|
2350
2536
|
iterationType?): boolean;
|
|
2351
2537
|
```
|
|
2352
2538
|
|
|
2353
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
2539
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1434](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/binary-tree.ts#L1434)
|
|
2354
2540
|
|
|
2355
2541
|
Checks if a node matching the predicate exists in the tree.
|
|
2356
2542
|
|
|
@@ -2443,7 +2629,7 @@ IBinaryTree.has
|
|
|
2443
2629
|
hasValue(value): boolean;
|
|
2444
2630
|
```
|
|
2445
2631
|
|
|
2446
|
-
Defined in: [data-structures/base/iterable-entry-base.ts:143](https://github.com/zrwusa/data-structure-typed/blob/
|
|
2632
|
+
Defined in: [data-structures/base/iterable-entry-base.ts:143](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/iterable-entry-base.ts#L143)
|
|
2447
2633
|
|
|
2448
2634
|
Whether there exists an entry with the given value.
|
|
2449
2635
|
|
|
@@ -2485,7 +2671,7 @@ IBinaryTree.hasValue
|
|
|
2485
2671
|
higher(keyNodeEntryOrPredicate): K | undefined;
|
|
2486
2672
|
```
|
|
2487
2673
|
|
|
2488
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
2674
|
+
Defined in: [data-structures/binary-tree/bst.ts:1887](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/bst.ts#L1887)
|
|
2489
2675
|
|
|
2490
2676
|
Returns the first key with a value > target.
|
|
2491
2677
|
Equivalent to Java TreeMap.higher.
|
|
@@ -2531,7 +2717,7 @@ higher<C>(
|
|
|
2531
2717
|
iterationType?): ReturnType<C>;
|
|
2532
2718
|
```
|
|
2533
2719
|
|
|
2534
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
2720
|
+
Defined in: [data-structures/binary-tree/bst.ts:1902](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/bst.ts#L1902)
|
|
2535
2721
|
|
|
2536
2722
|
Returns the first node with a key > target and applies callback.
|
|
2537
2723
|
Time Complexity: O(log n) average, O(h) worst case.
|
|
@@ -2578,7 +2764,7 @@ Space Complexity: O(h) for recursion, O(1) for iteration.
|
|
|
2578
2764
|
isAVLBalanced(iterationType?): boolean;
|
|
2579
2765
|
```
|
|
2580
2766
|
|
|
2581
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
2767
|
+
Defined in: [data-structures/binary-tree/bst.ts:2418](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/bst.ts#L2418)
|
|
2582
2768
|
|
|
2583
2769
|
Checks if the tree meets the AVL balance condition (height difference <= 1).
|
|
2584
2770
|
|
|
@@ -2622,7 +2808,7 @@ Time O(N), as it must visit every node to compute height. Space O(log N) for rec
|
|
|
2622
2808
|
isBST(startNode?, iterationType?): boolean;
|
|
2623
2809
|
```
|
|
2624
2810
|
|
|
2625
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
2811
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1619](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/binary-tree.ts#L1619)
|
|
2626
2812
|
|
|
2627
2813
|
Checks if the tree is a valid Binary Search Tree (BST).
|
|
2628
2814
|
|
|
@@ -2682,7 +2868,7 @@ IBinaryTree.isBST
|
|
|
2682
2868
|
isEmpty(): boolean;
|
|
2683
2869
|
```
|
|
2684
2870
|
|
|
2685
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
2871
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1556](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/binary-tree.ts#L1556)
|
|
2686
2872
|
|
|
2687
2873
|
Checks if the tree is empty.
|
|
2688
2874
|
|
|
@@ -2723,7 +2909,7 @@ IBinaryTree.isEmpty
|
|
|
2723
2909
|
isEntry(keyNodeOrEntry): keyNodeOrEntry is BTNEntry<K, V>;
|
|
2724
2910
|
```
|
|
2725
2911
|
|
|
2726
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:545](https://github.com/zrwusa/data-structure-typed/blob/
|
|
2912
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:545](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/binary-tree.ts#L545)
|
|
2727
2913
|
|
|
2728
2914
|
Checks if the given item is a [key, value] entry pair.
|
|
2729
2915
|
|
|
@@ -2761,7 +2947,7 @@ Time O(1), Space O(1)
|
|
|
2761
2947
|
isLeaf(keyNodeOrEntry): boolean;
|
|
2762
2948
|
```
|
|
2763
2949
|
|
|
2764
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:531](https://github.com/zrwusa/data-structure-typed/blob/
|
|
2950
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:531](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/binary-tree.ts#L531)
|
|
2765
2951
|
|
|
2766
2952
|
Checks if a node is a leaf (has no real children).
|
|
2767
2953
|
|
|
@@ -2799,7 +2985,7 @@ Time O(N) if a key/entry is passed (due to `ensureNode`). O(1) if a node is pass
|
|
|
2799
2985
|
isNIL(keyNodeOrEntry): boolean;
|
|
2800
2986
|
```
|
|
2801
2987
|
|
|
2802
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:500](https://github.com/zrwusa/data-structure-typed/blob/
|
|
2988
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:500](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/binary-tree.ts#L500)
|
|
2803
2989
|
|
|
2804
2990
|
Checks if the given item is the sentinel NIL node.
|
|
2805
2991
|
|
|
@@ -2837,7 +3023,7 @@ Time O(1), Space O(1)
|
|
|
2837
3023
|
isNode(keyNodeOrEntry): keyNodeOrEntry is RedBlackTreeNode<K, V>;
|
|
2838
3024
|
```
|
|
2839
3025
|
|
|
2840
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:328](https://github.com/zrwusa/data-structure-typed/blob/
|
|
3026
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:328](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/red-black-tree.ts#L328)
|
|
2841
3027
|
|
|
2842
3028
|
Type guard: check whether the input is a RedBlackTreeNode.
|
|
2843
3029
|
|
|
@@ -2875,7 +3061,7 @@ Time O(1), Space O(1)
|
|
|
2875
3061
|
isPerfectlyBalanced(startNode?): boolean;
|
|
2876
3062
|
```
|
|
2877
3063
|
|
|
2878
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
3064
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:1567](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/binary-tree.ts#L1567)
|
|
2879
3065
|
|
|
2880
3066
|
Checks if the tree is perfectly balanced.
|
|
2881
3067
|
|
|
@@ -2918,7 +3104,7 @@ IBinaryTree.isPerfectlyBalanced
|
|
|
2918
3104
|
isRange(keyNodeEntryOrPredicate): keyNodeEntryOrPredicate is Range<K>;
|
|
2919
3105
|
```
|
|
2920
3106
|
|
|
2921
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:511](https://github.com/zrwusa/data-structure-typed/blob/
|
|
3107
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:511](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/binary-tree.ts#L511)
|
|
2922
3108
|
|
|
2923
3109
|
Checks if the given item is a `Range` object.
|
|
2924
3110
|
|
|
@@ -2958,7 +3144,7 @@ Time O(1), Space O(1)
|
|
|
2958
3144
|
isRaw(keyNodeEntryOrRaw): keyNodeEntryOrRaw is R;
|
|
2959
3145
|
```
|
|
2960
3146
|
|
|
2961
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:460](https://github.com/zrwusa/data-structure-typed/blob/
|
|
3147
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:460](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/binary-tree.ts#L460)
|
|
2962
3148
|
|
|
2963
3149
|
Checks if the given item is a raw data object (R) that needs conversion via `toEntryFn`.
|
|
2964
3150
|
|
|
@@ -2997,7 +3183,7 @@ Time O(1), Space O(1)
|
|
|
2997
3183
|
isRealNode(keyNodeOrEntry): keyNodeOrEntry is BinaryTreeNode<K, V>;
|
|
2998
3184
|
```
|
|
2999
3185
|
|
|
3000
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:473](https://github.com/zrwusa/data-structure-typed/blob/
|
|
3186
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:473](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/binary-tree.ts#L473)
|
|
3001
3187
|
|
|
3002
3188
|
Checks if the given item is a "real" node (i.e., not null, undefined, or NIL).
|
|
3003
3189
|
|
|
@@ -3035,7 +3221,7 @@ Time O(1), Space O(1)
|
|
|
3035
3221
|
isRealNodeOrNull(keyNodeOrEntry): keyNodeOrEntry is BinaryTreeNode<K, V> | null;
|
|
3036
3222
|
```
|
|
3037
3223
|
|
|
3038
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:487](https://github.com/zrwusa/data-structure-typed/blob/
|
|
3224
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:487](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/binary-tree.ts#L487)
|
|
3039
3225
|
|
|
3040
3226
|
Checks if the given item is either a "real" node or null.
|
|
3041
3227
|
|
|
@@ -3073,7 +3259,7 @@ Time O(1), Space O(1)
|
|
|
3073
3259
|
isValidKey(key): key is K;
|
|
3074
3260
|
```
|
|
3075
3261
|
|
|
3076
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
3262
|
+
Defined in: [data-structures/binary-tree/bst.ts:436](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/bst.ts#L436)
|
|
3077
3263
|
|
|
3078
3264
|
Checks if the given key is valid (comparable).
|
|
3079
3265
|
|
|
@@ -3081,7 +3267,7 @@ Checks if the given key is valid (comparable).
|
|
|
3081
3267
|
|
|
3082
3268
|
##### key
|
|
3083
3269
|
|
|
3084
|
-
`
|
|
3270
|
+
`unknown`
|
|
3085
3271
|
|
|
3086
3272
|
The key to validate.
|
|
3087
3273
|
|
|
@@ -3107,7 +3293,7 @@ Time O(1)
|
|
|
3107
3293
|
keys(): IterableIterator<K>;
|
|
3108
3294
|
```
|
|
3109
3295
|
|
|
3110
|
-
Defined in: [data-structures/base/iterable-entry-base.ts:42](https://github.com/zrwusa/data-structure-typed/blob/
|
|
3296
|
+
Defined in: [data-structures/base/iterable-entry-base.ts:42](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/iterable-entry-base.ts#L42)
|
|
3111
3297
|
|
|
3112
3298
|
Iterate over keys only.
|
|
3113
3299
|
|
|
@@ -3163,7 +3349,7 @@ The traversal method.
|
|
|
3163
3349
|
leaves(): (K | undefined)[];
|
|
3164
3350
|
```
|
|
3165
3351
|
|
|
3166
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
3352
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:2316](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/binary-tree.ts#L2316)
|
|
3167
3353
|
|
|
3168
3354
|
Get leaf nodes
|
|
3169
3355
|
|
|
@@ -3201,7 +3387,7 @@ leaves<C>(
|
|
|
3201
3387
|
iterationType?): ReturnType<C>[];
|
|
3202
3388
|
```
|
|
3203
3389
|
|
|
3204
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
3390
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:2318](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/binary-tree.ts#L2318)
|
|
3205
3391
|
|
|
3206
3392
|
Get leaf nodes
|
|
3207
3393
|
|
|
@@ -3289,7 +3475,7 @@ The traversal method.
|
|
|
3289
3475
|
lesserOrGreaterTraverse(): (K | undefined)[];
|
|
3290
3476
|
```
|
|
3291
3477
|
|
|
3292
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
3478
|
+
Defined in: [data-structures/binary-tree/bst.ts:2244](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/bst.ts#L2244)
|
|
3293
3479
|
|
|
3294
3480
|
##### Returns
|
|
3295
3481
|
|
|
@@ -3309,7 +3495,7 @@ lesserOrGreaterTraverse<C>(
|
|
|
3309
3495
|
iterationType?): ReturnType<C>[];
|
|
3310
3496
|
```
|
|
3311
3497
|
|
|
3312
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
3498
|
+
Defined in: [data-structures/binary-tree/bst.ts:2246](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/bst.ts#L2246)
|
|
3313
3499
|
|
|
3314
3500
|
##### Type Parameters
|
|
3315
3501
|
|
|
@@ -3378,7 +3564,7 @@ The traversal method.
|
|
|
3378
3564
|
listLevels(): (K | undefined)[][];
|
|
3379
3565
|
```
|
|
3380
3566
|
|
|
3381
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
3567
|
+
Defined in: [data-structures/binary-tree/bst.ts:721](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/bst.ts#L721)
|
|
3382
3568
|
|
|
3383
3569
|
Level-order grouping
|
|
3384
3570
|
|
|
@@ -3419,7 +3605,7 @@ listLevels<C>(
|
|
|
3419
3605
|
iterationType?): ReturnType<C>[][];
|
|
3420
3606
|
```
|
|
3421
3607
|
|
|
3422
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
3608
|
+
Defined in: [data-structures/binary-tree/bst.ts:723](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/bst.ts#L723)
|
|
3423
3609
|
|
|
3424
3610
|
Level-order grouping
|
|
3425
3611
|
|
|
@@ -3484,7 +3670,7 @@ IBinaryTree.listLevels
|
|
|
3484
3670
|
lower(keyNodeEntryOrPredicate): K | undefined;
|
|
3485
3671
|
```
|
|
3486
3672
|
|
|
3487
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
3673
|
+
Defined in: [data-structures/binary-tree/bst.ts:2141](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/bst.ts#L2141)
|
|
3488
3674
|
|
|
3489
3675
|
Returns the first key with a value < target.
|
|
3490
3676
|
Equivalent to Java TreeMap.lower.
|
|
@@ -3530,7 +3716,7 @@ lower<C>(
|
|
|
3530
3716
|
iterationType?): ReturnType<C>;
|
|
3531
3717
|
```
|
|
3532
3718
|
|
|
3533
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
3719
|
+
Defined in: [data-structures/binary-tree/bst.ts:2156](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/bst.ts#L2156)
|
|
3534
3720
|
|
|
3535
3721
|
Returns the first node with a key < target and applies callback.
|
|
3536
3722
|
Time Complexity: O(log n) average, O(h) worst case.
|
|
@@ -3580,7 +3766,7 @@ map<MK, MV, MR>(
|
|
|
3580
3766
|
thisArg?): RedBlackTree<MK, MV, MR>;
|
|
3581
3767
|
```
|
|
3582
3768
|
|
|
3583
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:
|
|
3769
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:1585](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/red-black-tree.ts#L1585)
|
|
3584
3770
|
|
|
3585
3771
|
Transform to new tree
|
|
3586
3772
|
|
|
@@ -3645,7 +3831,7 @@ IBinaryTree.map
|
|
|
3645
3831
|
merge(anotherTree): void;
|
|
3646
3832
|
```
|
|
3647
3833
|
|
|
3648
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
3834
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:902](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/binary-tree.ts#L902)
|
|
3649
3835
|
|
|
3650
3836
|
Merges another tree into this one by seting all its nodes.
|
|
3651
3837
|
|
|
@@ -3719,7 +3905,7 @@ The node to start from.
|
|
|
3719
3905
|
morris(): (K | undefined)[];
|
|
3720
3906
|
```
|
|
3721
3907
|
|
|
3722
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
3908
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:2534](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/binary-tree.ts#L2534)
|
|
3723
3909
|
|
|
3724
3910
|
Morris traversal (O(1) space)
|
|
3725
3911
|
|
|
@@ -3757,7 +3943,7 @@ morris<C>(
|
|
|
3757
3943
|
startNode?): ReturnType<C>[];
|
|
3758
3944
|
```
|
|
3759
3945
|
|
|
3760
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
3946
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:2536](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/binary-tree.ts#L2536)
|
|
3761
3947
|
|
|
3762
3948
|
Morris traversal (O(1) space)
|
|
3763
3949
|
|
|
@@ -3817,7 +4003,7 @@ IBinaryTree.morris
|
|
|
3817
4003
|
perfectlyBalance(_iterationType?): boolean;
|
|
3818
4004
|
```
|
|
3819
4005
|
|
|
3820
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:
|
|
4006
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:1432](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/red-black-tree.ts#L1432)
|
|
3821
4007
|
|
|
3822
4008
|
Red-Black trees are self-balancing — `perfectlyBalance` rebuilds via
|
|
3823
4009
|
sorted bulk insert, which naturally produces a balanced RBT.
|
|
@@ -3859,7 +4045,7 @@ Time O(N), Space O(N)
|
|
|
3859
4045
|
print(options?, startNode?): void;
|
|
3860
4046
|
```
|
|
3861
4047
|
|
|
3862
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
4048
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:2895](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/binary-tree.ts#L2895)
|
|
3863
4049
|
|
|
3864
4050
|
Prints a visual representation of the tree to the console.
|
|
3865
4051
|
|
|
@@ -3904,6 +4090,108 @@ Time O(N) (via `toVisual`). Space O(N*H) or O(N^2) (via `toVisual`).
|
|
|
3904
4090
|
|
|
3905
4091
|
***
|
|
3906
4092
|
|
|
4093
|
+
### rangeByRank()
|
|
4094
|
+
|
|
4095
|
+
#### Call Signature
|
|
4096
|
+
|
|
4097
|
+
```ts
|
|
4098
|
+
rangeByRank(start, end): (K | undefined)[];
|
|
4099
|
+
```
|
|
4100
|
+
|
|
4101
|
+
Defined in: [data-structures/binary-tree/bst.ts:1332](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/bst.ts#L1332)
|
|
4102
|
+
|
|
4103
|
+
Returns elements by position range in tree order (0-indexed, inclusive on both ends).
|
|
4104
|
+
|
|
4105
|
+
##### Parameters
|
|
4106
|
+
|
|
4107
|
+
###### start
|
|
4108
|
+
|
|
4109
|
+
`number`
|
|
4110
|
+
|
|
4111
|
+
Start position (inclusive, 0-indexed). Clamped to 0 if negative.
|
|
4112
|
+
|
|
4113
|
+
###### end
|
|
4114
|
+
|
|
4115
|
+
`number`
|
|
4116
|
+
|
|
4117
|
+
End position (inclusive, 0-indexed). Clamped to size-1 if too large.
|
|
4118
|
+
|
|
4119
|
+
##### Returns
|
|
4120
|
+
|
|
4121
|
+
(`K` \| `undefined`)[]
|
|
4122
|
+
|
|
4123
|
+
Array of keys in tree order within the specified range.
|
|
4124
|
+
|
|
4125
|
+
##### Remarks
|
|
4126
|
+
|
|
4127
|
+
Time O(log n + k), Space O(k), where k = end - start + 1. Requires `enableOrderStatistic: true`.
|
|
4128
|
+
|
|
4129
|
+
##### Inherited from
|
|
4130
|
+
|
|
4131
|
+
[`BST`](BST.md).[`rangeByRank`](BST.md#rangebyrank)
|
|
4132
|
+
|
|
4133
|
+
#### Call Signature
|
|
4134
|
+
|
|
4135
|
+
```ts
|
|
4136
|
+
rangeByRank<C>(
|
|
4137
|
+
start,
|
|
4138
|
+
end,
|
|
4139
|
+
callback,
|
|
4140
|
+
iterationType?): ReturnType<C>[];
|
|
4141
|
+
```
|
|
4142
|
+
|
|
4143
|
+
Defined in: [data-structures/binary-tree/bst.ts:1344](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/bst.ts#L1344)
|
|
4144
|
+
|
|
4145
|
+
Returns elements by position range in tree order with callback and optional iteration type.
|
|
4146
|
+
|
|
4147
|
+
##### Type Parameters
|
|
4148
|
+
|
|
4149
|
+
###### C
|
|
4150
|
+
|
|
4151
|
+
`C` *extends* `NodeCallback`\<[`BSTNode`](BSTNode.md)\<`K`, `V`\>\>
|
|
4152
|
+
|
|
4153
|
+
##### Parameters
|
|
4154
|
+
|
|
4155
|
+
###### start
|
|
4156
|
+
|
|
4157
|
+
`number`
|
|
4158
|
+
|
|
4159
|
+
Start rank (inclusive, 0-indexed).
|
|
4160
|
+
|
|
4161
|
+
###### end
|
|
4162
|
+
|
|
4163
|
+
`number`
|
|
4164
|
+
|
|
4165
|
+
End rank (inclusive, 0-indexed).
|
|
4166
|
+
|
|
4167
|
+
###### callback
|
|
4168
|
+
|
|
4169
|
+
`C`
|
|
4170
|
+
|
|
4171
|
+
Callback to apply to each node in the range.
|
|
4172
|
+
|
|
4173
|
+
###### iterationType?
|
|
4174
|
+
|
|
4175
|
+
`IterationType`
|
|
4176
|
+
|
|
4177
|
+
Iteration strategy ('ITERATIVE' or 'RECURSIVE').
|
|
4178
|
+
|
|
4179
|
+
##### Returns
|
|
4180
|
+
|
|
4181
|
+
`ReturnType`\<`C`\>[]
|
|
4182
|
+
|
|
4183
|
+
Array of callback results for nodes in the rank range.
|
|
4184
|
+
|
|
4185
|
+
##### Remarks
|
|
4186
|
+
|
|
4187
|
+
Time O(log n + k), Space O(k), where k = end - start + 1. Requires `enableOrderStatistic: true`.
|
|
4188
|
+
|
|
4189
|
+
##### Inherited from
|
|
4190
|
+
|
|
4191
|
+
[`BST`](BST.md).[`rangeByRank`](BST.md#rangebyrank)
|
|
4192
|
+
|
|
4193
|
+
***
|
|
4194
|
+
|
|
3907
4195
|
### rangeSearch()
|
|
3908
4196
|
|
|
3909
4197
|
Performs an optimized search for nodes within a given key range.
|
|
@@ -3938,7 +4226,7 @@ The traversal method.
|
|
|
3938
4226
|
rangeSearch(range): (K | undefined)[];
|
|
3939
4227
|
```
|
|
3940
4228
|
|
|
3941
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
4229
|
+
Defined in: [data-structures/binary-tree/bst.ts:1151](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/bst.ts#L1151)
|
|
3942
4230
|
|
|
3943
4231
|
Find all keys in a range
|
|
3944
4232
|
|
|
@@ -3976,7 +4264,7 @@ rangeSearch<C>(
|
|
|
3976
4264
|
iterationType?): ReturnType<C>[];
|
|
3977
4265
|
```
|
|
3978
4266
|
|
|
3979
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
4267
|
+
Defined in: [data-structures/binary-tree/bst.ts:1153](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/bst.ts#L1153)
|
|
3980
4268
|
|
|
3981
4269
|
Find all keys in a range
|
|
3982
4270
|
|
|
@@ -4033,7 +4321,7 @@ Find all keys in a range
|
|
|
4033
4321
|
reduce<U>(callbackfn, initialValue): U;
|
|
4034
4322
|
```
|
|
4035
4323
|
|
|
4036
|
-
Defined in: [data-structures/base/iterable-entry-base.ts:171](https://github.com/zrwusa/data-structure-typed/blob/
|
|
4324
|
+
Defined in: [data-structures/base/iterable-entry-base.ts:171](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/iterable-entry-base.ts#L171)
|
|
4037
4325
|
|
|
4038
4326
|
Reduce entries into a single accumulator.
|
|
4039
4327
|
|
|
@@ -4085,7 +4373,7 @@ IBinaryTree.reduce
|
|
|
4085
4373
|
refill(keysNodesEntriesOrRaws, values?): void;
|
|
4086
4374
|
```
|
|
4087
4375
|
|
|
4088
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
4376
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:913](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/binary-tree.ts#L913)
|
|
4089
4377
|
|
|
4090
4378
|
Clears the tree and refills it with new items.
|
|
4091
4379
|
|
|
@@ -4169,7 +4457,7 @@ Whether to use 'RECURSIVE' or 'ITERATIVE' search.
|
|
|
4169
4457
|
search(keyNodeEntryOrPredicate, onlyOne?): (K | undefined)[];
|
|
4170
4458
|
```
|
|
4171
4459
|
|
|
4172
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
4460
|
+
Defined in: [data-structures/binary-tree/bst.ts:957](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/bst.ts#L957)
|
|
4173
4461
|
|
|
4174
4462
|
Search nodes by predicate
|
|
4175
4463
|
|
|
@@ -4225,7 +4513,7 @@ search<C>(
|
|
|
4225
4513
|
iterationType?): ReturnType<C>[];
|
|
4226
4514
|
```
|
|
4227
4515
|
|
|
4228
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
4516
|
+
Defined in: [data-structures/binary-tree/bst.ts:969](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/bst.ts#L969)
|
|
4229
4517
|
|
|
4230
4518
|
Search nodes by predicate
|
|
4231
4519
|
|
|
@@ -4299,7 +4587,7 @@ IBinaryTree.search
|
|
|
4299
4587
|
set(keyNodeOrEntry, value?): boolean;
|
|
4300
4588
|
```
|
|
4301
4589
|
|
|
4302
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:
|
|
4590
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:1024](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/red-black-tree.ts#L1024)
|
|
4303
4591
|
|
|
4304
4592
|
Insert or update a key/value (map mode) or key-only (set mode).
|
|
4305
4593
|
|
|
@@ -4374,7 +4662,7 @@ setMany(
|
|
|
4374
4662
|
iterationType?): boolean[];
|
|
4375
4663
|
```
|
|
4376
4664
|
|
|
4377
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
4665
|
+
Defined in: [data-structures/binary-tree/bst.ts:1643](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/bst.ts#L1643)
|
|
4378
4666
|
|
|
4379
4667
|
Adds multiple items to the tree.
|
|
4380
4668
|
|
|
@@ -4443,7 +4731,7 @@ setWithHint(
|
|
|
4443
4731
|
hint?): boolean;
|
|
4444
4732
|
```
|
|
4445
4733
|
|
|
4446
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:
|
|
4734
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:862](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/red-black-tree.ts#L862)
|
|
4447
4735
|
|
|
4448
4736
|
Boolean wrapper for setWithHintNode.
|
|
4449
4737
|
|
|
@@ -4480,7 +4768,7 @@ setWithHintNode(
|
|
|
4480
4768
|
hint?): RedBlackTreeNode<K, V> | undefined;
|
|
4481
4769
|
```
|
|
4482
4770
|
|
|
4483
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:
|
|
4771
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:762](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/red-black-tree.ts#L762)
|
|
4484
4772
|
|
|
4485
4773
|
Insert/update using a hint node to speed up nearby insertions.
|
|
4486
4774
|
|
|
@@ -4521,7 +4809,7 @@ Time O(log n) average, Space O(1)
|
|
|
4521
4809
|
some(predicate, thisArg?): boolean;
|
|
4522
4810
|
```
|
|
4523
4811
|
|
|
4524
|
-
Defined in: [data-structures/base/iterable-entry-base.ts:83](https://github.com/zrwusa/data-structure-typed/blob/
|
|
4812
|
+
Defined in: [data-structures/base/iterable-entry-base.ts:83](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/iterable-entry-base.ts#L83)
|
|
4525
4813
|
|
|
4526
4814
|
Test whether any entry satisfies the predicate.
|
|
4527
4815
|
|
|
@@ -4535,7 +4823,7 @@ Test whether any entry satisfies the predicate.
|
|
|
4535
4823
|
|
|
4536
4824
|
##### thisArg?
|
|
4537
4825
|
|
|
4538
|
-
`
|
|
4826
|
+
`unknown`
|
|
4539
4827
|
|
|
4540
4828
|
Optional `this` for callback.
|
|
4541
4829
|
|
|
@@ -4567,7 +4855,7 @@ IBinaryTree.some
|
|
|
4567
4855
|
toArray(): [K, V | undefined][];
|
|
4568
4856
|
```
|
|
4569
4857
|
|
|
4570
|
-
Defined in: [data-structures/base/iterable-entry-base.ts:186](https://github.com/zrwusa/data-structure-typed/blob/
|
|
4858
|
+
Defined in: [data-structures/base/iterable-entry-base.ts:186](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/iterable-entry-base.ts#L186)
|
|
4571
4859
|
|
|
4572
4860
|
Converts data structure to `[key, value]` pairs.
|
|
4573
4861
|
|
|
@@ -4593,7 +4881,7 @@ Time O(n), Space O(n)
|
|
|
4593
4881
|
toVisual(startNode?, options?): string;
|
|
4594
4882
|
```
|
|
4595
4883
|
|
|
4596
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
4884
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:2825](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/binary-tree.ts#L2825)
|
|
4597
4885
|
|
|
4598
4886
|
Generates a string representation of the tree for visualization.
|
|
4599
4887
|
|
|
@@ -4636,7 +4924,7 @@ Time O(N), visits every node. Space O(N*H) or O(N^2) in the worst case, as the s
|
|
|
4636
4924
|
values(): IterableIterator<V | undefined>;
|
|
4637
4925
|
```
|
|
4638
4926
|
|
|
4639
|
-
Defined in: [data-structures/base/iterable-entry-base.ts:53](https://github.com/zrwusa/data-structure-typed/blob/
|
|
4927
|
+
Defined in: [data-structures/base/iterable-entry-base.ts:53](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/base/iterable-entry-base.ts#L53)
|
|
4640
4928
|
|
|
4641
4929
|
Iterate over values only.
|
|
4642
4930
|
|
|
@@ -4671,7 +4959,7 @@ IBinaryTree.values
|
|
|
4671
4959
|
protected readonly _comparator: Comparator<K>;
|
|
4672
4960
|
```
|
|
4673
4961
|
|
|
4674
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
4962
|
+
Defined in: [data-structures/binary-tree/bst.ts:377](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/bst.ts#L377)
|
|
4675
4963
|
|
|
4676
4964
|
The comparator function used to determine the order of keys in the tree.
|
|
4677
4965
|
|
|
@@ -4691,7 +4979,7 @@ Time O(1) Space O(1)
|
|
|
4691
4979
|
protected readonly _DEFAULT_NODE_CALLBACK: NodeCallback<BinaryTreeNode<K, V> | null | undefined, K | undefined>;
|
|
4692
4980
|
```
|
|
4693
4981
|
|
|
4694
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
4982
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:3091](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/binary-tree.ts#L3091)
|
|
4695
4983
|
|
|
4696
4984
|
(Protected) Default callback function, returns the node's key.
|
|
4697
4985
|
|
|
@@ -4719,7 +5007,7 @@ The node's key or undefined.
|
|
|
4719
5007
|
protected _header: RedBlackTreeNode<K, V>;
|
|
4720
5008
|
```
|
|
4721
5009
|
|
|
4722
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:291](https://github.com/zrwusa/data-structure-typed/blob/
|
|
5010
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:291](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/red-black-tree.ts#L291)
|
|
4723
5011
|
|
|
4724
5012
|
(Internal) Header sentinel:
|
|
4725
5013
|
- header.parent -> root
|
|
@@ -4739,7 +5027,7 @@ IMPORTANT:
|
|
|
4739
5027
|
protected _minNode: RedBlackTreeNode<K, V> | undefined;
|
|
4740
5028
|
```
|
|
4741
5029
|
|
|
4742
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:297](https://github.com/zrwusa/data-structure-typed/blob/
|
|
5030
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:297](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/red-black-tree.ts#L297)
|
|
4743
5031
|
|
|
4744
5032
|
(Internal) Cache of the current minimum and maximum nodes.
|
|
4745
5033
|
Used for fast-path insert/update when keys are monotonic or near-boundary.
|
|
@@ -4755,7 +5043,7 @@ protected _attachNewNode(
|
|
|
4755
5043
|
node): void;
|
|
4756
5044
|
```
|
|
4757
5045
|
|
|
4758
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:
|
|
5046
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:561](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/red-black-tree.ts#L561)
|
|
4759
5047
|
|
|
4760
5048
|
(Internal) Attach a new node directly under a known parent/side (no search).
|
|
4761
5049
|
|
|
@@ -4800,7 +5088,7 @@ protected _bound(
|
|
|
4800
5088
|
iterationType): BSTNode<K, V> | undefined;
|
|
4801
5089
|
```
|
|
4802
5090
|
|
|
4803
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
5091
|
+
Defined in: [data-structures/binary-tree/bst.ts:2899](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/bst.ts#L2899)
|
|
4804
5092
|
|
|
4805
5093
|
(Protected) Core bound search implementation supporting all parameter types.
|
|
4806
5094
|
Unified logic for both lowerBound and upperBound.
|
|
@@ -4852,7 +5140,7 @@ protected _boundByKey(
|
|
|
4852
5140
|
iterationType): BSTNode<K, V> | undefined;
|
|
4853
5141
|
```
|
|
4854
5142
|
|
|
4855
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
5143
|
+
Defined in: [data-structures/binary-tree/bst.ts:2956](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/bst.ts#L2956)
|
|
4856
5144
|
|
|
4857
5145
|
(Protected) Binary search for bound by key with pruning optimization.
|
|
4858
5146
|
Performs standard BST binary search, choosing left or right subtree based on comparator result.
|
|
@@ -4897,7 +5185,7 @@ The first node matching the bound condition, or undefined if none exists.
|
|
|
4897
5185
|
protected _boundByPredicate(predicate, iterationType): BSTNode<K, V> | undefined;
|
|
4898
5186
|
```
|
|
4899
5187
|
|
|
4900
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
5188
|
+
Defined in: [data-structures/binary-tree/bst.ts:3011](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/bst.ts#L3011)
|
|
4901
5189
|
|
|
4902
5190
|
(Protected) In-order traversal search by predicate.
|
|
4903
5191
|
Falls back to linear in-order traversal when predicate-based search is required.
|
|
@@ -4937,7 +5225,7 @@ The first node satisfying predicate, or undefined if none found.
|
|
|
4937
5225
|
protected _clearNodes(): void;
|
|
4938
5226
|
```
|
|
4939
5227
|
|
|
4940
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
5228
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:3525](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/binary-tree.ts#L3525)
|
|
4941
5229
|
|
|
4942
5230
|
(Protected) Clears all nodes from the tree.
|
|
4943
5231
|
|
|
@@ -4961,7 +5249,7 @@ Time O(1)
|
|
|
4961
5249
|
protected _clearValues(): void;
|
|
4962
5250
|
```
|
|
4963
5251
|
|
|
4964
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
5252
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:3534](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/binary-tree.ts#L3534)
|
|
4965
5253
|
|
|
4966
5254
|
(Protected) Clears all values from the external store.
|
|
4967
5255
|
|
|
@@ -4985,7 +5273,7 @@ Time O(N)
|
|
|
4985
5273
|
protected _clone(cloned): void;
|
|
4986
5274
|
```
|
|
4987
5275
|
|
|
4988
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
5276
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:3184](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/binary-tree.ts#L3184)
|
|
4989
5277
|
|
|
4990
5278
|
(Protected) Helper for cloning. Performs a BFS and sets all nodes to the new tree.
|
|
4991
5279
|
|
|
@@ -5017,7 +5305,7 @@ Time O(N * M) (O(N) BFS + O(M) `set` for each node).
|
|
|
5017
5305
|
protected _compare(a, b): number;
|
|
5018
5306
|
```
|
|
5019
5307
|
|
|
5020
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
5308
|
+
Defined in: [data-structures/binary-tree/bst.ts:3275](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/bst.ts#L3275)
|
|
5021
5309
|
|
|
5022
5310
|
(Protected) Compares two keys using the tree's comparator and reverse setting.
|
|
5023
5311
|
|
|
@@ -5057,7 +5345,7 @@ Time O(1) Space O(1)
|
|
|
5057
5345
|
protected _createDefaultComparator(): Comparator<K>;
|
|
5058
5346
|
```
|
|
5059
5347
|
|
|
5060
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
5348
|
+
Defined in: [data-structures/binary-tree/bst.ts:2626](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/bst.ts#L2626)
|
|
5061
5349
|
|
|
5062
5350
|
(Protected) Creates the default comparator function for keys that don't have a custom comparator.
|
|
5063
5351
|
|
|
@@ -5083,7 +5371,7 @@ Time O(1) Space O(1)
|
|
|
5083
5371
|
protected _createInstance<TK, TV, TR>(options?): this;
|
|
5084
5372
|
```
|
|
5085
5373
|
|
|
5086
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:
|
|
5374
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:1603](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/red-black-tree.ts#L1603)
|
|
5087
5375
|
|
|
5088
5376
|
(Internal) Create an empty instance of the same concrete tree type.
|
|
5089
5377
|
|
|
@@ -5127,7 +5415,7 @@ Time O(1) average, Space O(1)
|
|
|
5127
5415
|
protected _createLike<TK, TV, TR>(iter?, options?): RedBlackTree<TK, TV, TR>;
|
|
5128
5416
|
```
|
|
5129
5417
|
|
|
5130
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:
|
|
5418
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:1615](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/red-black-tree.ts#L1615)
|
|
5131
5419
|
|
|
5132
5420
|
(Internal) Create a like-kind tree (same concrete class) populated from an iterable.
|
|
5133
5421
|
|
|
@@ -5181,7 +5469,7 @@ Time O(m log m) average (m = iterable length), Space O(m)
|
|
|
5181
5469
|
protected _deleteByKey(key): boolean;
|
|
5182
5470
|
```
|
|
5183
5471
|
|
|
5184
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
5472
|
+
Defined in: [data-structures/binary-tree/bst.ts:3286](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/bst.ts#L3286)
|
|
5185
5473
|
|
|
5186
5474
|
(Private) Deletes a node by its key.
|
|
5187
5475
|
|
|
@@ -5215,7 +5503,7 @@ Standard BST deletion algorithm. Time O(log N), O(N) worst-case. Space O(1).
|
|
|
5215
5503
|
protected _deleteFixup(node): void;
|
|
5216
5504
|
```
|
|
5217
5505
|
|
|
5218
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:
|
|
5506
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:1800](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/red-black-tree.ts#L1800)
|
|
5219
5507
|
|
|
5220
5508
|
(Protected) Restore red-black properties after deletion (recolor/rotate).
|
|
5221
5509
|
|
|
@@ -5255,7 +5543,7 @@ protected _dfs<C>(
|
|
|
5255
5543
|
shouldProcessRoot?): ReturnType<C>[];
|
|
5256
5544
|
```
|
|
5257
5545
|
|
|
5258
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
5546
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:2902](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/binary-tree.ts#L2902)
|
|
5259
5547
|
|
|
5260
5548
|
#### Type Parameters
|
|
5261
5549
|
|
|
@@ -5348,7 +5636,7 @@ Array of callback results.
|
|
|
5348
5636
|
protected _displayAux(node, options): NodeDisplayLayout;
|
|
5349
5637
|
```
|
|
5350
5638
|
|
|
5351
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
5639
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:3208](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/binary-tree.ts#L3208)
|
|
5352
5640
|
|
|
5353
5641
|
(Protected) Recursive helper for `toVisual`.
|
|
5354
5642
|
|
|
@@ -5388,7 +5676,7 @@ Time O(N), Space O(N*H) or O(N^2)
|
|
|
5388
5676
|
protected _ensurePredicate(keyNodeEntryOrPredicate): NodePredicate<BinaryTreeNode<K, V>>;
|
|
5389
5677
|
```
|
|
5390
5678
|
|
|
5391
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
5679
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:3431](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/binary-tree.ts#L3431)
|
|
5392
5680
|
|
|
5393
5681
|
(Protected) Converts a key, node, entry, or predicate into a standardized predicate function.
|
|
5394
5682
|
|
|
@@ -5427,7 +5715,7 @@ Time O(1)
|
|
|
5427
5715
|
protected _extractKey(keyNodeOrEntry): K | null | undefined;
|
|
5428
5716
|
```
|
|
5429
5717
|
|
|
5430
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
5718
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:3491](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/binary-tree.ts#L3491)
|
|
5431
5719
|
|
|
5432
5720
|
(Protected) Extracts the key from a key, node, or entry.
|
|
5433
5721
|
|
|
@@ -5465,7 +5753,7 @@ Time O(1)
|
|
|
5465
5753
|
protected _findNodeByKey(key): RedBlackTreeNode<K, V> | undefined;
|
|
5466
5754
|
```
|
|
5467
5755
|
|
|
5468
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:
|
|
5756
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:495](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/red-black-tree.ts#L495)
|
|
5469
5757
|
|
|
5470
5758
|
(Internal) Find a node by key using a tight BST walk (no allocations).
|
|
5471
5759
|
|
|
@@ -5493,7 +5781,7 @@ Time O(log n) average, Space O(1)
|
|
|
5493
5781
|
protected _floorByKey(key, iterationType): BSTNode<K, V> | undefined;
|
|
5494
5782
|
```
|
|
5495
5783
|
|
|
5496
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
5784
|
+
Defined in: [data-structures/binary-tree/bst.ts:2664](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/bst.ts#L2664)
|
|
5497
5785
|
|
|
5498
5786
|
(Protected) Binary search for floor by key with pruning optimization.
|
|
5499
5787
|
Performs standard BST binary search, choosing left or right subtree based on comparator result.
|
|
@@ -5535,7 +5823,7 @@ Time O(h) where h is tree height.
|
|
|
5535
5823
|
protected _floorByPredicate(predicate, iterationType): BSTNode<K, V> | undefined;
|
|
5536
5824
|
```
|
|
5537
5825
|
|
|
5538
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
5826
|
+
Defined in: [data-structures/binary-tree/bst.ts:2717](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/bst.ts#L2717)
|
|
5539
5827
|
|
|
5540
5828
|
(Protected) In-order traversal search for floor by predicate.
|
|
5541
5829
|
Falls back to linear in-order traversal when predicate-based search is required.
|
|
@@ -5572,13 +5860,81 @@ Space Complexity: O(h) for recursion, O(h) for iterative stack.
|
|
|
5572
5860
|
|
|
5573
5861
|
***
|
|
5574
5862
|
|
|
5863
|
+
### \_getByRankIterative()
|
|
5864
|
+
|
|
5865
|
+
```ts
|
|
5866
|
+
protected _getByRankIterative(node, k): BSTNode<K, V> | undefined;
|
|
5867
|
+
```
|
|
5868
|
+
|
|
5869
|
+
Defined in: [data-structures/binary-tree/bst.ts:3167](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/bst.ts#L3167)
|
|
5870
|
+
|
|
5871
|
+
(Protected) Finds the node at position k in tree order (iterative).
|
|
5872
|
+
|
|
5873
|
+
#### Parameters
|
|
5874
|
+
|
|
5875
|
+
##### node
|
|
5876
|
+
|
|
5877
|
+
`OptNode`\<[`BSTNode`](BSTNode.md)\<`K`, `V`\>\>
|
|
5878
|
+
|
|
5879
|
+
##### k
|
|
5880
|
+
|
|
5881
|
+
`number`
|
|
5882
|
+
|
|
5883
|
+
#### Returns
|
|
5884
|
+
|
|
5885
|
+
[`BSTNode`](BSTNode.md)\<`K`, `V`\> \| `undefined`
|
|
5886
|
+
|
|
5887
|
+
#### Remarks
|
|
5888
|
+
|
|
5889
|
+
Time O(log n), Space O(1)
|
|
5890
|
+
|
|
5891
|
+
#### Inherited from
|
|
5892
|
+
|
|
5893
|
+
[`BST`](BST.md).[`_getByRankIterative`](BST.md#_getbyrankiterative)
|
|
5894
|
+
|
|
5895
|
+
***
|
|
5896
|
+
|
|
5897
|
+
### \_getByRankRecursive()
|
|
5898
|
+
|
|
5899
|
+
```ts
|
|
5900
|
+
protected _getByRankRecursive(node, k): BSTNode<K, V> | undefined;
|
|
5901
|
+
```
|
|
5902
|
+
|
|
5903
|
+
Defined in: [data-structures/binary-tree/bst.ts:3188](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/bst.ts#L3188)
|
|
5904
|
+
|
|
5905
|
+
(Protected) Finds the node at position k in tree order (recursive).
|
|
5906
|
+
|
|
5907
|
+
#### Parameters
|
|
5908
|
+
|
|
5909
|
+
##### node
|
|
5910
|
+
|
|
5911
|
+
`OptNode`\<[`BSTNode`](BSTNode.md)\<`K`, `V`\>\>
|
|
5912
|
+
|
|
5913
|
+
##### k
|
|
5914
|
+
|
|
5915
|
+
`number`
|
|
5916
|
+
|
|
5917
|
+
#### Returns
|
|
5918
|
+
|
|
5919
|
+
[`BSTNode`](BSTNode.md)\<`K`, `V`\> \| `undefined`
|
|
5920
|
+
|
|
5921
|
+
#### Remarks
|
|
5922
|
+
|
|
5923
|
+
Time O(log n), Space O(log n) call stack
|
|
5924
|
+
|
|
5925
|
+
#### Inherited from
|
|
5926
|
+
|
|
5927
|
+
[`BST`](BST.md).[`_getByRankRecursive`](BST.md#_getbyrankrecursive)
|
|
5928
|
+
|
|
5929
|
+
***
|
|
5930
|
+
|
|
5575
5931
|
### \_getIterator()
|
|
5576
5932
|
|
|
5577
5933
|
```ts
|
|
5578
5934
|
protected _getIterator(node?): IterableIterator<[K, V | undefined]>;
|
|
5579
5935
|
```
|
|
5580
5936
|
|
|
5581
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
5937
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:3047](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/binary-tree.ts#L3047)
|
|
5582
5938
|
|
|
5583
5939
|
(Protected) Gets the iterator for the tree (default in-order).
|
|
5584
5940
|
|
|
@@ -5606,13 +5962,81 @@ Time O(N) for full iteration. O(H) to get the first element. Space O(H) for the
|
|
|
5606
5962
|
|
|
5607
5963
|
***
|
|
5608
5964
|
|
|
5965
|
+
### \_getRankIterative()
|
|
5966
|
+
|
|
5967
|
+
```ts
|
|
5968
|
+
protected _getRankIterative(node, key): number;
|
|
5969
|
+
```
|
|
5970
|
+
|
|
5971
|
+
Defined in: [data-structures/binary-tree/bst.ts:3200](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/bst.ts#L3200)
|
|
5972
|
+
|
|
5973
|
+
(Protected) Computes the rank of a key iteratively.
|
|
5974
|
+
|
|
5975
|
+
#### Parameters
|
|
5976
|
+
|
|
5977
|
+
##### node
|
|
5978
|
+
|
|
5979
|
+
`OptNode`\<[`BSTNode`](BSTNode.md)\<`K`, `V`\>\>
|
|
5980
|
+
|
|
5981
|
+
##### key
|
|
5982
|
+
|
|
5983
|
+
`K`
|
|
5984
|
+
|
|
5985
|
+
#### Returns
|
|
5986
|
+
|
|
5987
|
+
`number`
|
|
5988
|
+
|
|
5989
|
+
#### Remarks
|
|
5990
|
+
|
|
5991
|
+
Time O(log n), Space O(1)
|
|
5992
|
+
|
|
5993
|
+
#### Inherited from
|
|
5994
|
+
|
|
5995
|
+
[`BST`](BST.md).[`_getRankIterative`](BST.md#_getrankiterative)
|
|
5996
|
+
|
|
5997
|
+
***
|
|
5998
|
+
|
|
5999
|
+
### \_getRankRecursive()
|
|
6000
|
+
|
|
6001
|
+
```ts
|
|
6002
|
+
protected _getRankRecursive(node, key): number;
|
|
6003
|
+
```
|
|
6004
|
+
|
|
6005
|
+
Defined in: [data-structures/binary-tree/bst.ts:3226](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/bst.ts#L3226)
|
|
6006
|
+
|
|
6007
|
+
(Protected) Computes the rank of a key recursively.
|
|
6008
|
+
|
|
6009
|
+
#### Parameters
|
|
6010
|
+
|
|
6011
|
+
##### node
|
|
6012
|
+
|
|
6013
|
+
`OptNode`\<[`BSTNode`](BSTNode.md)\<`K`, `V`\>\>
|
|
6014
|
+
|
|
6015
|
+
##### key
|
|
6016
|
+
|
|
6017
|
+
`K`
|
|
6018
|
+
|
|
6019
|
+
#### Returns
|
|
6020
|
+
|
|
6021
|
+
`number`
|
|
6022
|
+
|
|
6023
|
+
#### Remarks
|
|
6024
|
+
|
|
6025
|
+
Time O(log n), Space O(log n) call stack
|
|
6026
|
+
|
|
6027
|
+
#### Inherited from
|
|
6028
|
+
|
|
6029
|
+
[`BST`](BST.md).[`_getRankRecursive`](BST.md#_getrankrecursive)
|
|
6030
|
+
|
|
6031
|
+
***
|
|
6032
|
+
|
|
5609
6033
|
### \_insert()
|
|
5610
6034
|
|
|
5611
6035
|
```ts
|
|
5612
6036
|
protected _insert(node): CRUD;
|
|
5613
6037
|
```
|
|
5614
6038
|
|
|
5615
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:
|
|
6039
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:1662](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/red-black-tree.ts#L1662)
|
|
5616
6040
|
|
|
5617
6041
|
(Protected) Standard BST insert followed by red-black fix-up.
|
|
5618
6042
|
|
|
@@ -5642,7 +6066,7 @@ Time O(log n) average, Space O(1)
|
|
|
5642
6066
|
protected _insertFixup(z): void;
|
|
5643
6067
|
```
|
|
5644
6068
|
|
|
5645
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:
|
|
6069
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:1731](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/red-black-tree.ts#L1731)
|
|
5646
6070
|
|
|
5647
6071
|
(Protected) Restore red-black properties after insertion (recolor/rotate).
|
|
5648
6072
|
|
|
@@ -5672,7 +6096,7 @@ Time O(log n) average, Space O(1)
|
|
|
5672
6096
|
protected _isDisplayLeaf(node, options): boolean;
|
|
5673
6097
|
```
|
|
5674
6098
|
|
|
5675
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
6099
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:3303](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/binary-tree.ts#L3303)
|
|
5676
6100
|
|
|
5677
6101
|
Check if a node is a display leaf (empty, null, undefined, NIL, or real leaf).
|
|
5678
6102
|
|
|
@@ -5702,7 +6126,7 @@ Check if a node is a display leaf (empty, null, undefined, NIL, or real leaf).
|
|
|
5702
6126
|
protected _isPredicate(p): p is NodePredicate<BinaryTreeNode<K, V>>;
|
|
5703
6127
|
```
|
|
5704
6128
|
|
|
5705
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
6129
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:3480](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/binary-tree.ts#L3480)
|
|
5706
6130
|
|
|
5707
6131
|
(Protected) Checks if an item is a predicate function.
|
|
5708
6132
|
|
|
@@ -5710,7 +6134,7 @@ Defined in: [data-structures/binary-tree/binary-tree.ts:3305](https://github.com
|
|
|
5710
6134
|
|
|
5711
6135
|
##### p
|
|
5712
6136
|
|
|
5713
|
-
`
|
|
6137
|
+
`unknown`
|
|
5714
6138
|
|
|
5715
6139
|
The item to check.
|
|
5716
6140
|
|
|
@@ -5736,7 +6160,7 @@ Time O(1)
|
|
|
5736
6160
|
protected _keyValueNodeOrEntryToNodeAndValue(keyNodeOrEntry, value?): [OptNode<BSTNode<K, V>>, V | undefined];
|
|
5737
6161
|
```
|
|
5738
6162
|
|
|
5739
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
6163
|
+
Defined in: [data-structures/binary-tree/bst.ts:3124](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/bst.ts#L3124)
|
|
5740
6164
|
|
|
5741
6165
|
(Protected) Converts a key, node, or entry into a standardized [node, value] tuple.
|
|
5742
6166
|
|
|
@@ -5780,7 +6204,7 @@ Time O(1)
|
|
|
5780
6204
|
protected _leftRotate(x): void;
|
|
5781
6205
|
```
|
|
5782
6206
|
|
|
5783
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:
|
|
6207
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:1879](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/red-black-tree.ts#L1879)
|
|
5784
6208
|
|
|
5785
6209
|
(Protected) Perform a left rotation around x.
|
|
5786
6210
|
|
|
@@ -5810,7 +6234,7 @@ Time O(1), Space O(1)
|
|
|
5810
6234
|
protected _lowerByKey(key, iterationType): BSTNode<K, V> | undefined;
|
|
5811
6235
|
```
|
|
5812
6236
|
|
|
5813
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
6237
|
+
Defined in: [data-structures/binary-tree/bst.ts:2782](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/bst.ts#L2782)
|
|
5814
6238
|
|
|
5815
6239
|
(Protected) Binary search for lower by key with pruning optimization.
|
|
5816
6240
|
Performs standard BST binary search, choosing left or right subtree based on comparator result.
|
|
@@ -5852,7 +6276,7 @@ Time O(h) where h is tree height.
|
|
|
5852
6276
|
protected _lowerByPredicate(predicate, iterationType): BSTNode<K, V> | undefined;
|
|
5853
6277
|
```
|
|
5854
6278
|
|
|
5855
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
6279
|
+
Defined in: [data-structures/binary-tree/bst.ts:2835](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/bst.ts#L2835)
|
|
5856
6280
|
|
|
5857
6281
|
(Protected) In-order traversal search for lower by predicate.
|
|
5858
6282
|
Falls back to linear in-order traversal when predicate-based search is required.
|
|
@@ -5889,13 +6313,43 @@ Space Complexity: O(h) for recursion, O(h) for iterative stack.
|
|
|
5889
6313
|
|
|
5890
6314
|
***
|
|
5891
6315
|
|
|
6316
|
+
### \_next()
|
|
6317
|
+
|
|
6318
|
+
```ts
|
|
6319
|
+
protected _next(node): BSTNode<K, V> | undefined;
|
|
6320
|
+
```
|
|
6321
|
+
|
|
6322
|
+
Defined in: [data-structures/binary-tree/bst.ts:3243](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/bst.ts#L3243)
|
|
6323
|
+
|
|
6324
|
+
(Protected) Finds the in-order successor of a node.
|
|
6325
|
+
|
|
6326
|
+
#### Parameters
|
|
6327
|
+
|
|
6328
|
+
##### node
|
|
6329
|
+
|
|
6330
|
+
[`BSTNode`](BSTNode.md)\<`K`, `V`\>
|
|
6331
|
+
|
|
6332
|
+
#### Returns
|
|
6333
|
+
|
|
6334
|
+
[`BSTNode`](BSTNode.md)\<`K`, `V`\> \| `undefined`
|
|
6335
|
+
|
|
6336
|
+
#### Remarks
|
|
6337
|
+
|
|
6338
|
+
Time O(log n), Space O(1)
|
|
6339
|
+
|
|
6340
|
+
#### Inherited from
|
|
6341
|
+
|
|
6342
|
+
[`BST`](BST.md).[`_next`](BST.md#_next)
|
|
6343
|
+
|
|
6344
|
+
***
|
|
6345
|
+
|
|
5892
6346
|
### \_predecessorOf()
|
|
5893
6347
|
|
|
5894
6348
|
```ts
|
|
5895
6349
|
protected _predecessorOf(node): RedBlackTreeNode<K, V> | undefined;
|
|
5896
6350
|
```
|
|
5897
6351
|
|
|
5898
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:
|
|
6352
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:513](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/red-black-tree.ts#L513)
|
|
5899
6353
|
|
|
5900
6354
|
(Internal) In-order predecessor of a node in a BST.
|
|
5901
6355
|
|
|
@@ -5921,7 +6375,7 @@ Time O(log n) average, Space O(1)
|
|
|
5921
6375
|
protected _replaceNode(oldNode, newNode): RedBlackTreeNode<K, V>;
|
|
5922
6376
|
```
|
|
5923
6377
|
|
|
5924
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:
|
|
6378
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:1647](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/red-black-tree.ts#L1647)
|
|
5925
6379
|
|
|
5926
6380
|
(Internal) Replace a node in place while preserving its color.
|
|
5927
6381
|
|
|
@@ -5958,7 +6412,7 @@ protected _resolveDisplayLeaf(
|
|
|
5958
6412
|
emptyDisplayLayout): NodeDisplayLayout;
|
|
5959
6413
|
```
|
|
5960
6414
|
|
|
5961
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
6415
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:3333](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/binary-tree.ts#L3333)
|
|
5962
6416
|
|
|
5963
6417
|
Resolve a display leaf node to its layout.
|
|
5964
6418
|
|
|
@@ -5992,7 +6446,7 @@ Resolve a display leaf node to its layout.
|
|
|
5992
6446
|
protected _rightRotate(y): void;
|
|
5993
6447
|
```
|
|
5994
6448
|
|
|
5995
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:
|
|
6449
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:1915](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/red-black-tree.ts#L1915)
|
|
5996
6450
|
|
|
5997
6451
|
(Protected) Perform a right rotation around y.
|
|
5998
6452
|
|
|
@@ -6022,7 +6476,7 @@ Time O(1), Space O(1)
|
|
|
6022
6476
|
protected _setKV(key, nextValue?): boolean;
|
|
6023
6477
|
```
|
|
6024
6478
|
|
|
6025
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:
|
|
6479
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:738](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/red-black-tree.ts#L738)
|
|
6026
6480
|
|
|
6027
6481
|
(Internal) Boolean wrapper around `_setKVNode`.
|
|
6028
6482
|
|
|
@@ -6063,7 +6517,7 @@ protected _setKVNode(key, nextValue?):
|
|
|
6063
6517
|
| undefined;
|
|
6064
6518
|
```
|
|
6065
6519
|
|
|
6066
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:
|
|
6520
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:611](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/red-black-tree.ts#L611)
|
|
6067
6521
|
|
|
6068
6522
|
(Internal) Core set implementation returning the affected node.
|
|
6069
6523
|
|
|
@@ -6107,7 +6561,7 @@ Time O(log n) average, Space O(1)
|
|
|
6107
6561
|
protected _setMaxCache(node): void;
|
|
6108
6562
|
```
|
|
6109
6563
|
|
|
6110
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:
|
|
6564
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:592](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/red-black-tree.ts#L592)
|
|
6111
6565
|
|
|
6112
6566
|
(Internal) Update max cache pointers (header._right is the canonical max pointer).
|
|
6113
6567
|
|
|
@@ -6133,7 +6587,7 @@ Time O(1), Space O(1)
|
|
|
6133
6587
|
protected _setMinCache(node): void;
|
|
6134
6588
|
```
|
|
6135
6589
|
|
|
6136
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:
|
|
6590
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:583](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/red-black-tree.ts#L583)
|
|
6137
6591
|
|
|
6138
6592
|
(Internal) Update min cache pointers (header._left is the canonical min pointer).
|
|
6139
6593
|
|
|
@@ -6159,7 +6613,7 @@ Time O(1), Space O(1)
|
|
|
6159
6613
|
protected _setRoot(v): void;
|
|
6160
6614
|
```
|
|
6161
6615
|
|
|
6162
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:
|
|
6616
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:1632](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/red-black-tree.ts#L1632)
|
|
6163
6617
|
|
|
6164
6618
|
(Internal) Set the root pointer and keep header.parent in sync.
|
|
6165
6619
|
|
|
@@ -6189,7 +6643,7 @@ Time O(1), Space O(1)
|
|
|
6189
6643
|
protected _setValue(key, value): boolean;
|
|
6190
6644
|
```
|
|
6191
6645
|
|
|
6192
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
6646
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:3512](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/binary-tree.ts#L3512)
|
|
6193
6647
|
|
|
6194
6648
|
(Protected) Sets a value in the external store (Map mode).
|
|
6195
6649
|
|
|
@@ -6229,7 +6683,7 @@ Time O(1) (average for Map.set).
|
|
|
6229
6683
|
protected _snapshotOptions<TK, TV, TR>(): BSTOptions<TK, TV, TR>;
|
|
6230
6684
|
```
|
|
6231
6685
|
|
|
6232
|
-
Defined in: [data-structures/binary-tree/bst.ts:
|
|
6686
|
+
Defined in: [data-structures/binary-tree/bst.ts:3108](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/bst.ts#L3108)
|
|
6233
6687
|
|
|
6234
6688
|
(Protected) Snapshots the current BST's configuration options.
|
|
6235
6689
|
|
|
@@ -6269,7 +6723,7 @@ Time O(1)
|
|
|
6269
6723
|
protected _successorOf(node): RedBlackTreeNode<K, V> | undefined;
|
|
6270
6724
|
```
|
|
6271
6725
|
|
|
6272
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:
|
|
6726
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:533](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/red-black-tree.ts#L533)
|
|
6273
6727
|
|
|
6274
6728
|
(Internal) In-order successor of a node in a BST.
|
|
6275
6729
|
|
|
@@ -6295,7 +6749,7 @@ Time O(log n) average, Space O(1)
|
|
|
6295
6749
|
protected _swapProperties(srcNode, destNode): BinaryTreeNode<K, V> | undefined;
|
|
6296
6750
|
```
|
|
6297
6751
|
|
|
6298
|
-
Defined in: [data-structures/binary-tree/binary-tree.ts:
|
|
6752
|
+
Defined in: [data-structures/binary-tree/binary-tree.ts:3359](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/binary-tree.ts#L3359)
|
|
6299
6753
|
|
|
6300
6754
|
(Protected) Swaps the key/value properties of two nodes.
|
|
6301
6755
|
|
|
@@ -6343,7 +6797,7 @@ Time O(1)
|
|
|
6343
6797
|
protected _transplant(u, v): void;
|
|
6344
6798
|
```
|
|
6345
6799
|
|
|
6346
|
-
Defined in: [data-structures/binary-tree/red-black-tree.ts:
|
|
6800
|
+
Defined in: [data-structures/binary-tree/red-black-tree.ts:1711](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/red-black-tree.ts#L1711)
|
|
6347
6801
|
|
|
6348
6802
|
(Protected) Transplant a subtree in place of another during deletion.
|
|
6349
6803
|
|
|
@@ -6372,3 +6826,63 @@ void
|
|
|
6372
6826
|
Time O(1), Space O(1)
|
|
6373
6827
|
|
|
6374
6828
|
***
|
|
6829
|
+
|
|
6830
|
+
### \_updateCount()
|
|
6831
|
+
|
|
6832
|
+
```ts
|
|
6833
|
+
protected _updateCount(node): void;
|
|
6834
|
+
```
|
|
6835
|
+
|
|
6836
|
+
Defined in: [data-structures/binary-tree/bst.ts:3143](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/bst.ts#L3143)
|
|
6837
|
+
|
|
6838
|
+
(Protected) Recalculates the subtree count for a single node.
|
|
6839
|
+
|
|
6840
|
+
#### Parameters
|
|
6841
|
+
|
|
6842
|
+
##### node
|
|
6843
|
+
|
|
6844
|
+
[`BSTNode`](BSTNode.md)\<`K`, `V`\>
|
|
6845
|
+
|
|
6846
|
+
#### Returns
|
|
6847
|
+
|
|
6848
|
+
`void`
|
|
6849
|
+
|
|
6850
|
+
#### Remarks
|
|
6851
|
+
|
|
6852
|
+
Time O(1). Only active when enableOrderStatistic is true.
|
|
6853
|
+
|
|
6854
|
+
#### Inherited from
|
|
6855
|
+
|
|
6856
|
+
[`BST`](BST.md).[`_updateCount`](BST.md#_updatecount)
|
|
6857
|
+
|
|
6858
|
+
***
|
|
6859
|
+
|
|
6860
|
+
### \_updateCountAlongPath()
|
|
6861
|
+
|
|
6862
|
+
```ts
|
|
6863
|
+
protected _updateCountAlongPath(node): void;
|
|
6864
|
+
```
|
|
6865
|
+
|
|
6866
|
+
Defined in: [data-structures/binary-tree/bst.ts:3154](https://github.com/zrwusa/data-structure-typed/blob/8292cb978daf85ebe846186c7c7572aece04fb7b/src/data-structures/binary-tree/bst.ts#L3154)
|
|
6867
|
+
|
|
6868
|
+
(Protected) Updates subtree counts from a node up to the root.
|
|
6869
|
+
|
|
6870
|
+
#### Parameters
|
|
6871
|
+
|
|
6872
|
+
##### node
|
|
6873
|
+
|
|
6874
|
+
`OptNode`\<[`BSTNode`](BSTNode.md)\<`K`, `V`\>\>
|
|
6875
|
+
|
|
6876
|
+
#### Returns
|
|
6877
|
+
|
|
6878
|
+
`void`
|
|
6879
|
+
|
|
6880
|
+
#### Remarks
|
|
6881
|
+
|
|
6882
|
+
Time O(log n). Only active when enableOrderStatistic is true.
|
|
6883
|
+
|
|
6884
|
+
#### Inherited from
|
|
6885
|
+
|
|
6886
|
+
[`BST`](BST.md).[`_updateCountAlongPath`](BST.md#_updatecountalongpath)
|
|
6887
|
+
|
|
6888
|
+
***
|