linked-list-typed 1.39.5 → 1.39.6

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 (46) hide show
  1. package/dist/data-structures/binary-tree/avl-tree.d.ts +6 -6
  2. package/dist/data-structures/binary-tree/avl-tree.js +13 -13
  3. package/dist/data-structures/binary-tree/binary-tree.d.ts +7 -7
  4. package/dist/data-structures/binary-tree/binary-tree.js +17 -17
  5. package/dist/data-structures/binary-tree/bst.d.ts +6 -6
  6. package/dist/data-structures/binary-tree/bst.js +13 -13
  7. package/dist/data-structures/binary-tree/rb-tree.d.ts +2 -2
  8. package/dist/data-structures/binary-tree/rb-tree.js +4 -4
  9. package/dist/data-structures/binary-tree/segment-tree.d.ts +7 -7
  10. package/dist/data-structures/binary-tree/segment-tree.js +16 -16
  11. package/dist/data-structures/binary-tree/tree-multiset.d.ts +6 -6
  12. package/dist/data-structures/binary-tree/tree-multiset.js +18 -18
  13. package/dist/data-structures/graph/abstract-graph.d.ts +17 -17
  14. package/dist/data-structures/graph/abstract-graph.js +24 -24
  15. package/dist/data-structures/graph/directed-graph.d.ts +12 -12
  16. package/dist/data-structures/graph/directed-graph.js +15 -15
  17. package/dist/data-structures/graph/map-graph.d.ts +9 -9
  18. package/dist/data-structures/graph/map-graph.js +13 -13
  19. package/dist/data-structures/graph/undirected-graph.d.ts +11 -11
  20. package/dist/data-structures/graph/undirected-graph.js +14 -14
  21. package/dist/data-structures/hash/hash-table.d.ts +4 -4
  22. package/dist/data-structures/hash/hash-table.js +8 -8
  23. package/dist/data-structures/linked-list/doubly-linked-list.d.ts +31 -31
  24. package/dist/data-structures/linked-list/doubly-linked-list.js +54 -54
  25. package/dist/data-structures/linked-list/singly-linked-list.d.ts +24 -24
  26. package/dist/data-structures/linked-list/singly-linked-list.js +52 -52
  27. package/dist/data-structures/queue/queue.js +1 -1
  28. package/dist/interfaces/binary-tree.d.ts +2 -2
  29. package/dist/interfaces/graph.d.ts +2 -2
  30. package/package.json +2 -2
  31. package/src/data-structures/binary-tree/avl-tree.ts +13 -13
  32. package/src/data-structures/binary-tree/binary-tree.ts +18 -18
  33. package/src/data-structures/binary-tree/bst.ts +16 -16
  34. package/src/data-structures/binary-tree/rb-tree.ts +6 -6
  35. package/src/data-structures/binary-tree/segment-tree.ts +15 -15
  36. package/src/data-structures/binary-tree/tree-multiset.ts +18 -18
  37. package/src/data-structures/graph/abstract-graph.ts +34 -34
  38. package/src/data-structures/graph/directed-graph.ts +16 -16
  39. package/src/data-structures/graph/map-graph.ts +13 -13
  40. package/src/data-structures/graph/undirected-graph.ts +15 -15
  41. package/src/data-structures/hash/hash-table.ts +9 -9
  42. package/src/data-structures/linked-list/doubly-linked-list.ts +61 -61
  43. package/src/data-structures/linked-list/singly-linked-list.ts +58 -58
  44. package/src/data-structures/queue/queue.ts +1 -1
  45. package/src/interfaces/binary-tree.ts +2 -2
  46. package/src/interfaces/graph.ts +2 -2
@@ -11,7 +11,7 @@ import { BTNCallback } from '../../types';
11
11
  import { IBinaryTree } from '../../interfaces';
12
12
  export declare class AVLTreeNode<V = any, N extends AVLTreeNode<V, N> = AVLTreeNodeNested<V>> extends BSTNode<V, N> {
13
13
  height: number;
14
- constructor(key: BTNKey, val?: V);
14
+ constructor(key: BTNKey, value?: V);
15
15
  }
