deque-typed 1.52.5 → 1.52.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 (77) hide show
  1. package/dist/constants/index.d.ts +4 -0
  2. package/dist/constants/index.js +8 -0
  3. package/dist/data-structures/base/iterable-element-base.d.ts +8 -1
  4. package/dist/data-structures/base/iterable-element-base.js +10 -1
  5. package/dist/data-structures/base/iterable-entry-base.d.ts +8 -1
  6. package/dist/data-structures/base/iterable-entry-base.js +10 -10
  7. package/dist/data-structures/binary-tree/avl-tree-multi-map.d.ts +31 -32
  8. package/dist/data-structures/binary-tree/avl-tree-multi-map.js +43 -44
  9. package/dist/data-structures/binary-tree/avl-tree.d.ts +23 -24
  10. package/dist/data-structures/binary-tree/avl-tree.js +71 -64
  11. package/dist/data-structures/binary-tree/binary-indexed-tree.js +2 -2
  12. package/dist/data-structures/binary-tree/binary-tree.d.ts +534 -402
  13. package/dist/data-structures/binary-tree/binary-tree.js +669 -598
  14. package/dist/data-structures/binary-tree/bst.d.ts +72 -65
  15. package/dist/data-structures/binary-tree/bst.js +115 -113
  16. package/dist/data-structures/binary-tree/rb-tree.d.ts +21 -24
  17. package/dist/data-structures/binary-tree/rb-tree.js +40 -39
  18. package/dist/data-structures/binary-tree/segment-tree.d.ts +2 -2
  19. package/dist/data-structures/binary-tree/segment-tree.js +2 -2
  20. package/dist/data-structures/binary-tree/tree-multi-map.d.ts +28 -31
  21. package/dist/data-structures/binary-tree/tree-multi-map.js +44 -43
  22. package/dist/data-structures/graph/abstract-graph.d.ts +2 -2
  23. package/dist/data-structures/graph/abstract-graph.js +7 -4
  24. package/dist/data-structures/graph/directed-graph.d.ts +2 -2
  25. package/dist/data-structures/graph/directed-graph.js +4 -2
  26. package/dist/data-structures/graph/undirected-graph.d.ts +2 -2
  27. package/dist/data-structures/hash/hash-map.d.ts +2 -2
  28. package/dist/data-structures/hash/hash-map.js +1 -1
  29. package/dist/data-structures/heap/heap.js +3 -3
  30. package/dist/data-structures/linked-list/doubly-linked-list.d.ts +2 -2
  31. package/dist/data-structures/linked-list/doubly-linked-list.js +7 -7
  32. package/dist/data-structures/linked-list/singly-linked-list.d.ts +2 -2
  33. package/dist/data-structures/linked-list/singly-linked-list.js +6 -6
  34. package/dist/data-structures/linked-list/skip-linked-list.d.ts +2 -2
  35. package/dist/data-structures/matrix/matrix.d.ts +2 -2
  36. package/dist/data-structures/matrix/navigator.d.ts +2 -2
  37. package/dist/data-structures/matrix/navigator.js +4 -2
  38. package/dist/data-structures/queue/deque.d.ts +3 -3
  39. package/dist/data-structures/queue/deque.js +29 -29
  40. package/dist/data-structures/queue/queue.d.ts +1 -1
  41. package/dist/data-structures/stack/stack.d.ts +2 -2
  42. package/dist/data-structures/trie/trie.d.ts +2 -2
  43. package/dist/data-structures/trie/trie.js +1 -1
  44. package/dist/index.d.ts +1 -0
  45. package/dist/index.js +1 -0
  46. package/dist/interfaces/binary-tree.d.ts +2 -2
  47. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +2 -4
  48. package/dist/types/data-structures/binary-tree/binary-tree.js +0 -6
  49. package/package.json +2 -2
  50. package/src/constants/index.ts +4 -0
  51. package/src/data-structures/base/iterable-element-base.ts +11 -1
  52. package/src/data-structures/base/iterable-entry-base.ts +11 -19
  53. package/src/data-structures/binary-tree/avl-tree-multi-map.ts +47 -50
  54. package/src/data-structures/binary-tree/avl-tree.ts +69 -71
  55. package/src/data-structures/binary-tree/binary-indexed-tree.ts +2 -2
  56. package/src/data-structures/binary-tree/binary-tree.ts +698 -726
  57. package/src/data-structures/binary-tree/bst.ts +123 -129
  58. package/src/data-structures/binary-tree/rb-tree.ts +44 -46
  59. package/src/data-structures/binary-tree/segment-tree.ts +2 -2
  60. package/src/data-structures/binary-tree/tree-multi-map.ts +48 -49
  61. package/src/data-structures/graph/abstract-graph.ts +6 -6
  62. package/src/data-structures/graph/directed-graph.ts +4 -4
  63. package/src/data-structures/graph/undirected-graph.ts +2 -2
  64. package/src/data-structures/hash/hash-map.ts +3 -3
  65. package/src/data-structures/heap/heap.ts +3 -3
  66. package/src/data-structures/linked-list/doubly-linked-list.ts +9 -9
  67. package/src/data-structures/linked-list/singly-linked-list.ts +8 -8
  68. package/src/data-structures/linked-list/skip-linked-list.ts +2 -2
  69. package/src/data-structures/matrix/matrix.ts +2 -2
  70. package/src/data-structures/matrix/navigator.ts +4 -4
  71. package/src/data-structures/queue/deque.ts +31 -31
  72. package/src/data-structures/queue/queue.ts +1 -1
  73. package/src/data-structures/stack/stack.ts +2 -2
  74. package/src/data-structures/trie/trie.ts +3 -3
  75. package/src/index.ts +2 -1
  76. package/src/interfaces/binary-tree.ts +3 -3
  77. package/src/types/data-structures/binary-tree/binary-tree.ts +3 -5
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * data-structure-typed
3
3
  *
