data-structure-typed 1.50.6 → 1.50.8

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 (57) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/README.md +27 -24
  3. package/benchmark/report.html +1 -37
  4. package/benchmark/report.json +17 -395
  5. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.d.ts +2 -2
  6. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js +6 -4
  7. package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js.map +1 -1
  8. package/dist/cjs/data-structures/binary-tree/avl-tree.js.map +1 -1
  9. package/dist/cjs/data-structures/binary-tree/binary-tree.d.ts +3 -3
  10. package/dist/cjs/data-structures/binary-tree/binary-tree.js +36 -33
  11. package/dist/cjs/data-structures/binary-tree/binary-tree.js.map +1 -1
  12. package/dist/cjs/data-structures/binary-tree/bst.d.ts +7 -5
  13. package/dist/cjs/data-structures/binary-tree/bst.js +68 -47
  14. package/dist/cjs/data-structures/binary-tree/bst.js.map +1 -1
  15. package/dist/cjs/data-structures/binary-tree/rb-tree.d.ts +2 -8
  16. package/dist/cjs/data-structures/binary-tree/rb-tree.js +7 -17
  17. package/dist/cjs/data-structures/binary-tree/rb-tree.js.map +1 -1
  18. package/dist/cjs/data-structures/binary-tree/tree-multi-map.d.ts +1 -2
  19. package/dist/cjs/data-structures/binary-tree/tree-multi-map.js +1 -1
  20. package/dist/cjs/data-structures/binary-tree/tree-multi-map.js.map +1 -1
  21. package/dist/cjs/types/common.d.ts +5 -22
  22. package/dist/cjs/types/common.js +0 -33
  23. package/dist/cjs/types/common.js.map +1 -1
  24. package/dist/mjs/data-structures/binary-tree/avl-tree-multi-map.d.ts +2 -2
  25. package/dist/mjs/data-structures/binary-tree/avl-tree-multi-map.js +6 -4
  26. package/dist/mjs/data-structures/binary-tree/binary-tree.d.ts +3 -3
  27. package/dist/mjs/data-structures/binary-tree/binary-tree.js +36 -33
  28. package/dist/mjs/data-structures/binary-tree/bst.d.ts +7 -5
  29. package/dist/mjs/data-structures/binary-tree/bst.js +68 -47
  30. package/dist/mjs/data-structures/binary-tree/rb-tree.d.ts +2 -8
  31. package/dist/mjs/data-structures/binary-tree/rb-tree.js +7 -17
  32. package/dist/mjs/data-structures/binary-tree/tree-multi-map.d.ts +1 -2
  33. package/dist/mjs/data-structures/binary-tree/tree-multi-map.js +2 -2
  34. package/dist/mjs/types/common.d.ts +5 -22
  35. package/dist/mjs/types/common.js +1 -32
  36. package/dist/umd/data-structure-typed.js +112 -138
  37. package/dist/umd/data-structure-typed.min.js +2 -2
  38. package/dist/umd/data-structure-typed.min.js.map +1 -1
  39. package/package.json +6 -6
  40. package/src/data-structures/binary-tree/avl-tree-multi-map.ts +8 -5
  41. package/src/data-structures/binary-tree/avl-tree.ts +1 -1
  42. package/src/data-structures/binary-tree/binary-tree.ts +35 -36
  43. package/src/data-structures/binary-tree/bst.ts +67 -44
  44. package/src/data-structures/binary-tree/rb-tree.ts +11 -22
  45. package/src/data-structures/binary-tree/tree-multi-map.ts +2 -2
  46. package/src/types/common.ts +6 -23
  47. package/test/integration/all-in-one.test.ts +2 -2
  48. package/test/integration/avl-tree.test.ts +1 -1
  49. package/test/integration/bst.test.ts +2 -2
  50. package/test/performance/data-structures/binary-tree/rb-tree.test.ts +13 -22
  51. package/test/unit/data-structures/binary-tree/avl-tree-multi-map.test.ts +12 -17
  52. package/test/unit/data-structures/binary-tree/avl-tree.test.ts +4 -4
  53. package/test/unit/data-structures/binary-tree/binary-tree.test.ts +118 -65
  54. package/test/unit/data-structures/binary-tree/bst.test.ts +12 -12
  55. package/test/unit/data-structures/binary-tree/overall.test.ts +7 -7
  56. package/test/unit/data-structures/binary-tree/rb-tree.test.ts +272 -267
  57. package/test/unit/data-structures/binary-tree/tree-multi-map.test.ts +249 -245
