min-heap-typed 1.54.0 → 1.54.1

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 (84) hide show
  1. package/dist/data-structures/binary-tree/avl-tree-counter.d.ts +213 -0
  2. package/dist/data-structures/binary-tree/avl-tree-counter.js +407 -0
  3. package/dist/data-structures/binary-tree/avl-tree-multi-map.d.ts +71 -177
  4. package/dist/data-structures/binary-tree/avl-tree-multi-map.js +135 -340
  5. package/dist/data-structures/binary-tree/avl-tree.d.ts +102 -57
  6. package/dist/data-structures/binary-tree/avl-tree.js +110 -47
  7. package/dist/data-structures/binary-tree/binary-indexed-tree.d.ts +3 -0
  8. package/dist/data-structures/binary-tree/binary-indexed-tree.js +3 -0
  9. package/dist/data-structures/binary-tree/binary-tree.d.ts +240 -190
  10. package/dist/data-structures/binary-tree/binary-tree.js +269 -240
  11. package/dist/data-structures/binary-tree/bst.d.ts +145 -112
  12. package/dist/data-structures/binary-tree/bst.js +180 -129
  13. package/dist/data-structures/binary-tree/index.d.ts +2 -0
  14. package/dist/data-structures/binary-tree/index.js +2 -0
  15. package/dist/data-structures/binary-tree/red-black-tree.d.ts +100 -82
  16. package/dist/data-structures/binary-tree/red-black-tree.js +115 -79
  17. package/dist/data-structures/binary-tree/tree-counter.d.ts +212 -0
  18. package/dist/data-structures/binary-tree/tree-counter.js +444 -0
  19. package/dist/data-structures/binary-tree/tree-multi-map.d.ts +78 -174
  20. package/dist/data-structures/binary-tree/tree-multi-map.js +142 -377
  21. package/dist/data-structures/graph/directed-graph.d.ts +3 -0
  22. package/dist/data-structures/graph/directed-graph.js +3 -0
  23. package/dist/data-structures/graph/map-graph.d.ts +3 -0
  24. package/dist/data-structures/graph/map-graph.js +3 -0
  25. package/dist/data-structures/graph/undirected-graph.d.ts +3 -0
  26. package/dist/data-structures/graph/undirected-graph.js +3 -0
  27. package/dist/data-structures/linked-list/singly-linked-list.d.ts +3 -0
  28. package/dist/data-structures/linked-list/singly-linked-list.js +3 -0
  29. package/dist/data-structures/linked-list/skip-linked-list.d.ts +3 -0
  30. package/dist/data-structures/linked-list/skip-linked-list.js +3 -0
  31. package/dist/data-structures/matrix/matrix.d.ts +3 -0
  32. package/dist/data-structures/matrix/matrix.js +3 -0
  33. package/dist/data-structures/matrix/navigator.d.ts +3 -0
  34. package/dist/data-structures/matrix/navigator.js +3 -0
  35. package/dist/data-structures/priority-queue/max-priority-queue.d.ts +3 -0
  36. package/dist/data-structures/priority-queue/max-priority-queue.js +3 -0
  37. package/dist/data-structures/priority-queue/min-priority-queue.d.ts +3 -0
  38. package/dist/data-structures/priority-queue/min-priority-queue.js +3 -0
  39. package/dist/data-structures/trie/trie.d.ts +0 -4
  40. package/dist/data-structures/trie/trie.js +0 -4
  41. package/dist/interfaces/binary-tree.d.ts +8 -8
  42. package/dist/types/data-structures/binary-tree/avl-tree-counter.d.ts +2 -0
  43. package/dist/types/data-structures/binary-tree/avl-tree-counter.js +2 -0
  44. package/dist/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +1 -4
  45. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +0 -3
  46. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +0 -3
  47. package/dist/types/data-structures/binary-tree/bst.d.ts +3 -3
  48. package/dist/types/data-structures/binary-tree/index.d.ts +2 -0
  49. package/dist/types/data-structures/binary-tree/index.js +2 -0
  50. package/dist/types/data-structures/binary-tree/rb-tree.d.ts +1 -4
  51. package/dist/types/data-structures/binary-tree/tree-counter.d.ts +2 -0
  52. package/dist/types/data-structures/binary-tree/tree-counter.js +2 -0
  53. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +1 -4
  54. package/package.json +2 -2
  55. package/src/data-structures/binary-tree/avl-tree-counter.ts +463 -0
  56. package/src/data-structures/binary-tree/avl-tree-multi-map.ts +155 -393
  57. package/src/data-structures/binary-tree/avl-tree.ts +144 -93
  58. package/src/data-structures/binary-tree/binary-indexed-tree.ts +3 -0
  59. package/src/data-structures/binary-tree/binary-tree.ts +433 -405
  60. package/src/data-structures/binary-tree/bst.ts +261 -239
  61. package/src/data-structures/binary-tree/index.ts +2 -0
  62. package/src/data-structures/binary-tree/red-black-tree.ts +163 -134
  63. package/src/data-structures/binary-tree/tree-counter.ts +504 -0
  64. package/src/data-structures/binary-tree/tree-multi-map.ts +161 -429
  65. package/src/data-structures/graph/directed-graph.ts +3 -0
  66. package/src/data-structures/graph/map-graph.ts +3 -0
  67. package/src/data-structures/graph/undirected-graph.ts +3 -0
  68. package/src/data-structures/linked-list/singly-linked-list.ts +3 -0
  69. package/src/data-structures/linked-list/skip-linked-list.ts +3 -0
  70. package/src/data-structures/matrix/matrix.ts +3 -0
  71. package/src/data-structures/matrix/navigator.ts +3 -0
  72. package/src/data-structures/priority-queue/max-priority-queue.ts +3 -0
  73. package/src/data-structures/priority-queue/min-priority-queue.ts +3 -0
  74. package/src/data-structures/trie/trie.ts +0 -4
  75. package/src/interfaces/binary-tree.ts +10 -24
  76. package/src/types/data-structures/binary-tree/avl-tree-counter.ts +3 -0
  77. package/src/types/data-structures/binary-tree/avl-tree-multi-map.ts +1 -6
  78. package/src/types/data-structures/binary-tree/avl-tree.ts +0 -5
  79. package/src/types/data-structures/binary-tree/binary-tree.ts +0 -5
  80. package/src/types/data-structures/binary-tree/bst.ts +5 -5
  81. package/src/types/data-structures/binary-tree/index.ts +2 -0
  82. package/src/types/data-structures/binary-tree/rb-tree.ts +1 -6
  83. package/src/types/data-structures/binary-tree/tree-counter.ts +3 -0
  84. package/src/types/data-structures/binary-tree/tree-multi-map.ts +1 -6
