data-structure-typed 1.18.5 → 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.
Files changed (156) hide show
  1. package/dist/data-structures/binary-tree/abstract-binary-tree.d.ts +357 -0
  2. package/dist/data-structures/binary-tree/abstract-binary-tree.js +1480 -0
  3. package/dist/data-structures/binary-tree/avl-tree.d.ts +8 -6
  4. package/dist/data-structures/binary-tree/avl-tree.js +7 -5
  5. package/dist/data-structures/binary-tree/binary-tree.d.ts +19 -337
  6. package/dist/data-structures/binary-tree/binary-tree.js +40 -1441
  7. package/dist/data-structures/binary-tree/bst.d.ts +31 -17
  8. package/dist/data-structures/binary-tree/bst.js +57 -40
  9. package/dist/data-structures/binary-tree/index.d.ts +1 -0
  10. package/dist/data-structures/binary-tree/index.js +1 -0
  11. package/dist/data-structures/binary-tree/rb-tree.d.ts +30 -1
  12. package/dist/data-structures/binary-tree/rb-tree.js +29 -20
  13. package/dist/data-structures/binary-tree/tree-multiset.d.ts +21 -25
  14. package/dist/data-structures/binary-tree/tree-multiset.js +40 -31
  15. package/dist/data-structures/graph/abstract-graph.d.ts +20 -21
  16. package/dist/data-structures/graph/abstract-graph.js +24 -19
  17. package/dist/data-structures/graph/directed-graph.d.ts +12 -13
  18. package/dist/data-structures/graph/directed-graph.js +21 -25
  19. package/dist/data-structures/graph/undirected-graph.d.ts +15 -19
  20. package/dist/data-structures/graph/undirected-graph.js +16 -29
  21. package/dist/data-structures/interfaces/abstract-binary-tree.d.ts +101 -0
  22. package/dist/data-structures/interfaces/abstract-binary-tree.js +2 -0
  23. package/dist/data-structures/interfaces/abstract-graph.d.ts +1 -4
  24. package/dist/data-structures/interfaces/avl-tree.d.ts +16 -1
  25. package/dist/data-structures/interfaces/binary-tree.d.ts +4 -25
  26. package/dist/data-structures/interfaces/bst.d.ts +18 -1
  27. package/dist/data-structures/interfaces/directed-graph.d.ts +4 -1
  28. package/dist/data-structures/interfaces/index.d.ts +1 -1
  29. package/dist/data-structures/interfaces/index.js +1 -1
  30. package/dist/data-structures/interfaces/rb-tree.d.ts +9 -0
  31. package/dist/data-structures/interfaces/rb-tree.js +2 -0
  32. package/dist/data-structures/interfaces/undirected-graph.d.ts +4 -1
  33. package/dist/data-structures/types/abstract-binary-tree.d.ts +32 -0
  34. package/dist/data-structures/types/abstract-binary-tree.js +21 -0
  35. package/dist/data-structures/types/avl-tree.d.ts +2 -4
  36. package/dist/data-structures/types/binary-tree.d.ts +2 -10
  37. package/dist/data-structures/types/bst.d.ts +10 -5
  38. package/dist/data-structures/types/bst.js +7 -0
  39. package/dist/data-structures/types/helpers.d.ts +8 -0
  40. package/dist/data-structures/types/helpers.js +2 -0
  41. package/dist/data-structures/types/index.d.ts +3 -0
  42. package/dist/data-structures/types/index.js +3 -0
  43. package/dist/data-structures/types/rb-tree.d.ts +6 -0
  44. package/dist/data-structures/types/rb-tree.js +8 -0
  45. package/dist/data-structures/types/tree-multiset.d.ts +5 -3
  46. package/dist/utils/utils.js +62 -0
  47. package/docs/assets/search.js +1 -1
  48. package/docs/classes/AVLTree.html +316 -204
  49. package/docs/classes/AVLTreeNode.html +141 -81
  50. package/docs/classes/AaTree.html +27 -10
  51. package/docs/classes/AbstractBinaryTree.html +2118 -0
  52. package/docs/classes/AbstractBinaryTreeNode.html +524 -0
  53. package/docs/classes/AbstractEdge.html +37 -20
  54. package/docs/classes/AbstractGraph.html +152 -144
  55. package/docs/classes/AbstractVertex.html +34 -17
  56. package/docs/classes/ArrayDeque.html +40 -23
  57. package/docs/classes/BST.html +294 -187
  58. package/docs/classes/BSTNode.html +144 -82
  59. package/docs/classes/BTree.html +27 -10
  60. package/docs/classes/BinaryIndexedTree.html +35 -18
  61. package/docs/classes/BinaryTree.html +597 -500
  62. package/docs/classes/BinaryTreeNode.html +189 -168
  63. package/docs/classes/Character.html +30 -13
  64. package/docs/classes/CoordinateMap.html +35 -18
  65. package/docs/classes/CoordinateSet.html +34 -17
  66. package/docs/classes/Deque.html +60 -43
  67. package/docs/classes/DirectedEdge.html +41 -24
  68. package/docs/classes/DirectedGraph.html +208 -247
  69. package/docs/classes/DirectedVertex.html +32 -15
  70. package/docs/classes/DoublyLinkedList.html +63 -46
  71. package/docs/classes/DoublyLinkedListNode.html +37 -20
  72. package/docs/classes/HashTable.html +27 -10
  73. package/docs/classes/Heap.html +41 -24
  74. package/docs/classes/HeapItem.html +34 -17
  75. package/docs/classes/Matrix2D.html +42 -25
  76. package/docs/classes/MatrixNTI2D.html +30 -13
  77. package/docs/classes/MaxHeap.html +41 -24
  78. package/docs/classes/MaxPriorityQueue.html +60 -43
  79. package/docs/classes/MinHeap.html +41 -24
  80. package/docs/classes/MinPriorityQueue.html +60 -43
  81. package/docs/classes/Navigator.html +36 -19
  82. package/docs/classes/ObjectDeque.html +51 -34
  83. package/docs/classes/Pair.html +27 -10
  84. package/docs/classes/PriorityQueue.html +58 -41
  85. package/docs/classes/Queue.html +40 -23
  86. package/docs/classes/RBTree.html +2388 -0
  87. package/docs/classes/RBTreeNode.html +516 -0
  88. package/docs/classes/SegmentTree.html +43 -26
  89. package/docs/classes/SegmentTreeNode.html +46 -29
  90. package/docs/classes/SinglyLinkedList.html +60 -43
  91. package/docs/classes/SinglyLinkedListNode.html +34 -17
  92. package/docs/classes/SkipLinkedList.html +27 -10
  93. package/docs/classes/SplayTree.html +27 -10
  94. package/docs/classes/Stack.html +38 -21
  95. package/docs/classes/TreeMap.html +27 -10
  96. package/docs/classes/TreeMultiSet.html +332 -224
  97. package/docs/classes/TreeMultiSetNode.html +499 -0
  98. package/docs/classes/TreeNode.html +42 -25
  99. package/docs/classes/TreeSet.html +27 -10
  100. package/docs/classes/Trie.html +39 -22
  101. package/docs/classes/TrieNode.html +37 -20
  102. package/docs/classes/TwoThreeTree.html +27 -10
  103. package/docs/classes/UndirectedEdge.html +38 -21
  104. package/docs/classes/UndirectedGraph.html +179 -227
  105. package/docs/classes/UndirectedVertex.html +32 -15
  106. package/docs/classes/Vector2D.html +54 -37
  107. package/docs/enums/CP.html +33 -16
  108. package/docs/enums/FamilyPosition.html +45 -28
  109. package/docs/enums/LoopType.html +39 -22
  110. package/docs/{interfaces/IBinaryTree.html → enums/RBColor.html} +51 -54
  111. package/docs/enums/TopologicalProperty.html +30 -13
  112. package/docs/index.html +26 -9
  113. package/docs/interfaces/IAVLTree.html +1378 -0
  114. package/docs/interfaces/IAVLTreeNode.html +405 -0
  115. package/docs/interfaces/IAbstractBinaryTree.html +1124 -0
  116. package/docs/interfaces/{IBinaryTreeNode.html → IAbstractBinaryTreeNode.html} +76 -75
  117. package/docs/interfaces/{IGraph.html → IAbstractGraph.html} +67 -94
  118. package/docs/interfaces/IBST.html +1271 -0
  119. package/docs/interfaces/IBSTNode.html +408 -0
  120. package/docs/interfaces/IDirectedGraph.html +344 -20
  121. package/docs/interfaces/IUNDirectedGraph.html +337 -12
  122. package/docs/modules.html +52 -18
  123. package/docs/types/{AVLTreeDeleted.html → AVLTreeOptions.html} +32 -24
  124. package/docs/types/{ResultsByProperty.html → AbstractBinaryTreeNodeProperties.html} +32 -15
  125. package/docs/types/AbstractBinaryTreeNodeProperty.html +152 -0
  126. package/docs/types/AbstractBinaryTreeOptions.html +156 -0
  127. package/docs/types/AbstractRecursiveBinaryTreeNode.html +152 -0
  128. package/docs/types/BSTComparator.html +27 -10
  129. package/docs/types/{TreeMultiSetDeletedResult.html → BSTOptions.html} +32 -22
  130. package/docs/types/BinaryTreeDeletedResult.html +159 -0
  131. package/docs/types/BinaryTreeNodeId.html +27 -10
  132. package/docs/types/BinaryTreeNodePropertyName.html +27 -10
  133. package/docs/types/{BinaryTreeDeleted.html → BinaryTreeOptions.html} +32 -24
  134. package/docs/types/DFSOrderPattern.html +27 -10
  135. package/docs/types/DijkstraResult.html +27 -10
  136. package/docs/types/Direction.html +27 -10
  137. package/docs/types/EdgeId.html +27 -10
  138. package/docs/types/HeapOptions.html +27 -10
  139. package/docs/types/IdObject.html +157 -0
  140. package/docs/types/{ResultByProperty.html → KeyValObject.html} +36 -19
  141. package/docs/types/NavigatorParams.html +27 -10
  142. package/docs/types/NodeOrPropertyName.html +27 -10
  143. package/docs/types/PriorityQueueComparator.html +27 -10
  144. package/docs/types/PriorityQueueDFSOrderPattern.html +27 -10
  145. package/docs/types/PriorityQueueOptions.html +27 -10
  146. package/docs/types/{BSTDeletedResult.html → RBTreeOptions.html} +32 -24
  147. package/docs/types/RecursiveAVLTreeNode.html +27 -10
  148. package/docs/types/RecursiveBSTNode.html +27 -10
  149. package/docs/types/RecursiveBinaryTreeNode.html +27 -10
  150. package/docs/types/RecursiveTreeMultiSetNode.html +152 -0
  151. package/docs/types/SegmentTreeNodeVal.html +27 -10
  152. package/docs/types/TopologicalStatus.html +27 -10
  153. package/docs/types/TreeMultiSetOptions.html +152 -0
  154. package/docs/types/Turning.html +27 -10
  155. package/docs/types/VertexId.html +27 -10
  156. package/package.json +2 -2
