data-structure-typed 1.34.9 → 1.35.0

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.
@@ -0,0 +1,38 @@
1
+ ---
2
+ name: Bug report
3
+ about: Create a report to help us improve
4
+ title: ''
5
+ labels: ''
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ **Describe the bug**
11
+ A clear and concise description of what the bug is.
12
+
13
+ **To Reproduce**
14
+ Steps to reproduce the behavior:
15
+ 1. Go to '...'
16
+ 2. Click on '....'
17
+ 3. Scroll down to '....'
18
+ 4. See error
19
+
20
+ **Expected behavior**
21
+ A clear and concise description of what you expected to happen.
22
+
23
+ **Screenshots**
24
+ If applicable, add screenshots to help explain your problem.
25
+
26
+ **Desktop (please complete the following information):**
27
+ - OS: [e.g. iOS]
28
+ - Browser [e.g. chrome, safari]
29
+ - Version [e.g. 22]
30
+
31
+ **Smartphone (please complete the following information):**
32
+ - Device: [e.g. iPhone6]
33
+ - OS: [e.g. iOS8.1]
34
+ - Browser [e.g. stock browser, safari]
35
+ - Version [e.g. 22]
36
+
37
+ **Additional context**
38
+ Add any other context about the problem here.
@@ -0,0 +1,10 @@
1
+ ---
2
+ name: Custom issue template
3
+ about: Describe this issue template's purpose here.
4
+ title: ''
5
+ labels: ''
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+
@@ -0,0 +1,20 @@
1
+ ---
2
+ name: Feature request
3
+ about: Suggest an idea for this project
4
+ title: ''
5
+ labels: ''
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ **Is your feature request related to a problem? Please describe.**
11
+ A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12
+
13
+ **Describe the solution you'd like**
14
+ A clear and concise description of what you want to happen.
15
+
16
+ **Describe alternatives you've considered**
17
+ A clear and concise description of any alternative solutions or features you've considered.
18
+
19
+ **Additional context**
20
+ Add any other context or screenshots about the feature request here.
@@ -1,84 +1,7 @@
1
- import { AbstractBinaryTreeNodeProperties, AbstractBinaryTreeNodeProperty, BinaryTreeDeletedResult, BinaryTreeNodeKey, BinaryTreeNodePropertyName, DFSOrderPattern, FamilyPosition, LoopType, NodeOrPropertyName } from '../types';
1
+ import { BinaryTreeNodeKey } from '../types';
2
2
  import { AbstractBinaryTreeNode } from '../data-structures';
3
3
  export interface IAbstractBinaryTreeNode<T, NEIGHBOR extends IAbstractBinaryTreeNode<T, NEIGHBOR>> {
4
- key: BinaryTreeNodeKey;
5
- val: T | undefined;
6
- get left(): NEIGHBOR | null | undefined;
7
- set left(v: NEIGHBOR | null | undefined);
8
- get right(): NEIGHBOR | null | undefined;
9
- set right(v: NEIGHBOR | null | undefined);
10
- parent: NEIGHBOR | null | undefined;
11
- get familyPosition(): FamilyPosition;
12
4
  }
