min-heap-typed 1.39.6 → 1.40.0

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 (93) hide show
  1. package/dist/data-structures/binary-tree/avl-tree.js +0 -1
  2. package/dist/data-structures/binary-tree/binary-indexed-tree.d.ts +0 -3
  3. package/dist/data-structures/binary-tree/binary-indexed-tree.js +2 -11
  4. package/dist/data-structures/binary-tree/binary-tree.d.ts +5 -20
  5. package/dist/data-structures/binary-tree/binary-tree.js +8 -29
  6. package/dist/data-structures/binary-tree/bst.d.ts +1 -1
  7. package/dist/data-structures/binary-tree/bst.js +3 -3
  8. package/dist/data-structures/binary-tree/rb-tree.d.ts +1 -3
  9. package/dist/data-structures/binary-tree/rb-tree.js +1 -7
  10. package/dist/data-structures/binary-tree/segment-tree.d.ts +10 -26
  11. package/dist/data-structures/binary-tree/segment-tree.js +10 -58
  12. package/dist/data-structures/binary-tree/tree-multiset.d.ts +1 -1
  13. package/dist/data-structures/binary-tree/tree-multiset.js +6 -6
  14. package/dist/data-structures/graph/abstract-graph.d.ts +5 -24
  15. package/dist/data-structures/graph/abstract-graph.js +4 -43
  16. package/dist/data-structures/graph/directed-graph.d.ts +4 -10
  17. package/dist/data-structures/graph/directed-graph.js +2 -20
  18. package/dist/data-structures/graph/map-graph.d.ts +4 -10
  19. package/dist/data-structures/graph/map-graph.js +2 -20
  20. package/dist/data-structures/graph/undirected-graph.d.ts +1 -8
  21. package/dist/data-structures/graph/undirected-graph.js +1 -14
  22. package/dist/data-structures/hash/coordinate-map.d.ts +0 -1
  23. package/dist/data-structures/hash/coordinate-map.js +0 -3
  24. package/dist/data-structures/hash/coordinate-set.d.ts +0 -1
  25. package/dist/data-structures/hash/coordinate-set.js +0 -3
  26. package/dist/data-structures/hash/hash-map.d.ts +8 -14
  27. package/dist/data-structures/hash/hash-map.js +4 -22
  28. package/dist/data-structures/hash/hash-table.d.ts +6 -9
  29. package/dist/data-structures/hash/hash-table.js +0 -9
  30. package/dist/data-structures/heap/heap.d.ts +12 -6
  31. package/dist/data-structures/heap/heap.js +40 -22
  32. package/dist/data-structures/linked-list/doubly-linked-list.d.ts +6 -14
  33. package/dist/data-structures/linked-list/doubly-linked-list.js +18 -42
  34. package/dist/data-structures/linked-list/singly-linked-list.d.ts +5 -11
  35. package/dist/data-structures/linked-list/singly-linked-list.js +17 -35
  36. package/dist/data-structures/linked-list/skip-linked-list.d.ts +29 -10
  37. package/dist/data-structures/linked-list/skip-linked-list.js +62 -17
  38. package/dist/data-structures/matrix/matrix.d.ts +1 -1
  39. package/dist/data-structures/matrix/matrix2d.d.ts +1 -1
  40. package/dist/data-structures/matrix/navigator.d.ts +4 -4
  41. package/dist/data-structures/queue/deque.d.ts +8 -12
  42. package/dist/data-structures/queue/deque.js +31 -43
  43. package/dist/data-structures/queue/queue.d.ts +20 -5
  44. package/dist/data-structures/queue/queue.js +35 -18
  45. package/dist/data-structures/stack/stack.d.ts +2 -1
  46. package/dist/data-structures/stack/stack.js +10 -7
  47. package/dist/data-structures/tree/tree.d.ts +3 -9
  48. package/dist/data-structures/tree/tree.js +3 -21
  49. package/dist/data-structures/trie/trie.d.ts +6 -12
  50. package/dist/data-structures/trie/trie.js +6 -24
  51. package/dist/interfaces/binary-tree.d.ts +1 -1
  52. package/dist/types/data-structures/binary-tree/bst.d.ts +1 -1
  53. package/package.json +2 -2
  54. package/src/data-structures/binary-tree/avl-tree.ts +2 -4
  55. package/src/data-structures/binary-tree/binary-indexed-tree.ts +3 -15
  56. package/src/data-structures/binary-tree/binary-tree.ts +17 -42
  57. package/src/data-structures/binary-tree/bst.ts +5 -6
  58. package/src/data-structures/binary-tree/rb-tree.ts +13 -21
  59. package/src/data-structures/binary-tree/segment-tree.ts +16 -83
  60. package/src/data-structures/binary-tree/tree-multiset.ts +8 -9
  61. package/src/data-structures/graph/abstract-graph.ts +21 -67
  62. package/src/data-structures/graph/directed-graph.ts +13 -39
  63. package/src/data-structures/graph/map-graph.ts +7 -32
  64. package/src/data-structures/graph/undirected-graph.ts +9 -26
  65. package/src/data-structures/hash/coordinate-map.ts +0 -4
  66. package/src/data-structures/hash/coordinate-set.ts +0 -4
  67. package/src/data-structures/hash/hash-map.ts +13 -37
  68. package/src/data-structures/hash/hash-table.ts +6 -18
  69. package/src/data-structures/hash/tree-map.ts +2 -1
  70. package/src/data-structures/hash/tree-set.ts +2 -1
  71. package/src/data-structures/heap/heap.ts +58 -30
  72. package/src/data-structures/heap/max-heap.ts +1 -1
  73. package/src/data-structures/heap/min-heap.ts +1 -1
  74. package/src/data-structures/linked-list/doubly-linked-list.ts +26 -60
  75. package/src/data-structures/linked-list/singly-linked-list.ts +24 -49
  76. package/src/data-structures/linked-list/skip-linked-list.ts +73 -25
  77. package/src/data-structures/matrix/matrix.ts +2 -2
  78. package/src/data-structures/matrix/matrix2d.ts +1 -1
  79. package/src/data-structures/matrix/navigator.ts +4 -4
  80. package/src/data-structures/matrix/vector2d.ts +2 -1
  81. package/src/data-structures/priority-queue/max-priority-queue.ts +1 -1
  82. package/src/data-structures/priority-queue/min-priority-queue.ts +1 -1
  83. package/src/data-structures/priority-queue/priority-queue.ts +1 -1
  84. package/src/data-structures/queue/deque.ts +38 -53
  85. package/src/data-structures/queue/queue.ts +38 -20
  86. package/src/data-structures/stack/stack.ts +13 -9
  87. package/src/data-structures/tree/tree.ts +7 -33
  88. package/src/data-structures/trie/trie.ts +14 -40
  89. package/src/interfaces/binary-tree.ts +1 -1
  90. package/src/types/data-structures/binary-tree/bst.ts +1 -1
  91. package/src/types/data-structures/matrix/navigator.ts +1 -1
  92. package/src/types/utils/utils.ts +1 -1
  93. package/src/types/utils/validate-type.ts +2 -2