@@ -1,27 +1,6 @@
1
- import { BinaryTreeNodeId } from '../types';
2
- import { FamilyPosition } from '../binary-tree';
3
- export interface IBinaryTreeNode<T, FAMILY extends IBinaryTreeNode<T, FAMILY>> {
4
- _createNode(id: BinaryTreeNodeId, val: T | null, count?: number): FAMILY | null;
5
- get id(): BinaryTreeNodeId;
6
- set id(v: BinaryTreeNodeId);
7
- get val(): T;
8
- set val(v: T);
9
- get left(): FAMILY | null | undefined;
10
- set left(v: FAMILY | null | undefined);
11
- get right(): FAMILY | null | undefined;
12
- set right(v: FAMILY | null | undefined);
13
- get parent(): FAMILY | null | undefined;
14
- set parent(v: FAMILY | null | undefined);
15
- get familyPosition(): FamilyPosition;
16
- set familyPosition(v: FamilyPosition);
17
- get count(): number;
18
- set count(v: number);
19
- get height(): number;
20
- set height(v: number);
21
- _createNode(id: BinaryTreeNodeId, val: T | null, count?: number): FAMILY | null;
22
- swapLocation(swapNode: FAMILY): FAMILY;
23
- 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> {
24
4
  }
25
- export interface IBinaryTree<N extends IBinaryTreeNode<N['val'], N>> {
26
- _createNode(id: BinaryTreeNodeId, val: N['val'] | null, count?: number): N | null;
5
+ export interface IBinaryTree<N extends BinaryTreeNode<N['val'], N>> extends IAbstractBinaryTree<N> {
27
6
  }
@@ -1 +1,18 @@
1
- export {};
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
- export interface IDirectedGraph<V, E> {
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
  }
@@ -1,4 +1,4 @@
1
- export * from './binary-tree';
1
+ export * from './abstract-binary-tree';
2
2
  export * from './bst';
3
3
  export * from './avl-tree';
4
4
  export * from './segment-tree';
@@ -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
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,2 +1,5 @@
1
- export interface IUNDirectedGraph<V, E> {
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
  }
@@ -0,0 +1,32 @@
1
+ import { AbstractBinaryTreeNode } from '../binary-tree';
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 = 0,
14
+ LEFT = 1,
15
+ RIGHT = 2
16
+ }
17
+ export type BinaryTreeNodePropertyName = 'id' | 'val' | 'count';
18
+ export type NodeOrPropertyName = 'node' | BinaryTreeNodePropertyName;
19
+ export type DFSOrderPattern = 'in' | 'pre' | 'post';
20
+ export type BinaryTreeNodeId = number;
21
+ export type BinaryTreeDeletedResult<N> = {
22
+ deleted: N | null | undefined;
23
+ needBalanced: N | null;
24
+ };
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
+ 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
+ export type AbstractBinaryTreeOptions = {
29
+ loopType?: LoopType;
30
+ autoIncrementId?: boolean;
31
+ isDuplicatedVal?: boolean;
32
+ };
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FamilyPosition = exports.LoopType = void 0;
4
+ /**
5
+ * Enum representing different loop types.
6
+ *
7
+ * - `iterative`: Indicates the iterative loop type (with loops that use iterations).
8
+ * - `recursive`: Indicates the recursive loop type (with loops that call themselves).
9
+ */
10
+ var LoopType;
11
+ (function (LoopType) {
12
+ LoopType["ITERATIVE"] = "ITERATIVE";
13
+ LoopType["RECURSIVE"] = "RECURSIVE";
14
+ })(LoopType || (exports.LoopType = LoopType = {}));
15
+ /* This enumeration defines the position of a node within a family tree composed of three associated nodes, where 'root' represents the root node of the family tree, 'left' represents the left child node, and 'right' represents the right child node. */
16
+ var FamilyPosition;
17
+ (function (FamilyPosition) {
18
+ FamilyPosition[FamilyPosition["ROOT"] = 0] = "ROOT";
19
+ FamilyPosition[FamilyPosition["LEFT"] = 1] = "LEFT";
20
+ FamilyPosition[FamilyPosition["RIGHT"] = 2] = "RIGHT";
21
+ })(FamilyPosition || (exports.FamilyPosition = FamilyPosition = {}));
@@ -1,6 +1,4 @@
1
1
  import { AVLTreeNode } from '../binary-tree';
2
- export type AVLTreeDeleted<N> = {
3
- deleted: N | null;
4
- needBalanced: N | null;
5
- };
2
+ import { BSTOptions } from './bst';
6
3
  export type RecursiveAVLTreeNode<T> = AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
4
+ export type AVLTreeOptions = BSTOptions & {};
@@ -1,12 +1,4 @@
1
1
  import { BinaryTreeNode } from '../binary-tree';
2
- export type BinaryTreeNodePropertyName = 'id' | 'val' | 'count';
3
- export type NodeOrPropertyName = 'node' | BinaryTreeNodePropertyName;
4
- export type DFSOrderPattern = 'in' | 'pre' | 'post';
5
- export type BinaryTreeNodeId = number;
6
- export type BinaryTreeDeleted<N> = {
7
- deleted: N | null | undefined;
8
- needBalanced: N | null;
9
- };
10
- export type ResultByProperty<N extends BinaryTreeNode<N['val'], N>> = N['val'] | N | number | BinaryTreeNodeId;
11
- export type ResultsByProperty<N extends BinaryTreeNode<N['val'], N>> = ResultByProperty<N>[];
2
+ import { AbstractBinaryTreeOptions } from './abstract-binary-tree';
12
3
  export type RecursiveBinaryTreeNode<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 = AbstractBinaryTreeOptions & {};
@@ -1,8 +1,13 @@
1
1
  import { BSTNode } from '../binary-tree';
2
- import type { BinaryTreeNodeId } from './binary-tree';
2
+ import type { BinaryTreeOptions } from './binary-tree';
3
+ import { BinaryTreeNodeId } from './abstract-binary-tree';
3
4
  export type BSTComparator = (a: BinaryTreeNodeId, b: BinaryTreeNodeId) => number;
4
- export type BSTDeletedResult<N extends BSTNode<N['val'], N>> = {
5
- deleted: N | null;
6
- needBalanced: N | null;
7
- };
8
5
  export type RecursiveBSTNode<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, BSTNode<T, BSTNode<T, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
6
+ export type BSTOptions = BinaryTreeOptions & {
7
+ comparator?: BSTComparator;
8
+ };
9
+ export declare enum CP {
10
+ lt = "lt",
11
+ eq = "eq",
12
+ gt = "gt"
13
+ }
@@ -1,2 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CP = void 0;
4
+ var CP;
5
+ (function (CP) {
6
+ CP["lt"] = "lt";
7
+ CP["eq"] = "eq";
8
+ CP["gt"] = "gt";
9
+ })(CP || (exports.CP = CP = {}));
@@ -0,0 +1,8 @@
1
+ export type IdObject = {
2
+ id: number;
3
+ } & {
4
+ [key: string]: any;
5
+ };
6
+ export type KeyValObject = {
7
+ [key: string]: any;
8
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -4,9 +4,12 @@ export * from './avl-tree';
4
4
  export * from './segment-tree';
5
5
  export * from './tree-multiset';
6
6
  export * from './abstract-graph';
7
+ export * from './abstract-binary-tree';
8
+ export * from './rb-tree';
7
9
  export * from './directed-graph';
8
10
  export * from './priority-queue';
9
11
  export * from './heap';
10
12
  export * from './singly-linked-list';
11
13
  export * from './doubly-linked-list';
12
14
  export * from './navigator';
15
+ export * from './helpers';
@@ -20,9 +20,12 @@ __exportStar(require("./avl-tree"), exports);
20
20
  __exportStar(require("./segment-tree"), exports);
21
21
  __exportStar(require("./tree-multiset"), exports);
22
22
  __exportStar(require("./abstract-graph"), exports);
23
+ __exportStar(require("./abstract-binary-tree"), exports);
24
+ __exportStar(require("./rb-tree"), exports);
23
25
  __exportStar(require("./directed-graph"), exports);
24
26
  __exportStar(require("./priority-queue"), exports);
25
27
  __exportStar(require("./heap"), exports);
26
28
  __exportStar(require("./singly-linked-list"), exports);
27
29
  __exportStar(require("./doubly-linked-list"), exports);
28
30
  __exportStar(require("./navigator"), exports);
31
+ __exportStar(require("./helpers"), exports);
@@ -0,0 +1,6 @@
1
+ import { BinaryTreeOptions } from './binary-tree';
2
+ export declare enum RBColor {
3
+ RED = "RED",
4
+ BLACK = "BLACK"
5
+ }
6
+ export type RBTreeOptions = BinaryTreeOptions & {};
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RBColor = void 0;
4
+ var RBColor;
5
+ (function (RBColor) {
6
+ RBColor["RED"] = "RED";
7
+ RBColor["BLACK"] = "BLACK";
8
+ })(RBColor || (exports.RBColor = RBColor = {}));
@@ -1,4 +1,6 @@
1
- export type TreeMultiSetDeletedResult<N> = {
2
- deleted: N | null;
3
- needBalanced: N | null;
1
+ import { BSTOptions } from './bst';
2
+ import { TreeMultiSetNode } from '../binary-tree';
3
+ export type RecursiveTreeMultiSetNode<T> = TreeMultiSetNode<T, TreeMultiSetNode<T, TreeMultiSetNode<T, TreeMultiSetNode<T, TreeMultiSetNode<T, TreeMultiSetNode<T, TreeMultiSetNode<T, TreeMultiSetNode<T, TreeMultiSetNode<T, TreeMultiSetNode<T, TreeMultiSetNode<T, TreeMultiSetNode<T, TreeMultiSetNode<T, TreeMultiSetNode<T, TreeMultiSetNode<T, TreeMultiSetNode<T, TreeMultiSetNode<T, TreeMultiSetNode<T, TreeMultiSetNode<T, TreeMultiSetNode<T, TreeMultiSetNode<T, TreeMultiSetNode<T, TreeMultiSetNode<T, TreeMultiSetNode<T, TreeMultiSetNode<T, TreeMultiSetNode<T, TreeMultiSetNode<T, TreeMultiSetNode<T, TreeMultiSetNode<T, TreeMultiSetNode<T, TreeMultiSetNode<T, TreeMultiSetNode<T, TreeMultiSetNode<T, TreeMultiSetNode<T, TreeMultiSetNode<T, TreeMultiSetNode<T, TreeMultiSetNode<T, TreeMultiSetNode<T, TreeMultiSetNode<T, TreeMultiSetNode<T, TreeMultiSetNode<T, TreeMultiSetNode<T, TreeMultiSetNode<T, TreeMultiSetNode<T, TreeMultiSetNode<T, TreeMultiSetNode<T, TreeMultiSetNode<T, TreeMultiSetNode<T, TreeMultiSetNode<T, TreeMultiSetNode<T, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
4
+ export type TreeMultiSetOptions = Omit<BSTOptions, 'isDuplicatedVal'> & {
5
+ isDuplicatedVal: true;
4
6
  };
@@ -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
+ // }