16
16
  export declare class AVLTree<V = any, N extends AVLTreeNode<V, N> = AVLTreeNode<V, AVLTreeNodeNested<V>>> extends BST<V, N> implements IBinaryTree<V, N> {
17
17
  /**
@@ -25,22 +25,22 @@ export declare class AVLTree<V = any, N extends AVLTreeNode<V, N> = AVLTreeNode<
25
25
  * The function creates a new AVL tree node with the specified key and value.
26
26
  * @param {BTNKey} key - The key parameter is the key value that will be associated with
27
27
  * the new node. It is used to determine the position of the node in the binary search tree.
28
- * @param [val] - The parameter `val` is an optional value that can be assigned to the node. It is of
29
- * type `V`, which means it can be any value that is assignable to the `val` property of the
28
+ * @param [value] - The parameter `value` is an optional value that can be assigned to the node. It is of
29
+ * type `V`, which means it can be any value that is assignable to the `value` property of the
30
30
  * node type `N`.
31
31
  * @returns a new AVLTreeNode object with the specified key and value.
32
32
  */
33
- createNode(key: BTNKey, val?: V): N;
33
+ createNode(key: BTNKey, value?: V): N;
34
34
  /**
35
35
  * The function overrides the add method of a binary tree node and balances the tree after inserting
36
36
  * a new node.
37
37
  * @param {BTNKey | N | null} keyOrNode - The `keyOrNode` parameter can accept either a
38
38
  * `BTNKey` or a `N` (which represents a node in the binary tree) or `null`.
39
- * @param [val] - The `val` parameter is the value that you want to assign to the new node that you
39
+ * @param [value] - The `value` parameter is the value that you want to assign to the new node that you
40
40
  * are adding to the binary search tree.
41
41
  * @returns The method is returning the inserted node (`N`), `null`, or `undefined`.
42
42
  */
43
- add(keyOrNode: BTNKey | N | null, val?: V): N | null | undefined;
43
+ add(keyOrNode: BTNKey | N | null, value?: V): N | null | undefined;
44
44
  /**
45
45
  * The function overrides the delete method of a binary tree and balances the tree after deleting a
46
46
  * node if necessary.
@@ -10,8 +10,8 @@ exports.AVLTree = exports.AVLTreeNode = void 0;
10
10
  */
11
11
  const bst_1 = require("./bst");
12
12
  class AVLTreeNode extends bst_1.BSTNode {
13
- constructor(key, val) {
14
- super(key, val);
13
+ constructor(key, value) {
14
+ super(key, value);
15
15
  this.height = 0;
16
16
  }
17
17
  }
@@ -30,26 +30,26 @@ class AVLTree extends bst_1.BST {
30
30
  * The function creates a new AVL tree node with the specified key and value.
31
31
  * @param {BTNKey} key - The key parameter is the key value that will be associated with
32
32
  * the new node. It is used to determine the position of the node in the binary search tree.
33
- * @param [val] - The parameter `val` is an optional value that can be assigned to the node. It is of
34
- * type `V`, which means it can be any value that is assignable to the `val` property of the
33
+ * @param [value] - The parameter `value` is an optional value that can be assigned to the node. It is of
34
+ * type `V`, which means it can be any value that is assignable to the `value` property of the
35
35
  * node type `N`.
36
36
  * @returns a new AVLTreeNode object with the specified key and value.
37
37
  */
38
- createNode(key, val) {
39
- return new AVLTreeNode(key, val);
38
+ createNode(key, value) {
39
+ return new AVLTreeNode(key, value);
40
40
  }
41
41
  /**
42
42
  * The function overrides the add method of a binary tree node and balances the tree after inserting
43
43
  * a new node.
44
44
  * @param {BTNKey | N | null} keyOrNode - The `keyOrNode` parameter can accept either a
45
45
  * `BTNKey` or a `N` (which represents a node in the binary tree) or `null`.
46
- * @param [val] - The `val` parameter is the value that you want to assign to the new node that you
46
+ * @param [value] - The `value` parameter is the value that you want to assign to the new node that you
47
47
  * are adding to the binary search tree.
48
48
  * @returns The method is returning the inserted node (`N`), `null`, or `undefined`.
49
49
  */
50
- add(keyOrNode, val) {
50
+ add(keyOrNode, value) {
51
51
  // TODO support node as a param
52
- const inserted = super.add(keyOrNode, val);
52
+ const inserted = super.add(keyOrNode, value);
53
53
  if (inserted)
54
54
  this._balancePath(inserted);
55
55
  return inserted;
@@ -86,15 +86,15 @@ class AVLTree extends bst_1.BST {
86
86
  * @returns The method is returning the `destNode` after swapping its properties with the `srcNode`.
87
87
  */
88
88
  _swap(srcNode, destNode) {
89
- const { key, val, height } = destNode;
90
- const tempNode = this.createNode(key, val);
89
+ const { key, value, height } = destNode;
90
+ const tempNode = this.createNode(key, value);
91
91
  if (tempNode) {
92
92
  tempNode.height = height;
93
93
  destNode.key = srcNode.key;
94
- destNode.val = srcNode.val;
94
+ destNode.value = srcNode.value;
95
95
  destNode.height = srcNode.height;
96
96
  srcNode.key = tempNode.key;
97
- srcNode.val = tempNode.val;
97
+ srcNode.value = tempNode.value;
98
98
  srcNode.height = tempNode.height;
99
99
  }
100
100
  return destNode;
@@ -21,7 +21,7 @@ export declare class BinaryTreeNode<V = any, N extends BinaryTreeNode<V, N> = Bi
21
21
  /**
22
22
  * The value stored in the node.
23
23
  */
24
- val: V | undefined;
24
+ value: V | undefined;
25
25
  /**
26
26
  * The parent node of the current node.
27
27
  */
@@ -29,9 +29,9 @@ export declare class BinaryTreeNode<V = any, N extends BinaryTreeNode<V, N> = Bi
29
29
  /**
30
30
  * Creates a new instance of BinaryTreeNode.
31
31
  * @param {BTNKey} key - The key associated with the node.
32
- * @param {V} val - The value stored in the node.
32
+ * @param {V} value - The value stored in the node.
33
33
  */
34
- constructor(key: BTNKey, val?: V);
34
+ constructor(key: BTNKey, value?: V);
35
35
  private _left;
36
36
  /**
37
37
  * Get the left child node.
@@ -91,10 +91,10 @@ export declare class BinaryTree<V = any, N extends BinaryTreeNode<V, N> = Binary
91
91
  /**
92
92
  * Creates a new instance of BinaryTreeNode with the given key and value.
93
93
  * @param {BTNKey} key - The key for the new node.
94
- * @param {V} val - The value for the new node.
94
+ * @param {V} value - The value for the new node.
95
95
  * @returns {N} - The newly created BinaryTreeNode.
96
96
  */
97
- createNode(key: BTNKey, val?: V): N;
97
+ createNode(key: BTNKey, value?: V): N;
98
98
  /**
99
99
  * Clear the binary tree, removing all nodes.
100
100
  */
@@ -107,10 +107,10 @@ export declare class BinaryTree<V = any, N extends BinaryTreeNode<V, N> = Binary
107
107
  /**
108
108
  * Add a node with the given key and value to the binary tree.
109
109
  * @param {BTNKey | N | null} keyOrNode - The key or node to add to the binary tree.
110
- * @param {V} val - The value for the new node (optional).
110
+ * @param {V} value - The value for the new node (optional).
111
111
  * @returns {N | null | undefined} - The inserted node, or null if nothing was inserted, or undefined if the operation failed.
112
112
  */
113
- add(keyOrNode: BTNKey | N | null, val?: V): N | null | undefined;
113
+ add(keyOrNode: BTNKey | N | null, value?: V): N | null | undefined;
114
114
  /**
115
115
  * The `addMany` function takes an array of binary tree node IDs or nodes, and optionally an array of corresponding data
116
116
  * values, and adds them to the binary tree.
@@ -20,11 +20,11 @@ class BinaryTreeNode {
20
20
  /**
21
21
  * Creates a new instance of BinaryTreeNode.
22
22
  * @param {BTNKey} key - The key associated with the node.
23
- * @param {V} val - The value stored in the node.
23
+ * @param {V} value - The value stored in the node.
24
24
  */
25
- constructor(key, val) {
25
+ constructor(key, value) {
26
26
  this.key = key;
27
- this.val = val;
27
+ this.value = value;
28
28
  }
29
29
  /**
30
30
  * Get the left child node.
@@ -123,11 +123,11 @@ class BinaryTree {
123
123
  /**
124
124
  * Creates a new instance of BinaryTreeNode with the given key and value.
125
125
  * @param {BTNKey} key - The key for the new node.
126
- * @param {V} val - The value for the new node.
126
+ * @param {V} value - The value for the new node.
127
127
  * @returns {N} - The newly created BinaryTreeNode.
128
128
  */
129
- createNode(key, val) {
130
- return new BinaryTreeNode(key, val);
129
+ createNode(key, value) {
130
+ return new BinaryTreeNode(key, value);
131
131
  }
132
132
  /**
133
133
  * Clear the binary tree, removing all nodes.
@@ -146,10 +146,10 @@ class BinaryTree {
146
146
  /**
147
147
  * Add a node with the given key and value to the binary tree.
148
148
  * @param {BTNKey | N | null} keyOrNode - The key or node to add to the binary tree.
149
- * @param {V} val - The value for the new node (optional).
149
+ * @param {V} value - The value for the new node (optional).
150
150
  * @returns {N | null | undefined} - The inserted node, or null if nothing was inserted, or undefined if the operation failed.
151
151
  */
152
- add(keyOrNode, val) {
152
+ add(keyOrNode, value) {
153
153
  const _bfs = (root, newNode) => {
154
154
  const queue = new queue_1.Queue([root]);
155
155
  while (queue.size > 0) {
@@ -175,7 +175,7 @@ class BinaryTree {
175
175
  needInsert = null;
176
176
  }
177
177
  else if (typeof keyOrNode === 'number') {
178
- needInsert = this.createNode(keyOrNode, val);
178
+ needInsert = this.createNode(keyOrNode, value);
179
179
  }
180
180
  else if (keyOrNode instanceof BinaryTreeNode) {
181
181
  needInsert = keyOrNode;
@@ -187,7 +187,7 @@ class BinaryTree {
187
187
  const existNode = key !== undefined ? this.get(key, (node) => node.key) : undefined;
188
188
  if (this.root) {
189
189
  if (existNode) {
190
- existNode.val = val;
190
+ existNode.value = value;
191
191
  inserted = existNode;
192
192
  }
193
193
  else {
@@ -220,13 +220,13 @@ class BinaryTree {
220
220
  // TODO not sure addMany not be run multi times
221
221
  return keysOrNodes.map((keyOrNode, i) => {
222
222
  if (keyOrNode instanceof BinaryTreeNode) {
223
- return this.add(keyOrNode.key, keyOrNode.val);
223
+ return this.add(keyOrNode.key, keyOrNode.value);
224
224
  }
225
225
  if (keyOrNode === null) {
226
226
  return this.add(null);
227
227
  }
228
- const val = values === null || values === void 0 ? void 0 : values[i];
229
- return this.add(keyOrNode, val);
228
+ const value = values === null || values === void 0 ? void 0 : values[i];
229
+ return this.add(keyOrNode, value);
230
230
  });
231
231
  }
232
232
  /**
@@ -1065,13 +1065,13 @@ class BinaryTree {
1065
1065
  * @returns {N} - The destination node after the swap.
1066
1066
  */
1067
1067
  _swap(srcNode, destNode) {
1068
- const { key, val } = destNode;
1069
- const tempNode = this.createNode(key, val);
1068
+ const { key, value } = destNode;
1069
+ const tempNode = this.createNode(key, value);
1070
1070
  if (tempNode) {
1071
1071
  destNode.key = srcNode.key;
1072
- destNode.val = srcNode.val;
1072
+ destNode.value = srcNode.value;
1073
1073
  srcNode.key = tempNode.key;
1074
- srcNode.val = tempNode.val;
1074
+ srcNode.value = tempNode.value;
1075
1075
  }
1076
1076
  return destNode;
1077
1077
  }
@@ -10,7 +10,7 @@ import { CP, IterationType } from '../../types';
10
10
  import { BinaryTree, BinaryTreeNode } from './binary-tree';
11
11
  import { IBinaryTree } from '../../interfaces';
12
12
  export declare class BSTNode<V = any, N extends BSTNode<V, N> = BSTNodeNested<V>> extends BinaryTreeNode<V, N> {
13
- constructor(key: BTNKey, val?: V);
13
+ constructor(key: BTNKey, value?: V);
14
14
  }
15
15
  export declare class BST<V = any, N extends BSTNode<V, N> = BSTNode<V, BSTNodeNested<V>>> extends BinaryTree<V, N> implements IBinaryTree<V, N> {
16
16
  /**
@@ -24,26 +24,26 @@ export declare class BST<V = any, N extends BSTNode<V, N> = BSTNode<V, BSTNodeNe
24
24
  * The function creates a new binary search tree node with the given key and value.
25
25
  * @param {BTNKey} key - The key parameter is the key value that will be associated with
26
26
  * the new node. It is used to determine the position of the node in the binary search tree.
27
- * @param [val] - The parameter `val` is an optional value that can be assigned to the node. It
27
+ * @param [value] - The parameter `value` is an optional value that can be assigned to the node. It
28
28
  * represents the value associated with the node in a binary search tree.
29
29
  * @returns a new instance of the BSTNode class with the specified key and value.
30
30
  */
31
- createNode(key: BTNKey, val?: V): N;
31
+ createNode(key: BTNKey, value?: V): N;
32
32
  /**
33
33
  * The `add` function in a binary search tree class inserts a new node with a given key and value
34
34
  * into the tree.
35
35
  * @param {BTNKey | N | null} keyOrNode - The `keyOrNode` parameter can be either a
36
36
  * `BTNKey` (which can be a number or a string), a `BSTNode` object, or `null`.
37
- * @param [val] - The `val` parameter is the value to be assigned to the new node being added to the
37
+ * @param [value] - The `value` parameter is the value to be assigned to the new node being added to the
38
38
  * binary search tree.
39
39
  * @returns the inserted node (N) if it was successfully added to the binary search tree. If the node
40
40
  * was not added or if the parameters were invalid, it returns null or undefined.
41
41
  */
42
- add(keyOrNode: BTNKey | N | null, val?: V): N | null | undefined;
42
+ add(keyOrNode: BTNKey | N | null, value?: V): N | null | undefined;
43
43
  /**
44
44
  * The `addMany` function is used to efficiently add multiple nodes to a binary search tree while
45
45
  * maintaining balance.
46
- * @param {[BTNKey | N, N['val']][]} keysOrNodes - The `arr` parameter in the `addMany` function
46
+ * @param {[BTNKey | N, N['value']][]} keysOrNodes - The `arr` parameter in the `addMany` function
47
47
  * represents an array of keys or nodes that need to be added to the binary search tree. It can be an
48
48
  * array of `BTNKey` or `N` (which represents the node type in the binary search tree) or
49
49
  * `null
@@ -5,8 +5,8 @@ const types_1 = require("../../types");
5
5
  const binary_tree_1 = require("./binary-tree");
6
6
  const queue_1 = require("../queue");
7
7
  class BSTNode extends binary_tree_1.BinaryTreeNode {
8
- constructor(key, val) {
9
- super(key, val);
8
+ constructor(key, value) {
9
+ super(key, value);
10
10
  }
11
11
  }
12
12
  exports.BSTNode = BSTNode;
@@ -31,24 +31,24 @@ class BST extends binary_tree_1.BinaryTree {
31
31
  * The function creates a new binary search tree node with the given key and value.
32
32
  * @param {BTNKey} key - The key parameter is the key value that will be associated with
33
33
  * the new node. It is used to determine the position of the node in the binary search tree.
34
- * @param [val] - The parameter `val` is an optional value that can be assigned to the node. It
34
+ * @param [value] - The parameter `value` is an optional value that can be assigned to the node. It
35
35
  * represents the value associated with the node in a binary search tree.
36
36
  * @returns a new instance of the BSTNode class with the specified key and value.
37
37
  */
38
- createNode(key, val) {
39
- return new BSTNode(key, val);
38
+ createNode(key, value) {
39
+ return new BSTNode(key, value);
40
40
  }
41
41
  /**
42
42
  * The `add` function in a binary search tree class inserts a new node with a given key and value
43
43
  * into the tree.
44
44
  * @param {BTNKey | N | null} keyOrNode - The `keyOrNode` parameter can be either a
45
45
  * `BTNKey` (which can be a number or a string), a `BSTNode` object, or `null`.
46
- * @param [val] - The `val` parameter is the value to be assigned to the new node being added to the
46
+ * @param [value] - The `value` parameter is the value to be assigned to the new node being added to the
47
47
  * binary search tree.
48
48
  * @returns the inserted node (N) if it was successfully added to the binary search tree. If the node
49
49
  * was not added or if the parameters were invalid, it returns null or undefined.
50
50
  */
51
- add(keyOrNode, val) {
51
+ add(keyOrNode, value) {
52
52
  // TODO support node as a parameter
53
53
  let inserted = null;
54
54
  let newNode = null;
@@ -56,7 +56,7 @@ class BST extends binary_tree_1.BinaryTree {
56
56
  newNode = keyOrNode;
57
57
  }
58
58
  else if (typeof keyOrNode === 'number') {
59
- newNode = this.createNode(keyOrNode, val);
59
+ newNode = this.createNode(keyOrNode, value);
60
60
  }
61
61
  else if (keyOrNode === null) {
62
62
  newNode = null;
@@ -73,7 +73,7 @@ class BST extends binary_tree_1.BinaryTree {
73
73
  if (cur !== null && newNode !== null) {
74
74
  if (this._compare(cur.key, newNode.key) === types_1.CP.eq) {
75
75
  if (newNode) {
76
- cur.val = newNode.val;
76
+ cur.value = newNode.value;
77
77
  }
78
78
  //Duplicates are not accepted.
79
79
  traversing = false;
@@ -126,7 +126,7 @@ class BST extends binary_tree_1.BinaryTree {
126
126
  /**
127
127
  * The `addMany` function is used to efficiently add multiple nodes to a binary search tree while
128
128
  * maintaining balance.
129
- * @param {[BTNKey | N, N['val']][]} keysOrNodes - The `arr` parameter in the `addMany` function
129
+ * @param {[BTNKey | N, N['value']][]} keysOrNodes - The `arr` parameter in the `addMany` function
130
130
  * represents an array of keys or nodes that need to be added to the binary search tree. It can be an
131
131
  * array of `BTNKey` or `N` (which represents the node type in the binary search tree) or
132
132
  * `null
@@ -170,7 +170,7 @@ class BST extends binary_tree_1.BinaryTree {
170
170
  throw new Error('Invalid input keysOrNodes');
171
171
  }
172
172
  sortedKeysOrNodes = sorted.map(([keyOrNode]) => keyOrNode);
173
- sortedData = sorted.map(([, val]) => val);
173
+ sortedData = sorted.map(([, value]) => value);
174
174
  const recursive = (arr, data) => {
175
175
  if (arr.length === 0)
176
176
  return;
@@ -414,7 +414,7 @@ class BST extends binary_tree_1.BinaryTree {
414
414
  return;
415
415
  const m = l + Math.floor((r - l) / 2);
416
416
  const midNode = sorted[m];
417
- this.add(midNode.key, midNode.val);
417
+ this.add(midNode.key, midNode.value);
418
418
  buildBalanceBST(l, m - 1);
419
419
  buildBalanceBST(m + 1, r);
420
420
  };
@@ -430,7 +430,7 @@ class BST extends binary_tree_1.BinaryTree {
430
430
  if (l <= r) {
431
431
  const m = l + Math.floor((r - l) / 2);
432
432
  const midNode = sorted[m];
433
- this.add(midNode.key, midNode.val);
433
+ this.add(midNode.key, midNode.value);
434
434
  stack.push([m + 1, r]);
435
435
  stack.push([l, m - 1]);
436
436
  }
@@ -2,12 +2,12 @@ import { BTNKey, RBColor, RBTreeNodeNested, RBTreeOptions } from '../../types';
2
2
  import { IBinaryTree } from '../../interfaces';
3
3
  import { BST, BSTNode } from './bst';
4
4
  export declare class RBTreeNode<V = any, N extends RBTreeNode<V, N> = RBTreeNodeNested<V>> extends BSTNode<V, N> {
5
- constructor(key: BTNKey, val?: V);
5
+ constructor(key: BTNKey, value?: V);
6
6
  private _color;
7
7
  get color(): RBColor;
8
8
  set color(value: RBColor);
9
9
  }
10
10
  export declare class RBTree<V, N extends RBTreeNode<V, N> = RBTreeNode<V, RBTreeNodeNested<V>>> extends BST<V, N> implements IBinaryTree<V, N> {
11
11
  constructor(options?: RBTreeOptions);
12
- createNode(key: BTNKey, val?: V): N;
12
+ createNode(key: BTNKey, value?: V): N;
13
13
  }
@@ -4,8 +4,8 @@ exports.RBTree = exports.RBTreeNode = void 0;
4
4
  const types_1 = require("../../types");
5
5
  const bst_1 = require("./bst");
6
6
  class RBTreeNode extends bst_1.BSTNode {
7
- constructor(key, val) {
8
- super(key, val);
7
+ constructor(key, value) {
8
+ super(key, value);
9
9
  this._color = types_1.RBColor.RED;
10
10
  }
11
11
  get color() {
@@ -20,8 +20,8 @@ class RBTree extends bst_1.BST {
20
20
  constructor(options) {
21
21
  super(options);
22
22
  }
23
- createNode(key, val) {
24
- return new RBTreeNode(key, val);
23
+ createNode(key, value) {
24
+ return new RBTreeNode(key, value);
25
25
  }
26
26
  }
27
27
  exports.RBTree = RBTree;
@@ -7,16 +7,16 @@
7
7
  */
8
8
  import type { SegmentTreeNodeVal } from '../../types';
9
9
  export declare class SegmentTreeNode {
10
- constructor(start: number, end: number, sum: number, val?: SegmentTreeNodeVal | null);
10
+ constructor(start: number, end: number, sum: number, value?: SegmentTreeNodeVal | null);
11
11
  private _start;
12
12
  get start(): number;
13
13
  set start(v: number);
14
14
  private _end;
15
15
  get end(): number;
16
16
  set end(v: number);
17
- private _val;
18
- get val(): SegmentTreeNodeVal | null;
19
- set val(v: SegmentTreeNodeVal | null);
17
+ private _value;
18
+ get value(): SegmentTreeNodeVal | null;
19
+ set value(v: SegmentTreeNodeVal | null);
20
20
  private _sum;
21
21
  get sum(): number;
22
22
  set sum(v: number);
@@ -62,12 +62,12 @@ export declare class SegmentTree {
62
62
  * updated.
63
63
  * @param {number} sum - The `sum` parameter represents the new value that should be assigned to the `sum` property of
64
64
  * the `SegmentTreeNode` at the specified `index`.
65
- * @param {SegmentTreeNodeVal} [val] - The `val` parameter is an optional value that can be assigned to the `val`
65
+ * @param {SegmentTreeNodeVal} [value] - The `value` parameter is an optional value that can be assigned to the `value`
66
66
  * property of the `SegmentTreeNode` object. It is not currently used in the code, but you can uncomment the line `//
67
- * cur.val = val;` and pass a value for `val` in the
67
+ * cur.value = value;` and pass a value for `value` in the
68
68
  * @returns The function does not return anything.
69
69
  */
70
- updateNode(index: number, sum: number, val?: SegmentTreeNodeVal): void;
70
+ updateNode(index: number, sum: number, value?: SegmentTreeNodeVal): void;
71
71
  /**
72
72
  * The function `querySumByRange` calculates the sum of values within a given range in a segment tree.
73
73
  * @param {number} indexA - The starting index of the range for which you want to calculate the sum.
@@ -9,17 +9,17 @@
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.SegmentTree = exports.SegmentTreeNode = void 0;
11
11
  class SegmentTreeNode {
12
- constructor(start, end, sum, val) {
12
+ constructor(start, end, sum, value) {
13
13
  this._start = 0;
14
14
  this._end = 0;
15
- this._val = null;
15
+ this._value = null;
16
16
  this._sum = 0;
17
17
  this._left = null;
18
18
  this._right = null;
19
19
  this._start = start;
20
20
  this._end = end;
21
21
  this._sum = sum;
22
- this._val = val || null;
22
+ this._value = value || null;
23
23
  }
24
24
  get start() {
25
25
  return this._start;
@@ -33,11 +33,11 @@ class SegmentTreeNode {
33
33
  set end(v) {
34
34
  this._end = v;
35
35
  }
36
- get val() {
37
- return this._val;
36
+ get value() {
37
+ return this._value;
38
38
  }
39
- set val(v) {
40
- this._val = v;
39
+ set value(v) {
40
+ this._value = v;
41
41
  }
42
42
  get sum() {
43
43
  return this._sum;
@@ -126,39 +126,39 @@ class SegmentTree {
126
126
  * updated.
127
127
  * @param {number} sum - The `sum` parameter represents the new value that should be assigned to the `sum` property of
128
128
  * the `SegmentTreeNode` at the specified `index`.
129
- * @param {SegmentTreeNodeVal} [val] - The `val` parameter is an optional value that can be assigned to the `val`
129
+ * @param {SegmentTreeNodeVal} [value] - The `value` parameter is an optional value that can be assigned to the `value`
130
130
  * property of the `SegmentTreeNode` object. It is not currently used in the code, but you can uncomment the line `//
131
- * cur.val = val;` and pass a value for `val` in the
131
+ * cur.value = value;` and pass a value for `value` in the
132
132
  * @returns The function does not return anything.
133
133
  */
134
- updateNode(index, sum, val) {
134
+ updateNode(index, sum, value) {
135
135
  const root = this.root || null;
136
136
  if (!root) {
137
137
  return;
138
138
  }
139
- const dfs = (cur, index, sum, val) => {
139
+ const dfs = (cur, index, sum, value) => {
140
140
  if (cur.start === cur.end && cur.start === index) {
141
141
  cur.sum = sum;
142
- if (val !== undefined)
143
- cur.val = val;
142
+ if (value !== undefined)
143
+ cur.value = value;
144
144
  return;
145
145
  }
146
146
  const mid = cur.start + Math.floor((cur.end - cur.start) / 2);
147
147
  if (index <= mid) {
148
148
  if (cur.left) {
149
- dfs(cur.left, index, sum, val);
149
+ dfs(cur.left, index, sum, value);
150
150
  }
151
151
  }
152
152
  else {
153
153
  if (cur.right) {
154
- dfs(cur.right, index, sum, val);
154
+ dfs(cur.right, index, sum, value);
155
155
  }
156
156
  }
157
157
  if (cur.left && cur.right) {
158
158
  cur.sum = cur.left.sum + cur.right.sum;
159
159
  }
160
160
  };
161
- dfs(root, index, sum, val);
161
+ dfs(root, index, sum, value);
162
162
  }
163
163
  /**
164
164
  * The function `querySumByRange` calculates the sum of values within a given range in a segment tree.
@@ -15,13 +15,13 @@ export declare class TreeMultisetNode<V = any, N extends TreeMultisetNode<V, N>
15
15
  * The constructor function initializes a BinaryTreeNode object with a key, value, and count.
16
16
  * @param {BTNKey} key - The `key` parameter is of type `BTNKey` and represents the unique identifier
17
17
  * of the binary tree node.
18
- * @param {V} [val] - The `val` parameter is an optional parameter of type `V`. It represents the value of the binary
18
+ * @param {V} [value] - The `value` parameter is an optional parameter of type `V`. It represents the value of the binary
19
19
  * tree node. If no value is provided, it will be `undefined`.
20
20
  * @param {number} [count=1] - The `count` parameter is a number that represents the number of times a particular value
21
21
  * occurs in a binary tree node. It has a default value of 1, which means that if no value is provided for the `count`
22
22
  * parameter when creating a new instance of the `BinaryTreeNode` class.
23
23
  */
24
- constructor(key: BTNKey, val?: V, count?: number);
24
+ constructor(key: BTNKey, value?: V, count?: number);
25
25
  }
26
26
  /**
27
27
  * The only distinction between a TreeMultiset and a AVLTree lies in the ability of the former to store duplicate nodes through the utilization of counters.
@@ -40,26 +40,26 @@ export declare class TreeMultiset<V = any, N extends TreeMultisetNode<V, N> = Tr
40
40
  * The function creates a new BSTNode with the given key, value, and count.
41
41
  * @param {BTNKey} key - The key parameter is the unique identifier for the binary tree node. It is used to
42
42
  * distinguish one node from another in the tree.
43
- * @param {N} val - The `val` parameter represents the value that will be stored in the binary search tree node.
43
+ * @param {N} value - The `value` parameter represents the value that will be stored in the binary search tree node.
44
44
  * @param {number} [count] - The "count" parameter is an optional parameter of type number. It represents the number of
45
45
  * occurrences of the value in the binary search tree node. If not provided, the count will default to 1.
46
46
  * @returns A new instance of the BSTNode class with the specified key, value, and count (if provided).
47
47
  */
48
- createNode(key: BTNKey, val?: V, count?: number): N;
48
+ createNode(key: BTNKey, value?: V, count?: number): N;
49
49
  /**
50
50
  * The `add` function adds a new node to a binary search tree, updating the count if the key already
51
51
  * exists, and balancing the tree if necessary.
52
52
  * @param {BTNKey | N | null} keyOrNode - The `keyOrNode` parameter can be either a
53
53
  * `BTNKey` (which represents the key of the node to be added), a `N` (which represents a
54
54
  * node to be added), or `null` (which represents a null node).
55
- * @param [val] - The `val` parameter represents the value associated with the key that is being
55
+ * @param [value] - The `value` parameter represents the value associated with the key that is being
56
56
  * added to the binary tree.
57
57
  * @param [count=1] - The `count` parameter represents the number of occurrences of the key/value
58
58
  * pair that will be added to the binary tree. It has a default value of 1, which means that if no
59
59
  * count is specified, the default count will be 1.
60
60
  * @returns The function `add` returns a value of type `N | null | undefined`.
61
61
  */
62
- add(keyOrNode: BTNKey | N | null, val?: V, count?: number): N | null | undefined;
62
+ add(keyOrNode: BTNKey | N | null, value?: V, count?: number): N | null | undefined;
63
63
  /**
64
64
  * The function adds a new node to a binary tree if there is an available slot in the parent node.
65
65
  * @param {N | null} newNode - The `newNode` parameter represents the node that needs to be added to