13
5
  export interface IAbstractBinaryTree<N extends AbstractBinaryTreeNode<N['val'], N>> {
14
6
  createNode(key: BinaryTreeNodeKey, val?: N['val'], count?: number): N | null;
15
- get loopType(): LoopType;
16
- get visitedKey(): BinaryTreeNodeKey[];
17
- get visitedVal(): Array<N['val']>;
18
- get visitedNode(): N[];
19
- get root(): N | null;
20
- get size(): number;
21
- swapLocation(srcNode: N, destNode: N): N;
22
- clear(): void;
23
- isEmpty(): boolean;
24
- add(key: BinaryTreeNodeKey | N, val?: N['val']): N | null | undefined;
25
- addMany(keysOrNodes: (BinaryTreeNodeKey | N | null)[], data?: N['val'][]): (N | null | undefined)[];
26
- refill(keysOrNodes: (BinaryTreeNodeKey | N | null)[], data?: N[] | Array<N['val']>): boolean;
27
- remove(key: BinaryTreeNodeKey, ignoreCount?: boolean): BinaryTreeDeletedResult<N>[];
28
- getDepth(node: N): number;
29
- getHeight(beginRoot?: N | null): number;
30
- getMinHeight(beginRoot?: N | null): number;
31
- isPerfectlyBalanced(beginRoot?: N | null): boolean;
32
- getNodes(nodeProperty: BinaryTreeNodeKey | N, propertyName?: BinaryTreeNodePropertyName, onlyOne?: boolean): N[];
33
- has(nodeProperty: BinaryTreeNodeKey | N, propertyName?: BinaryTreeNodePropertyName): boolean;
34
- get(nodeProperty: BinaryTreeNodeKey | N, propertyName?: BinaryTreeNodePropertyName): N | null;
35
- getPathToRoot(node: N): N[];
36
- getLeftMost(): N | null;
37
- getLeftMost(node: N): N;
38
- getLeftMost(node?: N | null): N | null;
39
- getRightMost(): N | null;
40
- getRightMost(node: N): N;
41
- getRightMost(node?: N | null): N | null;
42
- isSubtreeBST(node: N | null): boolean;
43
- isBST(): boolean;
44
- getSubTreeSize(subTreeRoot: N | null | undefined): number;
45
- subTreeSum(subTreeRoot: N, propertyName?: BinaryTreeNodePropertyName): number;
46
- subTreeAdd(subTreeRoot: N, delta: number, propertyName?: BinaryTreeNodePropertyName): boolean;
47
- bfs(): BinaryTreeNodeKey[];
48
- bfs(nodeOrPropertyName: 'key'): BinaryTreeNodeKey[];
49
- bfs(nodeOrPropertyName: 'val'): N['val'][];
50
- bfs(nodeOrPropertyName: 'node'): N[];
51
- bfs(nodeOrPropertyName: 'count'): number[];
52
- bfs(nodeOrPropertyName?: NodeOrPropertyName): AbstractBinaryTreeNodeProperties<N>;
53
- dfs(): BinaryTreeNodeKey[];
54
- dfs(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'key'): BinaryTreeNodeKey[];
55
- dfs(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'val'): N[];
56
- dfs(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'node'): N[];
57
- dfs(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'count'): number[];
58
- dfs(pattern?: 'in' | 'pre' | 'post', nodeOrPropertyName?: NodeOrPropertyName): AbstractBinaryTreeNodeProperties<N>;
59
- dfsIterative(): BinaryTreeNodeKey[];
60
- dfsIterative(pattern: DFSOrderPattern): BinaryTreeNodeKey[];
61
- dfsIterative(pattern: DFSOrderPattern, nodeOrPropertyName: 'key'): BinaryTreeNodeKey[];
62
- dfsIterative(pattern: DFSOrderPattern, nodeOrPropertyName: 'val'): N['val'][];
63
- dfsIterative(pattern: DFSOrderPattern, nodeOrPropertyName: 'node'): N[];
64
- dfsIterative(pattern?: DFSOrderPattern, nodeOrPropertyName?: NodeOrPropertyName): AbstractBinaryTreeNodeProperties<N>;
65
- levelIterative(node: N | null): BinaryTreeNodeKey[];
66
- levelIterative(node: N | null, nodeOrPropertyName?: 'key'): BinaryTreeNodeKey[];
67
- levelIterative(node: N | null, nodeOrPropertyName?: 'val'): N['val'][];
68
- levelIterative(node: N | null, nodeOrPropertyName?: 'node'): N[];
69
- levelIterative(node: N | null, nodeOrPropertyName?: 'count'): number[];
70
- levelIterative(node: N | null, nodeOrPropertyName?: NodeOrPropertyName): AbstractBinaryTreeNodeProperties<N>;
71
- listLevels(node: N | null): BinaryTreeNodeKey[][];
72
- listLevels(node: N | null, nodeOrPropertyName?: 'key'): BinaryTreeNodeKey[][];
73
- listLevels(node: N | null, nodeOrPropertyName?: 'val'): N['val'][][];
74
- listLevels(node: N | null, nodeOrPropertyName?: 'node'): N[][];
75
- listLevels(node: N | null, nodeOrPropertyName?: 'count'): number[][];
76
- listLevels(node: N | null, nodeOrPropertyName?: NodeOrPropertyName): AbstractBinaryTreeNodeProperty<N>[][];
77
- getPredecessor(node: N): N;
78
- morris(): BinaryTreeNodeKey[];
79
- morris(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'key'): BinaryTreeNodeKey[];
80
- morris(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'val'): N[];
81
- morris(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'node'): N[];
82
- morris(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'count'): number[];
83
- morris(pattern?: 'in' | 'pre' | 'post', nodeOrPropertyName?: NodeOrPropertyName): AbstractBinaryTreeNodeProperties<N>;
84
7
  }
