data-structure-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 (193) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/dist/cjs/data-structures/binary-tree/avl-tree.js +0 -1
  3. package/dist/cjs/data-structures/binary-tree/avl-tree.js.map +1 -1
  4. package/dist/cjs/data-structures/binary-tree/binary-indexed-tree.d.ts +0 -3
  5. package/dist/cjs/data-structures/binary-tree/binary-indexed-tree.js +2 -11
  6. package/dist/cjs/data-structures/binary-tree/binary-indexed-tree.js.map +1 -1
  7. package/dist/cjs/data-structures/binary-tree/binary-tree.d.ts +5 -20
  8. package/dist/cjs/data-structures/binary-tree/binary-tree.js +8 -29
  9. package/dist/cjs/data-structures/binary-tree/binary-tree.js.map +1 -1
  10. package/dist/cjs/data-structures/binary-tree/bst.d.ts +1 -1
  11. package/dist/cjs/data-structures/binary-tree/bst.js +3 -3
  12. package/dist/cjs/data-structures/binary-tree/bst.js.map +1 -1
  13. package/dist/cjs/data-structures/binary-tree/rb-tree.d.ts +1 -3
  14. package/dist/cjs/data-structures/binary-tree/rb-tree.js +1 -7
  15. package/dist/cjs/data-structures/binary-tree/rb-tree.js.map +1 -1
  16. package/dist/cjs/data-structures/binary-tree/segment-tree.d.ts +10 -26
  17. package/dist/cjs/data-structures/binary-tree/segment-tree.js +10 -58
  18. package/dist/cjs/data-structures/binary-tree/segment-tree.js.map +1 -1
  19. package/dist/cjs/data-structures/binary-tree/tree-multiset.d.ts +1 -1
  20. package/dist/cjs/data-structures/binary-tree/tree-multiset.js +6 -6
  21. package/dist/cjs/data-structures/binary-tree/tree-multiset.js.map +1 -1
  22. package/dist/cjs/data-structures/graph/abstract-graph.d.ts +5 -24
  23. package/dist/cjs/data-structures/graph/abstract-graph.js +4 -43
  24. package/dist/cjs/data-structures/graph/abstract-graph.js.map +1 -1
  25. package/dist/cjs/data-structures/graph/directed-graph.d.ts +4 -10
  26. package/dist/cjs/data-structures/graph/directed-graph.js +2 -20
  27. package/dist/cjs/data-structures/graph/directed-graph.js.map +1 -1
  28. package/dist/cjs/data-structures/graph/map-graph.d.ts +4 -10
  29. package/dist/cjs/data-structures/graph/map-graph.js +2 -20
  30. package/dist/cjs/data-structures/graph/map-graph.js.map +1 -1
  31. package/dist/cjs/data-structures/graph/undirected-graph.d.ts +1 -8
  32. package/dist/cjs/data-structures/graph/undirected-graph.js +1 -14
  33. package/dist/cjs/data-structures/graph/undirected-graph.js.map +1 -1
  34. package/dist/cjs/data-structures/hash/coordinate-map.d.ts +0 -1
  35. package/dist/cjs/data-structures/hash/coordinate-map.js +0 -3
  36. package/dist/cjs/data-structures/hash/coordinate-map.js.map +1 -1
  37. package/dist/cjs/data-structures/hash/coordinate-set.d.ts +0 -1
  38. package/dist/cjs/data-structures/hash/coordinate-set.js +0 -3
  39. package/dist/cjs/data-structures/hash/coordinate-set.js.map +1 -1
  40. package/dist/cjs/data-structures/hash/hash-map.d.ts +8 -14
  41. package/dist/cjs/data-structures/hash/hash-map.js +4 -22
  42. package/dist/cjs/data-structures/hash/hash-map.js.map +1 -1
  43. package/dist/cjs/data-structures/hash/hash-table.d.ts +6 -9
  44. package/dist/cjs/data-structures/hash/hash-table.js +0 -9
  45. package/dist/cjs/data-structures/hash/hash-table.js.map +1 -1
  46. package/dist/cjs/data-structures/hash/tree-map.js.map +1 -1
  47. package/dist/cjs/data-structures/hash/tree-set.js.map +1 -1
  48. package/dist/cjs/data-structures/heap/heap.d.ts +12 -6
  49. package/dist/cjs/data-structures/heap/heap.js +40 -22
  50. package/dist/cjs/data-structures/heap/heap.js.map +1 -1
  51. package/dist/cjs/data-structures/heap/max-heap.js.map +1 -1
  52. package/dist/cjs/data-structures/heap/min-heap.js.map +1 -1
  53. package/dist/cjs/data-structures/linked-list/doubly-linked-list.d.ts +6 -14
  54. package/dist/cjs/data-structures/linked-list/doubly-linked-list.js +18 -42
  55. package/dist/cjs/data-structures/linked-list/doubly-linked-list.js.map +1 -1
  56. package/dist/cjs/data-structures/linked-list/singly-linked-list.d.ts +5 -11
  57. package/dist/cjs/data-structures/linked-list/singly-linked-list.js +17 -35
  58. package/dist/cjs/data-structures/linked-list/singly-linked-list.js.map +1 -1
  59. package/dist/cjs/data-structures/linked-list/skip-linked-list.d.ts +29 -10
  60. package/dist/cjs/data-structures/linked-list/skip-linked-list.js +62 -17
  61. package/dist/cjs/data-structures/linked-list/skip-linked-list.js.map +1 -1
  62. package/dist/cjs/data-structures/matrix/matrix.d.ts +1 -1
  63. package/dist/cjs/data-structures/matrix/matrix.js.map +1 -1
  64. package/dist/cjs/data-structures/matrix/matrix2d.d.ts +1 -1
  65. package/dist/cjs/data-structures/matrix/navigator.d.ts +4 -4
  66. package/dist/cjs/data-structures/matrix/vector2d.js.map +1 -1
  67. package/dist/cjs/data-structures/priority-queue/max-priority-queue.js.map +1 -1
  68. package/dist/cjs/data-structures/priority-queue/min-priority-queue.js.map +1 -1
  69. package/dist/cjs/data-structures/priority-queue/priority-queue.js.map +1 -1
  70. package/dist/cjs/data-structures/queue/deque.d.ts +8 -12
  71. package/dist/cjs/data-structures/queue/deque.js +31 -43
  72. package/dist/cjs/data-structures/queue/deque.js.map +1 -1
  73. package/dist/cjs/data-structures/queue/queue.d.ts +20 -5
  74. package/dist/cjs/data-structures/queue/queue.js +35 -18
  75. package/dist/cjs/data-structures/queue/queue.js.map +1 -1
  76. package/dist/cjs/data-structures/stack/stack.d.ts +2 -1
  77. package/dist/cjs/data-structures/stack/stack.js +10 -7
  78. package/dist/cjs/data-structures/stack/stack.js.map +1 -1
  79. package/dist/cjs/data-structures/tree/tree.d.ts +3 -9
  80. package/dist/cjs/data-structures/tree/tree.js +3 -21
  81. package/dist/cjs/data-structures/tree/tree.js.map +1 -1
  82. package/dist/cjs/data-structures/trie/trie.d.ts +6 -12
  83. package/dist/cjs/data-structures/trie/trie.js +6 -24
  84. package/dist/cjs/data-structures/trie/trie.js.map +1 -1
  85. package/dist/cjs/interfaces/binary-tree.d.ts +1 -1
  86. package/dist/cjs/types/data-structures/binary-tree/bst.d.ts +1 -1
  87. package/dist/mjs/data-structures/binary-tree/avl-tree.js +0 -1
  88. package/dist/mjs/data-structures/binary-tree/binary-indexed-tree.d.ts +0 -3
  89. package/dist/mjs/data-structures/binary-tree/binary-indexed-tree.js +2 -11
  90. package/dist/mjs/data-structures/binary-tree/binary-tree.d.ts +5 -20
  91. package/dist/mjs/data-structures/binary-tree/binary-tree.js +8 -29
  92. package/dist/mjs/data-structures/binary-tree/bst.d.ts +1 -1
  93. package/dist/mjs/data-structures/binary-tree/bst.js +3 -3
  94. package/dist/mjs/data-structures/binary-tree/rb-tree.d.ts +1 -3
  95. package/dist/mjs/data-structures/binary-tree/rb-tree.js +2 -8
  96. package/dist/mjs/data-structures/binary-tree/segment-tree.d.ts +10 -26
  97. package/dist/mjs/data-structures/binary-tree/segment-tree.js +10 -58
  98. package/dist/mjs/data-structures/binary-tree/tree-multiset.d.ts +1 -1
  99. package/dist/mjs/data-structures/binary-tree/tree-multiset.js +6 -6
  100. package/dist/mjs/data-structures/graph/abstract-graph.d.ts +5 -24
  101. package/dist/mjs/data-structures/graph/abstract-graph.js +8 -47
  102. package/dist/mjs/data-structures/graph/directed-graph.d.ts +4 -10
  103. package/dist/mjs/data-structures/graph/directed-graph.js +4 -22
  104. package/dist/mjs/data-structures/graph/map-graph.d.ts +4 -10
  105. package/dist/mjs/data-structures/graph/map-graph.js +4 -22
  106. package/dist/mjs/data-structures/graph/undirected-graph.d.ts +1 -8
  107. package/dist/mjs/data-structures/graph/undirected-graph.js +2 -15
  108. package/dist/mjs/data-structures/hash/coordinate-map.d.ts +0 -1
  109. package/dist/mjs/data-structures/hash/coordinate-map.js +0 -3
  110. package/dist/mjs/data-structures/hash/coordinate-set.d.ts +0 -1
  111. package/dist/mjs/data-structures/hash/coordinate-set.js +0 -3
  112. package/dist/mjs/data-structures/hash/hash-map.d.ts +8 -14
  113. package/dist/mjs/data-structures/hash/hash-map.js +4 -22
  114. package/dist/mjs/data-structures/hash/hash-table.d.ts +6 -9
  115. package/dist/mjs/data-structures/hash/hash-table.js +0 -9
  116. package/dist/mjs/data-structures/heap/heap.d.ts +12 -6
  117. package/dist/mjs/data-structures/heap/heap.js +44 -26
  118. package/dist/mjs/data-structures/linked-list/doubly-linked-list.d.ts +6 -14
  119. package/dist/mjs/data-structures/linked-list/doubly-linked-list.js +21 -45
  120. package/dist/mjs/data-structures/linked-list/singly-linked-list.d.ts +5 -11
  121. package/dist/mjs/data-structures/linked-list/singly-linked-list.js +19 -37
  122. package/dist/mjs/data-structures/linked-list/skip-linked-list.d.ts +29 -10
  123. package/dist/mjs/data-structures/linked-list/skip-linked-list.js +62 -17
  124. package/dist/mjs/data-structures/matrix/matrix.d.ts +1 -1
  125. package/dist/mjs/data-structures/matrix/matrix2d.d.ts +1 -1
  126. package/dist/mjs/data-structures/matrix/navigator.d.ts +4 -4
  127. package/dist/mjs/data-structures/queue/deque.d.ts +8 -12
  128. package/dist/mjs/data-structures/queue/deque.js +31 -43
  129. package/dist/mjs/data-structures/queue/queue.d.ts +20 -5
  130. package/dist/mjs/data-structures/queue/queue.js +34 -17
  131. package/dist/mjs/data-structures/stack/stack.d.ts +2 -1
  132. package/dist/mjs/data-structures/stack/stack.js +11 -8
  133. package/dist/mjs/data-structures/tree/tree.d.ts +3 -9
  134. package/dist/mjs/data-structures/tree/tree.js +6 -24
  135. package/dist/mjs/data-structures/trie/trie.d.ts +6 -12
  136. package/dist/mjs/data-structures/trie/trie.js +10 -28
  137. package/dist/mjs/interfaces/binary-tree.d.ts +1 -1
  138. package/dist/mjs/types/data-structures/binary-tree/bst.d.ts +1 -1
  139. package/dist/umd/data-structure-typed.min.js +1 -1
  140. package/dist/umd/data-structure-typed.min.js.map +1 -1
  141. package/package.json +5 -5
  142. package/src/data-structures/binary-tree/avl-tree.ts +2 -4
  143. package/src/data-structures/binary-tree/binary-indexed-tree.ts +3 -15
  144. package/src/data-structures/binary-tree/binary-tree.ts +17 -42
  145. package/src/data-structures/binary-tree/bst.ts +5 -6
  146. package/src/data-structures/binary-tree/rb-tree.ts +13 -21
  147. package/src/data-structures/binary-tree/segment-tree.ts +16 -83
  148. package/src/data-structures/binary-tree/tree-multiset.ts +8 -9
  149. package/src/data-structures/graph/abstract-graph.ts +21 -67
  150. package/src/data-structures/graph/directed-graph.ts +13 -39
  151. package/src/data-structures/graph/map-graph.ts +7 -32
  152. package/src/data-structures/graph/undirected-graph.ts +9 -26
  153. package/src/data-structures/hash/coordinate-map.ts +0 -4
  154. package/src/data-structures/hash/coordinate-set.ts +0 -4
  155. package/src/data-structures/hash/hash-map.ts +13 -37
  156. package/src/data-structures/hash/hash-table.ts +6 -18
  157. package/src/data-structures/hash/tree-map.ts +2 -1
  158. package/src/data-structures/hash/tree-set.ts +2 -1
  159. package/src/data-structures/heap/heap.ts +58 -30
  160. package/src/data-structures/heap/max-heap.ts +1 -1
  161. package/src/data-structures/heap/min-heap.ts +1 -1
  162. package/src/data-structures/linked-list/doubly-linked-list.ts +26 -60
  163. package/src/data-structures/linked-list/singly-linked-list.ts +24 -49
  164. package/src/data-structures/linked-list/skip-linked-list.ts +73 -25
  165. package/src/data-structures/matrix/matrix.ts +2 -2
  166. package/src/data-structures/matrix/matrix2d.ts +1 -1
  167. package/src/data-structures/matrix/navigator.ts +4 -4
  168. package/src/data-structures/matrix/vector2d.ts +2 -1
  169. package/src/data-structures/priority-queue/max-priority-queue.ts +1 -1
  170. package/src/data-structures/priority-queue/min-priority-queue.ts +1 -1
  171. package/src/data-structures/priority-queue/priority-queue.ts +1 -1
  172. package/src/data-structures/queue/deque.ts +38 -53
  173. package/src/data-structures/queue/queue.ts +38 -20
  174. package/src/data-structures/stack/stack.ts +13 -9
  175. package/src/data-structures/tree/tree.ts +7 -33
  176. package/src/data-structures/trie/trie.ts +14 -40
  177. package/src/interfaces/binary-tree.ts +1 -1
  178. package/src/types/data-structures/binary-tree/bst.ts +1 -1
  179. package/src/types/data-structures/matrix/navigator.ts +1 -1
  180. package/src/types/utils/utils.ts +1 -1
  181. package/src/types/utils/validate-type.ts +2 -2
  182. package/test/integration/avl-tree.test.ts +1 -1
  183. package/test/integration/bst.test.ts +2 -2
  184. package/test/unit/data-structures/binary-tree/binary-index-tree.test.ts +2 -2
  185. package/test/unit/data-structures/graph/abstract-graph.test.ts +4 -6
  186. package/test/unit/data-structures/graph/directed-graph.test.ts +4 -4
  187. package/test/unit/data-structures/graph/map-graph.test.ts +2 -2
  188. package/test/unit/data-structures/hash/coordinate-map.test.ts +1 -1
  189. package/test/unit/data-structures/hash/coordinate-set.test.ts +1 -1
  190. package/test/unit/data-structures/hash/hash-map.test.ts +0 -1
  191. package/test/unit/data-structures/hash/hash-table.test.ts +3 -3
  192. package/test/unit/data-structures/linked-list/skip-list.test.ts +31 -0
  193. package/test/unit/data-structures/queue/queue.test.ts +8 -8