@@ -48,7 +48,6 @@ class AVLTree extends bst_1.BST {
48
48
  * @returns The method is returning the inserted node (`N`), `null`, or `undefined`.
49
49
  */
50
50
  add(keyOrNode, value) {
51
- // TODO support node as a param
52
51
  const inserted = super.add(keyOrNode, value);
53
52
  if (inserted)
54
53
  this._balancePath(inserted);
@@ -13,13 +13,10 @@ export declare class BinaryIndexedTree {
13
13
  });
14
14
  protected _freqMap: Record<number, number>;
15
15
  get freqMap(): Record<number, number>;
16
- set freqMap(value: Record<number, number>);
17
16
  protected _msb: number;
18
17
  get msb(): number;
19
- set msb(value: number);
20
18
  protected _negativeCount: number;
21
19
  get negativeCount(): number;
22
- set negativeCount(value: number);
23
20
  get freq(): number;
24
21
  get max(): number;
25
22
  /**
@@ -26,21 +26,12 @@ class BinaryIndexedTree {
26
26
  get freqMap() {
27
27
  return this._freqMap;
28
28
  }
29
- set freqMap(value) {
30
- this._freqMap = value;
31
- }
32
29
  get msb() {
33
30
  return this._msb;
34
31
  }
35
- set msb(value) {
36
- this._msb = value;
37
- }
38
32
  get negativeCount() {
39
33
  return this._negativeCount;
40
34
  }
41
- set negativeCount(value) {
42
- this._negativeCount = value;
43
- }
44
35
  get freq() {
45
36
  return this._freq;
46
37
  }
@@ -198,10 +189,10 @@ class BinaryIndexedTree {
198
189
  */
199
190
  _updateNegativeCount(freqCur, freqNew) {
200
191
  if (freqCur < 0 && freqNew >= 0) {
201
- this.negativeCount--;
192
+ this._negativeCount--;
202
193
  }
203
194
  else if (freqCur >= 0 && freqNew < 0) {
204
- this.negativeCount++;
195
+ this._negativeCount++;
205
196
  }
206
197
  }
207
198
  /**
@@ -32,7 +32,7 @@ export declare class BinaryTreeNode<V = any, N extends BinaryTreeNode<V, N> = Bi
32
32
  * @param {V} value - The value stored in the node.
33
33
  */
34
34
  constructor(key: BTNKey, value?: V);
35
- private _left;
35
+ protected _left: N | null | undefined;
36
36
  /**
37
37
  * Get the left child node.
38
38
  */
@@ -42,7 +42,7 @@ export declare class BinaryTreeNode<V = any, N extends BinaryTreeNode<V, N> = Bi
42
42
  * @param {N | null | undefined} v - The left child node.
43
43
  */
44
44
  set left(v: N | null | undefined);
45
- private _right;
45
+ protected _right: N | null | undefined;
46
46
  /**
47
47
  * Get the right child node.
48
48
  */
@@ -63,27 +63,18 @@ export declare class BinaryTreeNode<V = any, N extends BinaryTreeNode<V, N> = Bi
63
63
  * @template N - The type of the binary tree's nodes.
64
64
  */
65
65
  export declare class BinaryTree<V = any, N extends BinaryTreeNode<V, N> = BinaryTreeNode<V, BinaryTreeNodeNested<V>>> implements IBinaryTree<V, N> {
66
+ iterationType: IterationType;
66
67
  /**
67
68
  * Creates a new instance of BinaryTree.
68
69
  * @param {BinaryTreeOptions} [options] - The options for the binary tree.
69
70
  */
70
71
  constructor(options?: BinaryTreeOptions);
71
- private _iterationType;
72
- /**
73
- * Get the iteration type used in the binary tree.
74
- */
75
- get iterationType(): IterationType;
76
- /**
77
- * Set the iteration type for the binary tree.
78
- * @param {IterationType} v - The new iteration type to set.
79
- */
80
- set iterationType(v: IterationType);
81
- private _root;
72
+ protected _root: N | null;
82
73
  /**
83
74
  * Get the root node of the binary tree.
84
75
  */
85
76
  get root(): N | null;
86
- private _size;
77
+ protected _size: number;
87
78
  /**
88
79
  * Get the number of nodes in the binary tree.
89
80
  */
@@ -361,10 +352,4 @@ export declare class BinaryTree<V = any, N extends BinaryTreeNode<V, N> = Binary
361
352
  * type `N` or `null`.
362
353
  */
363
354
  protected _setRoot(v: N | null): void;
364
- /**
365
- * The function sets the value of the protected property "_size" to the given number.
366
- * @param {number} v - The parameter "v" is a number that represents the size value that we want to
367
- * set.
368
- */
369
- protected _setSize(v: number): void;
370
355
  }
@@ -87,27 +87,14 @@ class BinaryTree {
87
87
  * @param {BinaryTreeOptions} [options] - The options for the binary tree.
88
88
  */
89
89
  constructor(options) {
90
- this._iterationType = types_1.IterationType.ITERATIVE;
90
+ this.iterationType = types_1.IterationType.ITERATIVE;
91
91
  this._root = null;
92
92
  this._size = 0;
93
93
  if (options !== undefined) {
94
94
  const { iterationType = types_1.IterationType.ITERATIVE } = options;
95
- this._iterationType = iterationType;
95
+ this.iterationType = iterationType;
96
96
  }
97
97
  }
98
- /**
99
- * Get the iteration type used in the binary tree.
100
- */
101
- get iterationType() {
102
- return this._iterationType;
103
- }
104
- /**
105
- * Set the iteration type for the binary tree.
106
- * @param {IterationType} v - The new iteration type to set.
107
- */
108
- set iterationType(v) {
109
- this._iterationType = v;
110
- }
111
98
  /**
112
99
  * Get the root node of the binary tree.
113
100
  */
@@ -133,7 +120,7 @@ class BinaryTree {
133
120
  * Clear the binary tree, removing all nodes.
134
121
  */
135
122
  clear() {
136
- this._root = null;
123
+ this._setRoot(null);
137
124
  this._size = 0;
138
125
  }
139
126
  /**
@@ -197,10 +184,10 @@ class BinaryTree {
197
184
  else {
198
185
  this._setRoot(needInsert);
199
186
  if (needInsert !== null) {
200
- this._setSize(1);
187
+ this._size = 1;
201
188
  }
202
189
  else {
203
- this._setSize(0);
190
+ this._size = 0;
204
191
  }
205
192
  inserted = this.root;
206
193
  }
@@ -297,7 +284,7 @@ class BinaryTree {
297
284
  }
298
285
  }
299
286
  }
300
- this._setSize(this.size - 1);
287
+ this._size = this.size - 1;
301
288
  bstDeletedResult.push({ deleted: orgCurrent, needBalanced });
302
289
  return bstDeletedResult;
303
290
  }
@@ -1093,14 +1080,14 @@ class BinaryTree {
1093
1080
  if (parent.left === undefined) {
1094
1081
  parent.left = newNode;
1095
1082
  if (newNode) {
1096
- this._setSize(this.size + 1);
1083
+ this._size = this.size + 1;
1097
1084
  }
1098
1085
  return parent.left;
1099
1086
  }
1100
1087
  else if (parent.right === undefined) {
1101
1088
  parent.right = newNode;
1102
1089
  if (newNode) {
1103
- this._setSize(this.size + 1);
1090
+ this._size = this.size + 1;
1104
1091
  }
1105
1092
  return parent.right;
1106
1093
  }
@@ -1124,13 +1111,5 @@ class BinaryTree {
1124
1111
  }
1125
1112
  this._root = v;
1126
1113
  }
1127
- /**
1128
- * The function sets the value of the protected property "_size" to the given number.
1129
- * @param {number} v - The parameter "v" is a number that represents the size value that we want to
1130
- * set.
1131
- */
1132
- _setSize(v) {
1133
- this._size = v;
1134
- }
1135
1114
  }
1136
1115
  exports.BinaryTree = BinaryTree;
@@ -5,7 +5,7 @@
5
5
  * @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
6
6
  * @license MIT License
7
7
  */
8
- import type { BTNKey, BSTComparator, BSTNodeNested, BSTOptions, BTNCallback } from '../../types';
8
+ import type { BSTComparator, BSTNodeNested, BSTOptions, BTNCallback, BTNKey } from '../../types';
9
9
  import { CP, IterationType } from '../../types';
10
10
  import { BinaryTree, BinaryTreeNode } from './binary-tree';
11
11
  import { IBinaryTree } from '../../interfaces';
@@ -63,7 +63,7 @@ class BST extends binary_tree_1.BinaryTree {
63
63
  }
64
64
  if (this.root === null) {
65
65
  this._setRoot(newNode);
66
- this._setSize(this.size + 1);
66
+ this._size = this.size + 1;
67
67
  inserted = this.root;
68
68
  }
69
69
  else {
@@ -87,7 +87,7 @@ class BST extends binary_tree_1.BinaryTree {
87
87
  }
88
88
  //Add to the left of the current node
89
89
  cur.left = newNode;
90
- this._setSize(this.size + 1);
90
+ this._size = this.size + 1;
91
91
  traversing = false;
92
92
  inserted = cur.left;
93
93
  }
@@ -105,7 +105,7 @@ class BST extends binary_tree_1.BinaryTree {
105
105
  }
106
106
  //Add to the right of the current node
107
107
  cur.right = newNode;
108
- this._setSize(this.size + 1);
108
+ this._size = this.size + 1;
109
109
  traversing = false;
110
110
  inserted = cur.right;
111
111
  }
@@ -3,9 +3,7 @@ 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
5
  constructor(key: BTNKey, value?: V);
6
- private _color;
7
- get color(): RBColor;
8
- set color(value: RBColor);
6
+ color: RBColor;
9
7
  }