@@ -45,6 +45,9 @@ export class DirectedEdge<E = any> extends AbstractEdge<E> {
45
45
  }
46
46
  }
47
47
 
48
+ /**
49
+ *
50
+ */
48
51
  export class DirectedGraph<
49
52
  V = any,
50
53
  E = any,
@@ -40,6 +40,9 @@ export class MapEdge<E = any> extends DirectedEdge<E> {
40
40
  }
41
41
  }
42
42
 
43
+ /**
44
+ *
45
+ */
43
46
  export class MapGraph<
44
47
  V = any,
45
48
  E = any,
@@ -42,6 +42,9 @@ export class UndirectedEdge<E = number> extends AbstractEdge<E> {
42
42
  }
43
43
  }
44
44
 
45
+ /**
46
+ *
47
+ */
45
48
  export class UndirectedGraph<
46
49
  V = any,
47
50
  E = any,
@@ -59,6 +59,9 @@ export class SinglyLinkedListNode<E = any> {
59
59
  }
60
60
  }
61
61
 
62
+ /**
63
+ *
64
+ */
62
65
  export class SinglyLinkedList<E = any, R = any> extends IterableElementBase<E, R, SinglyLinkedList<E, R>> {
63
66
  constructor(
64
67
  elements: Iterable<E> | Iterable<R> | Iterable<SinglyLinkedListNode<E>> = [],
@@ -19,6 +19,9 @@ export class SkipListNode<K, V> {
19
19
  }
20
20
  }
21
21
 
22
+ /**
23
+ *
24
+ */
22
25
  export class SkipList<K, V> {
23
26
  /**
24
27
  * The constructor function initializes a SkipLinkedList object with optional options and elements.
@@ -7,6 +7,9 @@
7
7
  */
8
8
  import type { MatrixOptions } from '../../types';
9
9
 
10
+ /**
11
+ *
12
+ */
10
13
  export class Matrix {
11
14
  /**
12
15
  * The constructor function initializes a matrix object with the provided data and options, or with
@@ -25,6 +25,9 @@ export class Character {
25
25
  }
26
26
  }
27
27
 
28
+ /**
29
+ *
30
+ */
28
31
  export class Navigator<T = number> {
29
32
  onMove: (cur: [number, number]) => void;
30
33
  protected readonly _matrix: T[][];
@@ -8,6 +8,9 @@
8
8
  import type { Comparator, ElementCallback, PriorityQueueOptions } from '../../types';
9
9
  import { PriorityQueue } from './priority-queue';
10
10
 
11
+ /**
12
+ *
13
+ */
11
14
  export class MaxPriorityQueue<E = any, R = any> extends PriorityQueue<E, R> {
12
15
  /**
13
16
  * The constructor initializes a PriorityQueue with optional elements and options, including a
@@ -8,6 +8,9 @@
8
8
  import type { Comparator, ElementCallback, PriorityQueueOptions } from '../../types';
9
9
  import { PriorityQueue } from './priority-queue';
10
10
 
11
+ /**
12
+ *
13
+ */
11
14
  export class MinPriorityQueue<E = any, R = any> extends PriorityQueue<E, R> {
12
15
  /**
13
16
  * The constructor initializes a PriorityQueue with optional elements and options, including a
@@ -8,10 +8,6 @@
8
8
  import type { ElementCallback, TrieOptions } from '../../types';
9
9
  import { IterableElementBase } from '../base';
10
10
 
11
- /**
12
- * TrieNode represents a node in the Trie data structure. It holds a character key, a map of children nodes,
13
- * and a flag indicating whether it's the end of a word.
14
- */
15
11
  export class TrieNode {
16
12
  constructor(key: string) {
17
13
  this._key = key;
@@ -1,30 +1,16 @@
1
- import { BinaryTree, BinaryTreeNode } from '../data-structures';
2
- import type {
3
- BinaryTreeDeleteResult,
4
- BinaryTreeNested,
5
- BinaryTreeNodeNested,
6
- BinaryTreeOptions,
7
- BTNRep,
8
- NodePredicate
9
- } from '../types';
1
+ import { BinaryTreeNode } from '../data-structures';
2
+ import type { BinaryTreeDeleteResult, BinaryTreeOptions, BTNRep, NodePredicate } from '../types';
10
3
 
11
- export interface IBinaryTree<
12
- K = any,
13
- V = any,
14
- R = object,
15
- MK = any,
16
- MV = any,
17
- MR = object,
18
- NODE extends BinaryTreeNode<K, V, NODE> = BinaryTreeNodeNested<K, V>,
19
- TREE extends BinaryTree<K, V, R, MK, MV, MR, NODE, TREE> = BinaryTreeNested<K, V, R, MK, MV, MR, NODE>
20
- > {
21
- createNode(key: K, value?: NODE['value']): NODE;
4
+ export interface IBinaryTree<K = any, V = any, R = object, MK = any, MV = any, MR = object> {
5
+ createNode(key: K, value?: BinaryTreeNode['value']): BinaryTreeNode;
22
6
 
23
- createTree(options?: Partial<BinaryTreeOptions<K, V, R>>): TREE;
7
+ createTree(options?: Partial<BinaryTreeOptions<K, V, R>>): IBinaryTree<K, V, R, MK, MV, MR>;
24
8
 
25
- add(keyOrNodeOrEntryOrRawElement: BTNRep<K, V, NODE>, value?: V, count?: number): boolean;
9
+ add(keyOrNodeOrEntryOrRawElement: BTNRep<K, V, BinaryTreeNode<K, V>>, value?: V, count?: number): boolean;
26
10
 
27
- addMany(nodes: Iterable<BTNRep<K, V, NODE>>, values?: Iterable<V | undefined>): boolean[];
11
+ addMany(nodes: Iterable<BTNRep<K, V, BinaryTreeNode<K, V>>>, values?: Iterable<V | undefined>): boolean[];
28
12
 
29
- delete(predicate: R | BTNRep<K, V, NODE> | NodePredicate<NODE>): BinaryTreeDeleteResult<NODE>[];
13
+ delete(
14
+ predicate: R | BTNRep<K, V, BinaryTreeNode<K, V>> | NodePredicate<BinaryTreeNode<K, V>>
15
+ ): BinaryTreeDeleteResult<BinaryTreeNode<K, V>>[];
30
16
  }
@@ -0,0 +1,3 @@
1
+ import { AVLTreeOptions } from './avl-tree';
2
+
3
+ export type AVLTreeCounterOptions<K, V, R> = AVLTreeOptions<K, V, R> & {};
@@ -1,8 +1,3 @@
1
- import { AVLTreeMultiMap, AVLTreeMultiMapNode } from '../../../data-structures';
2
1
  import type { AVLTreeOptions } from './avl-tree';
3
2
 
4
- export type AVLTreeMultiMapNodeNested<K, V> = AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, any>>>
5
-
6
- export type AVLTreeMultiMapNested<K, V, R, MK, MV, MR, NODE extends AVLTreeMultiMapNode<K, V, NODE>> = AVLTreeMultiMap<K, V, R, MK, MV, MR, NODE, AVLTreeMultiMap<K, V, R, MK, MV, MR, NODE, AVLTreeMultiMap<K, V, R, MK, MV, MR, NODE, any>>>
7
-
8
- export type AVLTreeMultiMapOptions<K, V, R> = AVLTreeOptions<K, V, R> & {}
3
+ export type AVLTreeMultiMapOptions<K, V, R> = Omit<AVLTreeOptions<K, V, R>, 'isMapMode'> & {}
@@ -1,8 +1,3 @@
1
- import { AVLTree, AVLTreeNode } from '../../../data-structures';
2
1
  import { BSTOptions } from './bst';
3
2
 
4
- export type AVLTreeNodeNested<K, V> = AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, any>>>
5
-
6
- export type AVLTreeNested<K, V, R,MK, MV, MR, NODE extends AVLTreeNode<K, V, NODE>> = AVLTree<K, V, R,MK, MV, MR, NODE, AVLTree<K, V, R,MK, MV, MR, NODE, AVLTree<K, V, R,MK, MV, MR, NODE, any>>>
7
-
8
3
  export type AVLTreeOptions<K, V, R> = BSTOptions<K, V, R> & {};
@@ -1,11 +1,6 @@
1
- import { BinaryTree, BinaryTreeNode } from '../../../data-structures';
2
1
  import { IterationType, OptValue } from '../../common';
3
2
  import { DFSOperation } from '../../../common';
4
3
 
5
- export type BinaryTreeNodeNested<K, V> = BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, any>>>
6
-
7
- export type BinaryTreeNested<K, V, R, MK, MV, MR, NODE extends BinaryTreeNode<K, V, NODE>> = BinaryTree<K, V, R, MK, MV, MR, NODE,BinaryTree<K, V, R, MK, MV, MR, NODE,BinaryTree<K, V, R, MK, MV, MR, NODE,any>>>
8
-
9
4
  export type ToEntryFn<K, V, R> = (rawElement: R) => BTNEntry<K, V>;
10
5
 
11
6
  export type BinaryTreeOptions<K, V, R> = {
@@ -1,10 +1,6 @@
1
- import { BST, BSTNode } from '../../../data-structures';
2
1
  import type { BinaryTreeOptions } from './binary-tree';
3
2
  import { Comparable } from '../../utils';
4
-
5
- export type BSTNodeNested<K, V> = BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, any>>>
6
-
7
- export type BSTNested<K, V, R,MK, MV, MR, NODE extends BSTNode<K, V, NODE>> = BST<K, V, R,MK, MV, MR, NODE,BST<K, V, R,MK, MV, MR, NODE,BST<K, V, R,MK, MV, MR, NODE, any>>>
3
+ import { OptValue } from '../../common';
8
4
 
9
5
  export type BSTOptions<K, V, R> = BinaryTreeOptions<K, V, R> & {
10
6
  specifyComparable?: (key: K) => Comparable
@@ -15,5 +11,9 @@ export type BSTNOptKey<K> = K | undefined;
15
11
 
16
12
  export type OptNode<NODE> = NODE | undefined;
17
13
 
14
+ export type BSTNEntry<K, V> = [BSTNOptKey<K>, OptValue<V>];
15
+
18
16
  export type BSTNOptKeyOrNode<K, NODE> = BSTNOptKey<K> | NODE;
19
17
 
18
+ export type BSTNRep<K, V, NODE> = BSTNEntry<K, V> | BSTNOptKeyOrNode<K, NODE>;
19
+
@@ -5,3 +5,5 @@ export * from './segment-tree';
5
5
  export * from './avl-tree-multi-map';
6
6
  export * from './rb-tree';
7
7
  export * from './tree-multi-map';
8
+ export * from './tree-counter';
9
+ export * from './avl-tree-counter';
@@ -1,10 +1,5 @@
1
- import { RedBlackTree, RedBlackTreeNode } from '../../../data-structures';
2
- import type { BSTOptions } from "./bst";
1
+ import type { BSTOptions } from './bst';
3
2
 
4
3
  export type RBTNColor = 'RED' | 'BLACK';
5
4
 
6
- export type RedBlackTreeNodeNested<K, V> = RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, any>>>
7
-
8
- export type RedBlackTreeNested<K, V, R, MK, MV, MR, NODE extends RedBlackTreeNode<K, V, NODE>> = RedBlackTree<K, V, R, MK, MV, MR, NODE, RedBlackTree<K, V, R, MK, MV, MR, NODE, RedBlackTree<K, V, R, MK, MV, MR, NODE, any>>>
9
-
10
5
  export type RedBlackTreeOptions<K, V, R> = BSTOptions<K, V, R> & {};
@@ -0,0 +1,3 @@
1
+ import type { RedBlackTreeOptions } from './rb-tree';
2
+
3
+ export type TreeCounterOptions<K, V, R> = RedBlackTreeOptions<K, V, R> & {};
@@ -1,8 +1,3 @@
1
- import { TreeMultiMap, TreeMultiMapNode } from '../../../data-structures';
2
1
  import type { RedBlackTreeOptions } from './rb-tree';
3
2
 
4
- export type TreeMultiMapNodeNested<K, V> = TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, TreeMultiMapNode<K, V, any>>>
5
-
6
- export type TreeMultiMapNested<K, V, R, MK, MV, MR, NODE extends TreeMultiMapNode<K, V, NODE>> = TreeMultiMap<K, V, R, MK, MV, MR, NODE, TreeMultiMap<K, V, R, MK, MV, MR, NODE,TreeMultiMap<K, V, R, MK, MV, MR, NODE, any>>>
7
-
8
- export type TreeMultiMapOptions<K, V, R> = RedBlackTreeOptions<K, V, R> & {}
3
+ export type TreeMultiMapOptions<K, V, R> = Omit<RedBlackTreeOptions<K, V, R>, 'isMapMode'> & {}