@@ -62,7 +62,7 @@ class BST extends binary_tree_1.BinaryTree {
62
62
  }
63
63
  if (this.root === null) {
64
64
  this._setRoot(newNode);
65
- this._setSize(this.size + 1);
65
+ this._size = this.size + 1;
66
66
  inserted = this.root;
67
67
  }
68
68
  else {
@@ -86,7 +86,7 @@ class BST extends binary_tree_1.BinaryTree {
86
86
  }
87
87
  //Add to the left of the current node
88
88
  cur.left = newNode;
89
- this._setSize(this.size + 1);
89
+ this._size = this.size + 1;
90
90
  traversing = false;
91
91
  inserted = cur.left;
92
92
  }
@@ -104,7 +104,7 @@ class BST extends binary_tree_1.BinaryTree {
104
104
  }
105
105
  //Add to the right of the current node
106
106
  cur.right = newNode;
107
- this._setSize(this.size + 1);
107
+ this._size = this.size + 1;
108
108
  traversing = false;
109
109
  inserted = cur.right;
110
110
  }
@@ -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,15 +6,9 @@ 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
- _color;
12
- get color() {
13
- return this._color;
14
- }
15
- set color(value) {
16
- this._color = value;
9
+ this.color = types_1.RBColor.RED;
17
10
  }