@@ -1,4 +1,3 @@
1
- import { BSTVariant, CP, IterationType } from '../../types';
2
1
  import { BinaryTree, BinaryTreeNode } from './binary-tree';
3
2
  import { Queue } from '../queue';
4
3
  export class BSTNode extends BinaryTreeNode {
@@ -86,7 +85,7 @@ export class BST extends BinaryTree {
86
85
  get root() {
87
86
  return this._root;
88
87
  }
89
- _variant = BSTVariant.STANDARD;
88
+ _variant = 'STANDARD';
90
89
  /**
91
90
  * The function returns the value of the _variant property.
92
91
  * @returns The value of the `_variant` property.
@@ -166,10 +165,10 @@ export class BST extends BinaryTree {
166
165
  * @param {K | NODE | undefined} keyOrNodeOrEntry - The `key` parameter can be of type `K`, `NODE`, or
167
166
  * `undefined`.
168
167
  * @param iterationType - The `iterationType` parameter is an optional parameter that specifies the
169
- * type of iteration to be performed. It has a default value of `IterationType.ITERATIVE`.
168
+ * type of iteration to be performed. It has a default value of `'ITERATIVE'`.
170
169
  * @returns either a node object (NODE) or undefined.
171
170
  */
172
- ensureNode(keyOrNodeOrEntry, iterationType = IterationType.ITERATIVE) {
171
+ ensureNode(keyOrNodeOrEntry, iterationType = 'ITERATIVE') {
173
172
  let res;
174
173
  if (this.isRealNode(keyOrNodeOrEntry)) {
175
174
  res = keyOrNodeOrEntry;
@@ -219,7 +218,7 @@ export class BST extends BinaryTree {
219
218
  }
220
219
  let current = this.root;
221
220
  while (current !== undefined) {
222
- if (this._compare(current.key, newNode.key) === CP.eq) {
221
+ if (this._compare(current.key, newNode.key) === 'EQ') {
223
222
  // if (current !== newNode) {
224
223
  // The key value is the same but the reference is different, update the value of the existing node
225
224
  this._replaceNode(current, newNode);
@@ -230,7 +229,7 @@ export class BST extends BinaryTree {
230
229
  // return;
231
230
  // }
232
231
  }
233
- else if (this._compare(current.key, newNode.key) === CP.gt) {
232
+ else if (this._compare(current.key, newNode.key) === 'GT') {
234
233
  if (current.left === undefined) {
235
234
  current.left = newNode;
236
235
  this._size++;
@@ -339,7 +338,7 @@ export class BST extends BinaryTree {
339
338
  }
340
339
  }
341
340
  };
342
- if (iterationType === IterationType.RECURSIVE) {
341
+ if (iterationType === 'RECURSIVE') {
343
342
  _dfs(sorted);
344
343
  }
345
344
  else {
@@ -365,18 +364,18 @@ export class BST extends BinaryTree {
365
364
  * @returns The function `getNodeByKey` returns a node (`NODE`) if a node with the specified key is
366
365
  * found in the binary tree. If no node is found, it returns `undefined`.
367
366
  */
368
- getNodeByKey(key, iterationType = IterationType.ITERATIVE) {
369
- if (!this.root)
367
+ getNodeByKey(key, iterationType = 'ITERATIVE') {
368
+ if (!this.isRealNode(this.root))
370
369
  return undefined;
371
- if (iterationType === IterationType.RECURSIVE) {
370
+ if (iterationType === 'RECURSIVE') {
372
371
  const _dfs = (cur) => {
373
372
  if (cur.key === key)
374
373
  return cur;
375
- if (!cur.left && !cur.right)
374
+ if (!this.isRealNode(cur.left) && !this.isRealNode(cur.right))
376
375
  return;
377
- if (this._compare(cur.key, key) === CP.gt && cur.left)
376
+ if (this._compare(cur.key, key) === 'GT' && this.isRealNode(cur.left))
378
377
  return _dfs(cur.left);
379
- if (this._compare(cur.key, key) === CP.lt && cur.right)
378
+ if (this._compare(cur.key, key) === 'LT' && this.isRealNode(cur.right))
380
379
  return _dfs(cur.right);
381
380
  };
382
381
  return _dfs(this.root);
@@ -385,13 +384,13 @@ export class BST extends BinaryTree {
385
384
  const queue = new Queue([this.root]);
386
385
  while (queue.size > 0) {
387
386
  const cur = queue.shift();
388
- if (cur) {
389
- if (this._compare(cur.key, key) === CP.eq)
387
+ if (this.isRealNode(cur)) {
388
+ if (this._compare(cur.key, key) === 'EQ')
390
389
  return cur;
391
- if (this._compare(cur.key, key) === CP.gt)
392
- cur.left && queue.push(cur.left);
393
- if (this._compare(cur.key, key) === CP.lt)
394
- cur.right && queue.push(cur.right);
390
+ if (this._compare(cur.key, key) === 'GT')
391
+ this.isRealNode(cur.left) && queue.push(cur.left);
392
+ if (this._compare(cur.key, key) === 'LT')
393
+ this.isRealNode(cur.right) && queue.push(cur.right);
395
394
  }
396
395
  }
397
396
  }
@@ -429,7 +428,7 @@ export class BST extends BinaryTree {
429
428
  if (!beginRoot)
430
429
  return [];
431
430
  const ans = [];
432
- if (iterationType === IterationType.RECURSIVE) {
431
+ if (iterationType === 'RECURSIVE') {
433
432
  const _traverse = (cur) => {
434
433
  const callbackResult = callback(cur);
435
434
  if (callbackResult === identifier) {
@@ -437,27 +436,27 @@ export class BST extends BinaryTree {
437
436
  if (onlyOne)
438
437
  return;
439
438
  }
440
- if (!cur.left && !cur.right)
439
+ if (!this.isRealNode(cur.left) && !this.isRealNode(cur.right))
441
440
  return;
442
441
  // TODO potential bug
443
442
  if (callback === this._defaultOneParamCallback) {
444
- if (this._compare(cur.key, identifier) === CP.gt)
445
- cur.left && _traverse(cur.left);
446
- if (this._compare(cur.key, identifier) === CP.lt)
447
- cur.right && _traverse(cur.right);
443
+ if (this.isRealNode(cur.left) && this._compare(cur.key, identifier) === 'GT')
444
+ _traverse(cur.left);
445
+ if (this.isRealNode(cur.right) && this._compare(cur.key, identifier) === 'LT')
446
+ _traverse(cur.right);
448
447
  }
449
448
  else {
450
- cur.left && _traverse(cur.left);
451
- cur.right && _traverse(cur.right);
449
+ this.isRealNode(cur.left) && _traverse(cur.left);
450
+ this.isRealNode(cur.right) && _traverse(cur.right);
452
451
  }
453
452
  };
454
453
  _traverse(beginRoot);
455
454
  }
456
455
  else {
457
- const queue = new Queue([beginRoot]);
458
- while (queue.size > 0) {
459
- const cur = queue.shift();
460
- if (cur) {
456
+ const stack = [beginRoot];
457
+ while (stack.length > 0) {
458
+ const cur = stack.pop();
459
+ if (this.isRealNode(cur)) {
461
460
  const callbackResult = callback(cur);
462
461
  if (callbackResult === identifier) {
463
462
  ans.push(cur);
@@ -466,14 +465,20 @@ export class BST extends BinaryTree {
466
465
  }
467
466
  // TODO potential bug
468
467
  if (callback === this._defaultOneParamCallback) {
469
- if (this._compare(cur.key, identifier) === CP.gt)
470
- cur.left && queue.push(cur.left);
471
- if (this._compare(cur.key, identifier) === CP.lt)
472
- cur.right && queue.push(cur.right);
468
+ if (this.isRealNode(cur.right) && this._compare(cur.key, identifier) === 'LT')
469
+ stack.push(cur.right);
470
+ if (this.isRealNode(cur.left) && this._compare(cur.key, identifier) === 'GT')
471
+ stack.push(cur.left);
472
+ // if (this.isRealNode(cur.right) && this._lt(cur.key, identifier as K)) stack.push(cur.right);
473
+ // if (this.isRealNode(cur.left) && this._gt(cur.key, identifier as K)) stack.push(cur.left);
474
+ // // @ts-ignore
475
+ // if (this.isRealNode(cur.right) && cur.key > identifier) stack.push(cur.right);
476
+ // // @ts-ignore
477
+ // if (this.isRealNode(cur.left) && cur.key < identifier) stack.push(cur.left);
473
478
  }
474
479
  else {
475
- cur.left && queue.push(cur.left);
476
- cur.right && queue.push(cur.right);
480
+ this.isRealNode(cur.right) && stack.push(cur.right);
481
+ this.isRealNode(cur.left) && stack.push(cur.left);
477
482
  }
478
483
  }
479
484
  }
@@ -503,7 +508,7 @@ export class BST extends BinaryTree {
503
508
  * following values:
504
509
  * @returns The method is returning an array of the return type of the callback function.
505
510
  */
506
- dfs(callback = this._defaultOneParamCallback, pattern = 'in', beginRoot = this.root, iterationType = IterationType.ITERATIVE) {
511
+ dfs(callback = this._defaultOneParamCallback, pattern = 'in', beginRoot = this.root, iterationType = 'ITERATIVE') {
507
512
  return super.dfs(callback, pattern, beginRoot, iterationType, false);
508
513
  }
509
514
  /**
@@ -576,7 +581,7 @@ export class BST extends BinaryTree {
576
581
  let current = this.ensureNode(beginRoot);
577
582
  if (!current)
578
583
  return undefined;
579
- if (this._variant === BSTVariant.STANDARD) {
584
+ if (this._variant === 'STANDARD') {
580
585
  // For BSTVariant.MIN, find the rightmost node
581
586
  while (current.right !== undefined) {
582
587
  current = current.right;
@@ -615,7 +620,7 @@ export class BST extends BinaryTree {
615
620
  * @returns The function `lesserOrGreaterTraverse` returns an array of values of type
616
621
  * `ReturnType<C>`, which is the return type of the callback function passed as an argument.
617
622
  */
618
- lesserOrGreaterTraverse(callback = this._defaultOneParamCallback, lesserOrGreater = CP.lt, targetNode = this.root, iterationType = this.iterationType) {
623
+ lesserOrGreaterTraverse(callback = this._defaultOneParamCallback, lesserOrGreater = 'LT', targetNode = this.root, iterationType = this.iterationType) {
619
624
  targetNode = this.ensureNode(targetNode);
620
625
  const ans = [];
621
626
  if (!targetNode)
@@ -623,7 +628,7 @@ export class BST extends BinaryTree {
623
628
  if (!this.root)
624
629
  return ans;
625
630
  const targetKey = targetNode.key;
626
- if (iterationType === IterationType.RECURSIVE) {
631
+ if (iterationType === 'RECURSIVE') {
627
632
  const _traverse = (cur) => {
628
633
  const compared = this._compare(cur.key, targetKey);
629
634
  if (compared === lesserOrGreater)
@@ -673,7 +678,7 @@ export class BST extends BinaryTree {
673
678
  this.clear();
674
679
  if (sorted.length < 1)
675
680
  return false;
676
- if (iterationType === IterationType.RECURSIVE) {
681
+ if (iterationType === 'RECURSIVE') {
677
682
  const buildBalanceBST = (l, r) => {
678
683
  if (l > r)
679
684
  return;
@@ -730,7 +735,7 @@ export class BST extends BinaryTree {
730
735
  if (!this.root)
731
736
  return true;
732
737
  let balanced = true;
733
- if (iterationType === IterationType.RECURSIVE) {
738
+ if (iterationType === 'RECURSIVE') {
734
739
  const _height = (cur) => {
735
740
  if (!cur)
736
741
  return 0;
@@ -787,13 +792,29 @@ export class BST extends BinaryTree {
787
792
  * is greater than, less than, or equal to the second value.
788
793
  * @param {K} a - The parameter "a" is of type K.
789
794
  * @param {K} b - The parameter "b" in the above code represents a K.
790
- * @returns a value of type CP (ComparisonResult). The possible return values are CP.gt (greater
791
- * than), CP.lt (less than), or CP.eq (equal).
795
+ * @returns a value of type CP (ComparisonResult). The possible return values are 'GT' (greater
796
+ * than), 'LT' (less than), or 'EQ' (equal).
792
797
  */
793
798
  _compare(a, b) {
794
799
  const extractedA = this.extractor(a);
795
800
  const extractedB = this.extractor(b);
796
- const compared = this.variant === BSTVariant.STANDARD ? extractedA - extractedB : extractedB - extractedA;
797
- return compared > 0 ? CP.gt : compared < 0 ? CP.lt : CP.eq;
801
+ const compared = this.variant === 'STANDARD' ? extractedA - extractedB : extractedB - extractedA;
802
+ return compared > 0 ? 'GT' : compared < 0 ? 'LT' : 'EQ';
803
+ }
804
+ _lt(a, b) {
805
+ const extractedA = this.extractor(a);
806
+ const extractedB = this.extractor(b);
807
+ // return this.variant === BSTVariant.STANDARD ? extractedA < extractedB : extractedA > extractedB;
808
+ return this.variant === 'STANDARD' ? extractedA < extractedB : extractedA > extractedB;
809
+ // return extractedA < extractedB;
810
+ // return a < b;
811
+ }
812
+ _gt(a, b) {
813
+ const extractedA = this.extractor(a);
814
+ const extractedB = this.extractor(b);
815
+ // return this.variant === BSTVariant.STANDARD ? extractedA > extractedB : extractedA < extractedB;
816
+ return this.variant === 'STANDARD' ? extractedA > extractedB : extractedA < extractedB;
817
+ // return extractedA > extractedB;
818
+ // return a > b;
798
819
  }
799
820
  }
@@ -1,5 +1,5 @@
1
1
  import type { BinaryTreeDeleteResult, BSTNKeyOrNode, BTNCallback, KeyOrNodeOrEntry, RBTreeOptions, RedBlackTreeNested, RedBlackTreeNodeNested } from '../../types';
2
- import { RBTNColor } from '../../types';
2
+ import { CRUD, RBTNColor } from '../../types';
3
3
  import { BST, BSTNode } from './bst';
4
4
  import { IBinaryTree } from '../../interfaces';
5
5
  export declare class RedBlackTreeNode<K = any, V = any, NODE extends RedBlackTreeNode<K, V, NODE> = RedBlackTreeNodeNested<K, V>> extends BSTNode<K, V, NODE> {
@@ -51,12 +51,6 @@ export declare class RedBlackTree<K = any, V = any, NODE extends RedBlackTreeNod
51
51
  * @returns The root node of the tree structure, or undefined if there is no root node.
52
52
  */
53
53
  get root(): NODE | undefined;
54
- protected _size: number;
55
- /**
56
- * The function returns the size of an object.
57
- * @returns The size of the object, which is a number.
58
- */
59
- get size(): number;
60
54
  /**
61
55
  * The function creates a new Red-Black Tree node with the specified key, value, and color.
62
56
  * @param {K} key - The key parameter represents the key of the node being created. It is of type K,
@@ -236,7 +230,7 @@ export declare class RedBlackTree<K = any, V = any, NODE extends RedBlackTreeNod
236
230
  * node in the tree.
237
231
  * @returns {'inserted' | 'updated'} - The result of the insertion.
238
232
  */
239
- protected _insert(node: NODE): 'inserted' | 'updated';
233
+ protected _insert(node: NODE): CRUD;
240
234
  /**
241
235
  * Time Complexity: O(1)
242
236
  * Space Complexity: O(1)
@@ -66,14 +66,6 @@ export class RedBlackTree extends BST {
66
66
  get root() {
67
67
  return this._root;
68
68
  }
69
- _size = 0;
70
- /**
71
- * The function returns the size of an object.
72
- * @returns The size of the object, which is a number.
73
- */
74
- get size() {
75
- return this._size;
76
- }
77
69
  /**
78
70
  * The function creates a new Red-Black Tree node with the specified key, value, and color.
79
71
  * @param {K} key - The key parameter represents the key of the node being created. It is of type K,
@@ -171,7 +163,7 @@ export class RedBlackTree extends BST {
171
163
  * @returns a boolean value.
172
164
  */
173
165
  isRealNode(node) {
174
- if (node === this._SENTINEL || node === undefined)
166
+ if (node === this.SENTINEL || node === undefined)
175
167
  return false;
176
168
  return node instanceof RedBlackTreeNode;
177
169
  }
@@ -201,9 +193,7 @@ export class RedBlackTree extends BST {
201
193
  * @returns The method is returning a value of type `NODE | null | undefined`.
202
194
  */
203
195
  getNode(identifier, callback = this._defaultOneParamCallback, beginRoot = this.root, iterationType = this.iterationType) {
204
- if (identifier instanceof RedBlackTreeNode)
205
- callback = (node => node);
206
- beginRoot = this.ensureNode(beginRoot);
196
+ // if ((identifier as any) instanceof RedBlackTreeNode) callback = (node => node) as C;
207
197
  return this.getNodes(identifier, callback, true, beginRoot, iterationType)[0] ?? undefined;
208
198
  }
209
199
  /**
@@ -218,8 +208,8 @@ export class RedBlackTree extends BST {
218
208
  * size counter to zero.
219
209
  */
220
210
  clear() {
211
+ super.clear();
221
212
  this._root = this.SENTINEL;
222
- this._size = 0;
223
213
  }
224
214
  /**
225
215
  * Time Complexity: O(log n)
@@ -243,7 +233,7 @@ export class RedBlackTree extends BST {
243
233
  if (!this.isRealNode(newNode))
244
234
  return false;
245
235
  const insertStatus = this._insert(newNode);
246
- if (insertStatus === 'inserted') {
236
+ if (insertStatus === 'CREATED') {
247
237
  // Ensure the root is black
248
238
  if (this.isRealNode(this._root)) {
249
239
  this._root.color = RBTNColor.BLACK;
@@ -255,7 +245,7 @@ export class RedBlackTree extends BST {
255
245
  return true;
256
246
  }
257
247
  else
258
- return insertStatus === 'updated';
248
+ return insertStatus === 'UPDATED';
259
249
  }
260
250
  /**
261
251
  * Time Complexity: O(log n)
@@ -387,7 +377,7 @@ export class RedBlackTree extends BST {
387
377
  }
388
378
  else {
389
379
  this._replaceNode(current, node);
390
- return 'updated';
380
+ return 'UPDATED';
391
381
  }
392
382
  }
393
383
  node.parent = parent;
@@ -404,7 +394,7 @@ export class RedBlackTree extends BST {
404
394
  node.right = this.SENTINEL;
405
395
  node.color = RBTNColor.RED;
406
396
  this._insertFixup(node);
407
- return 'inserted';
397
+ return 'CREATED';
408
398
  }
409
399
  /**
410
400
  * Time Complexity: O(1)
@@ -6,7 +6,6 @@
6
6
  * @license MIT License
7
7
  */
8
8
  import type { BinaryTreeDeleteResult, BSTNKeyOrNode, BTNCallback, KeyOrNodeOrEntry, TreeMultiMapNested, TreeMultiMapNodeNested, TreeMultiMapOptions } from '../../types';
9
- import { IterationType } from '../../types';
10
9
  import { IBinaryTree } from '../../interfaces';
11
10
  import { RedBlackTree, RedBlackTreeNode } from './rb-tree';
12
11
  export declare class TreeMultiMapNode<K = any, V = any, NODE extends TreeMultiMapNode<K, V, NODE> = TreeMultiMapNodeNested<K, V>> extends RedBlackTreeNode<K, V, NODE> {
@@ -164,7 +163,7 @@ export declare class TreeMultiMap<K = any, V = any, NODE extends TreeMultiMapNod
164
163
  * values:
165
164
  * @returns a boolean value.
166
165
  */
167
- perfectlyBalance(iterationType?: IterationType): boolean;
166
+ perfectlyBalance(iterationType?: import("../../types").IterationType): boolean;
168
167
  /**
169
168
  * Time complexity: O(n)
170
169
  * Space complexity: O(n)
@@ -1,4 +1,4 @@
1
- import { IterationType, RBTNColor } from '../../types';
1
+ import { RBTNColor } from '../../types';
2
2
  import { RedBlackTree, RedBlackTreeNode } from './rb-tree';
3
3
  export class TreeMultiMapNode extends RedBlackTreeNode {
4
4
  /**
@@ -311,7 +311,7 @@ export class TreeMultiMap extends RedBlackTree {
311
311
  if (sorted.length < 1)
312
312
  return false;
313
313
  this.clear();
314
- if (iterationType === IterationType.RECURSIVE) {
314
+ if (iterationType === 'RECURSIVE') {
315
315
  const buildBalanceBST = (l, r) => {
316
316
  if (l > r)
317
317
  return;
@@ -1,31 +1,13 @@
1
- export declare enum BSTVariant {
2
- STANDARD = "STANDARD",
3
- INVERSE = "INVERSE"
4
- }
5
- export declare enum CP {
6
- lt = "lt",
7
- eq = "eq",
8
- gt = "gt"
9
- }
1
+ export type BSTVariant = 'STANDARD' | 'INVERSE';
2
+ export type CP = 'LT' | 'EQ' | 'GT';
10
3
  /**
11
4
  * Enum representing different loop types.
12
5
  *
13
6
  * - `iterative`: Indicates the iterative loop type (with loops that use iterations).
14
7
  * - `recursive`: Indicates the recursive loop type (with loops that call themselves).
15
8
  */
16
- export declare enum IterationType {
17
- ITERATIVE = "ITERATIVE",
18
- RECURSIVE = "RECURSIVE"
19
- }
20
- export declare enum FamilyPosition {
21
- ROOT = "ROOT",
22
- LEFT = "LEFT",
23
- RIGHT = "RIGHT",
24
- ROOT_LEFT = "ROOT_LEFT",
25
- ROOT_RIGHT = "ROOT_RIGHT",
26
- ISOLATED = "ISOLATED",
27
- MAL_NODE = "MAL_NODE"
28
- }
9
+ export type IterationType = 'ITERATIVE' | 'RECURSIVE';
10
+ export type FamilyPosition = 'ROOT' | 'LEFT' | 'RIGHT' | 'ROOT_LEFT' | 'ROOT_RIGHT' | 'ISOLATED' | 'MAL_NODE';
29
11
  export type Comparator<K> = (a: K, b: K) => number;
30
12
  export type DFSOrderPattern = 'pre' | 'in' | 'post';
31
13
  export type NodeDisplayLayout = [string[], number, number, number];
@@ -52,3 +34,4 @@ export type BinaryTreeDeleteResult<N> = {
52
34
  deleted: N | null | undefined;
53
35
  needBalanced: N | null | undefined;
54
36
  };
37
+ export type CRUD = 'CREATED' | 'READ' | 'UPDATED' | 'DELETED';
@@ -1,32 +1 @@
1
- export var BSTVariant;
2
- (function (BSTVariant) {
3
- BSTVariant["STANDARD"] = "STANDARD";
4
- BSTVariant["INVERSE"] = "INVERSE";
5
- })(BSTVariant || (BSTVariant = {}));
6
- export var CP;
7
- (function (CP) {
8
- CP["lt"] = "lt";
9
- CP["eq"] = "eq";
10
- CP["gt"] = "gt";
11
- })(CP || (CP = {}));
12
- /**
13
- * Enum representing different loop types.
14
- *
15
- * - `iterative`: Indicates the iterative loop type (with loops that use iterations).
16
- * - `recursive`: Indicates the recursive loop type (with loops that call themselves).
17
- */
18
- export var IterationType;
19
- (function (IterationType) {
20
- IterationType["ITERATIVE"] = "ITERATIVE";
21
- IterationType["RECURSIVE"] = "RECURSIVE";
22
- })(IterationType || (IterationType = {}));
23
- export var FamilyPosition;
24
- (function (FamilyPosition) {
25
- FamilyPosition["ROOT"] = "ROOT";
26
- FamilyPosition["LEFT"] = "LEFT";
27
- FamilyPosition["RIGHT"] = "RIGHT";
28
- FamilyPosition["ROOT_LEFT"] = "ROOT_LEFT";
29
- FamilyPosition["ROOT_RIGHT"] = "ROOT_RIGHT";
30
- FamilyPosition["ISOLATED"] = "ISOLATED";
31
- FamilyPosition["MAL_NODE"] = "MAL_NODE";
32
- })(FamilyPosition || (FamilyPosition = {}));
1
+ export {};