@@ -1,17 +1,5 @@
1
1
  import { VertexKey } from '../types';
2
2
  export interface IAbstractGraph<V, E> {
3
- hasVertex(vertexOrKey: V | VertexKey): boolean;
4
- addVertex(key: VertexKey, val?: V): boolean;
5
- removeVertex(vertexOrKey: V | VertexKey): boolean;
6
- removeAllVertices(vertices: V[] | VertexKey[]): boolean;
7
- degreeOf(vertexOrKey: V | VertexKey): number;
8
- edgesOf(vertexOrKey: V | VertexKey): E[];
9
- hasEdge(src: V | VertexKey, dest: V | VertexKey): boolean;
10
- getEdge(srcOrKey: V | VertexKey, destOrKey: V | VertexKey): E | null;
11
- edgeSet(): E[];
12
- addEdge(src: V | VertexKey, dest: V | VertexKey, weight: number, val: E): boolean;
13
- removeEdge(edge: E): E | null;
14
- setEdgeWeight(srcOrKey: V | VertexKey, destOrKey: V | VertexKey, weight: number): boolean;
15
- getMinPathBetween(v1: V | VertexKey, v2: V | VertexKey, isWeight?: boolean): V[] | null;
16
- getNeighbors(vertexOrKey: V | VertexKey): V[];
3
+ createVertex(key: VertexKey, val?: V): V;
4
+ createEdge(srcOrV1: VertexKey | string, destOrV2: VertexKey | string, weight?: number, val?: E): E;
17
5
  }
@@ -1,10 +1,7 @@
1
1
  import { AVLTreeNode } from '../data-structures';
2
2
  import { IBST, IBSTNode } from './bst';
3
- import { BinaryTreeDeletedResult, BinaryTreeNodeKey } from '../types';
4
3
  export interface IAVLTreeNode<T, NEIGHBOR extends IAVLTreeNode<T, NEIGHBOR>> extends IBSTNode<T, NEIGHBOR> {
5
4
  height: number;
6
5
  }
7
6
  export interface IAVLTree<N extends AVLTreeNode<N['val'], N>> extends IBST<N> {
8
- add(key: BinaryTreeNodeKey, val?: N['val'] | null): N | null | undefined;
9
- remove(key: BinaryTreeNodeKey): BinaryTreeDeletedResult<N>[];
10
7
  }
@@ -1,4 +1,6 @@
1
1
  import { BinaryTreeNode } from '../data-structures';
2
2
  import { IAbstractBinaryTree, IAbstractBinaryTreeNode } from './abstract-binary-tree';
3
- export type IBinaryTreeNode<T, NEIGHBOR extends IBinaryTreeNode<T, NEIGHBOR>> = IAbstractBinaryTreeNode<T, NEIGHBOR>;
4
- export type IBinaryTree<N extends BinaryTreeNode<N['val'], N>> = IAbstractBinaryTree<N>;
3
+ export interface IBinaryTreeNode<T, NEIGHBOR extends IBinaryTreeNode<T, NEIGHBOR>> extends IAbstractBinaryTreeNode<T, NEIGHBOR> {
4
+ }
5
+ export interface IBinaryTree<N extends BinaryTreeNode<N['val'], N>> extends IAbstractBinaryTree<N> {
6
+ }
@@ -1,17 +1,6 @@
1
1
  import { BSTNode } from '../data-structures';
2
2
  import { IBinaryTree, IBinaryTreeNode } from './binary-tree';
3
- import { BinaryTreeDeletedResult, BinaryTreeNodeKey, BinaryTreeNodePropertyName } from '../types';
4
3
  export interface IBSTNode<T, NEIGHBOR extends IBSTNode<T, NEIGHBOR>> extends IBinaryTreeNode<T, NEIGHBOR> {
5
4
  }
6
5
  export interface IBST<N extends BSTNode<N['val'], N>> extends IBinaryTree<N> {
7
- createNode(key: BinaryTreeNodeKey, val?: N['val'], count?: number): N;
8
- add(key: BinaryTreeNodeKey, val?: N['val'] | null, count?: number): N | null | undefined;
9
- get(nodeProperty: BinaryTreeNodeKey | N, propertyName?: BinaryTreeNodePropertyName): N | null;
10
- lastKey(): BinaryTreeNodeKey;
11
- remove(key: BinaryTreeNodeKey, ignoreCount?: boolean): BinaryTreeDeletedResult<N>[];
12
- getNodes(nodeProperty: BinaryTreeNodeKey | N, propertyName?: BinaryTreeNodePropertyName, onlyOne?: boolean): N[];
13
- lesserSum(key: BinaryTreeNodeKey, propertyName?: BinaryTreeNodePropertyName): number;
14
- allGreaterNodesAdd(node: N, delta: number, propertyName?: BinaryTreeNodePropertyName): boolean;
15
- perfectlyBalance(): boolean;
16
- isAVLBalanced(): boolean;
17
6
  }
