data-structure-typed 1.36.1 → 1.36.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -1
- package/README.md +1 -1
- package/dist/data-structures/binary-tree/avl-tree.d.ts +3 -3
- package/dist/data-structures/binary-tree/avl-tree.js.map +1 -1
- package/dist/data-structures/binary-tree/binary-tree.d.ts +8 -8
- package/dist/data-structures/binary-tree/binary-tree.js +11 -13
- package/dist/data-structures/binary-tree/binary-tree.js.map +1 -1
- package/dist/data-structures/binary-tree/bst.d.ts +3 -3
- package/dist/data-structures/binary-tree/bst.js.map +1 -1
- package/dist/data-structures/binary-tree/index.d.ts +0 -5
- package/dist/data-structures/binary-tree/index.js +0 -5
- package/dist/data-structures/binary-tree/index.js.map +1 -1
- package/dist/data-structures/binary-tree/rb-tree.d.ts +3 -3
- package/dist/data-structures/binary-tree/rb-tree.js.map +1 -1
- package/dist/data-structures/binary-tree/tree-multiset.d.ts +3 -3
- package/dist/data-structures/binary-tree/tree-multiset.js.map +1 -1
- package/dist/data-structures/graph/abstract-graph.d.ts +2 -2
- package/dist/data-structures/graph/directed-graph.d.ts +2 -2
- package/dist/data-structures/graph/map-graph.d.ts +1 -1
- package/dist/data-structures/graph/map-graph.js +1 -1
- package/dist/data-structures/graph/undirected-graph.d.ts +2 -2
- package/dist/data-structures/hash/index.d.ts +0 -1
- package/dist/data-structures/hash/index.js +0 -1
- package/dist/data-structures/hash/index.js.map +1 -1
- package/dist/data-structures/heap/heap.d.ts +4 -4
- package/dist/data-structures/heap/heap.js.map +1 -1
- package/dist/data-structures/heap/max-heap.d.ts +2 -2
- package/dist/data-structures/heap/max-heap.js.map +1 -1
- package/dist/data-structures/heap/min-heap.d.ts +2 -2
- package/dist/data-structures/heap/min-heap.js.map +1 -1
- package/dist/data-structures/priority-queue/max-priority-queue.d.ts +2 -2
- package/dist/data-structures/priority-queue/max-priority-queue.js.map +1 -1
- package/dist/data-structures/priority-queue/min-priority-queue.d.ts +2 -2
- package/dist/data-structures/priority-queue/min-priority-queue.js.map +1 -1
- package/dist/data-structures/priority-queue/priority-queue.d.ts +2 -2
- package/dist/data-structures/priority-queue/priority-queue.js.map +1 -1
- package/dist/interfaces/binary-tree.d.ts +5 -4
- package/dist/interfaces/{abstract-graph.d.ts → graph.d.ts} +1 -1
- package/dist/interfaces/{bst.js → graph.js} +1 -1
- package/dist/interfaces/graph.js.map +1 -0
- package/dist/interfaces/index.d.ts +1 -8
- package/dist/interfaces/index.js +1 -8
- package/dist/interfaces/index.js.map +1 -1
- package/dist/types/data-structures/abstract-graph.d.ts +0 -1
- package/dist/types/data-structures/binary-tree.d.ts +30 -2
- package/dist/types/data-structures/binary-tree.js +22 -0
- package/dist/types/data-structures/binary-tree.js.map +1 -1
- package/dist/types/data-structures/bst.d.ts +1 -2
- package/dist/types/data-structures/heap.d.ts +2 -1
- package/dist/types/data-structures/index.d.ts +0 -2
- package/dist/types/data-structures/index.js +0 -2
- package/dist/types/data-structures/index.js.map +1 -1
- package/lib/data-structures/binary-tree/avl-tree.d.ts +3 -3
- package/lib/data-structures/binary-tree/binary-tree.d.ts +8 -8
- package/lib/data-structures/binary-tree/binary-tree.js +11 -13
- package/lib/data-structures/binary-tree/bst.d.ts +3 -3
- package/lib/data-structures/binary-tree/index.d.ts +0 -5
- package/lib/data-structures/binary-tree/index.js +0 -5
- package/lib/data-structures/binary-tree/rb-tree.d.ts +3 -3
- package/lib/data-structures/binary-tree/tree-multiset.d.ts +3 -3
- package/lib/data-structures/graph/abstract-graph.d.ts +2 -2
- package/lib/data-structures/graph/directed-graph.d.ts +2 -2
- package/lib/data-structures/graph/map-graph.d.ts +1 -1
- package/lib/data-structures/graph/map-graph.js +1 -1
- package/lib/data-structures/graph/undirected-graph.d.ts +2 -2
- package/lib/data-structures/hash/index.d.ts +0 -1
- package/lib/data-structures/hash/index.js +0 -1
- package/lib/data-structures/heap/heap.d.ts +4 -4
- package/lib/data-structures/heap/max-heap.d.ts +2 -2
- package/lib/data-structures/heap/min-heap.d.ts +2 -2
- package/lib/data-structures/priority-queue/max-priority-queue.d.ts +2 -2
- package/lib/data-structures/priority-queue/min-priority-queue.d.ts +2 -2
- package/lib/data-structures/priority-queue/priority-queue.d.ts +2 -2
- package/lib/interfaces/binary-tree.d.ts +5 -4
- package/lib/interfaces/{abstract-graph.d.ts → graph.d.ts} +1 -1
- package/lib/interfaces/index.d.ts +1 -8
- package/lib/interfaces/index.js +1 -8
- package/lib/types/data-structures/abstract-graph.d.ts +0 -1
- package/lib/types/data-structures/binary-tree.d.ts +30 -2
- package/lib/types/data-structures/binary-tree.js +21 -1
- package/lib/types/data-structures/bst.d.ts +1 -2
- package/lib/types/data-structures/heap.d.ts +2 -1
- package/lib/types/data-structures/index.d.ts +0 -2
- package/lib/types/data-structures/index.js +0 -2
- package/package.json +5 -5
- package/src/data-structures/binary-tree/avl-tree.ts +6 -6
- package/src/data-structures/binary-tree/binary-tree.ts +29 -39
- package/src/data-structures/binary-tree/bst.ts +3 -6
- package/src/data-structures/binary-tree/index.ts +0 -5
- package/src/data-structures/binary-tree/rb-tree.ts +6 -6
- package/src/data-structures/binary-tree/tree-multiset.ts +6 -6
- package/src/data-structures/graph/abstract-graph.ts +2 -2
- package/src/data-structures/graph/directed-graph.ts +2 -2
- package/src/data-structures/graph/map-graph.ts +1 -1
- package/src/data-structures/graph/undirected-graph.ts +2 -2
- package/src/data-structures/hash/index.ts +0 -1
- package/src/data-structures/heap/heap.ts +5 -5
- package/src/data-structures/heap/max-heap.ts +2 -2
- package/src/data-structures/heap/min-heap.ts +2 -2
- package/src/data-structures/priority-queue/max-priority-queue.ts +2 -2
- package/src/data-structures/priority-queue/min-priority-queue.ts +2 -2
- package/src/data-structures/priority-queue/priority-queue.ts +2 -2
- package/src/interfaces/binary-tree.ts +7 -4
- package/src/interfaces/{abstract-graph.ts → graph.ts} +1 -1
- package/src/interfaces/index.ts +1 -8
- package/src/types/data-structures/abstract-graph.ts +1 -1
- package/src/types/data-structures/binary-tree.ts +42 -2
- package/src/types/data-structures/bst.ts +2 -2
- package/src/types/data-structures/heap.ts +3 -1
- package/src/types/data-structures/index.ts +0 -2
- package/src/types/data-structures/navigator.ts +1 -0
- package/test/unit/data-structures/heap/max-heap.test.ts +2 -2
- package/test/unit/data-structures/heap/min-heap.test.ts +2 -2
- package/umd/bundle.min.js +1 -1
- package/umd/bundle.min.js.map +1 -1
- package/dist/data-structures/binary-tree/aa-tree.d.ts +0 -2
- package/dist/data-structures/binary-tree/aa-tree.js +0 -7
- package/dist/data-structures/binary-tree/aa-tree.js.map +0 -1
- package/dist/data-structures/binary-tree/abstract-binary-tree.d.ts +0 -21
- package/dist/data-structures/binary-tree/abstract-binary-tree.js +0 -25
- package/dist/data-structures/binary-tree/abstract-binary-tree.js.map +0 -1
- package/dist/data-structures/binary-tree/b-tree.d.ts +0 -2
- package/dist/data-structures/binary-tree/b-tree.js +0 -7
- package/dist/data-structures/binary-tree/b-tree.js.map +0 -1
- package/dist/data-structures/binary-tree/splay-tree.d.ts +0 -2
- package/dist/data-structures/binary-tree/splay-tree.js +0 -7
- package/dist/data-structures/binary-tree/splay-tree.js.map +0 -1
- package/dist/data-structures/binary-tree/two-three-tree.d.ts +0 -2
- package/dist/data-structures/binary-tree/two-three-tree.js +0 -7
- package/dist/data-structures/binary-tree/two-three-tree.js.map +0 -1
- package/dist/data-structures/hash/pair.d.ts +0 -2
- package/dist/data-structures/hash/pair.js +0 -7
- package/dist/data-structures/hash/pair.js.map +0 -1
- package/dist/interfaces/abstract-binary-tree.d.ts +0 -7
- package/dist/interfaces/abstract-binary-tree.js +0 -3
- package/dist/interfaces/abstract-binary-tree.js.map +0 -1
- package/dist/interfaces/abstract-graph.js +0 -3
- package/dist/interfaces/abstract-graph.js.map +0 -1
- package/dist/interfaces/avl-tree.d.ts +0 -7
- package/dist/interfaces/avl-tree.js +0 -3
- package/dist/interfaces/avl-tree.js.map +0 -1
- package/dist/interfaces/bst.d.ts +0 -6
- package/dist/interfaces/bst.js.map +0 -1
- package/dist/interfaces/directed-graph.d.ts +0 -3
- package/dist/interfaces/directed-graph.js +0 -3
- package/dist/interfaces/directed-graph.js.map +0 -1
- package/dist/interfaces/rb-tree.d.ts +0 -6
- package/dist/interfaces/rb-tree.js +0 -3
- package/dist/interfaces/rb-tree.js.map +0 -1
- package/dist/interfaces/tree-multiset.d.ts +0 -6
- package/dist/interfaces/tree-multiset.js +0 -3
- package/dist/interfaces/tree-multiset.js.map +0 -1
- package/dist/interfaces/undirected-graph.d.ts +0 -3
- package/dist/interfaces/undirected-graph.js +0 -3
- package/dist/interfaces/undirected-graph.js.map +0 -1
- package/dist/types/data-structures/abstract-binary-tree.d.ts +0 -32
- package/dist/types/data-structures/abstract-binary-tree.js +0 -25
- package/dist/types/data-structures/abstract-binary-tree.js.map +0 -1
- package/dist/types/data-structures/priority-queue.d.ts +0 -7
- package/dist/types/data-structures/priority-queue.js +0 -3
- package/dist/types/data-structures/priority-queue.js.map +0 -1
- package/lib/data-structures/binary-tree/aa-tree.d.ts +0 -2
- package/lib/data-structures/binary-tree/aa-tree.js +0 -2
- package/lib/data-structures/binary-tree/abstract-binary-tree.d.ts +0 -21
- package/lib/data-structures/binary-tree/abstract-binary-tree.js +0 -19
- package/lib/data-structures/binary-tree/b-tree.d.ts +0 -2
- package/lib/data-structures/binary-tree/b-tree.js +0 -2
- package/lib/data-structures/binary-tree/splay-tree.d.ts +0 -2
- package/lib/data-structures/binary-tree/splay-tree.js +0 -2
- package/lib/data-structures/binary-tree/two-three-tree.d.ts +0 -2
- package/lib/data-structures/binary-tree/two-three-tree.js +0 -2
- package/lib/data-structures/hash/pair.d.ts +0 -2
- package/lib/data-structures/hash/pair.js +0 -2
- package/lib/interfaces/abstract-binary-tree.d.ts +0 -7
- package/lib/interfaces/abstract-graph.js +0 -1
- package/lib/interfaces/avl-tree.d.ts +0 -7
- package/lib/interfaces/avl-tree.js +0 -1
- package/lib/interfaces/bst.d.ts +0 -6
- package/lib/interfaces/bst.js +0 -1
- package/lib/interfaces/directed-graph.d.ts +0 -3
- package/lib/interfaces/directed-graph.js +0 -1
- package/lib/interfaces/rb-tree.d.ts +0 -6
- package/lib/interfaces/rb-tree.js +0 -1
- package/lib/interfaces/tree-multiset.d.ts +0 -6
- package/lib/interfaces/tree-multiset.js +0 -1
- package/lib/interfaces/undirected-graph.d.ts +0 -3
- package/lib/interfaces/undirected-graph.js +0 -1
- package/lib/types/data-structures/abstract-binary-tree.d.ts +0 -32
- package/lib/types/data-structures/abstract-binary-tree.js +0 -21
- package/lib/types/data-structures/priority-queue.d.ts +0 -7
- package/lib/types/data-structures/priority-queue.js +0 -1
- package/src/data-structures/binary-tree/aa-tree.ts +0 -1
- package/src/data-structures/binary-tree/abstract-binary-tree.ts +0 -33
- package/src/data-structures/binary-tree/b-tree.ts +0 -1
- package/src/data-structures/binary-tree/splay-tree.ts +0 -1
- package/src/data-structures/binary-tree/two-three-tree.ts +0 -1
- package/src/data-structures/hash/pair.ts +0 -1
- package/src/interfaces/abstract-binary-tree.ts +0 -8
- package/src/interfaces/avl-tree.ts +0 -8
- package/src/interfaces/bst.ts +0 -6
- package/src/interfaces/directed-graph.ts +0 -3
- package/src/interfaces/rb-tree.ts +0 -6
- package/src/interfaces/tree-multiset.ts +0 -7
- package/src/interfaces/undirected-graph.ts +0 -3
- package/src/types/data-structures/abstract-binary-tree.ts +0 -49
- package/src/types/data-structures/priority-queue.ts +0 -9
- /package/lib/interfaces/{abstract-binary-tree.js → graph.js} +0 -0
|
@@ -5,10 +5,9 @@
|
|
|
5
5
|
* @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
|
|
6
6
|
* @license MIT License
|
|
7
7
|
*/
|
|
8
|
-
import { AbstractBinaryTree, AbstractBinaryTreeNode } from './abstract-binary-tree';
|
|
9
8
|
import { FamilyPosition, LoopType } from '../../types';
|
|
10
9
|
import { trampoline } from '../../utils';
|
|
11
|
-
export class BinaryTreeNode
|
|
10
|
+
export class BinaryTreeNode {
|
|
12
11
|
/**
|
|
13
12
|
* The constructor function initializes a BinaryTreeNode object with a key and an optional value.
|
|
14
13
|
* @param {BinaryTreeNodeKey} key - The `key` parameter is of type `BinaryTreeNodeKey` and represents the unique identifier
|
|
@@ -17,8 +16,8 @@ export class BinaryTreeNode extends AbstractBinaryTreeNode {
|
|
|
17
16
|
* stored in the binary tree node. If no value is provided, it will be set to undefined.
|
|
18
17
|
*/
|
|
19
18
|
constructor(key, val) {
|
|
20
|
-
super(val);
|
|
21
19
|
this.key = key;
|
|
20
|
+
this.val = val;
|
|
22
21
|
}
|
|
23
22
|
get left() {
|
|
24
23
|
return this._left;
|
|
@@ -75,7 +74,7 @@ export class BinaryTreeNode extends AbstractBinaryTreeNode {
|
|
|
75
74
|
}
|
|
76
75
|
}
|
|
77
76
|
}
|
|
78
|
-
export class BinaryTree
|
|
77
|
+
export class BinaryTree {
|
|
79
78
|
/**
|
|
80
79
|
* This is a constructor function for a binary tree class that takes an optional options parameter.
|
|
81
80
|
* @param {BinaryTreeOptions} [options] - The `options` parameter is an optional object that can be passed to the
|
|
@@ -83,7 +82,6 @@ export class BinaryTree extends AbstractBinaryTree {
|
|
|
83
82
|
* different configuration options.
|
|
84
83
|
*/
|
|
85
84
|
constructor(options) {
|
|
86
|
-
super();
|
|
87
85
|
// TODO placeholder node may need redesigned
|
|
88
86
|
this._root = null;
|
|
89
87
|
this._size = 0;
|
|
@@ -190,7 +188,7 @@ export class BinaryTree extends AbstractBinaryTree {
|
|
|
190
188
|
else if (typeof keyOrNode === 'number') {
|
|
191
189
|
needInsert = this.createNode(keyOrNode, val);
|
|
192
190
|
}
|
|
193
|
-
else if (keyOrNode instanceof
|
|
191
|
+
else if (keyOrNode instanceof BinaryTreeNode) {
|
|
194
192
|
needInsert = keyOrNode;
|
|
195
193
|
}
|
|
196
194
|
else {
|
|
@@ -233,7 +231,7 @@ export class BinaryTree extends AbstractBinaryTree {
|
|
|
233
231
|
const inserted = [];
|
|
234
232
|
for (let i = 0; i < keysOrNodes.length; i++) {
|
|
235
233
|
const keyOrNode = keysOrNodes[i];
|
|
236
|
-
if (keyOrNode instanceof
|
|
234
|
+
if (keyOrNode instanceof BinaryTreeNode) {
|
|
237
235
|
inserted.push(this.add(keyOrNode.key, keyOrNode.val));
|
|
238
236
|
continue;
|
|
239
237
|
}
|
|
@@ -755,7 +753,7 @@ export class BinaryTree extends AbstractBinaryTree {
|
|
|
755
753
|
* @param {NodeOrPropertyName} [nodeOrPropertyName] - An optional parameter that represents either a node or a property name.
|
|
756
754
|
* If a node is provided, the bfs algorithm will be performed starting from that node.
|
|
757
755
|
* If a property name is provided, the bfs algorithm will be performed starting from the root node, accumulating the specified property.
|
|
758
|
-
* @returns An instance of the `
|
|
756
|
+
* @returns An instance of the `BinaryTreeNodeProperties` class with generic type `N`.
|
|
759
757
|
*/
|
|
760
758
|
bfs(nodeOrPropertyName = 'key') {
|
|
761
759
|
this._clearResults();
|
|
@@ -777,7 +775,7 @@ export class BinaryTree extends AbstractBinaryTree {
|
|
|
777
775
|
* each node based on the specified pattern and property name.
|
|
778
776
|
* @param {'in' | 'pre' | 'post'} [pattern] - The traversal pattern: 'in' (in-order), 'pre' (pre-order), or 'post' (post-order).
|
|
779
777
|
* @param {NodeOrPropertyName} [nodeOrPropertyName] - The name of a property of the nodes in the binary tree. This property will be used to accumulate values during the depth-first search traversal. If no `nodeOrPropertyName` is provided, the default value is `'key'`.
|
|
780
|
-
* @returns an instance of the
|
|
778
|
+
* @returns an instance of the BinaryTreeNodeProperties class, which contains the accumulated properties of the binary tree nodes based on the specified pattern and node or property name.
|
|
781
779
|
*/
|
|
782
780
|
dfs(pattern = 'in', nodeOrPropertyName = 'key') {
|
|
783
781
|
this._clearResults();
|
|
@@ -814,7 +812,7 @@ export class BinaryTree extends AbstractBinaryTree {
|
|
|
814
812
|
* specify the traversal pattern and the property name to accumulate results by.
|
|
815
813
|
* @param {'in' | 'pre' | 'post'} [pattern] - The traversal pattern: 'in' (in-order), 'pre' (pre-order), or 'post' (post-order).
|
|
816
814
|
* @param {NodeOrPropertyName} [nodeOrPropertyName] - The name of a property of the nodes in the binary tree. This property will be used to accumulate values during the depth-first search traversal. By default, it is set to `'key'`.
|
|
817
|
-
* @returns An object of type
|
|
815
|
+
* @returns An object of type BinaryTreeNodeProperties<N>.
|
|
818
816
|
*/
|
|
819
817
|
dfsIterative(pattern = 'in', nodeOrPropertyName = 'key') {
|
|
820
818
|
this._clearResults();
|
|
@@ -866,7 +864,7 @@ export class BinaryTree extends AbstractBinaryTree {
|
|
|
866
864
|
* can be either a `BinaryTreeNode` property name or the string `'key'`. If a property name is provided, the function
|
|
867
865
|
* will accumulate results based on that property. If no property name is provided, the function will default to
|
|
868
866
|
* accumulating results based on the 'key' property.
|
|
869
|
-
* @returns An object of type `
|
|
867
|
+
* @returns An object of type `BinaryTreeNodeProperties<N>`.
|
|
870
868
|
*/
|
|
871
869
|
levelIterative(node = this.root, nodeOrPropertyName = 'key') {
|
|
872
870
|
if (!node)
|
|
@@ -964,7 +962,7 @@ export class BinaryTree extends AbstractBinaryTree {
|
|
|
964
962
|
* The `morris` function performs an in-order, pre-order, or post-order traversal on a binary tree using the Morris traversal algorithm.
|
|
965
963
|
* @param {'in' | 'pre' | 'post'} [pattern] - The traversal pattern: 'in' (in-order), 'pre' (pre-order), or 'post' (post-order).
|
|
966
964
|
* @param {NodeOrPropertyName} [nodeOrPropertyName] - The property name of the nodes to retrieve or perform operations on during the traversal. It can be any valid property name of the nodes in the binary tree. If not provided, it defaults to 'key'.
|
|
967
|
-
* @returns An array of
|
|
965
|
+
* @returns An array of BinaryTreeNodeProperties<N> objects.
|
|
968
966
|
*/
|
|
969
967
|
morris(pattern = 'in', nodeOrPropertyName = 'key') {
|
|
970
968
|
if (this.root === null)
|
|
@@ -1189,7 +1187,7 @@ export class BinaryTree extends AbstractBinaryTree {
|
|
|
1189
1187
|
* name.
|
|
1190
1188
|
* @param {NodeOrPropertyName} [nodeOrPropertyName] - The parameter `nodeOrPropertyName` is an optional parameter that
|
|
1191
1189
|
* can accept either a `NodeOrPropertyName` type or be undefined.
|
|
1192
|
-
* @returns The method `_getResultByPropertyName` returns an instance of `
|
|
1190
|
+
* @returns The method `_getResultByPropertyName` returns an instance of `BinaryTreeNodeProperties<N>`.
|
|
1193
1191
|
*/
|
|
1194
1192
|
_getResultByPropertyName(nodeOrPropertyName = 'key') {
|
|
1195
1193
|
switch (nodeOrPropertyName) {
|
|
@@ -8,11 +8,11 @@
|
|
|
8
8
|
import type { BinaryTreeNodeKey, BinaryTreeNodePropertyName, BSTComparator, BSTNodeNested, BSTOptions } from '../../types';
|
|
9
9
|
import { CP } from '../../types';
|
|
10
10
|
import { BinaryTree, BinaryTreeNode } from './binary-tree';
|
|
11
|
-
import {
|
|
12
|
-
export declare class BSTNode<V = any, FAMILY extends BSTNode<V, FAMILY> = BSTNodeNested<V>> extends BinaryTreeNode<V, FAMILY>
|
|
11
|
+
import { IBinaryTree } from '../../interfaces';
|
|
12
|
+
export declare class BSTNode<V = any, FAMILY extends BSTNode<V, FAMILY> = BSTNodeNested<V>> extends BinaryTreeNode<V, FAMILY> {
|
|
13
13
|
constructor(key: BinaryTreeNodeKey, val?: V);
|
|
14
14
|
}
|
|
15
|
-
export declare class BST<N extends BSTNode<N['val'], N> = BSTNode> extends BinaryTree<N> implements
|
|
15
|
+
export declare class BST<N extends BSTNode<N['val'], N> = BSTNode> extends BinaryTree<N> implements IBinaryTree<N> {
|
|
16
16
|
/**
|
|
17
17
|
* The constructor function initializes a binary search tree object with an optional comparator function.
|
|
18
18
|
* @param {BSTOptions} [options] - An optional object that contains configuration options for the binary search tree.
|
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
export * from './abstract-binary-tree';
|
|
2
1
|
export * from './binary-tree';
|
|
3
2
|
export * from './bst';
|
|
4
3
|
export * from './binary-indexed-tree';
|
|
5
4
|
export * from './segment-tree';
|
|
6
5
|
export * from './avl-tree';
|
|
7
|
-
export * from './b-tree';
|
|
8
6
|
export * from './rb-tree';
|
|
9
|
-
export * from './splay-tree';
|
|
10
|
-
export * from './aa-tree';
|
|
11
7
|
export * from './tree-multiset';
|
|
12
|
-
export * from './two-three-tree';
|
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
export * from './abstract-binary-tree';
|
|
2
1
|
export * from './binary-tree';
|
|
3
2
|
export * from './bst';
|
|
4
3
|
export * from './binary-indexed-tree';
|
|
5
4
|
export * from './segment-tree';
|
|
6
5
|
export * from './avl-tree';
|
|
7
|
-
export * from './b-tree';
|
|
8
6
|
export * from './rb-tree';
|
|
9
|
-
export * from './splay-tree';
|
|
10
|
-
export * from './aa-tree';
|
|
11
7
|
export * from './tree-multiset';
|
|
12
|
-
export * from './two-three-tree';
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { BinaryTreeNodeKey, RBColor, RBTreeNodeNested, RBTreeOptions } from '../../types';
|
|
2
|
-
import {
|
|
2
|
+
import { IBinaryTree } from '../../interfaces';
|
|
3
3
|
import { BST, BSTNode } from './bst';
|
|
4
|
-
export declare class RBTreeNode<V = any, FAMILY extends RBTreeNode<V, FAMILY> = RBTreeNodeNested<V>> extends BSTNode<V, FAMILY>
|
|
4
|
+
export declare class RBTreeNode<V = any, FAMILY extends RBTreeNode<V, FAMILY> = RBTreeNodeNested<V>> extends BSTNode<V, FAMILY> {
|
|
5
5
|
private _color;
|
|
6
6
|
constructor(key: BinaryTreeNodeKey, val?: V);
|
|
7
7
|
get color(): RBColor;
|
|
8
8
|
set color(value: RBColor);
|
|
9
9
|
}
|
|
10
|
-
export declare class RBTree<N extends RBTreeNode<N['val'], N> = RBTreeNode> extends BST<N> implements
|
|
10
|
+
export declare class RBTree<N extends RBTreeNode<N['val'], N> = RBTreeNode> extends BST<N> implements IBinaryTree<N> {
|
|
11
11
|
constructor(options?: RBTreeOptions);
|
|
12
12
|
createNode(key: BinaryTreeNodeKey, val?: N['val']): N;
|
|
13
13
|
}
|
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import type { BinaryTreeNodeKey, TreeMultisetNodeNested, TreeMultisetOptions } from '../../types';
|
|
9
9
|
import { BinaryTreeDeletedResult, DFSOrderPattern } from '../../types';
|
|
10
|
-
import {
|
|
10
|
+
import { IBinaryTree } from '../../interfaces';
|
|
11
11
|
import { AVLTree, AVLTreeNode } from './avl-tree';
|
|
12
|
-
export declare class TreeMultisetNode<V = any, FAMILY extends TreeMultisetNode<V, FAMILY> = TreeMultisetNodeNested<V>> extends AVLTreeNode<V, FAMILY>
|
|
12
|
+
export declare class TreeMultisetNode<V = any, FAMILY extends TreeMultisetNode<V, FAMILY> = TreeMultisetNodeNested<V>> extends AVLTreeNode<V, FAMILY> {
|
|
13
13
|
/**
|
|
14
14
|
* The constructor function initializes a BinaryTreeNode object with a key, value, and count.
|
|
15
15
|
* @param {BinaryTreeNodeKey} key - The `key` parameter is of type `BinaryTreeNodeKey` and represents the unique identifier
|
|
@@ -26,7 +26,7 @@ export declare class TreeMultisetNode<V = any, FAMILY extends TreeMultisetNode<V
|
|
|
26
26
|
/**
|
|
27
27
|
* The only distinction between a TreeMultiset and a AVLTree lies in the ability of the former to store duplicate nodes through the utilization of counters.
|
|
28
28
|
*/
|
|
29
|
-
export declare class TreeMultiset<N extends TreeMultisetNode<N['val'], N> = TreeMultisetNode> extends AVLTree<N> implements
|
|
29
|
+
export declare class TreeMultiset<N extends TreeMultisetNode<N['val'], N> = TreeMultisetNode> extends AVLTree<N> implements IBinaryTree<N> {
|
|
30
30
|
/**
|
|
31
31
|
* The constructor function for a TreeMultiset class in TypeScript, which extends another class and sets an option to
|
|
32
32
|
* merge duplicated values.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { DijkstraResult, VertexKey } from '../../types';
|
|
2
|
-
import {
|
|
2
|
+
import { IGraph } from '../../interfaces';
|
|
3
3
|
export declare abstract class AbstractVertex<V = any> {
|
|
4
4
|
/**
|
|
5
5
|
* The function is a protected constructor that takes an key and an optional value as parameters.
|
|
@@ -46,7 +46,7 @@ export declare abstract class AbstractEdge<V = any> {
|
|
|
46
46
|
*/
|
|
47
47
|
protected _setHashCode(v: string): void;
|
|
48
48
|
}
|
|
49
|
-
export declare abstract class AbstractGraph<V extends AbstractVertex<any> = AbstractVertex<any>, E extends AbstractEdge<any> = AbstractEdge<any>> implements
|
|
49
|
+
export declare abstract class AbstractGraph<V extends AbstractVertex<any> = AbstractVertex<any>, E extends AbstractEdge<any> = AbstractEdge<any>> implements IGraph<V, E> {
|
|
50
50
|
private _vertices;
|
|
51
51
|
get vertices(): Map<VertexKey, V>;
|
|
52
52
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AbstractEdge, AbstractGraph, AbstractVertex } from './abstract-graph';
|
|
2
2
|
import type { VertexKey } from '../../types';
|
|
3
|
-
import {
|
|
3
|
+
import { IGraph } from '../../interfaces';
|
|
4
4
|
export declare class DirectedVertex<V = any> extends AbstractVertex<V> {
|
|
5
5
|
/**
|
|
6
6
|
* The constructor function initializes a vertex with an optional value.
|
|
@@ -31,7 +31,7 @@ export declare class DirectedEdge<V = any> extends AbstractEdge<V> {
|
|
|
31
31
|
get dest(): VertexKey;
|
|
32
32
|
set dest(v: VertexKey);
|
|
33
33
|
}
|
|
34
|
-
export declare class DirectedGraph<V extends DirectedVertex<any> = DirectedVertex, E extends DirectedEdge<any> = DirectedEdge> extends AbstractGraph<V, E> implements
|
|
34
|
+
export declare class DirectedGraph<V extends DirectedVertex<any> = DirectedVertex, E extends DirectedEdge<any> = DirectedEdge> extends AbstractGraph<V, E> implements IGraph<V, E> {
|
|
35
35
|
/**
|
|
36
36
|
* The constructor function initializes an instance of a class.
|
|
37
37
|
*/
|
|
@@ -73,7 +73,7 @@ export declare class MapGraph<V extends MapVertex<V['val']> = MapVertex, E exten
|
|
|
73
73
|
* If the weight is not provided, it can be set to a default value or left undefined.
|
|
74
74
|
* @param [val] - The `val` parameter is an optional value that can be assigned to the edge. It can be of any type,
|
|
75
75
|
* depending on the specific implementation of the `MapEdge` class.
|
|
76
|
-
* @returns a new instance of the `MapEdge` class,
|
|
76
|
+
* @returns a new instance of the `MapEdge` class, cast as type `E`.
|
|
77
77
|
*/
|
|
78
78
|
createEdge(src: VertexKey, dest: VertexKey, weight?: number, val?: E['val']): E;
|
|
79
79
|
}
|
|
@@ -97,7 +97,7 @@ export class MapGraph extends DirectedGraph {
|
|
|
97
97
|
* If the weight is not provided, it can be set to a default value or left undefined.
|
|
98
98
|
* @param [val] - The `val` parameter is an optional value that can be assigned to the edge. It can be of any type,
|
|
99
99
|
* depending on the specific implementation of the `MapEdge` class.
|
|
100
|
-
* @returns a new instance of the `MapEdge` class,
|
|
100
|
+
* @returns a new instance of the `MapEdge` class, cast as type `E`.
|
|
101
101
|
*/
|
|
102
102
|
createEdge(src, dest, weight, val) {
|
|
103
103
|
return new MapEdge(src, dest, weight, val);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AbstractEdge, AbstractGraph, AbstractVertex } from './abstract-graph';
|
|
2
2
|
import type { VertexKey } from '../../types';
|
|
3
|
-
import {
|
|
3
|
+
import { IGraph } from '../../interfaces';
|
|
4
4
|
export declare class UndirectedVertex<V = any> extends AbstractVertex<V> {
|
|
5
5
|
/**
|
|
6
6
|
* The constructor function initializes a vertex with an optional value.
|
|
@@ -27,7 +27,7 @@ export declare class UndirectedEdge<V = number> extends AbstractEdge<V> {
|
|
|
27
27
|
get vertices(): [VertexKey, VertexKey];
|
|
28
28
|
set vertices(v: [VertexKey, VertexKey]);
|
|
29
29
|
}
|
|
30
|
-
export declare class UndirectedGraph<V extends UndirectedVertex<any> = UndirectedVertex, E extends UndirectedEdge<any> = UndirectedEdge> extends AbstractGraph<V, E> implements
|
|
30
|
+
export declare class UndirectedGraph<V extends UndirectedVertex<any> = UndirectedVertex, E extends UndirectedEdge<any> = UndirectedEdge> extends AbstractGraph<V, E> implements IGraph<V, E> {
|
|
31
31
|
/**
|
|
32
32
|
* The constructor initializes a new Map object to store edges.
|
|
33
33
|
*/
|
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
* @copyright Copyright (c) 2022 Kirk Qi <qilinaus@gmail.com>
|
|
5
5
|
* @license MIT License
|
|
6
6
|
*/
|
|
7
|
-
import type {
|
|
7
|
+
import type { HeapComparator, HeapDFSOrderPattern } from '../../types';
|
|
8
8
|
export declare class Heap<E> {
|
|
9
9
|
protected nodes: E[];
|
|
10
10
|
private readonly comparator;
|
|
11
|
-
constructor(comparator:
|
|
11
|
+
constructor(comparator: HeapComparator<E>);
|
|
12
12
|
/**
|
|
13
13
|
* Insert an element into the heap and maintain the heap properties.
|
|
14
14
|
* @param value - The element to be inserted.
|
|
@@ -72,7 +72,7 @@ export declare class Heap<E> {
|
|
|
72
72
|
* @param order - Traversal order parameter: 'in' (in-order), 'pre' (pre-order) or 'post' (post-order).
|
|
73
73
|
* @returns An array containing elements traversed in the specified order.
|
|
74
74
|
*/
|
|
75
|
-
dfs(order:
|
|
75
|
+
dfs(order: HeapDFSOrderPattern): E[];
|
|
76
76
|
/**
|
|
77
77
|
* Convert the heap to an array.
|
|
78
78
|
* @returns An array containing the elements of the heap.
|
|
@@ -95,5 +95,5 @@ export declare class Heap<E> {
|
|
|
95
95
|
* @param comparator - Comparison function.
|
|
96
96
|
* @returns A new Heap instance.
|
|
97
97
|
*/
|
|
98
|
-
static heapify<E>(nodes: E[], comparator:
|
|
98
|
+
static heapify<E>(nodes: E[], comparator: HeapComparator<E>): Heap<E>;
|
|
99
99
|
}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* @license MIT License
|
|
7
7
|
*/
|
|
8
8
|
import { Heap } from './heap';
|
|
9
|
-
import type {
|
|
9
|
+
import type { HeapComparator } from '../../types';
|
|
10
10
|
export declare class MaxHeap<E = any> extends Heap<E> {
|
|
11
|
-
constructor(comparator?:
|
|
11
|
+
constructor(comparator?: HeapComparator<E>);
|
|
12
12
|
}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* @license MIT License
|
|
7
7
|
*/
|
|
8
8
|
import { Heap } from './heap';
|
|
9
|
-
import type {
|
|
9
|
+
import type { HeapComparator } from '../../types';
|
|
10
10
|
export declare class MinHeap<E = any> extends Heap<E> {
|
|
11
|
-
constructor(comparator?:
|
|
11
|
+
constructor(comparator?: HeapComparator<E>);
|
|
12
12
|
}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* @license MIT License
|
|
7
7
|
*/
|
|
8
8
|
import { PriorityQueue } from './priority-queue';
|
|
9
|
-
import type {
|
|
9
|
+
import type { HeapComparator } from '../../types';
|
|
10
10
|
export declare class MaxPriorityQueue<E = any> extends PriorityQueue<E> {
|
|
11
|
-
constructor(compare?:
|
|
11
|
+
constructor(compare?: HeapComparator<E>);
|
|
12
12
|
}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* @license MIT License
|
|
7
7
|
*/
|
|
8
8
|
import { PriorityQueue } from './priority-queue';
|
|
9
|
-
import type {
|
|
9
|
+
import type { HeapComparator } from '../../types';
|
|
10
10
|
export declare class MinPriorityQueue<E = any> extends PriorityQueue<E> {
|
|
11
|
-
constructor(compare?:
|
|
11
|
+
constructor(compare?: HeapComparator<E>);
|
|
12
12
|
}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* @license MIT License
|
|
7
7
|
*/
|
|
8
8
|
import { Heap } from '../heap';
|
|
9
|
-
import {
|
|
9
|
+
import { HeapComparator } from '../../types';
|
|
10
10
|
export declare class PriorityQueue<E> extends Heap<E> {
|
|
11
|
-
constructor(comparator:
|
|
11
|
+
constructor(comparator: HeapComparator<E>);
|
|
12
12
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { BinaryTreeNode } from '../data-structures';
|
|
2
|
-
import {
|
|
3
|
-
export interface
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
import { BinaryTreeDeletedResult, BinaryTreeNodeKey } from '../types';
|
|
3
|
+
export interface IBinaryTree<N extends BinaryTreeNode<N['val'], N>> {
|
|
4
|
+
createNode(key: BinaryTreeNodeKey, val?: N['val']): N;
|
|
5
|
+
add(keyOrNode: BinaryTreeNodeKey | N | null, val?: N['val']): N | null | undefined;
|
|
6
|
+
remove(nodeOrKey: N | BinaryTreeNodeKey): BinaryTreeDeletedResult<N>[];
|
|
6
7
|
}
|
|
@@ -1,15 +1,8 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './abstract-graph';
|
|
3
|
-
export * from './avl-tree';
|
|
1
|
+
export * from './graph';
|
|
4
2
|
export * from './binary-tree';
|
|
5
|
-
export * from './bst';
|
|
6
|
-
export * from './directed-graph';
|
|
7
3
|
export * from './doubly-linked-list';
|
|
8
4
|
export * from './heap';
|
|
9
5
|
export * from './navigator';
|
|
10
6
|
export * from './priority-queue';
|
|
11
|
-
export * from './rb-tree';
|
|
12
7
|
export * from './segment-tree';
|
|
13
8
|
export * from './singly-linked-list';
|
|
14
|
-
export * from './tree-multiset';
|
|
15
|
-
export * from './undirected-graph';
|
package/lib/interfaces/index.js
CHANGED
|
@@ -1,15 +1,8 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './abstract-graph';
|
|
3
|
-
export * from './avl-tree';
|
|
1
|
+
export * from './graph';
|
|
4
2
|
export * from './binary-tree';
|
|
5
|
-
export * from './bst';
|
|
6
|
-
export * from './directed-graph';
|
|
7
3
|
export * from './doubly-linked-list';
|
|
8
4
|
export * from './heap';
|
|
9
5
|
export * from './navigator';
|
|
10
6
|
export * from './priority-queue';
|
|
11
|
-
export * from './rb-tree';
|
|
12
7
|
export * from './segment-tree';
|
|
13
8
|
export * from './singly-linked-list';
|
|
14
|
-
export * from './tree-multiset';
|
|
15
|
-
export * from './undirected-graph';
|
|
@@ -1,6 +1,34 @@
|
|
|
1
1
|
import { BinaryTreeNode } from '../../data-structures/binary-tree';
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Enum representing different loop types.
|
|
4
|
+
*
|
|
5
|
+
* - `iterative`: Indicates the iterative loop type (with loops that use iterations).
|
|
6
|
+
* - `recursive`: Indicates the recursive loop type (with loops that call themselves).
|
|
7
|
+
*/
|
|
8
|
+
export declare enum LoopType {
|
|
9
|
+
ITERATIVE = "ITERATIVE",
|
|
10
|
+
RECURSIVE = "RECURSIVE"
|
|
11
|
+
}
|
|
12
|
+
export declare enum FamilyPosition {
|
|
13
|
+
ROOT = "ROOT",
|
|
14
|
+
LEFT = "LEFT",
|
|
15
|
+
RIGHT = "RIGHT",
|
|
16
|
+
ROOT_LEFT = "ROOT_LEFT",
|
|
17
|
+
ROOT_RIGHT = "ROOT_RIGHT",
|
|
18
|
+
ISOLATED = "ISOLATED",
|
|
19
|
+
MAL_NODE = "MAL_NODE"
|
|
20
|
+
}
|
|
21
|
+
export type BinaryTreeNodePropertyName = 'key' | 'val';
|
|
22
|
+
export type NodeOrPropertyName = 'node' | BinaryTreeNodePropertyName;
|
|
23
|
+
export type DFSOrderPattern = 'in' | 'pre' | 'post';
|
|
24
|
+
export type BinaryTreeNodeKey = number;
|
|
25
|
+
export type BinaryTreeNodeProperty<N extends BinaryTreeNode<N['val'], N>> = N['val'] | N | number | BinaryTreeNodeKey;
|
|
26
|
+
export type BinaryTreeDeletedResult<N> = {
|
|
27
|
+
deleted: N | null | undefined;
|
|
28
|
+
needBalanced: N | null;
|
|
29
|
+
};
|
|
30
|
+
export type BinaryTreeNodeProperties<N extends BinaryTreeNode<N['val'], N>> = BinaryTreeNodeProperty<N>[];
|
|
3
31
|
export type BinaryTreeNodeNested<T> = BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
|
|
4
|
-
export type BinaryTreeOptions =
|
|
32
|
+
export type BinaryTreeOptions = {
|
|
5
33
|
loopType?: LoopType;
|
|
6
34
|
};
|
|
@@ -1 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Enum representing different loop types.
|
|
3
|
+
*
|
|
4
|
+
* - `iterative`: Indicates the iterative loop type (with loops that use iterations).
|
|
5
|
+
* - `recursive`: Indicates the recursive loop type (with loops that call themselves).
|
|
6
|
+
*/
|
|
7
|
+
export var LoopType;
|
|
8
|
+
(function (LoopType) {
|
|
9
|
+
LoopType["ITERATIVE"] = "ITERATIVE";
|
|
10
|
+
LoopType["RECURSIVE"] = "RECURSIVE";
|
|
11
|
+
})(LoopType || (LoopType = {}));
|
|
12
|
+
export var FamilyPosition;
|
|
13
|
+
(function (FamilyPosition) {
|
|
14
|
+
FamilyPosition["ROOT"] = "ROOT";
|
|
15
|
+
FamilyPosition["LEFT"] = "LEFT";
|
|
16
|
+
FamilyPosition["RIGHT"] = "RIGHT";
|
|
17
|
+
FamilyPosition["ROOT_LEFT"] = "ROOT_LEFT";
|
|
18
|
+
FamilyPosition["ROOT_RIGHT"] = "ROOT_RIGHT";
|
|
19
|
+
FamilyPosition["ISOLATED"] = "ISOLATED";
|
|
20
|
+
FamilyPosition["MAL_NODE"] = "MAL_NODE";
|
|
21
|
+
})(FamilyPosition || (FamilyPosition = {}));
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { BSTNode } from '../../data-structures/binary-tree';
|
|
2
|
-
import type { BinaryTreeOptions } from './binary-tree';
|
|
3
|
-
import { BinaryTreeNodeKey } from './abstract-binary-tree';
|
|
2
|
+
import type { BinaryTreeNodeKey, BinaryTreeOptions } from './binary-tree';
|
|
4
3
|
export type BSTComparator = (a: BinaryTreeNodeKey, b: BinaryTreeNodeKey) => number;
|
|
5
4
|
export type BSTNodeNested<T> = BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
|
|
6
5
|
export type BSTOptions = BinaryTreeOptions & {
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export type
|
|
1
|
+
export type HeapComparator<T> = (a: T, b: T) => number;
|
|
2
|
+
export type HeapDFSOrderPattern = 'pre' | 'in' | 'post';
|
|
@@ -5,10 +5,8 @@ export * from './segment-tree';
|
|
|
5
5
|
export * from './tree-multiset';
|
|
6
6
|
export * from './abstract-graph';
|
|
7
7
|
export * from './map-graph';
|
|
8
|
-
export * from './abstract-binary-tree';
|
|
9
8
|
export * from './rb-tree';
|
|
10
9
|
export * from './directed-graph';
|
|
11
|
-
export * from './priority-queue';
|
|
12
10
|
export * from './heap';
|
|
13
11
|
export * from './singly-linked-list';
|
|
14
12
|
export * from './doubly-linked-list';
|
|
@@ -5,10 +5,8 @@ export * from './segment-tree';
|
|
|
5
5
|
export * from './tree-multiset';
|
|
6
6
|
export * from './abstract-graph';
|
|
7
7
|
export * from './map-graph';
|
|
8
|
-
export * from './abstract-binary-tree';
|
|
9
8
|
export * from './rb-tree';
|
|
10
9
|
export * from './directed-graph';
|
|
11
|
-
export * from './priority-queue';
|
|
12
10
|
export * from './heap';
|
|
13
11
|
export * from './singly-linked-list';
|
|
14
12
|
export * from './doubly-linked-list';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "data-structure-typed",
|
|
3
|
-
"version": "1.36.
|
|
3
|
+
"version": "1.36.3",
|
|
4
4
|
"description": "Data Structures of Javascript & TypeScript. Binary Tree, BST, Graph, Heap, Priority Queue, Linked List, Queue, Deque, Stack, AVL Tree, Tree Multiset, Trie, Directed Graph, Undirected Graph, Singly Linked List, Doubly Linked List, Max Heap, Max Priority Queue, Min Heap, Min Priority Queue.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "lib/index.js",
|
|
@@ -54,17 +54,17 @@
|
|
|
54
54
|
"@typescript-eslint/eslint-plugin": "^6.7.4",
|
|
55
55
|
"@typescript-eslint/parser": "^6.7.4",
|
|
56
56
|
"auto-changelog": "^2.4.0",
|
|
57
|
-
"avl-tree-typed": "^1.36.
|
|
57
|
+
"avl-tree-typed": "^1.36.2",
|
|
58
58
|
"benchmark": "^2.1.4",
|
|
59
|
-
"binary-tree-typed": "^1.36.
|
|
60
|
-
"bst-typed": "^1.36.
|
|
59
|
+
"binary-tree-typed": "^1.36.2",
|
|
60
|
+
"bst-typed": "^1.36.2",
|
|
61
61
|
"dependency-cruiser": "^14.1.0",
|
|
62
62
|
"eslint": "^8.50.0",
|
|
63
63
|
"eslint-config-prettier": "^9.0.0",
|
|
64
64
|
"eslint-import-resolver-alias": "^1.1.2",
|
|
65
65
|
"eslint-import-resolver-typescript": "^3.6.1",
|
|
66
66
|
"eslint-plugin-import": "^2.28.1",
|
|
67
|
-
"heap-typed": "^1.
|
|
67
|
+
"heap-typed": "^1.36.2",
|
|
68
68
|
"istanbul-badges-readme": "^1.8.5",
|
|
69
69
|
"jest": "^29.7.0",
|
|
70
70
|
"prettier": "^3.0.3",
|
|
@@ -7,12 +7,12 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import {BST, BSTNode} from './bst';
|
|
9
9
|
import type {AVLTreeNodeNested, AVLTreeOptions, BinaryTreeDeletedResult, BinaryTreeNodeKey} from '../../types';
|
|
10
|
-
import {
|
|
10
|
+
import {IBinaryTree} from '../../interfaces';
|
|
11
11
|
|
|
12
|
-
export class AVLTreeNode<V = any, FAMILY extends AVLTreeNode<V, FAMILY> = AVLTreeNodeNested<V>>
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
{
|
|
12
|
+
export class AVLTreeNode<V = any, FAMILY extends AVLTreeNode<V, FAMILY> = AVLTreeNodeNested<V>> extends BSTNode<
|
|
13
|
+
V,
|
|
14
|
+
FAMILY
|
|
15
|
+
> {
|
|
16
16
|
height: number;
|
|
17
17
|
|
|
18
18
|
constructor(key: BinaryTreeNodeKey, val?: V) {
|
|
@@ -21,7 +21,7 @@ export class AVLTreeNode<V = any, FAMILY extends AVLTreeNode<V, FAMILY> = AVLTre
|
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
export class AVLTree<N extends AVLTreeNode<N['val'], N> = AVLTreeNode> extends BST<N> implements
|
|
24
|
+
export class AVLTree<N extends AVLTreeNode<N['val'], N> = AVLTreeNode> extends BST<N> implements IBinaryTree<N> {
|
|
25
25
|
/**
|
|
26
26
|
* This is a constructor function for an AVL tree data structure in TypeScript.
|
|
27
27
|
* @param {AVLTreeOptions} [options] - The `options` parameter is an optional object that can be passed to the
|