10
8
  export declare class RBTree<V, N extends RBTreeNode<V, N> = RBTreeNode<V, RBTreeNodeNested<V>>> extends BST<V, N> implements IBinaryTree<V, N> {
11
9
  constructor(options?: RBTreeOptions);
@@ -6,13 +6,7 @@ const bst_1 = require("./bst");
6
6
  class RBTreeNode extends bst_1.BSTNode {
7
7
  constructor(key, value) {
8
8
  super(key, value);
9
- this._color = types_1.RBColor.RED;
10
- }
11
- get color() {
12
- return this._color;
13
- }
14
- set color(value) {
15
- this._color = value;
9
+ this.color = types_1.RBColor.RED;
16
10
  }
17
11
  }
18
12
  exports.RBTreeNode = RBTreeNode;
@@ -7,25 +7,13 @@
7
7
  */
8
8
  import type { SegmentTreeNodeVal } from '../../types';
9
9
  export declare class SegmentTreeNode {
10
+ start: number;
11
+ end: number;
12
+ value: SegmentTreeNodeVal | null;
13
+ sum: number;
14
+ left: SegmentTreeNode | null;
15
+ right: SegmentTreeNode | null;
10
16
  constructor(start: number, end: number, sum: number, value?: SegmentTreeNodeVal | null);
11
- private _start;
12
- get start(): number;
13
- set start(v: number);
14
- private _end;
15
- get end(): number;
16
- set end(v: number);
17
- private _value;
18
- get value(): SegmentTreeNodeVal | null;
19
- set value(v: SegmentTreeNodeVal | null);
20
- private _sum;
21
- get sum(): number;
22
- set sum(v: number);
23
- private _left;
24
- get left(): SegmentTreeNode | null;
25
- set left(v: SegmentTreeNode | null);
26
- private _right;
27
- get right(): SegmentTreeNode | null;
28
- set right(v: SegmentTreeNode | null);
29
17
  }
30
18
  export declare class SegmentTree {
31
19
  /**
@@ -38,13 +26,13 @@ export declare class SegmentTree {
38
26
  * included in the range. If not provided, it defaults to the index of the last element in the "values" array.
39
27
  */
40
28
  constructor(values: number[], start?: number, end?: number);
41
- private _values;
29
+ protected _values: number[];
42
30
  get values(): number[];
43
- private _start;
31
+ protected _start: number;
44
32
  get start(): number;
45
- private _end;
33
+ protected _end: number;
46
34
  get end(): number;
47
- private _root;
35
+ protected _root: SegmentTreeNode | null;
48
36
  get root(): SegmentTreeNode | null;
49
37
  /**
50
38
  * The build function creates a segment tree by recursively dividing the given range into smaller segments and assigning
@@ -76,8 +64,4 @@ export declare class SegmentTree {
76
64
  * @returns The function `querySumByRange` returns a number.
77
65
  */
78
66
  querySumByRange(indexA: number, indexB: number): number;
79
- protected _setValues(value: number[]): void;
80
- protected _setStart(value: number): void;
81
- protected _setEnd(value: number): void;
82
- protected _setRoot(v: SegmentTreeNode | null): void;
83
67
  }
@@ -10,52 +10,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.SegmentTree = exports.SegmentTreeNode = void 0;
11
11
  class SegmentTreeNode {
12
12
  constructor(start, end, sum, value) {
13
- this._start = 0;
14
- this._end = 0;
15
- this._value = null;
16
- this._sum = 0;
17
- this._left = null;
18
- this._right = null;
19
- this._start = start;
20
- this._end = end;
21
- this._sum = sum;
22
- this._value = value || null;
23
- }
24
- get start() {
25
- return this._start;
26
- }
27
- set start(v) {
28
- this._start = v;
29
- }
30
- get end() {
31
- return this._end;
32
- }
33
- set end(v) {
34
- this._end = v;
35
- }
36
- get value() {
37
- return this._value;
38
- }
39
- set value(v) {
40
- this._value = v;
41
- }
42
- get sum() {
43
- return this._sum;
44
- }
45
- set sum(v) {
46
- this._sum = v;
47
- }
48
- get left() {
49
- return this._left;
50
- }
51
- set left(v) {
52
- this._left = v;
53
- }
54
- get right() {
55
- return this._right;
56
- }
57
- set right(v) {
58
- this._right = v;
13
+ this.start = 0;
14
+ this.end = 0;
15
+ this.value = null;
16
+ this.sum = 0;
17
+ this.left = null;
18
+ this.right = null;
19
+ this.start = start;
20
+ this.end = end;
21
+ this.sum = sum;
22
+ this.value = value || null;
59
23
  }
60
24
  }
61
25
  exports.SegmentTreeNode = SegmentTreeNode;
@@ -212,17 +176,5 @@ class SegmentTree {
212
176
  };
213
177
  return dfs(root, indexA, indexB);
214
178
  }