4
- * @author Tyler Zeng
5
- * @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
4
+ * @author Pablo Zeng
5
+ * @copyright Copyright (c) 2022 Pablo Zeng <zrwusa@gmail.com>
6
6
  * @license MIT License
7
7
  */
8
8
  import type { SkipLinkedListOptions } from '../../types';
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * data-structure-typed
3
3
  *
4
- * @author Tyler Zeng
5
- * @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
4
+ * @author Pablo Zeng
5
+ * @copyright Copyright (c) 2022 Pablo Zeng <zrwusa@gmail.com>
6
6
  * @license MIT License
7
7
  */
8
8
  import type { MatrixOptions } from '../../types';
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * data-structure-typed
3
3
  *
4
- * @author Tyler Zeng
5
- * @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
4
+ * @author Pablo Zeng
5
+ * @copyright Copyright (c) 2022 Pablo Zeng <zrwusa@gmail.com>
6
6
  * @license MIT License
7
7
  */
8
8
  import type { Direction, NavigatorParams, Turning } from '../../types';
@@ -42,7 +42,7 @@ export class Navigator<T = number> {
42
42
  this._cur = cur;
43
43
  this._character = new Character(charDir, turning);
44
44
  this.onMove = onMove;
45
- this.onMove && this.onMove(this._cur);
45
+ if (this.onMove) this.onMove(this._cur);
46
46
  this._VISITED = VISITED;
47
47
  this._matrix[this._cur[0]][this._cur[1]] = this._VISITED;
48
48
  }
@@ -116,6 +116,6 @@ export class Navigator<T = number> {
116
116
 
117
117
  const [i, j] = this._cur;
118
118
  this._matrix[i][j] = this._VISITED;
119
- this.onMove && this.onMove(this._cur);
119
+ if (this.onMove) this.onMove(this._cur);
120
120
  }
121
121
  }
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * data-structure-typed
3
3
  *
4
- * @author Tyler Zeng
5
- * @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
4
+ * @author Pablo Zeng
5
+ * @copyright Copyright (c) 2022 Pablo Zeng <zrwusa@gmail.com>
6
6
  * @license MIT License
7
7
  */
8
8
  import type { DequeOptions, ElementCallback, IterableWithSizeOrLength } from '../../types';
@@ -163,7 +163,7 @@ export class Deque<E = any, R = any> extends IterableElementBase<E, R, Deque<E,
163
163
  * @returns The first element of the collection, of type E, is being returned.
164
164
  */
165
165
  get first(): E | undefined {
166
- if (this.size === 0) return;
166
+ if (this._size === 0) return;
167
167
  return this._buckets[this._bucketFirst][this._firstInBucket];
168
168
  }
169
169
 
@@ -172,7 +172,7 @@ export class Deque<E = any, R = any> extends IterableElementBase<E, R, Deque<E,
172
172
  * @return The last element in the array
173
173
  */
174
174
  get last(): E | undefined {
175
- if (this.size === 0) return;
175
+ if (this._size === 0) return;
176
176
  return this._buckets[this._bucketLast][this._lastInBucket];
177
177
  }
178
178
 
@@ -186,7 +186,7 @@ export class Deque<E = any, R = any> extends IterableElementBase<E, R, Deque<E,
186
186
  * @returns The size of the data structure after the element has been pushed.
187
187
  */