@@ -1,12 +1,3 @@
1
- import { VertexKey } from '../types';
2
1
  import { IAbstractGraph } from './abstract-graph';
3
2
  export interface IDirectedGraph<V, E> extends IAbstractGraph<V, E> {
4
- incomingEdgesOf(vertex: V): E[];
5
- outgoingEdgesOf(vertex: V): E[];
6
- inDegreeOf(vertexOrKey: V | VertexKey): number;
7
- outDegreeOf(vertexOrKey: V | VertexKey): number;
8
- getEdgeSrc(e: E): V | null;
9
- getEdgeDest(e: E): V | null;
10
- removeEdgeSrcToDest(srcOrKey: V | VertexKey, destOrKey: V | VertexKey): E | null;
11
- removeEdgesBetween(v1: V | VertexKey, v2: V | VertexKey): E[];
12
3
  }
@@ -1,7 +1,6 @@
1
1
  import { RBTreeNode } from '../data-structures';
2
2
  import { IBST, IBSTNode } from './bst';
3
- import { BinaryTreeNodeKey } from '../types';
4
- export type IRBTreeNode<T, NEIGHBOR extends IRBTreeNode<T, NEIGHBOR>> = IBSTNode<T, NEIGHBOR>;
3
+ export interface IRBTreeNode<T, NEIGHBOR extends IRBTreeNode<T, NEIGHBOR>> extends IBSTNode<T, NEIGHBOR> {
4
+ }
5
5
  export interface IRBTree<N extends RBTreeNode<N['val'], N>> extends IBST<N> {
6
- createNode(key: BinaryTreeNodeKey, val?: N['val'], count?: number): N;
7
6
  }
@@ -1,5 +1,6 @@
1
1
  import { TreeMultisetNode } from '../data-structures';
2
- import { IBSTNode } from './bst';
3
- import { IAVLTree } from './avl-tree';
4
- export type ITreeMultisetNode<T, NEIGHBOR extends ITreeMultisetNode<T, NEIGHBOR>> = IBSTNode<T, NEIGHBOR>;
5
- export type ITreeMultiset<N extends TreeMultisetNode<N['val'], N>> = IAVLTree<N>;
2
+ import { IAVLTree, IAVLTreeNode } from './avl-tree';
3
+ export interface ITreeMultisetNode<T, NEIGHBOR extends ITreeMultisetNode<T, NEIGHBOR>> extends IAVLTreeNode<T, NEIGHBOR> {
4
+ }
5
+ export interface ITreeMultiset<N extends TreeMultisetNode<N['val'], N>> extends IAVLTree<N> {
6
+ }
@@ -1,5 +1,3 @@
1
- import { VertexKey } from '../types';
2
1
  import { IAbstractGraph } from './abstract-graph';