215
- _setValues(value) {
216
- this._values = value;
217
- }
218
- _setStart(value) {
219
- this._start = value;
220
- }
221
- _setEnd(value) {
222
- this._end = value;
223
- }
224
- _setRoot(v) {
225
- this._root = v;
226
- }
227
179
  }
228
180
  exports.SegmentTree = SegmentTree;
@@ -6,7 +6,7 @@
6
6
  * @license MIT License
7
7
  */
8
8
  import type { BTNKey, TreeMultisetNodeNested, TreeMultisetOptions } from '../../types';
9
- import { BinaryTreeDeletedResult, IterationType, BTNCallback } from '../../types';
9
+ import { BinaryTreeDeletedResult, BTNCallback, IterationType } from '../../types';
10
10
  import { IBinaryTree } from '../../interfaces';
11
11
  import { AVLTree, AVLTreeNode } from './avl-tree';
12
12
  export declare class TreeMultisetNode<V = any, N extends TreeMultisetNode<V, N> = TreeMultisetNodeNested<V>> extends AVLTreeNode<V, N> {
@@ -75,7 +75,7 @@ class TreeMultiset extends avl_tree_1.AVLTree {
75
75
  }
76
76
  if (!this.root) {
77
77
  this._setRoot(newNode);
78
- this._setSize(this.size + 1);
78
+ this._size = this.size + 1;
79
79
  newNode && this._setCount(this.count + newNode.count);
80
80
  inserted = this.root;
81
81
  }
@@ -97,7 +97,7 @@ class TreeMultiset extends avl_tree_1.AVLTree {
97
97
  if (cur.left === undefined) {
98
98
  //Add to the left of the current node
99
99
  cur.left = newNode;
100
- this._setSize(this.size + 1);
100
+ this._size = this.size + 1;
101
101
  this._setCount(this.count + newNode.count);
102
102
  traversing = false;
103
103
  inserted = cur.left;
@@ -113,7 +113,7 @@ class TreeMultiset extends avl_tree_1.AVLTree {
113
113
  if (cur.right === undefined) {
114
114
  //Add to the right of the current node
115
115
  cur.right = newNode;
116
- this._setSize(this.size + 1);
116
+ this._size = this.size + 1;
117
117
  this._setCount(this.count + newNode.count);
118
118
  traversing = false;
119
119
  inserted = cur.right;
@@ -151,7 +151,7 @@ class TreeMultiset extends avl_tree_1.AVLTree {
151
151
  if (parent.left === undefined) {
152
152
  parent.left = newNode;
153
153
  if (newNode !== null) {
154
- this._setSize(this.size + 1);
154
+ this._size = this.size + 1;
155
155
  this._setCount(this.count + newNode.count);
156
156
  }
157
157
  return parent.left;
@@ -159,7 +159,7 @@ class TreeMultiset extends avl_tree_1.AVLTree {
159
159
  else if (parent.right === undefined) {
160
160
  parent.right = newNode;
161
161
  if (newNode !== null) {
162
- this._setSize(this.size + 1);
162
+ this._size = (this.size + 1);
163
163
  this._setCount(this.count + newNode.count);
164
164
  }
165
165
  return parent.right;
@@ -304,7 +304,7 @@ class TreeMultiset extends avl_tree_1.AVLTree {
304
304
  }
305
305
  }
306
306
  }
307
- this._setSize(this.size - 1);
307
+ this._size = this.size - 1;
308
308
  // TODO How to handle when the count of target node is lesser than current node's count
309
309
  this._setCount(this.count - orgCurrent.count);
310
310
  }
@@ -1,6 +1,8 @@
1
1
  import type { DijkstraResult, VertexKey } from '../../types';
2
2
  import { IGraph } from '../../interfaces';
3
3
  export declare abstract class AbstractVertex<V = any> {
4
+ key: VertexKey;
5
+ value: V | undefined;
4
6
  /**
5
7
  * The function is a protected constructor that takes an key and an optional value as parameters.
6
8
  * @param {VertexKey} key - The `key` parameter is of type `VertexKey` and represents the identifier of the vertex. It is
@@ -9,14 +11,10 @@ export declare abstract class AbstractVertex<V = any> {
9
11
  * vertex. If no value is provided, it will be set to undefined.
10
12
  */
11
13
  protected constructor(key: VertexKey, value?: V);
12
- private _key;
13
- get key(): VertexKey;
14
- set key(v: VertexKey);
15
- private _value;
16
- get value(): V | undefined;
17
- set value(value: V | undefined);
18
14
  }
19
15
  export declare abstract class AbstractEdge<E = any> {
16
+ value: E | undefined;
17
+ weight: number;
20
18
  /**
21
19
  * The above function is a protected constructor that initializes the weight, value, and hash code properties of an
22
20
  * object.
@@ -27,27 +25,11 @@ export declare abstract class AbstractEdge<E = any> {
27
25
  * meaning it can be omitted when creating an instance of the class.
28
26
  */
29
27
  protected constructor(weight?: number, value?: E);
30
- private _value;
31
- get value(): E | undefined;
32
- set value(value: E | undefined);
33
- private _weight;
34
- get weight(): number;
35
- set weight(v: number);
36
28
  protected _hashCode: string;
37
29
  get hashCode(): string;
38
- /**
39
- * In TypeScript, a subclass inherits the interface implementation of its parent class, without needing to implement the same interface again in the subclass. This behavior differs from Java's approach. In Java, if a parent class implements an interface, the subclass needs to explicitly implement the same interface, even if the parent class has already implemented it.
40
- * This means that using abstract methods in the parent class cannot constrain the grandchild classes. Defining methods within an interface also cannot constrain the descendant classes. When inheriting from this class, developers need to be aware that this method needs to be overridden.
41
- */
42
- /**
43
- * The function sets the value of the _hashCode property to the provided string.
44
- * @param {string} v - The parameter "v" is of type string and represents the value that will be assigned to the
45
- * "_hashCode" property.
46
- */
47
- protected _setHashCode(v: string): void;
48
30
  }
49
31
  export declare abstract class AbstractGraph<V = any, E = any, VO extends AbstractVertex<V> = AbstractVertex<V>, EO extends AbstractEdge<E> = AbstractEdge<E>> implements IGraph<V, E, VO, EO> {
50
- private _vertices;
32
+ protected _vertices: Map<VertexKey, VO>;
51
33
  get vertices(): Map<VertexKey, VO>;
52
34
  /**
53
35
  * In TypeScript, a subclass inherits the interface implementation of its parent class, without needing to implement the same interface again in the subclass. This behavior differs from Java's approach. In Java, if a parent class implements an interface, the subclass needs to explicitly implement the same interface, even if the parent class has already implemented it.
@@ -328,5 +310,4 @@ export declare abstract class AbstractGraph<V = any, E = any, VO extends Abstrac
328
310
  protected _addVertexOnly(newVertex: VO): boolean;
329
311
  protected _getVertex(vertexOrKey: VertexKey | VO): VO | null;
330
312
  protected _getVertexKey(vertexOrKey: VO | VertexKey): VertexKey;
331
- protected _setVertices(value: Map<VertexKey, VO>): void;
332
313
  }
@@ -20,20 +20,8 @@ class AbstractVertex {
20
20
  * vertex. If no value is provided, it will be set to undefined.
21
21
  */
22
22
  constructor(key, value) {
23
- this._key = key;
24
- this._value = value;
25
- }
26
- get key() {
27
- return this._key;
28
- }
29
- set key(v) {
30
- this._key = v;
31
- }
32
- get value() {
33
- return this._value;
34
- }
35
- set value(value) {
36
- this._value = value;
23
+ this.key = key;
24
+ this.value = value;
37
25
  }
38
26
  }
39
27
  exports.AbstractVertex = AbstractVertex;
@@ -48,37 +36,13 @@ class AbstractEdge {
48
36
  * meaning it can be omitted when creating an instance of the class.
49
37
  */
50
38
  constructor(weight, value) {
51
- this._weight = weight !== undefined ? weight : 1;
52
- this._value = value;
39
+ this.weight = weight !== undefined ? weight : 1;
40
+ this.value = value;
53
41
  this._hashCode = (0, utils_1.uuidV4)();
54
42
  }
55
- get value() {
56
- return this._value;
57
- }
58
- set value(value) {
59
- this._value = value;
60
- }
61
- get weight() {
62
- return this._weight;
63
- }
64
- set weight(v) {
65
- this._weight = v;
66
- }
67
43
  get hashCode() {
68
44
  return this._hashCode;
69
45
  }
70
- /**
71
- * In TypeScript, a subclass inherits the interface implementation of its parent class, without needing to implement the same interface again in the subclass. This behavior differs from Java's approach. In Java, if a parent class implements an interface, the subclass needs to explicitly implement the same interface, even if the parent class has already implemented it.
72
- * This means that using abstract methods in the parent class cannot constrain the grandchild classes. Defining methods within an interface also cannot constrain the descendant classes. When inheriting from this class, developers need to be aware that this method needs to be overridden.
73
- */
74
- /**
75
- * The function sets the value of the _hashCode property to the provided string.
76
- * @param {string} v - The parameter "v" is of type string and represents the value that will be assigned to the
77
- * "_hashCode" property.
78
- */
79
- _setHashCode(v) {
80
- this._hashCode = v;
81
- }
82
46
  }
83
47
  exports.AbstractEdge = AbstractEdge;
84
48
  class AbstractGraph {
@@ -916,8 +880,5 @@ class AbstractGraph {
916
880
  _getVertexKey(vertexOrKey) {
917
881
  return vertexOrKey instanceof AbstractVertex ? vertexOrKey.key : vertexOrKey;
918
882
  }
919
- _setVertices(value) {
920
- this._vertices = value;
921
- }
922
883
  }
923
884
  exports.AbstractGraph = AbstractGraph;
@@ -12,6 +12,8 @@ export declare class DirectedVertex<V = any> extends AbstractVertex<V> {
12
12
  constructor(key: VertexKey, value?: V);
13
13
  }
14
14
  export declare class DirectedEdge<E = any> extends AbstractEdge<E> {
15
+ src: VertexKey;
16
+ dest: VertexKey;
15
17
  /**
16
18
  * The constructor function initializes the source and destination vertices of an edge, along with an optional weight
17
19
  * and value.
@@ -24,21 +26,15 @@ export declare class DirectedEdge<E = any> extends AbstractEdge<E> {
24
26
  * the edge.
25
27
  */
26
28
  constructor(src: VertexKey, dest: VertexKey, weight?: number, value?: E);
27
- private _src;
28
- get src(): VertexKey;
29
- set src(v: VertexKey);
30
- private _dest;
31
- get dest(): VertexKey;
32
- set dest(v: VertexKey);
33
29
  }
34
30
  export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V> = DirectedVertex<V>, EO extends DirectedEdge<E> = DirectedEdge<E>> extends AbstractGraph<V, E, VO, EO> implements IGraph<V, E, VO, EO> {
35
31
  /**
36
32
  * The constructor function initializes an instance of a class.
37
33
  */
38
34
  constructor();
39
- private _outEdgeMap;
35
+ protected _outEdgeMap: Map<VO, EO[]>;
40
36
  get outEdgeMap(): Map<VO, EO[]>;
41
- private _inEdgeMap;
37
+ protected _inEdgeMap: Map<VO, EO[]>;
42
38
  get inEdgeMap(): Map<VO, EO[]>;
43
39
  /**
44
40
  * In TypeScript, a subclass inherits the interface implementation of its parent class, without needing to implement the same interface again in the subclass. This behavior differs from Java's approach. In Java, if a parent class implements an interface, the subclass needs to explicitly implement the same interface, even if the parent class has already implemented it.
@@ -195,6 +191,4 @@ export declare class DirectedGraph<V = any, E = any, VO extends DirectedVertex<V
195
191
  * source or destination vertex does not exist in the graph.
196
192
  */
197
193
  protected _addEdgeOnly(edge: EO): boolean;
198
- protected _setOutEdgeMap(value: Map<VO, EO[]>): void;
199
- protected _setInEdgeMap(value: Map<VO, EO[]>): void;
200
194
  }