11
+ color;
18
12
  }
19
13
  exports.RBTreeNode = RBTreeNode;
20
14
  class RBTree extends bst_1.BST {
@@ -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
  }
@@ -9,53 +9,17 @@
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.SegmentTree = exports.SegmentTreeNode = void 0;
11
11
  class SegmentTreeNode {
12
+ start = 0;
13
+ end = 0;
14
+ value = null;
15
+ sum = 0;
16
+ left = null;
17
+ right = null;
12
18
  constructor(start, end, sum, value) {
13
- this._start = start;
14
- this._end = end;
15
- this._sum = sum;
16
- this._value = value || null;
17
- }
18
- _start = 0;
19
- get start() {
20
- return this._start;
21
- }
22
- set start(v) {
23
- this._start = v;
24
- }
25
- _end = 0;
26
- get end() {
27
- return this._end;
28
- }
29
- set end(v) {
30
- this._end = v;
31
- }
32
- _value = null;
33
- get value() {
34
- return this._value;
35
- }
36
- set value(v) {
37
- this._value = v;
38
- }
39
- _sum = 0;
40
- get sum() {
41
- return this._sum;
42
- }
43
- set sum(v) {
44
- this._sum = v;
45
- }
46
- _left = null;
47
- get left() {
48
- return this._left;
49
- }
50
- set left(v) {
51
- this._left = v;
52
- }
53
- _right = null;
54
- get right() {
55
- return this._right;
56
- }
57
- set right(v) {
58
- this._right = v;
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;
@@ -214,17 +178,5 @@ class SegmentTree {
214
178
  };
215
179
  return dfs(root, indexA, indexB);
216
180
  }
217
- _setValues(value) {
218
- this._values = value;
219
- }
220
- _setStart(value) {
221
- this._start = value;
222
- }
223
- _setEnd(value) {
224
- this._end = value;
225
- }
226
- _setRoot(v) {
227
- this._root = v;
228
- }
229
181
  }