188
188
  push(element: E): boolean {
189
- if (this.size) {
189
+ if (this._size) {
190
190
  if (this._lastInBucket < this._bucketSize - 1) {
191
191
  this._lastInBucket += 1;
192
192
  } else if (this._bucketLast < this._bucketCount - 1) {
@@ -213,9 +213,9 @@ export class Deque<E = any, R = any> extends IterableElementBase<E, R, Deque<E,
213
213
  * @returns The element that was removed from the data structure is being returned.
214
214
  */
215
215
  pop(): E | undefined {
216
- if (this.size === 0) return;
216
+ if (this._size === 0) return;
217
217
  const element = this._buckets[this._bucketLast][this._lastInBucket];
218
- if (this.size !== 1) {
218
+ if (this._size !== 1) {
219
219
  if (this._lastInBucket > 0) {
220
220
  this._lastInBucket -= 1;
221
221
  } else if (this._bucketLast > 0) {
@@ -241,7 +241,7 @@ export class Deque<E = any, R = any> extends IterableElementBase<E, R, Deque<E,
241
241
  * @returns The size of the data structure after the element has been added.
242
242
  */
243
243
  unshift(element: E): boolean {
244
- if (this.size) {
244
+ if (this._size) {
245
245
  if (this._firstInBucket > 0) {
246
246
  this._firstInBucket -= 1;
247
247
  } else if (this._bucketFirst > 0) {
@@ -269,9 +269,9 @@ export class Deque<E = any, R = any> extends IterableElementBase<E, R, Deque<E,
269
269
  * returned.
270
270
  */
271
271
  shift(): E | undefined {
272
- if (this.size === 0) return;
272
+ if (this._size === 0) return;
273
273
  const element = this._buckets[this._bucketFirst][this._firstInBucket];
274
- if (this.size !== 1) {
274
+ if (this._size !== 1) {
275
275
  if (this._firstInBucket < this._bucketSize - 1) {
276
276
  this._firstInBucket += 1;
277
277
  } else if (this._bucketFirst < this._bucketCount - 1) {
@@ -294,7 +294,7 @@ export class Deque<E = any, R = any> extends IterableElementBase<E, R, Deque<E,
294
294
  * @returns A boolean value indicating whether the size of the object is 0 or not.
295
295
  */
296
296
  isEmpty(): boolean {
297
- return this.size === 0;
297
+ return this._size === 0;
298
298
  }
299
299
 
300
300
  /**
@@ -316,7 +316,7 @@ export class Deque<E = any, R = any> extends IterableElementBase<E, R, Deque<E,
316
316
  */
317
317
  *begin(): Generator<E> {
318
318
  let index = 0;
319
- while (index < this.size) {
319
+ while (index < this._size) {
320
320
  yield this.at(index);
321
321
  index++;
322
322
  }
@@ -327,7 +327,7 @@ export class Deque<E = any, R = any> extends IterableElementBase<E, R, Deque<E,
327
327
  * the last element.
328
328
  */
329
329
  *reverseBegin(): Generator<E> {
330
- let index = this.size - 1;
330
+ let index = this._size - 1;
331
331
  while (index >= 0) {
332
332
  yield this.at(index);
333
333
  index--;
@@ -345,7 +345,7 @@ export class Deque<E = any, R = any> extends IterableElementBase<E, R, Deque<E,
345
345
  * @returns The element at the specified position in the data structure is being returned.
346
346
  */
347
347
  at(pos: number): E {
348
- rangeCheck(pos, 0, this.size - 1);
348
+ rangeCheck(pos, 0, this._size - 1);
349
349
  const { bucketIndex, indexInBucket } = this._getBucketAndPosition(pos);
350
350
  return this._buckets[bucketIndex][indexInBucket]!;
351
351
  }
@@ -361,7 +361,7 @@ export class Deque<E = any, R = any> extends IterableElementBase<E, R, Deque<E,
361
361
  * position in the data structure.
362
362
  */
363
363
  setAt(pos: number, element: E): boolean {
364
- rangeCheck(pos, 0, this.size - 1);
364
+ rangeCheck(pos, 0, this._size - 1);
365
365
  const { bucketIndex, indexInBucket } = this._getBucketAndPosition(pos);
366
366
  this._buckets[bucketIndex][indexInBucket] = element;
367
367
  return true;
@@ -383,15 +383,15 @@ export class Deque<E = any, R = any> extends IterableElementBase<E, R, Deque<E,
383
383
  * @returns The size of the array after the insertion is being returned.
384
384
  */
385
385
  addAt(pos: number, element: E, num = 1): boolean {
386
- const length = this.size;
386
+ const length = this._size;
387
387
  rangeCheck(pos, 0, length);
388
388
  if (pos === 0) {
389
389
  while (num--) this.unshift(element);
390
- } else if (pos === this.size) {
390
+ } else if (pos === this._size) {
391
391
  while (num--) this.push(element);
392
392
  } else {
393
393
  const arr: E[] = [];
394
- for (let i = pos; i < this.size; ++i) {
394
+ for (let i = pos; i < this._size; ++i) {
395
395
  arr.push(this.at(i));
396
396
  }
397
397
  this.cut(pos - 1, true);
@@ -462,7 +462,7 @@ export class Deque<E = any, R = any> extends IterableElementBase<E, R, Deque<E,
462
462
  } else {
463
463
  const newDeque = new Deque<E>([], { bucketSize: this._bucketSize });
464
464
  if (pos < 0) pos = 0;
465
- for (let i = pos; i < this.size; i++) {
465
+ for (let i = pos; i < this._size; i++) {
466
466
  newDeque.push(this.at(i));
467
467
  }
468
468
 
@@ -482,11 +482,11 @@ export class Deque<E = any, R = any> extends IterableElementBase<E, R, Deque<E,
482
482
  * @returns The size of the data structure after the deletion operation is performed.
483
483
  */
484
484
  deleteAt(pos: number): boolean {
485
- rangeCheck(pos, 0, this.size - 1);
485
+ rangeCheck(pos, 0, this._size - 1);
486
486
  if (pos === 0) this.shift();
487
- else if (pos === this.size - 1) this.pop();
487
+ else if (pos === this._size - 1) this.pop();
488
488
  else {
489
- const length = this.size - 1;
489
+ const length = this._size - 1;
490
490
  let { bucketIndex: curBucket, indexInBucket: curPointer } = this._getBucketAndPosition(pos);
491
491
  for (let i = pos; i < length; ++i) {
492
492
  const { bucketIndex: nextBucket, indexInBucket: nextPointer } = this._getBucketAndPosition(pos + 1);
@@ -510,7 +510,7 @@ export class Deque<E = any, R = any> extends IterableElementBase<E, R, Deque<E,
510
510
  * @returns The size of the data structure after the element has been deleted.
511
511
  */
512
512
  delete(element: E): boolean {
513
- const size = this.size;
513
+ const size = this._size;
514
514
  if (size === 0) return false;
515
515
  let i = 0;
516
516
  let index = 0;
@@ -556,12 +556,12 @@ export class Deque<E = any, R = any> extends IterableElementBase<E, R, Deque<E,
556
556
  * @returns The size of the modified array is being returned.
557
557
  */
558
558
  unique(): this {
559
- if (this.size <= 1) {
559
+ if (this._size <= 1) {
560
560
  return this;
561
561
  }
562
562
  let index = 1;
563
563
  let prev = this.at(0);
564
- for (let i = 1; i < this.size; ++i) {
564
+ for (let i = 1; i < this._size; ++i) {
565
565
  const cur = this.at(i);
566
566
  if (cur !== prev) {
567
567
  prev = cur;
@@ -584,11 +584,11 @@ export class Deque<E = any, R = any> extends IterableElementBase<E, R, Deque<E,
584
584
  */
585
585
  sort(comparator?: (x: E, y: E) => number): this {
586
586
  const arr: E[] = [];
587
- for (let i = 0; i < this.size; ++i) {
587
+ for (let i = 0; i < this._size; ++i) {
588
588
  arr.push(this.at(i));
589
589
  }
590
590
  arr.sort(comparator);
591
- for (let i = 0; i < this.size; ++i) {
591
+ for (let i = 0; i < this._size; ++i) {
592
592
  this.setAt(i, arr[i]);
593
593
  }
594
594
  return this;
@@ -601,10 +601,10 @@ export class Deque<E = any, R = any> extends IterableElementBase<E, R, Deque<E,
601
601
  * The `shrinkToFit` function reorganizes the elements in an array-like data structure to minimize
602
602
  * memory usage.
603
603
  * @returns Nothing is being returned. The function is using the `return` statement to exit early if
604
- * `this.size` is 0, but it does not return any value.
604
+ * `this._size` is 0, but it does not return any value.
605
605
  */
606
606
  shrinkToFit(): void {
607
- if (this.size === 0) return;
607
+ if (this._size === 0) return;
608
608
  const newBuckets = [];
609
609
  if (this._bucketFirst === this._bucketLast) return;
610
610
  else if (this._bucketFirst < this._bucketLast) {
@@ -636,7 +636,7 @@ export class Deque<E = any, R = any> extends IterableElementBase<E, R, Deque<E,
636
636
  * in the data structure. If the element is not found, it returns -1.
637
637
  */
638
638
  indexOf(element: E): number {
639
- for (let i = 0; i < this.size; ++i) {
639
+ for (let i = 0; i < this._size; ++i) {
640
640
  if (this.at(i) === element) {
641
641
  return i;
642
642
  }
@@ -736,7 +736,7 @@ export class Deque<E = any, R = any> extends IterableElementBase<E, R, Deque<E,
736
736
  * object to be iterated over using a for...of loop.
737
737
  */
738
738
  protected *_getIterator(): IterableIterator<E> {
739
- for (let i = 0; i < this.size; ++i) {
739
+ for (let i = 0; i < this._size; ++i) {
740
740
  yield this.at(i);
741
741
  }
742
742
  }
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license MIT
3
- * @copyright Tyler Zeng <zrwusa@gmail.com>
3
+ * @copyright Pablo Zeng <zrwusa@gmail.com>
4
4
  * @class
5
5
  */
6
6
  import type { ElementCallback, QueueOptions } from '../../types';
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * data-structure-typed
3
3
  *
4
- * @author Tyler Zeng
5
- * @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
4
+ * @author Pablo Zeng
5
+ * @copyright Copyright (c) 2022 Pablo Zeng <zrwusa@gmail.com>
6
6
  * @license MIT License
7
7
  */
8
8
  import type { ElementCallback, StackOptions } from '../../types';
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * data-structure-typed
3
3
  *
4
- * @author Tyler Zeng
5
- * @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
4
+ * @author Pablo Zeng
5
+ * @copyright Copyright (c) 2022 Pablo Zeng <zrwusa@gmail.com>
6
6
  * @license MIT License
7
7
  */
8
8
  import type { ElementCallback, TrieOptions } from '../../types';
@@ -202,7 +202,7 @@ export class Trie<R = any> extends IterableElementBase<string, R, Trie<R>> {
202
202
  * @return True if the size of the queue is 0
203
203
  */
204
204
  isEmpty(): boolean {
205
- return this.size === 0;
205
+ return this._size === 0;
206
206
  }
207
207
 
208
208
  /**
package/src/index.ts CHANGED
@@ -8,4 +8,5 @@
8
8
  // export { Deque, ObjectDeque, ArrayDeque } from 'data-structure-typed';
9
9
  export * from './data-structures/queue/deque';
10
10
  export * from './types/data-structures/queue/deque';
11
- export * from './types/common';
11
+ export * from './types/common';
12
+ export * from './constants';
@@ -4,8 +4,8 @@ import type {
4
4
  BinaryTreeNested,
5
5
  BinaryTreeNodeNested,
6
6
  BinaryTreeOptions,
7
- BTNCallback,
8
- BTNKeyOrNodeOrEntry
7
+ BTNKeyOrNodeOrEntry,
8
+ BTNPredicate
9
9
  } from '../types';
10
10
 
11
11
  export interface IBinaryTree<
@@ -23,5 +23,5 @@ export interface IBinaryTree<
23
23
 
24
24
  addMany(nodes: Iterable<BTNKeyOrNodeOrEntry<K, V, NODE>>, values?: Iterable<V | undefined>): boolean[];
25
25
 
26
- delete<C extends BTNCallback<NODE>>(identifier: ReturnType<C> | null, callback: C): BinaryTreeDeleteResult<NODE>[];
26
+ delete(predicate: R | BTNKeyOrNodeOrEntry<K, V, NODE> | BTNPredicate<NODE>): BinaryTreeDeleteResult<NODE>[];
27
27
  }
@@ -1,5 +1,6 @@
1
1
  import { BinaryTree, BinaryTreeNode } from '../../../data-structures';
2
2
  import { IterationType, OptValue } from '../../common';
3
+ import { DFSOperation } from '../../../constants';
3
4
 
4
5
  export type BinaryTreeNodeNested<K, V> = BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
5
6
 
@@ -30,9 +31,6 @@ export type BinaryTreeDeleteResult<NODE> = { deleted: OptBTNOrNull<NODE>; needBa
30
31
 
31
32
  export type BTNCallback<NODE, D = any> = (node: NODE) => D;
32
33
 
33
- export enum DFSOperation {
34
- VISIT = 0,
35
- PROCESS = 1,
36
- }
34
+ export type BTNPredicate<NODE> = (node: NODE) => boolean;
37
35
 
38
- export type DFSStackItem<NODE> = { opt: DFSOperation; node: OptBTNOrNull<NODE> }
36
+ export type DFSStackItem<NODE> = { opt: DFSOperation; node: OptBTNOrNull<NODE> }