data-structure-typed 1.18.6 → 1.18.7
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/dist/data-structures/binary-tree/abstract-binary-tree.d.ts +48 -24
- package/dist/data-structures/binary-tree/abstract-binary-tree.js +51 -26
- package/dist/data-structures/binary-tree/avl-tree.d.ts +5 -4
- package/dist/data-structures/binary-tree/avl-tree.js +5 -3
- package/dist/data-structures/binary-tree/binary-tree.d.ts +13 -3
- package/dist/data-structures/binary-tree/binary-tree.js +14 -5
- package/dist/data-structures/binary-tree/bst.d.ts +26 -5
- package/dist/data-structures/binary-tree/bst.js +26 -4
- package/dist/data-structures/binary-tree/rb-tree.d.ts +30 -1
- package/dist/data-structures/binary-tree/rb-tree.js +27 -14
- package/dist/data-structures/binary-tree/tree-multiset.d.ts +15 -4
- package/dist/data-structures/binary-tree/tree-multiset.js +15 -3
- package/dist/data-structures/graph/abstract-graph.d.ts +20 -21
- package/dist/data-structures/graph/abstract-graph.js +24 -19
- package/dist/data-structures/graph/directed-graph.d.ts +10 -9
- package/dist/data-structures/graph/directed-graph.js +18 -18
- package/dist/data-structures/graph/undirected-graph.d.ts +5 -11
- package/dist/data-structures/graph/undirected-graph.js +4 -17
- package/dist/data-structures/interfaces/abstract-binary-tree.d.ts +101 -0
- package/dist/data-structures/interfaces/abstract-binary-tree.js +2 -0
- package/dist/data-structures/interfaces/abstract-graph.d.ts +1 -4
- package/dist/data-structures/interfaces/avl-tree.d.ts +16 -1
- package/dist/data-structures/interfaces/binary-tree.d.ts +4 -24
- package/dist/data-structures/interfaces/bst.d.ts +18 -1
- package/dist/data-structures/interfaces/directed-graph.d.ts +4 -1
- package/dist/data-structures/interfaces/index.d.ts +1 -1
- package/dist/data-structures/interfaces/index.js +1 -1
- package/dist/data-structures/interfaces/rb-tree.d.ts +9 -0
- package/dist/data-structures/interfaces/rb-tree.js +2 -0
- package/dist/data-structures/interfaces/undirected-graph.d.ts +4 -1
- package/dist/data-structures/types/abstract-binary-tree.d.ts +2 -2
- package/dist/utils/utils.js +62 -0
- package/docs/assets/search.js +1 -1
- package/docs/classes/AVLTree.html +292 -180
- package/docs/classes/AVLTreeNode.html +126 -77
- package/docs/classes/AaTree.html +12 -6
- package/docs/classes/AbstractBinaryTree.html +258 -163
- package/docs/classes/AbstractBinaryTreeNode.html +117 -84
- package/docs/classes/AbstractEdge.html +22 -16
- package/docs/classes/AbstractGraph.html +137 -140
- package/docs/classes/AbstractVertex.html +19 -13
- package/docs/classes/ArrayDeque.html +25 -19
- package/docs/classes/BST.html +275 -174
- package/docs/classes/BSTNode.html +127 -77
- package/docs/classes/BTree.html +12 -6
- package/docs/classes/BinaryIndexedTree.html +20 -14
- package/docs/classes/BinaryTree.html +265 -169
- package/docs/classes/BinaryTreeNode.html +110 -61
- package/docs/classes/Character.html +15 -9
- package/docs/classes/CoordinateMap.html +20 -14
- package/docs/classes/CoordinateSet.html +19 -13
- package/docs/classes/Deque.html +45 -39
- package/docs/classes/DirectedEdge.html +26 -20
- package/docs/classes/DirectedGraph.html +189 -154
- package/docs/classes/DirectedVertex.html +17 -11
- package/docs/classes/DoublyLinkedList.html +48 -42
- package/docs/classes/DoublyLinkedListNode.html +22 -16
- package/docs/classes/HashTable.html +12 -6
- package/docs/classes/Heap.html +26 -20
- package/docs/classes/HeapItem.html +19 -13
- package/docs/classes/Matrix2D.html +27 -21
- package/docs/classes/MatrixNTI2D.html +15 -9
- package/docs/classes/MaxHeap.html +26 -20
- package/docs/classes/MaxPriorityQueue.html +45 -39
- package/docs/classes/MinHeap.html +26 -20
- package/docs/classes/MinPriorityQueue.html +45 -39
- package/docs/classes/Navigator.html +21 -15
- package/docs/classes/ObjectDeque.html +36 -30
- package/docs/classes/Pair.html +12 -6
- package/docs/classes/PriorityQueue.html +43 -37
- package/docs/classes/Queue.html +25 -19
- package/docs/classes/RBTree.html +2388 -0
- package/docs/classes/RBTreeNode.html +516 -0
- package/docs/classes/SegmentTree.html +28 -22
- package/docs/classes/SegmentTreeNode.html +31 -25
- package/docs/classes/SinglyLinkedList.html +45 -39
- package/docs/classes/SinglyLinkedListNode.html +19 -13
- package/docs/classes/SkipLinkedList.html +12 -6
- package/docs/classes/SplayTree.html +12 -6
- package/docs/classes/Stack.html +23 -17
- package/docs/classes/TreeMap.html +12 -6
- package/docs/classes/TreeMultiSet.html +273 -172
- package/docs/classes/TreeMultiSetNode.html +126 -77
- package/docs/classes/TreeNode.html +27 -21
- package/docs/classes/TreeSet.html +12 -6
- package/docs/classes/Trie.html +24 -18
- package/docs/classes/TrieNode.html +22 -16
- package/docs/classes/TwoThreeTree.html +12 -6
- package/docs/classes/UndirectedEdge.html +23 -17
- package/docs/classes/UndirectedGraph.html +160 -146
- package/docs/classes/UndirectedVertex.html +17 -11
- package/docs/classes/Vector2D.html +39 -33
- package/docs/enums/CP.html +15 -9
- package/docs/enums/FamilyPosition.html +15 -9
- package/docs/enums/LoopType.html +14 -8
- package/docs/enums/RBColor.html +14 -8
- package/docs/enums/TopologicalProperty.html +15 -9
- package/docs/index.html +11 -5
- package/docs/interfaces/IAVLTree.html +1378 -0
- package/docs/interfaces/IAVLTreeNode.html +405 -0
- package/docs/interfaces/IAbstractBinaryTree.html +1124 -0
- package/docs/interfaces/{IBinaryTreeNode.html → IAbstractBinaryTreeNode.html} +61 -73
- package/docs/interfaces/{IGraph.html → IAbstractGraph.html} +52 -90
- package/docs/interfaces/IBST.html +1271 -0
- package/docs/interfaces/IBSTNode.html +408 -0
- package/docs/interfaces/IDirectedGraph.html +329 -16
- package/docs/interfaces/IUNDirectedGraph.html +322 -8
- package/docs/modules.html +22 -10
- package/docs/types/AVLTreeOptions.html +12 -6
- package/docs/types/{AbstractResultsByProperty.html → AbstractBinaryTreeNodeProperties.html} +16 -10
- package/docs/types/{AbstractResultByProperty.html → AbstractBinaryTreeNodeProperty.html} +16 -10
- package/docs/types/AbstractBinaryTreeOptions.html +12 -6
- package/docs/types/AbstractRecursiveBinaryTreeNode.html +12 -6
- package/docs/types/BSTComparator.html +12 -6
- package/docs/types/BSTOptions.html +12 -6
- package/docs/types/BinaryTreeDeletedResult.html +12 -6
- package/docs/types/BinaryTreeNodeId.html +12 -6
- package/docs/types/BinaryTreeNodePropertyName.html +12 -6
- package/docs/types/BinaryTreeOptions.html +12 -6
- package/docs/types/DFSOrderPattern.html +12 -6
- package/docs/types/DijkstraResult.html +12 -6
- package/docs/types/Direction.html +12 -6
- package/docs/types/EdgeId.html +12 -6
- package/docs/types/HeapOptions.html +12 -6
- package/docs/types/IdObject.html +12 -6
- package/docs/types/KeyValObject.html +12 -6
- package/docs/types/NavigatorParams.html +12 -6
- package/docs/types/NodeOrPropertyName.html +12 -6
- package/docs/types/PriorityQueueComparator.html +12 -6
- package/docs/types/PriorityQueueDFSOrderPattern.html +12 -6
- package/docs/types/PriorityQueueOptions.html +12 -6
- package/docs/types/RBTreeOptions.html +12 -6
- package/docs/types/RecursiveAVLTreeNode.html +12 -6
- package/docs/types/RecursiveBSTNode.html +12 -6
- package/docs/types/RecursiveBinaryTreeNode.html +12 -6
- package/docs/types/RecursiveTreeMultiSetNode.html +12 -6
- package/docs/types/SegmentTreeNodeVal.html +12 -6
- package/docs/types/TopologicalStatus.html +12 -6
- package/docs/types/TreeMultiSetOptions.html +12 -6
- package/docs/types/Turning.html +12 -6
- package/docs/types/VertexId.html +12 -6
- package/package.json +2 -2
- package/docs/interfaces/IBinaryTree.html +0 -189
|
@@ -1,26 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
get id(): BinaryTreeNodeId;
|
|
5
|
-
set id(v: BinaryTreeNodeId);
|
|
6
|
-
get val(): T;
|
|
7
|
-
set val(v: T);
|
|
8
|
-
get left(): FAMILY | null | undefined;
|
|
9
|
-
set left(v: FAMILY | null | undefined);
|
|
10
|
-
get right(): FAMILY | null | undefined;
|
|
11
|
-
set right(v: FAMILY | null | undefined);
|
|
12
|
-
get parent(): FAMILY | null | undefined;
|
|
13
|
-
set parent(v: FAMILY | null | undefined);
|
|
14
|
-
get familyPosition(): FamilyPosition;
|
|
15
|
-
set familyPosition(v: FamilyPosition);
|
|
16
|
-
get count(): number;
|
|
17
|
-
set count(v: number);
|
|
18
|
-
get height(): number;
|
|
19
|
-
set height(v: number);
|
|
20
|
-
_createNode(id: BinaryTreeNodeId, val: T | null, count?: number): FAMILY | null;
|
|
21
|
-
swapLocation(swapNode: FAMILY): FAMILY;
|
|
22
|
-
clone(): FAMILY | null;
|
|
1
|
+
import { BinaryTreeNode } from '../binary-tree';
|
|
2
|
+
import { IAbstractBinaryTree, IAbstractBinaryTreeNode } from './abstract-binary-tree';
|
|
3
|
+
export interface IBinaryTreeNode<T, FAMILY extends IBinaryTreeNode<T, FAMILY>> extends IAbstractBinaryTreeNode<T, FAMILY> {
|
|
23
4
|
}
|
|
24
|
-
export interface IBinaryTree<N extends
|
|
25
|
-
_createNode(id: BinaryTreeNodeId, val: N['val'] | null, count?: number): N | null;
|
|
5
|
+
export interface IBinaryTree<N extends BinaryTreeNode<N['val'], N>> extends IAbstractBinaryTree<N> {
|
|
26
6
|
}
|
|
@@ -1 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
import { BSTNode } from '../binary-tree';
|
|
2
|
+
import { IBinaryTree, IBinaryTreeNode } from './binary-tree';
|
|
3
|
+
import { BinaryTreeDeletedResult, BinaryTreeNodeId, BinaryTreeNodePropertyName } from '../types';
|
|
4
|
+
export interface IBSTNode<T, FAMILY extends IBSTNode<T, FAMILY>> extends IBinaryTreeNode<T, FAMILY> {
|
|
5
|
+
createNode(id: BinaryTreeNodeId, val?: T, count?: number): FAMILY;
|
|
6
|
+
}
|
|
7
|
+
export interface IBST<N extends BSTNode<N['val'], N>> extends IBinaryTree<N> {
|
|
8
|
+
createNode(id: BinaryTreeNodeId, val?: N['val'] | null, count?: number): N;
|
|
9
|
+
add(id: BinaryTreeNodeId, val: N['val'] | null, count: number): N | null;
|
|
10
|
+
get(nodeProperty: BinaryTreeNodeId | N, propertyName?: BinaryTreeNodePropertyName): N | null;
|
|
11
|
+
lastKey(): BinaryTreeNodeId;
|
|
12
|
+
remove(id: BinaryTreeNodeId, ignoreCount?: boolean): BinaryTreeDeletedResult<N>[];
|
|
13
|
+
getNodes(nodeProperty: BinaryTreeNodeId | N, propertyName?: BinaryTreeNodePropertyName, onlyOne?: boolean): N[];
|
|
14
|
+
lesserSum(id: BinaryTreeNodeId, propertyName?: BinaryTreeNodePropertyName): number;
|
|
15
|
+
allGreaterNodesAdd(node: N, delta: number, propertyName?: BinaryTreeNodePropertyName): boolean;
|
|
16
|
+
balance(): boolean;
|
|
17
|
+
isAVLBalanced(): boolean;
|
|
18
|
+
}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { VertexId } from '../types';
|
|
2
|
-
|
|
2
|
+
import { IAbstractGraph } from './abstract-graph';
|
|
3
|
+
export interface IDirectedGraph<V, E> extends IAbstractGraph<V, E> {
|
|
3
4
|
incomingEdgesOf(vertex: V): E[];
|
|
4
5
|
outgoingEdgesOf(vertex: V): E[];
|
|
5
6
|
inDegreeOf(vertexOrId: V | VertexId): number;
|
|
6
7
|
outDegreeOf(vertexOrId: V | VertexId): number;
|
|
7
8
|
getEdgeSrc(e: E): V | null;
|
|
8
9
|
getEdgeDest(e: E): V | null;
|
|
10
|
+
removeEdgeSrcToDest(srcOrId: V | VertexId, destOrId: V | VertexId): E | null;
|
|
11
|
+
removeEdgesBetween(v1: V | VertexId, v2: V | VertexId): E[];
|
|
9
12
|
}
|
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./binary-tree"), exports);
|
|
17
|
+
__exportStar(require("./abstract-binary-tree"), exports);
|
|
18
18
|
__exportStar(require("./bst"), exports);
|
|
19
19
|
__exportStar(require("./avl-tree"), exports);
|
|
20
20
|
__exportStar(require("./segment-tree"), exports);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { RBTreeNode } from '../binary-tree';
|
|
2
|
+
import { IBST, IBSTNode } from './bst';
|
|
3
|
+
import { BinaryTreeNodeId } from '../types';
|
|
4
|
+
export interface IRBTreeNode<T, FAMILY extends IRBTreeNode<T, FAMILY>> extends IBSTNode<T, FAMILY> {
|
|
5
|
+
createNode(id: BinaryTreeNodeId, val?: T | null, count?: number): FAMILY;
|
|
6
|
+
}
|
|
7
|
+
export interface IRBTree<N extends RBTreeNode<N['val'], N>> extends IBST<N> {
|
|
8
|
+
createNode(id: BinaryTreeNodeId, val?: N | null, count?: number): N;
|
|
9
|
+
}
|
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { VertexId } from '../types';
|
|
2
|
+
import { IAbstractGraph } from './abstract-graph';
|
|
3
|
+
export interface IUNDirectedGraph<V, E> extends IAbstractGraph<V, E> {
|
|
4
|
+
removeEdgeBetween(v1: V | VertexId, v2: V | VertexId): E | null;
|
|
2
5
|
}
|
|
@@ -22,8 +22,8 @@ export type BinaryTreeDeletedResult<N> = {
|
|
|
22
22
|
deleted: N | null | undefined;
|
|
23
23
|
needBalanced: N | null;
|
|
24
24
|
};
|
|
25
|
-
export type
|
|
26
|
-
export type
|
|
25
|
+
export type AbstractBinaryTreeNodeProperty<N extends AbstractBinaryTreeNode<N['val'], N>> = N['val'] | N | number | BinaryTreeNodeId;
|
|
26
|
+
export type AbstractBinaryTreeNodeProperties<N extends AbstractBinaryTreeNode<N['val'], N>> = AbstractBinaryTreeNodeProperty<N>[];
|
|
27
27
|
export type AbstractRecursiveBinaryTreeNode<T> = AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, AbstractBinaryTreeNode<T, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
|
|
28
28
|
export type AbstractBinaryTreeOptions = {
|
|
29
29
|
loopType?: LoopType;
|
package/dist/utils/utils.js
CHANGED
|
@@ -149,3 +149,65 @@ var trampolineAsync = function (fn) {
|
|
|
149
149
|
}, { cont: cont });
|
|
150
150
|
};
|
|
151
151
|
exports.trampolineAsync = trampolineAsync;
|
|
152
|
+
// export class AutoPruneMap<K, V> extends Map<K, V> {
|
|
153
|
+
//
|
|
154
|
+
// private _proxySet: Set<V>;
|
|
155
|
+
// get proxySet(): Set<V> {
|
|
156
|
+
// return this._proxySet;
|
|
157
|
+
// }
|
|
158
|
+
//
|
|
159
|
+
// set proxySet(value: Set<V>) {
|
|
160
|
+
// this._proxySet = value;
|
|
161
|
+
// }
|
|
162
|
+
//
|
|
163
|
+
// private _isEmptyArrayAllowed: boolean;
|
|
164
|
+
//
|
|
165
|
+
// get isEmptyArrayAllowed(): boolean {
|
|
166
|
+
// return this._isEmptyArrayAllowed;
|
|
167
|
+
// }
|
|
168
|
+
//
|
|
169
|
+
// set isEmptyArrayAllowed(value: boolean) {
|
|
170
|
+
// this._isEmptyArrayAllowed = value;
|
|
171
|
+
// }
|
|
172
|
+
//
|
|
173
|
+
// constructor(isEmptyArrayAllowed: boolean = false) {
|
|
174
|
+
// super();
|
|
175
|
+
// this._isEmptyArrayAllowed = isEmptyArrayAllowed;
|
|
176
|
+
// this._proxySet = new Set<V>();
|
|
177
|
+
// }
|
|
178
|
+
//
|
|
179
|
+
// set(key: K, value: V): this {
|
|
180
|
+
// if (Array.isArray(value) && !this.proxySet.has(value)) {
|
|
181
|
+
// if(!this.isEmptyArrayAllowed && value.length === 0) return this;
|
|
182
|
+
// value = this.createArrayProxy(value, key);
|
|
183
|
+
// if (!this.proxySet.has(value)) this.proxySet.add(value);
|
|
184
|
+
// }
|
|
185
|
+
// super.set(key, value);
|
|
186
|
+
// return this;
|
|
187
|
+
// }
|
|
188
|
+
//
|
|
189
|
+
// private createArrayProxy(array: V & any[], key: K) {
|
|
190
|
+
// const that = this;
|
|
191
|
+
// const proxyHandler: ProxyHandler<V & any[]> = {
|
|
192
|
+
// set(target: any, property: PropertyKey, value: any): boolean {
|
|
193
|
+
// const result = Reflect.set(target, property, value);
|
|
194
|
+
// that.checkAndDeleteEmptyArray(key);
|
|
195
|
+
// return result;
|
|
196
|
+
// },
|
|
197
|
+
// deleteProperty(target: any, property: PropertyKey): boolean {
|
|
198
|
+
// const result = Reflect.deleteProperty(target, property);
|
|
199
|
+
// that.checkAndDeleteEmptyArray(key);
|
|
200
|
+
// return result;
|
|
201
|
+
// },
|
|
202
|
+
// }
|
|
203
|
+
// return new Proxy(array, proxyHandler);
|
|
204
|
+
// }
|
|
205
|
+
//
|
|
206
|
+
// private checkAndDeleteEmptyArray(key: K): void {
|
|
207
|
+
// const value = this.get(key);
|
|
208
|
+
//
|
|
209
|
+
// if (Array.isArray(value) && value.length === 0) {
|
|
210
|
+
// super.delete(key);
|
|
211
|
+
// }
|
|
212
|
+
// }
|
|
213
|
+
// }
|