3
2
  export interface IUNDirectedGraph<V, E> extends IAbstractGraph<V, E> {
4
- removeEdgeBetween(v1: V | VertexKey, v2: V | VertexKey): E | null;
5
3
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "data-structure-typed",
3
- "version": "1.34.9",
3
+ "version": "1.35.0",
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",
@@ -22,7 +22,7 @@
22
22
  "fix:src": "npm run lint:src && npm run format:src",
23
23
  "fix:test": "npm run lint:test && npm run format:test",
24
24
  "fix": "npm run fix:src && npm run fix:test",
25
- "update:test-deps": "npm i avl-tree-typed binary-tree-typed bst-typed heap-typed --save-dev",
25
+ "update:individuals": "npm i avl-tree-typed binary-tree-typed bst-typed heap-typed --save-dev",
26
26
  "install:individuals": "npm i avl-tree-typed binary-tree-typed bst-typed deque-typed directed-graph-typed doubly-linked-list-typed graph-typed heap-typed linked-list-typed max-heap-typed max-priority-queue-typed min-heap-typed min-priority-queue-typed priority-queue-typed singly-linked-list-typed stack-typed tree-multiset-typed trie-typed undirected-graph-typed queue-typed --save-dev",
27
27
  "test": "jest",
28
28
  "check:deps": "dependency-cruiser src",
@@ -1,176 +1,8 @@
1
- import {
2
- AbstractBinaryTreeNodeProperties,
3
- AbstractBinaryTreeNodeProperty,
4
- BinaryTreeDeletedResult,
5
- BinaryTreeNodeKey,
6
- BinaryTreeNodePropertyName,
7
- DFSOrderPattern,
8
- FamilyPosition,
9
- LoopType,
10
- NodeOrPropertyName
11
- } from '../types';
1
+ import {BinaryTreeNodeKey} from '../types';
12
2
  import {AbstractBinaryTreeNode} from '../data-structures';
13
3
 
14
- export interface IAbstractBinaryTreeNode<T, NEIGHBOR extends IAbstractBinaryTreeNode<T, NEIGHBOR>> {
15
- key: BinaryTreeNodeKey;
16
-
17
- val: T | undefined;
18
-
19
- get left(): NEIGHBOR | null | undefined;
20
-
21
- set left(v: NEIGHBOR | null | undefined);
22
-
23
- get right(): NEIGHBOR | null | undefined;
24
-
25
- set right(v: NEIGHBOR | null | undefined);
26
-
27
- parent: NEIGHBOR | null | undefined;
28
-
29
- get familyPosition(): FamilyPosition;
30
- }
4
+ export interface IAbstractBinaryTreeNode<T, NEIGHBOR extends IAbstractBinaryTreeNode<T, NEIGHBOR>> {}
31
5
 
32
6
  export interface IAbstractBinaryTree<N extends AbstractBinaryTreeNode<N['val'], N>> {
33
7
  createNode(key: BinaryTreeNodeKey, val?: N['val'], count?: number): N | null;
34
-
35
- get loopType(): LoopType;
36
-
37
- get visitedKey(): BinaryTreeNodeKey[];
38
-
39
- get visitedVal(): Array<N['val']>;
40
-
41
- get visitedNode(): N[];
42
-
43
- get root(): N | null;
44
-
45
- get size(): number;
46
-
47
- swapLocation(srcNode: N, destNode: N): N;
48
-
49
- clear(): void;
50
-
51
- isEmpty(): boolean;
52
-
53
- add(key: BinaryTreeNodeKey | N, val?: N['val']): N | null | undefined;
54
-
55
- addMany(keysOrNodes: (BinaryTreeNodeKey | N | null)[], data?: N['val'][]): (N | null | undefined)[];
56
-
57
- refill(keysOrNodes: (BinaryTreeNodeKey | N | null)[], data?: N[] | Array<N['val']>): boolean;
58
-
59
- remove(key: BinaryTreeNodeKey, ignoreCount?: boolean): BinaryTreeDeletedResult<N>[];
60
-
61
- getDepth(node: N): number;
62
-
63
- getHeight(beginRoot?: N | null): number;
64
-
65
- getMinHeight(beginRoot?: N | null): number;
66
-
67
- isPerfectlyBalanced(beginRoot?: N | null): boolean;
68
-
69
- getNodes(nodeProperty: BinaryTreeNodeKey | N, propertyName?: BinaryTreeNodePropertyName, onlyOne?: boolean): N[];
70
-
71
- has(nodeProperty: BinaryTreeNodeKey | N, propertyName?: BinaryTreeNodePropertyName): boolean;
72
-
73
- get(nodeProperty: BinaryTreeNodeKey | N, propertyName?: BinaryTreeNodePropertyName): N | null;
74
-
75
- getPathToRoot(node: N): N[];
76
-
77
- getLeftMost(): N | null;
78
-
79
- getLeftMost(node: N): N;
80
-
81
- getLeftMost(node?: N | null): N | null;
82
-
83
- getRightMost(): N | null;
84
-
85
- getRightMost(node: N): N;
86
-
87
- getRightMost(node?: N | null): N | null;
88
-
89
- isSubtreeBST(node: N | null): boolean;
90
-
91
- isBST(): boolean;
92
-
93
- getSubTreeSize(subTreeRoot: N | null | undefined): number;
94
-
95
- // --- start additional methods ---
96
-
97
- subTreeSum(subTreeRoot: N, propertyName?: BinaryTreeNodePropertyName): number;
98
-
99
- subTreeAdd(subTreeRoot: N, delta: number, propertyName?: BinaryTreeNodePropertyName): boolean;
100
-
101
- bfs(): BinaryTreeNodeKey[];
102
-
103
- bfs(nodeOrPropertyName: 'key'): BinaryTreeNodeKey[];
104
-
105
- bfs(nodeOrPropertyName: 'val'): N['val'][];
106
-
107
- bfs(nodeOrPropertyName: 'node'): N[];
108
-
109
- bfs(nodeOrPropertyName: 'count'): number[];
110
-
111
- bfs(nodeOrPropertyName?: NodeOrPropertyName): AbstractBinaryTreeNodeProperties<N>;
112
-
113
- dfs(): BinaryTreeNodeKey[];
114
-
115
- dfs(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'key'): BinaryTreeNodeKey[];
116
-
117
- dfs(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'val'): N[];
118
-
119
- dfs(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'node'): N[];
120
-
121
- dfs(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'count'): number[];
122
-
123
- dfs(pattern?: 'in' | 'pre' | 'post', nodeOrPropertyName?: NodeOrPropertyName): AbstractBinaryTreeNodeProperties<N>;
124
-
125
- dfsIterative(): BinaryTreeNodeKey[];
126
-
127
- dfsIterative(pattern: DFSOrderPattern): BinaryTreeNodeKey[];
128
-
129
- dfsIterative(pattern: DFSOrderPattern, nodeOrPropertyName: 'key'): BinaryTreeNodeKey[];
130
-
131
- dfsIterative(pattern: DFSOrderPattern, nodeOrPropertyName: 'val'): N['val'][];
132
-
133
- dfsIterative(pattern: DFSOrderPattern, nodeOrPropertyName: 'node'): N[];
134
-
135
- dfsIterative(pattern?: DFSOrderPattern, nodeOrPropertyName?: NodeOrPropertyName): AbstractBinaryTreeNodeProperties<N>;
136
-
137
- levelIterative(node: N | null): BinaryTreeNodeKey[];
138
-
139
- levelIterative(node: N | null, nodeOrPropertyName?: 'key'): BinaryTreeNodeKey[];
140
-
141
- levelIterative(node: N | null, nodeOrPropertyName?: 'val'): N['val'][];
142
-
143
- levelIterative(node: N | null, nodeOrPropertyName?: 'node'): N[];
144
-
145
- levelIterative(node: N | null, nodeOrPropertyName?: 'count'): number[];
146
-
147
- levelIterative(node: N | null, nodeOrPropertyName?: NodeOrPropertyName): AbstractBinaryTreeNodeProperties<N>;
148
-
149
- listLevels(node: N | null): BinaryTreeNodeKey[][];
150
-
151
- listLevels(node: N | null, nodeOrPropertyName?: 'key'): BinaryTreeNodeKey[][];
152
-
153
- listLevels(node: N | null, nodeOrPropertyName?: 'val'): N['val'][][];
154
-
155
- listLevels(node: N | null, nodeOrPropertyName?: 'node'): N[][];
156
-
157
- listLevels(node: N | null, nodeOrPropertyName?: 'count'): number[][];
158
-
159
- listLevels(node: N | null, nodeOrPropertyName?: NodeOrPropertyName): AbstractBinaryTreeNodeProperty<N>[][];
160
-
161
- getPredecessor(node: N): N;
162
-
163
- morris(): BinaryTreeNodeKey[];
164
-
165
- morris(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'key'): BinaryTreeNodeKey[];
166
-
167
- morris(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'val'): N[];
168
-
169
- morris(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'node'): N[];
170
-
171
- morris(pattern?: DFSOrderPattern, nodeOrPropertyName?: 'count'): number[];
172
-
173
- morris(pattern?: 'in' | 'pre' | 'post', nodeOrPropertyName?: NodeOrPropertyName): AbstractBinaryTreeNodeProperties<N>;
174
-
175
- // --- end additional methods ---
176
8
  }
@@ -1,31 +1,7 @@
1
1
  import {VertexKey} from '../types';
2
2
 
3
3
  export interface IAbstractGraph<V, E> {
4
- hasVertex(vertexOrKey: V | VertexKey): boolean;
4
+ createVertex(key: VertexKey, val?: V): V;
5
5
 
6
- addVertex(key: VertexKey, val?: V): boolean;
7
-
8
- removeVertex(vertexOrKey: V | VertexKey): boolean;
9
-
10
- removeAllVertices(vertices: V[] | VertexKey[]): boolean;
11
-
12
- degreeOf(vertexOrKey: V | VertexKey): number;
13
-
14
- edgesOf(vertexOrKey: V | VertexKey): E[];
15
-
16
- hasEdge(src: V | VertexKey, dest: V | VertexKey): boolean;
17
-
18
- getEdge(srcOrKey: V | VertexKey, destOrKey: V | VertexKey): E | null;
19
-
20
- edgeSet(): E[];
21
-
22
- addEdge(src: V | VertexKey, dest: V | VertexKey, weight: number, val: E): boolean;
23
-
24
- removeEdge(edge: E): E | null;
25
-
26
- setEdgeWeight(srcOrKey: V | VertexKey, destOrKey: V | VertexKey, weight: number): boolean;
27
-
28
- getMinPathBetween(v1: V | VertexKey, v2: V | VertexKey, isWeight?: boolean): V[] | null;
29
-
30
- getNeighbors(vertexOrKey: V | VertexKey): V[];
6
+ createEdge(srcOrV1: VertexKey | string, destOrV2: VertexKey | string, weight?: number, val?: E): E;
31
7
  }
@@ -1,27 +1,8 @@
1
1
  import {AVLTreeNode} from '../data-structures';
2
2
  import {IBST, IBSTNode} from './bst';
3
- import {BinaryTreeDeletedResult, BinaryTreeNodeKey} from '../types';
4
3
 
5
4
  export interface IAVLTreeNode<T, NEIGHBOR extends IAVLTreeNode<T, NEIGHBOR>> extends IBSTNode<T, NEIGHBOR> {
6
5
  height: number;
7
6
  }
8
7
 
9
- export interface IAVLTree<N extends AVLTreeNode<N['val'], N>> extends IBST<N> {
10
- add(key: BinaryTreeNodeKey, val?: N['val'] | null): N | null | undefined;
11
-
12
- remove(key: BinaryTreeNodeKey): BinaryTreeDeletedResult<N>[];
13
-
14
- // _balanceFactor(node: N): number
15
- //
16
- // _updateHeight(node: N): void
17
- //
18
- // _balancePath(node: N): void
19
- //
20
- // _balanceLL(A: N): void
21
- //
22
- // _balanceLR(A: N): void
23
- //
24
- // _balanceRR(A: N): void
25
- //
26
- // _balanceRL(A: N): void
27
- }
8
+ export interface IAVLTree<N extends AVLTreeNode<N['val'], N>> extends IBST<N> {}
@@ -1,6 +1,7 @@
1
1
  import {BinaryTreeNode} from '../data-structures';
2
2
  import {IAbstractBinaryTree, IAbstractBinaryTreeNode} from './abstract-binary-tree';
3
3
 
4
- export type IBinaryTreeNode<T, NEIGHBOR extends IBinaryTreeNode<T, NEIGHBOR>> = IAbstractBinaryTreeNode<T, NEIGHBOR>;
4
+ export interface IBinaryTreeNode<T, NEIGHBOR extends IBinaryTreeNode<T, NEIGHBOR>>
5
+ extends IAbstractBinaryTreeNode<T, NEIGHBOR> {}
5
6
 
6
- export type IBinaryTree<N extends BinaryTreeNode<N['val'], N>> = IAbstractBinaryTree<N>;
7
+ export interface IBinaryTree<N extends BinaryTreeNode<N['val'], N>> extends IAbstractBinaryTree<N> {}
@@ -1,31 +1,6 @@
1
1
  import {BSTNode} from '../data-structures';
2
2
  import {IBinaryTree, IBinaryTreeNode} from './binary-tree';
3
- import {BinaryTreeDeletedResult, BinaryTreeNodeKey, BinaryTreeNodePropertyName} from '../types';
4
3
 
5
4
  export interface IBSTNode<T, NEIGHBOR extends IBSTNode<T, NEIGHBOR>> extends IBinaryTreeNode<T, NEIGHBOR> {}
6
5
 
7
- export interface IBST<N extends BSTNode<N['val'], N>> extends IBinaryTree<N> {
8
- createNode(key: BinaryTreeNodeKey, val?: N['val'], count?: number): N;
9
-
10
- add(key: BinaryTreeNodeKey, val?: N['val'] | null, count?: number): N | null | undefined;
11
-
12
- get(nodeProperty: BinaryTreeNodeKey | N, propertyName?: BinaryTreeNodePropertyName): N | null;
13
-
14
- lastKey(): BinaryTreeNodeKey;
15
-
16
- remove(key: BinaryTreeNodeKey, ignoreCount?: boolean): BinaryTreeDeletedResult<N>[];
17
-
18
- getNodes(nodeProperty: BinaryTreeNodeKey | N, propertyName?: BinaryTreeNodePropertyName, onlyOne?: boolean): N[];
19
-
20
- // --- start additional functions
21
-
22
- lesserSum(key: BinaryTreeNodeKey, propertyName?: BinaryTreeNodePropertyName): number;
23
-
24
- allGreaterNodesAdd(node: N, delta: number, propertyName?: BinaryTreeNodePropertyName): boolean;
25
-
26
- perfectlyBalance(): boolean;
27
-
28
- isAVLBalanced(): boolean;
29
-
30
- // --- end additional functions
31
- }
6
+ export interface IBST<N extends BSTNode<N['val'], N>> extends IBinaryTree<N> {}
@@ -1,20 +1,3 @@
1
- import {VertexKey} from '../types';
2
1
  import {IAbstractGraph} from './abstract-graph';
3
2
 
4
- export interface IDirectedGraph<V, E> extends IAbstractGraph<V, E> {
5
- incomingEdgesOf(vertex: V): E[];
6
-
7
- outgoingEdgesOf(vertex: V): E[];
8
-
9
- inDegreeOf(vertexOrKey: V | VertexKey): number;
10
-
11
- outDegreeOf(vertexOrKey: V | VertexKey): number;
12
-
13
- getEdgeSrc(e: E): V | null;
14
-
15
- getEdgeDest(e: E): V | null;
16
-
17
- removeEdgeSrcToDest(srcOrKey: V | VertexKey, destOrKey: V | VertexKey): E | null;
18
-
19
- removeEdgesBetween(v1: V | VertexKey, v2: V | VertexKey): E[];
20
- }
3
+ export interface IDirectedGraph<V, E> extends IAbstractGraph<V, E> {}
@@ -1,9 +1,6 @@
1
1
  import {RBTreeNode} from '../data-structures';
2
2
  import {IBST, IBSTNode} from './bst';
3
- import {BinaryTreeNodeKey} from '../types';
4
3
 
5
- export type IRBTreeNode<T, NEIGHBOR extends IRBTreeNode<T, NEIGHBOR>> = IBSTNode<T, NEIGHBOR>;
4
+ export interface IRBTreeNode<T, NEIGHBOR extends IRBTreeNode<T, NEIGHBOR>> extends IBSTNode<T, NEIGHBOR> {}
6
5
 
7
- export interface IRBTree<N extends RBTreeNode<N['val'], N>> extends IBST<N> {
8
- createNode(key: BinaryTreeNodeKey, val?: N['val'], count?: number): N;
9
- }
6
+ export interface IRBTree<N extends RBTreeNode<N['val'], N>> extends IBST<N> {}
@@ -1,7 +1,7 @@
1
1
  import {TreeMultisetNode} from '../data-structures';
2
- import {IBSTNode} from './bst';
3
- import {IAVLTree} from './avl-tree';
2
+ import {IAVLTree, IAVLTreeNode} from './avl-tree';
4
3
 
5
- export type ITreeMultisetNode<T, NEIGHBOR extends ITreeMultisetNode<T, NEIGHBOR>> = IBSTNode<T, NEIGHBOR>;
4
+ export interface ITreeMultisetNode<T, NEIGHBOR extends ITreeMultisetNode<T, NEIGHBOR>>
5
+ extends IAVLTreeNode<T, NEIGHBOR> {}
6
6
 
7
- export type ITreeMultiset<N extends TreeMultisetNode<N['val'], N>> = IAVLTree<N>;
7
+ export interface ITreeMultiset<N extends TreeMultisetNode<N['val'], N>> extends IAVLTree<N> {}
@@ -1,6 +1,3 @@
1
- import {VertexKey} from '../types';
2
1
  import {IAbstractGraph} from './abstract-graph';
3
2
 
4
- export interface IUNDirectedGraph<V, E> extends IAbstractGraph<V, E> {
5
- removeEdgeBetween(v1: V | VertexKey, v2: V | VertexKey): E | null;
6
- }
3
+ export interface IUNDirectedGraph<V, E> extends IAbstractGraph<V, E> {}
@@ -349,7 +349,7 @@ describe('DoublyLinkedList Performance Test', () => {
349
349
  for (let i = 0; i < magnitude.LINEAR; i++) {
350
350
  list.unshift(i);
351
351
  }
352
- expect(performance.now() - startPushTime).toBeLessThan(bigO.LINEAR * 10);
352
+ expect(performance.now() - startPushTime).toBeLessThan(bigO.LINEAR * 20);
353
353
 
354
354
  expect(list.length).toBeGreaterThan(0);
355
355
  const startPopTime = performance.now();