230
182
  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> {
@@ -76,7 +76,7 @@ class TreeMultiset extends avl_tree_1.AVLTree {
76
76
  }
77
77
  if (!this.root) {
78
78
  this._setRoot(newNode);
79
- this._setSize(this.size + 1);
79
+ this._size = this.size + 1;
80
80
  newNode && this._setCount(this.count + newNode.count);
81
81
  inserted = this.root;
82
82
  }
@@ -98,7 +98,7 @@ class TreeMultiset extends avl_tree_1.AVLTree {
98
98
  if (cur.left === undefined) {
99
99
  //Add to the left of the current node
100
100
  cur.left = newNode;
101
- this._setSize(this.size + 1);
101
+ this._size = this.size + 1;
102
102
  this._setCount(this.count + newNode.count);
103
103
  traversing = false;
104
104
  inserted = cur.left;
@@ -114,7 +114,7 @@ class TreeMultiset extends avl_tree_1.AVLTree {
114
114
  if (cur.right === undefined) {
115
115
  //Add to the right of the current node
116
116
  cur.right = newNode;
117
- this._setSize(this.size + 1);
117
+ this._size = this.size + 1;
118
118
  this._setCount(this.count + newNode.count);
119
119
  traversing = false;
120
120
  inserted = cur.right;
@@ -152,7 +152,7 @@ class TreeMultiset extends avl_tree_1.AVLTree {
152
152
  if (parent.left === undefined) {
153
153
  parent.left = newNode;
154
154
  if (newNode !== null) {
155
- this._setSize(this.size + 1);
155
+ this._size = this.size + 1;
156
156
  this._setCount(this.count + newNode.count);
157
157
  }
158
158
  return parent.left;
@@ -160,7 +160,7 @@ class TreeMultiset extends avl_tree_1.AVLTree {
160
160
  else if (parent.right === undefined) {
161
161
  parent.right = newNode;
162
162
  if (newNode !== null) {
163
- this._setSize(this.size + 1);
163
+ this._size = (this.size + 1);
164
164
  this._setCount(this.count + newNode.count);
165
165
  }
166
166
  return parent.right;
@@ -305,7 +305,7 @@ class TreeMultiset extends avl_tree_1.AVLTree {
305
305
  }
306
306
  }
307
307
  }
308
- this._setSize(this.size - 1);
308
+ this._size = this.size - 1;
309
309
  // TODO How to handle when the count of target node is lesser than current node's count
310
310
  this._setCount(this.count - orgCurrent.count);
311
311
  }
@@ -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
  }
@@ -12,6 +12,8 @@ const utils_1 = require("../../utils");
12
12
  const priority_queue_1 = require("../priority-queue");
13
13
  const queue_1 = require("../queue");
14
14
  class AbstractVertex {
15
+ key;
16
+ value;
15
17
  /**
16
18
  * The function is a protected constructor that takes an key and an optional value as parameters.
17
19
  * @param {VertexKey} key - The `key` parameter is of type `VertexKey` and represents the identifier of the vertex. It is
@@ -20,26 +22,14 @@ class AbstractVertex {
20
22
  * vertex. If no value is provided, it will be set to undefined.
21
23
  */
22
24
  constructor(key, value) {
23
- this._key = key;
24
- this._value = value;
25
- }
26
- _key;
27
- get key() {
28
- return this._key;
29
- }
30
- set key(v) {
31
- this._key = v;
32
- }
33
- _value;
34
- get value() {
35
- return this._value;
36
- }
37
- set value(value) {
38
- this._value = value;
25
+ this.key = key;
26
+ this.value = value;
39
27
  }
40
28
  }
41
29
  exports.AbstractVertex = AbstractVertex;
42
30
  class AbstractEdge {
31
+ value;
32
+ weight;
43
33
  /**
44
34
  * The above function is a protected constructor that initializes the weight, value, and hash code properties of an
45
35
  * object.
@@ -50,40 +40,14 @@ class AbstractEdge {
50
40
  * meaning it can be omitted when creating an instance of the class.
51
41
  */
52
42
  constructor(weight, value) {
53
- this._weight = weight !== undefined ? weight : 1;
54
- this._value = value;
43
+ this.weight = weight !== undefined ? weight : 1;
44
+ this.value = value;
55
45
  this._hashCode = (0, utils_1.uuidV4)();
56
46
  }
57
- _value;
58
- get value() {
59
- return this._value;
60
- }
61
- set value(value) {
62
- this._value = value;
63
- }
64
- _weight;
65
- get weight() {
66
- return this._weight;
67
- }
68
- set weight(v) {
69
- this._weight = v;
70
- }
71
47
  _hashCode;
72
48
  get hashCode() {
73
49
  return this._hashCode;
74
50
  }
75
- /**
76
- * 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.
77
- * 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.
78
- */
79
- /**
80
- * The function sets the value of the _hashCode property to the provided string.
81
- * @param {string} v - The parameter "v" is of type string and represents the value that will be assigned to the
82
- * "_hashCode" property.
83
- */
84
- _setHashCode(v) {
85
- this._hashCode = v;
86
- }
87
51
  }
88
52
  exports.AbstractEdge = AbstractEdge;
89
53
  class AbstractGraph {
@@ -915,8 +879,5 @@ class AbstractGraph {
915
879
  _getVertexKey(vertexOrKey) {
916
880
  return vertexOrKey instanceof AbstractVertex ? vertexOrKey.key : vertexOrKey;
917
881
  }
918
- _setVertices(value) {
919
- this._vertices = value;
920
- }
921
882
  }
922
883
  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
  }
@@ -24,6 +24,8 @@ class DirectedVertex extends abstract_graph_1.AbstractVertex {
24
24
  }
25
25
  exports.DirectedVertex = DirectedVertex;
26
26
  class DirectedEdge extends abstract_graph_1.AbstractEdge {
27
+ src;
28
+ dest;
27
29
  /**
28
30
  * The constructor function initializes the source and destination vertices of an edge, along with an optional weight
29
31
  * and value.
@@ -37,22 +39,8 @@ class DirectedEdge extends abstract_graph_1.AbstractEdge {
37
39
  */
38
40
  constructor(src, dest, weight, value) {
39
41
  super(weight, value);
40
- this._src = src;
41
- this._dest = dest;
42
- }
43
- _src;
44
- get src() {
45
- return this._src;
46
- }
47
- set src(v) {
48
- this._src = v;
49
- }
50
- _dest;
51
- get dest() {
52
- return this._dest;
53
- }
54
- set dest(v) {
55
- this._dest = v;
42
+ this.src = src;
43
+ this.dest = dest;
56
44
  }
57
45
  }
58
46
  exports.DirectedEdge = DirectedEdge;
@@ -414,11 +402,5 @@ class DirectedGraph extends abstract_graph_1.AbstractGraph {
414
402
  return false;
415
403
  }
416
404
  }
417
- _setOutEdgeMap(value) {
418
- this._outEdgeMap = value;
419
- }
420
- _setInEdgeMap(value) {
421
- this._inEdgeMap = value;
422
- }
423
405
  }
424
406
  exports.DirectedGraph = DirectedGraph;
@@ -1,6 +1,8 @@
1
1
  import { MapGraphCoordinate, VertexKey } from '../../types';
2
2
  import { DirectedEdge, DirectedGraph, DirectedVertex } from './directed-graph';
3
3
  export declare class MapVertex<V = any> extends DirectedVertex<V> {
4
+ lat: number;
5
+ long: number;
4
6
  /**
5
7
  * The constructor function initializes an object with an key, latitude, longitude, and an optional value.
6
8
  * @param {VertexKey} key - The `key` parameter is of type `VertexKey` and represents the identifier of the vertex.
@@ -14,12 +16,6 @@ export declare class MapVertex<V = any> extends DirectedVertex<V> {
14
16
  * creating an instance of the class.
15
17
  */
16
18
  constructor(key: VertexKey, value: V, lat: number, long: number);
17
- private _lat;
18
- get lat(): number;
19
- set lat(value: number);
20
- private _long;
21
- get long(): number;
22
- set long(value: number);
23
19
  }
24
20
  export declare class MapEdge<E = any> extends DirectedEdge<E> {
25
21
  /**
@@ -45,12 +41,10 @@ export declare class MapGraph<V = any, E = any, VO extends MapVertex<V> = MapVer
45
41
  * it will default to `undefined`.
46
42
  */
47
43
  constructor(origin: MapGraphCoordinate, bottomRight?: MapGraphCoordinate);
48
- private _origin;
44
+ protected _origin: MapGraphCoordinate;
49
45
  get origin(): MapGraphCoordinate;
50
- set origin(value: MapGraphCoordinate);
51
- private _bottomRight;
46
+ protected _bottomRight: MapGraphCoordinate | undefined;
52
47
  get bottomRight(): MapGraphCoordinate | undefined;
53
- set bottomRight(value: MapGraphCoordinate | undefined);
54
48
  /**
55
49
  * The function creates a new vertex with the given key, value, latitude, and longitude.
56
50
  * @param {VertexKey} key - The key parameter is the unique identifier for the vertex. It is of type VertexKey, which could
@@ -3,6 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MapGraph = exports.MapEdge = exports.MapVertex = void 0;
4
4
  const directed_graph_1 = require("./directed-graph");
5
5
  class MapVertex extends directed_graph_1.DirectedVertex {
6
+ lat;
7
+ long;
6
8
  /**
7
9
  * The constructor function initializes an object with an key, latitude, longitude, and an optional value.
8
10
  * @param {VertexKey} key - The `key` parameter is of type `VertexKey` and represents the identifier of the vertex.
@@ -17,22 +19,8 @@ class MapVertex extends directed_graph_1.DirectedVertex {
17
19
  */
18
20
  constructor(key, value, lat, long) {
19
21
  super(key, value);
20
- this._lat = lat;
21
- this._long = long;
22
- }
23
- _lat;
24
- get lat() {
25
- return this._lat;
26
- }
27
- set lat(value) {
28
- this._lat = value;
29
- }
30
- _long;
31
- get long() {
32
- return this._long;
33
- }
34
- set long(value) {
35
- this._long = value;
22
+ this.lat = lat;
23
+ this.long = long;
36
24
  }
37
25
  }
38
26
  exports.MapVertex = MapVertex;
@@ -71,16 +59,10 @@ class MapGraph extends directed_graph_1.DirectedGraph {
71
59
  get origin() {
72
60
  return this._origin;
73
61
  }
74
- set origin(value) {
75
- this._origin = value;
76
- }
77
62
  _bottomRight;
78
63
  get bottomRight() {
79
64
  return this._bottomRight;
80
65
  }
81
- set bottomRight(value) {
82
- this._bottomRight = value;
83
- }
84
66
  /**
85
67
  * The function creates a new vertex with the given key, value, latitude, and longitude.
86
68
  * @param {VertexKey} key - The key parameter is the unique identifier for the vertex. It is of type VertexKey, which could
@@ -12,6 +12,7 @@ export declare class UndirectedVertex<V = any> extends AbstractVertex<V> {
12
12
  constructor(key: VertexKey, value?: V);
13
13
  }
14
14
  export declare class UndirectedEdge<E = number> extends AbstractEdge<E> {
15
+ vertices: [VertexKey, VertexKey];
15
16
  /**
16
17
  * The constructor function creates an instance of a class with two vertex IDs, an optional weight, and an optional
17
18
  * value.
@@ -23,9 +24,6 @@ export declare class UndirectedEdge<E = number> extends AbstractEdge<E> {
23
24
  * with the edge.
24
25
  */
25
26
  constructor(v1: VertexKey, v2: VertexKey, weight?: number, value?: E);
26
- private _vertices;
27
- get vertices(): [VertexKey, VertexKey];
28
- set vertices(v: [VertexKey, VertexKey]);
29
27
  }
30
28
  export declare class UndirectedGraph<V = any, E = any, VO extends UndirectedVertex<V> = UndirectedVertex<V>, EO extends UndirectedEdge<E> = UndirectedEdge<E>> extends AbstractGraph<V, E, VO, EO> implements IGraph<V, E, VO, EO> {
31
29
  /**
@@ -119,9 +117,4 @@ export declare class UndirectedGraph<V = any, E = any, VO extends UndirectedVert
119
117
  * @returns a boolean value.
120
118
  */
121
119
  protected _addEdgeOnly(edge: EO): boolean;
122
- /**
123
- * The function sets the edges of a graph.
124
- * @param v - A map where the keys are of type VO and the values are arrays of type EO.
125
- */
126
- protected _setEdges(v: Map<VO, EO[]>): void;
127
120
  }
@@ -24,6 +24,7 @@ class UndirectedVertex extends abstract_graph_1.AbstractVertex {
24
24
  }
25
25
  exports.UndirectedVertex = UndirectedVertex;
26
26
  class UndirectedEdge extends abstract_graph_1.AbstractEdge {
27
+ vertices;
27
28
  /**
28
29
  * The constructor function creates an instance of a class with two vertex IDs, an optional weight, and an optional
29
30
  * value.
@@ -36,14 +37,7 @@ class UndirectedEdge extends abstract_graph_1.AbstractEdge {
36
37
  */
37
38
  constructor(v1, v2, weight, value) {
38
39
  super(weight, value);
39
- this._vertices = [v1, v2];
40
- }
41
- _vertices;
42
- get vertices() {
43
- return this._vertices;
44
- }
45
- set vertices(v) {
46
- this._vertices = v;
40
+ this.vertices = [v1, v2];
47
41
  }
48
42
  }
49
43
  exports.UndirectedEdge = UndirectedEdge;
@@ -241,12 +235,5 @@ class UndirectedGraph extends abstract_graph_1.AbstractGraph {
241
235
  }
242
236
  return true;
243
237
  }
244
- /**
245
- * The function sets the edges of a graph.
246
- * @param v - A map where the keys are of type VO and the values are arrays of type EO.
247
- */
248
- _setEdges(v) {
249
- this._edges = v;
250
- }
251
238
  }
252
239
  exports.UndirectedGraph = UndirectedGraph;
@@ -41,5 +41,4 @@ export declare class CoordinateMap<V> extends Map<any, V> {
41
41
  * `key` array joined together using the `_joint` property.
42
42
  */
43
43
  delete(key: number[]): boolean;
44
- protected _setJoint(v: string): void;
45
44
  }
@@ -58,8 +58,5 @@ class CoordinateMap extends Map {
58
58
  delete(key) {
59
59
  return super.delete(key.join(this._joint));
60
60
  }
61
- _setJoint(v) {
62
- this._joint = v;
63
- }
64
61
  }
65
62
  exports.CoordinateMap = CoordinateMap;
@@ -33,5 +33,4 @@ export declare class CoordinateSet extends Set<any> {
33
33
  * `value` array joined together using the `_joint` property.
34
34
  */
35
35
  delete(value: number[]): boolean;
36
- protected _setJoint(v: string): void;
37
36
  }