data-structure-typed 1.33.0 → 1.33.5

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 (222) hide show
  1. package/{.eslintrc.json → .eslintrc.js} +2 -1
  2. package/.github/workflows/ci.yml +15 -3
  3. package/.github/workflows/release-package.yml +32 -0
  4. package/{.prettierrc → .prettierrc.js} +1 -1
  5. package/CHANGELOG.md +5 -1
  6. package/README.md +196 -257
  7. package/coverage/coverage-final.json +64 -64
  8. package/coverage/coverage-summary.json +16 -16
  9. package/dist/data-structures/binary-tree/abstract-binary-tree.js +1 -16
  10. package/dist/data-structures/binary-tree/abstract-binary-tree.js.map +1 -1
  11. package/dist/data-structures/binary-tree/avl-tree.js +2 -2
  12. package/dist/data-structures/binary-tree/avl-tree.js.map +1 -1
  13. package/dist/data-structures/binary-tree/rb-tree.js +3 -4
  14. package/dist/data-structures/binary-tree/rb-tree.js.map +1 -1
  15. package/dist/data-structures/graph/abstract-graph.js +12 -12
  16. package/dist/data-structures/graph/abstract-graph.js.map +1 -1
  17. package/dist/data-structures/graph/directed-graph.js.map +1 -1
  18. package/dist/data-structures/graph/undirected-graph.js.map +1 -1
  19. package/dist/data-structures/hash/hash-table.js +107 -2
  20. package/dist/data-structures/hash/hash-table.js.map +1 -1
  21. package/dist/data-structures/heap/max-heap.js.map +1 -1
  22. package/dist/data-structures/heap/min-heap.js.map +1 -1
  23. package/dist/data-structures/linked-list/doubly-linked-list.js +30 -0
  24. package/dist/data-structures/linked-list/doubly-linked-list.js.map +1 -1
  25. package/dist/data-structures/matrix/matrix2d.js +5 -8
  26. package/dist/data-structures/matrix/matrix2d.js.map +1 -1
  27. package/dist/data-structures/priority-queue/max-priority-queue.js.map +1 -1
  28. package/dist/data-structures/priority-queue/min-priority-queue.js.map +1 -1
  29. package/dist/data-structures/priority-queue/priority-queue.js +6 -6
  30. package/dist/data-structures/priority-queue/priority-queue.js.map +1 -1
  31. package/dist/data-structures/queue/deque.js.map +1 -1
  32. package/docs/index.html +196 -256
  33. package/docs/modules.html +2 -0
  34. package/lib/data-structures/binary-tree/abstract-binary-tree.d.ts +8 -18
  35. package/lib/data-structures/binary-tree/abstract-binary-tree.js +5 -23
  36. package/lib/data-structures/binary-tree/avl-tree.d.ts +7 -10
  37. package/lib/data-structures/binary-tree/avl-tree.js +6 -9
  38. package/lib/data-structures/binary-tree/binary-tree.d.ts +2 -2
  39. package/lib/data-structures/binary-tree/bst.d.ts +2 -2
  40. package/lib/data-structures/binary-tree/rb-tree.d.ts +3 -3
  41. package/lib/data-structures/binary-tree/rb-tree.js +3 -3
  42. package/lib/data-structures/binary-tree/tree-multiset.d.ts +3 -3
  43. package/lib/data-structures/binary-tree/tree-multiset.js +1 -1
  44. package/lib/data-structures/graph/abstract-graph.d.ts +10 -10
  45. package/lib/data-structures/graph/abstract-graph.js +2 -2
  46. package/lib/data-structures/graph/directed-graph.d.ts +6 -6
  47. package/lib/data-structures/graph/directed-graph.js +2 -2
  48. package/lib/data-structures/graph/map-graph.d.ts +6 -6
  49. package/lib/data-structures/graph/map-graph.js +2 -2
  50. package/lib/data-structures/graph/undirected-graph.d.ts +6 -6
  51. package/lib/data-structures/graph/undirected-graph.js +2 -2
  52. package/lib/data-structures/hash/hash-table.d.ts +61 -1
  53. package/lib/data-structures/hash/hash-table.js +136 -0
  54. package/lib/data-structures/heap/heap.d.ts +31 -31
  55. package/lib/data-structures/heap/heap.js +11 -11
  56. package/lib/data-structures/heap/max-heap.d.ts +4 -4
  57. package/lib/data-structures/heap/max-heap.js +1 -1
  58. package/lib/data-structures/heap/min-heap.d.ts +4 -4
  59. package/lib/data-structures/heap/min-heap.js +1 -1
  60. package/lib/data-structures/linked-list/doubly-linked-list.d.ts +93 -54
  61. package/lib/data-structures/linked-list/doubly-linked-list.js +79 -22
  62. package/lib/data-structures/linked-list/singly-linked-list.d.ts +46 -46
  63. package/lib/data-structures/linked-list/singly-linked-list.js +20 -20
  64. package/lib/data-structures/matrix/matrix.d.ts +3 -3
  65. package/lib/data-structures/matrix/matrix2d.d.ts +1 -1
  66. package/lib/data-structures/matrix/matrix2d.js +3 -2
  67. package/lib/data-structures/priority-queue/max-priority-queue.d.ts +4 -4
  68. package/lib/data-structures/priority-queue/min-priority-queue.d.ts +4 -4
  69. package/lib/data-structures/priority-queue/priority-queue.d.ts +26 -26
  70. package/lib/data-structures/priority-queue/priority-queue.js +8 -8
  71. package/lib/data-structures/queue/deque.d.ts +30 -30
  72. package/lib/data-structures/queue/deque.js +7 -7
  73. package/lib/data-structures/queue/queue.d.ts +27 -27
  74. package/lib/data-structures/queue/queue.js +8 -8
  75. package/lib/data-structures/stack/stack.d.ts +15 -15
  76. package/lib/data-structures/stack/stack.js +6 -6
  77. package/lib/data-structures/tree/tree.d.ts +7 -7
  78. package/lib/interfaces/abstract-binary-tree.d.ts +0 -1
  79. package/lib/interfaces/avl-tree.d.ts +1 -1
  80. package/lib/types/data-structures/navigator.d.ts +1 -1
  81. package/package.json +68 -62
  82. package/src/data-structures/binary-tree/aa-tree.ts +1 -0
  83. package/src/data-structures/binary-tree/abstract-binary-tree.ts +1608 -0
  84. package/src/data-structures/binary-tree/avl-tree.ts +307 -0
  85. package/src/data-structures/binary-tree/b-tree.ts +1 -0
  86. package/src/data-structures/binary-tree/binary-indexed-tree.ts +76 -0
  87. package/src/data-structures/binary-tree/binary-tree.ts +47 -0
  88. package/src/data-structures/binary-tree/bst.ts +537 -0
  89. package/src/data-structures/binary-tree/index.ts +12 -0
  90. package/src/data-structures/binary-tree/rb-tree.ts +366 -0
  91. package/src/data-structures/binary-tree/segment-tree.ts +242 -0
  92. package/src/data-structures/binary-tree/splay-tree.ts +1 -0
  93. package/src/data-structures/binary-tree/tree-multiset.ts +700 -0
  94. package/src/data-structures/binary-tree/two-three-tree.ts +1 -0
  95. package/src/data-structures/graph/abstract-graph.ts +1040 -0
  96. package/src/data-structures/graph/directed-graph.ts +470 -0
  97. package/src/data-structures/graph/index.ts +4 -0
  98. package/src/data-structures/graph/map-graph.ts +129 -0
  99. package/src/data-structures/graph/undirected-graph.ts +274 -0
  100. package/src/data-structures/hash/coordinate-map.ts +67 -0
  101. package/src/data-structures/hash/coordinate-set.ts +56 -0
  102. package/src/data-structures/hash/hash-table.ts +157 -0
  103. package/src/data-structures/hash/index.ts +6 -0
  104. package/src/data-structures/hash/pair.ts +1 -0
  105. package/src/data-structures/hash/tree-map.ts +1 -0
  106. package/src/data-structures/hash/tree-set.ts +1 -0
  107. package/src/data-structures/heap/heap.ts +212 -0
  108. package/src/data-structures/heap/index.ts +3 -0
  109. package/src/data-structures/heap/max-heap.ts +31 -0
  110. package/src/data-structures/heap/min-heap.ts +32 -0
  111. package/src/data-structures/index.ts +11 -0
  112. package/src/data-structures/linked-list/doubly-linked-list.ts +636 -0
  113. package/src/data-structures/linked-list/index.ts +3 -0
  114. package/src/data-structures/linked-list/singly-linked-list.ts +501 -0
  115. package/src/data-structures/linked-list/skip-linked-list.ts +1 -0
  116. package/src/data-structures/matrix/index.ts +4 -0
  117. package/src/data-structures/matrix/matrix.ts +27 -0
  118. package/src/data-structures/matrix/matrix2d.ts +213 -0
  119. package/src/data-structures/matrix/navigator.ts +121 -0
  120. package/src/data-structures/matrix/vector2d.ts +316 -0
  121. package/src/data-structures/priority-queue/index.ts +3 -0
  122. package/src/data-structures/priority-queue/max-priority-queue.ts +56 -0
  123. package/src/data-structures/priority-queue/min-priority-queue.ts +57 -0
  124. package/src/data-structures/priority-queue/priority-queue.ts +359 -0
  125. package/src/data-structures/queue/deque.ts +297 -0
  126. package/src/data-structures/queue/index.ts +2 -0
  127. package/src/data-structures/queue/queue.ts +191 -0
  128. package/src/data-structures/stack/index.ts +1 -0
  129. package/src/data-structures/stack/stack.ts +98 -0
  130. package/src/data-structures/tree/index.ts +1 -0
  131. package/src/data-structures/tree/tree.ts +69 -0
  132. package/src/data-structures/trie/index.ts +1 -0
  133. package/src/data-structures/trie/trie.ts +225 -0
  134. package/src/index.ts +4 -0
  135. package/src/interfaces/abstract-binary-tree.ts +189 -0
  136. package/src/interfaces/abstract-graph.ts +31 -0
  137. package/src/interfaces/avl-tree.ts +25 -0
  138. package/src/interfaces/binary-tree.ts +6 -0
  139. package/src/interfaces/bst.ts +31 -0
  140. package/src/interfaces/directed-graph.ts +20 -0
  141. package/src/interfaces/doubly-linked-list.ts +1 -0
  142. package/src/interfaces/heap.ts +1 -0
  143. package/src/interfaces/index.ts +15 -0
  144. package/src/interfaces/navigator.ts +1 -0
  145. package/src/interfaces/priority-queue.ts +1 -0
  146. package/src/interfaces/rb-tree.ts +9 -0
  147. package/src/interfaces/segment-tree.ts +1 -0
  148. package/src/interfaces/singly-linked-list.ts +1 -0
  149. package/src/interfaces/tree-multiset.ts +7 -0
  150. package/src/interfaces/undirected-graph.ts +6 -0
  151. package/src/types/data-structures/abstract-binary-tree.ts +50 -0
  152. package/src/types/data-structures/abstract-graph.ts +11 -0
  153. package/src/types/data-structures/avl-tree.ts +5 -0
  154. package/src/types/data-structures/binary-tree.ts +5 -0
  155. package/src/types/data-structures/bst.ts +13 -0
  156. package/src/types/data-structures/directed-graph.ts +8 -0
  157. package/src/types/data-structures/doubly-linked-list.ts +1 -0
  158. package/src/types/data-structures/heap.ts +5 -0
  159. package/src/types/data-structures/index.ts +15 -0
  160. package/src/types/data-structures/map-graph.ts +1 -0
  161. package/src/types/data-structures/navigator.ts +13 -0
  162. package/src/types/data-structures/priority-queue.ts +9 -0
  163. package/src/types/data-structures/rb-tree.ts +8 -0
  164. package/src/types/data-structures/segment-tree.ts +1 -0
  165. package/src/types/data-structures/singly-linked-list.ts +1 -0
  166. package/src/types/data-structures/tree-multiset.ts +6 -0
  167. package/src/types/helpers.ts +1 -0
  168. package/src/types/index.ts +3 -0
  169. package/src/types/utils/index.ts +2 -0
  170. package/src/types/utils/utils.ts +6 -0
  171. package/src/types/utils/validate-type.ts +35 -0
  172. package/src/utils/index.ts +1 -0
  173. package/src/utils/utils.ts +79 -0
  174. package/test/integration/avl-tree.test.ts +14 -17
  175. package/test/integration/bst.test.ts +50 -41
  176. package/test/integration/heap.test.js +0 -3
  177. package/test/integration/index.html +6 -6
  178. package/test/unit/data-structures/binary-tree/avl-tree.test.ts +14 -17
  179. package/test/unit/data-structures/binary-tree/binary-tree.test.ts +142 -0
  180. package/test/unit/data-structures/binary-tree/bst.test.ts +50 -41
  181. package/test/unit/data-structures/binary-tree/overall.test.ts +36 -28
  182. package/test/unit/data-structures/binary-tree/rb-tree.test.ts +43 -0
  183. package/test/unit/data-structures/binary-tree/tree-multiset.test.ts +23 -12
  184. package/test/unit/data-structures/graph/directed-graph.test.ts +27 -25
  185. package/test/unit/data-structures/graph/map-graph.test.ts +4 -5
  186. package/test/unit/data-structures/graph/overall.test.ts +10 -11
  187. package/test/unit/data-structures/graph/undirected-graph.test.ts +0 -1
  188. package/test/unit/data-structures/hash/coordinate-map.test.ts +54 -0
  189. package/test/unit/data-structures/hash/coordinate-set.test.ts +41 -0
  190. package/test/unit/data-structures/hash/hash-table.test.ts +97 -0
  191. package/test/unit/data-structures/heap/heap.test.ts +7 -8
  192. package/test/unit/data-structures/heap/max-heap.test.ts +7 -5
  193. package/test/unit/data-structures/heap/min-heap.test.ts +6 -5
  194. package/test/unit/data-structures/linked-list/doubly-linked-list.test.ts +8 -9
  195. package/test/unit/data-structures/linked-list/linked-list.test.ts +2 -4
  196. package/test/unit/data-structures/linked-list/singly-linked-list.test.ts +57 -7
  197. package/test/unit/data-structures/linked-list/skip-linked-list.test.ts +3 -3
  198. package/test/unit/data-structures/matrix/matrix.test.ts +54 -0
  199. package/test/unit/data-structures/matrix/matrix2d.test.ts +138 -0
  200. package/test/unit/data-structures/matrix/navigator.test.ts +79 -0
  201. package/test/unit/data-structures/priority-queue/max-priority-queue.test.ts +5 -7
  202. package/test/unit/data-structures/priority-queue/min-priority-queue.test.ts +13 -13
  203. package/test/unit/data-structures/priority-queue/priority-queue.test.ts +8 -8
  204. package/test/unit/data-structures/queue/deque.test.ts +130 -0
  205. package/test/unit/data-structures/queue/queue.test.ts +167 -4
  206. package/test/unit/data-structures/stack/stack.test.ts +67 -0
  207. package/test/unit/data-structures/tree/tree.test.ts +39 -0
  208. package/test/unit/data-structures/trie/trie.test.ts +95 -0
  209. package/test/utils/magnitude.ts +3 -3
  210. package/tsconfig.json +3 -12
  211. package/tsconfig.prod.json +25 -0
  212. package/umd/bundle.min.js +1 -1
  213. package/umd/bundle.min.js.map +1 -1
  214. package/.auto-changelog +0 -9
  215. package/.gitattributes +0 -112
  216. package/.idea/data-structure-typed.iml +0 -19
  217. package/.idea/inspectionProfiles/Project_Default.xml +0 -6
  218. package/.idea/misc.xml +0 -6
  219. package/.idea/modules.xml +0 -8
  220. package/.idea/vcs.xml +0 -6
  221. package/.prettierignore +0 -6
  222. package/webpack.config.js +0 -28
@@ -5,81 +5,81 @@
5
5
  * @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
6
6
  * @license MIT License
7
7
  */
8
- export declare class SinglyLinkedListNode<T = number> {
8
+ export declare class SinglyLinkedListNode<E = any> {
9
9
  /**
10
10
  * The constructor function initializes an instance of a class with a given value and sets the next property to null.
11
- * @param {T} val - The "val" parameter is of type T, which means it can be any data type. It represents the value that
11
+ * @param {E} val - The "val" parameter is of type E, which means it can be any data type. It represents the value that
12
12
  * will be stored in the node of a linked list.
13
13
  */
14
- constructor(val: T);
14
+ constructor(val: E);
15
15
  private _val;
16
- get val(): T;
17
- set val(value: T);
16
+ get val(): E;
17
+ set val(value: E);
18
18
  private _next;
19
- get next(): SinglyLinkedListNode<T> | null;
20
- set next(value: SinglyLinkedListNode<T> | null);
19
+ get next(): SinglyLinkedListNode<E> | null;
20
+ set next(value: SinglyLinkedListNode<E> | null);
21
21
  }
22
- export declare class SinglyLinkedList<T = any> {
22
+ export declare class SinglyLinkedList<E = any> {
23
23
  /**
24
24
  * The constructor initializes the linked list with an empty head, tail, and length.
25
25
  */
26
26
  constructor();
27
27
  private _head;
28
- get head(): SinglyLinkedListNode<T> | null;
29
- set head(value: SinglyLinkedListNode<T> | null);
28
+ get head(): SinglyLinkedListNode<E> | null;
29
+ set head(value: SinglyLinkedListNode<E> | null);
30
30
  private _tail;
31
- get tail(): SinglyLinkedListNode<T> | null;
32
- set tail(value: SinglyLinkedListNode<T> | null);
31
+ get tail(): SinglyLinkedListNode<E> | null;
32
+ set tail(value: SinglyLinkedListNode<E> | null);
33
33
  private _length;
34
34
  get length(): number;
35
35
  /**
36
36
  * The `fromArray` function creates a new SinglyLinkedList instance and populates it with the elements from the given
37
37
  * array.
38
- * @param {T[]} data - The `data` parameter is an array of elements of type `T`.
38
+ * @param {E[]} data - The `data` parameter is an array of elements of type `E`.
39
39
  * @returns The `fromArray` function returns a `SinglyLinkedList` object.
40
40
  */
41
- static fromArray<T>(data: T[]): SinglyLinkedList<T>;
41
+ static fromArray<E>(data: E[]): SinglyLinkedList<E>;
42
42
  getLength(): number;
43
43
  /**
44
44
  * The `push` function adds a new node with the given data to the end of a singly linked list.
45
- * @param {T} data - The "data" parameter represents the value that you want to add to the linked list. It can be of
46
- * any type (T) as specified in the generic type declaration of the class or function.
45
+ * @param {E} data - The "data" parameter represents the value that you want to add to the linked list. It can be of
46
+ * any type (E) as specified in the generic type declaration of the class or function.
47
47
  */
48
- push(data: T): void;
48
+ push(data: E): void;
49
49
  /**
50
50
  * The `pop()` function removes and returns the value of the last element in a linked list, updating the head and tail
51
51
  * pointers accordingly.
52
52
  * @returns The method `pop()` returns the value of the node that is being removed from the end of the linked list. If
53
53
  * the linked list is empty, it returns `null`.
54
54
  */
55
- pop(): T | undefined;
55
+ pop(): E | undefined;
56
56
  /**
57
57
  * The `shift()` function removes and returns the value of the first node in a linked list.
58
58
  * @returns The value of the node that is being removed from the beginning of the linked list.
59
59
  */
60
- shift(): T | undefined;
60
+ shift(): E | undefined;
61
61
  /**
62
62
  * The unshift function adds a new node with the given value to the beginning of a singly linked list.
63
- * @param {T} val - The parameter "val" represents the value of the new node that will be added to the beginning of the
63
+ * @param {E} val - The parameter "val" represents the value of the new node that will be added to the beginning of the
64
64
  * linked list.
65
65
  */
66
- unshift(val: T): void;
66
+ unshift(val: E): void;
67
67
  /**
68
68
  * The function `getAt` returns the value at a specified index in a linked list, or null if the index is out of range.
69
69
  * @param {number} index - The index parameter is a number that represents the position of the element we want to
70
70
  * retrieve from the list.
71
- * @returns The method `getAt(index: number): T | null` returns the value at the specified index in the linked list, or
71
+ * @returns The method `getAt(index: number): E | null` returns the value at the specified index in the linked list, or
72
72
  * `null` if the index is out of bounds.
73
73
  */
74
- getAt(index: number): T | undefined;
74
+ getAt(index: number): E | undefined;
75
75
  /**
76
76
  * The function `getNodeAt` returns the node at a given index in a singly linked list.
77
77
  * @param {number} index - The `index` parameter is a number that represents the position of the node we want to
78
78
  * retrieve from the linked list. It indicates the zero-based index of the node we want to access.
79
- * @returns The method `getNodeAt(index: number)` returns a `SinglyLinkedListNode<T>` object if the node at the
79
+ * @returns The method `getNodeAt(index: number)` returns a `SinglyLinkedListNode<E>` object if the node at the
80
80
  * specified index exists, or `null` if the index is out of bounds.
81
81
  */
82
- getNodeAt(index: number): SinglyLinkedListNode<T> | null;
82
+ getNodeAt(index: number): SinglyLinkedListNode<E> | null;
83
83
  /**
84
84
  * The `deleteAt` function removes an element at a specified index from a linked list and returns the removed element.
85
85
  * @param {number} index - The index parameter represents the position of the element that needs to be deleted in the
@@ -87,19 +87,19 @@ export declare class SinglyLinkedList<T = any> {
87
87
  * @returns The method `deleteAt` returns the value of the node that was deleted, or `null` if the index is out of
88
88
  * bounds.
89
89
  */
90
- deleteAt(index: number): T | undefined;
91
- delete(valueOrNode: T): boolean;
92
- delete(valueOrNode: SinglyLinkedListNode<T>): boolean;
90
+ deleteAt(index: number): E | undefined;
91
+ delete(valueOrNode: E): boolean;
92
+ delete(valueOrNode: SinglyLinkedListNode<E>): boolean;
93
93
  /**
94
94
  * The `insertAt` function inserts a value at a specified index in a singly linked list.
95
95
  * @param {number} index - The index parameter represents the position at which the new value should be inserted in the
96
96
  * linked list. It is of type number.
97
- * @param {T} val - The `val` parameter represents the value that you want to insert into the linked list at the
97
+ * @param {E} val - The `val` parameter represents the value that you want to insert into the linked list at the
98
98
  * specified index.
99
99
  * @returns The `insert` method returns a boolean value. It returns `true` if the insertion is successful, and `false`
100
100
  * if the index is out of bounds.
101
101
  */
102
- insertAt(index: number, val: T): boolean;
102
+ insertAt(index: number, val: E): boolean;
103
103
  /**
104
104
  * The function checks if the length of a data structure is equal to zero and returns a boolean value indicating
105
105
  * whether it is empty or not.
@@ -112,9 +112,9 @@ export declare class SinglyLinkedList<T = any> {
112
112
  clear(): void;
113
113
  /**
114
114
  * The `toArray` function converts a linked list into an array.
115
- * @returns The `toArray()` method is returning an array of type `T[]`.
115
+ * @returns The `toArray()` method is returning an array of type `E[]`.
116
116
  */
117
- toArray(): T[];
117
+ toArray(): E[];
118
118
  /**
119
119
  * The `reverse` function reverses the order of the nodes in a singly linked list.
120
120
  * @returns The reverse() method does not return anything. It has a return type of void.
@@ -122,36 +122,36 @@ export declare class SinglyLinkedList<T = any> {
122
122
  reverse(): void;
123
123
  /**
124
124
  * The `find` function iterates through a linked list and returns the first element that satisfies a given condition.
125
- * @param callback - A function that takes a value of type T as its parameter and returns a boolean value. This
125
+ * @param callback - A function that takes a value of type E as its parameter and returns a boolean value. This
126
126
  * function is used to determine whether a particular value in the linked list satisfies a certain condition.
127
127
  * @returns The method `find` returns the first element in the linked list that satisfies the condition specified by
128
128
  * the callback function. If no element satisfies the condition, it returns `null`.
129
129
  */
130
- find(callback: (val: T) => boolean): T | null;
130
+ find(callback: (val: E) => boolean): E | null;
131
131
  /**
132
132
  * The `indexOf` function returns the index of the first occurrence of a given value in a linked list.
133
- * @param {T} value - The value parameter is the value that you want to find the index of in the linked list.
133
+ * @param {E} value - The value parameter is the value that you want to find the index of in the linked list.
134
134
  * @returns The method is returning the index of the first occurrence of the specified value in the linked list. If the
135
135
  * value is not found, it returns -1.
136
136
  */
137
- indexOf(value: T): number;
137
+ indexOf(value: E): number;
138
138
  /**
139
139
  * The function finds a node in a singly linked list by its value and returns the node if found, otherwise returns
140
140
  * null.
141
- * @param {T} value - The value parameter is the value that we want to search for in the linked list.
142
- * @returns a `SinglyLinkedListNode<T>` if a node with the specified value is found in the linked list. If no node with
141
+ * @param {E} value - The value parameter is the value that we want to search for in the linked list.
142
+ * @returns a `SinglyLinkedListNode<E>` if a node with the specified value is found in the linked list. If no node with
143
143
  * the specified value is found, the function returns `null`.
144
144
  */
145
- findNode(value: T): SinglyLinkedListNode<T> | null;
146
- insertBefore(existingValue: T, newValue: T): boolean;
147
- insertBefore(existingValue: SinglyLinkedListNode<T>, newValue: T): boolean;
148
- insertAfter(existingValueOrNode: T, newValue: T): boolean;
149
- insertAfter(existingValueOrNode: SinglyLinkedListNode<T>, newValue: T): boolean;
145
+ findNode(value: E): SinglyLinkedListNode<E> | null;
146
+ insertBefore(existingValue: E, newValue: E): boolean;
147
+ insertBefore(existingValue: SinglyLinkedListNode<E>, newValue: E): boolean;
148
+ insertAfter(existingValueOrNode: E, newValue: E): boolean;
149
+ insertAfter(existingValueOrNode: SinglyLinkedListNode<E>, newValue: E): boolean;
150
150
  /**
151
151
  * The function counts the number of occurrences of a given value in a linked list.
152
- * @param {T} value - The value parameter is the value that you want to count the occurrences of in the linked list.
152
+ * @param {E} value - The value parameter is the value that you want to count the occurrences of in the linked list.
153
153
  * @returns The count of occurrences of the given value in the linked list.
154
154
  */
155
- countOccurrences(value: T): number;
156
- [Symbol.iterator](): Generator<T, void, unknown>;
155
+ countOccurrences(value: E): number;
156
+ [Symbol.iterator](): Generator<E, void, unknown>;
157
157
  }
@@ -8,7 +8,7 @@
8
8
  export class SinglyLinkedListNode {
9
9
  /**
10
10
  * The constructor function initializes an instance of a class with a given value and sets the next property to null.
11
- * @param {T} val - The "val" parameter is of type T, which means it can be any data type. It represents the value that
11
+ * @param {E} val - The "val" parameter is of type E, which means it can be any data type. It represents the value that
12
12
  * will be stored in the node of a linked list.
13
13
  */
14
14
  constructor(val) {
@@ -55,7 +55,7 @@ export class SinglyLinkedList {
55
55
  /**
56
56
  * The `fromArray` function creates a new SinglyLinkedList instance and populates it with the elements from the given
57
57
  * array.
58
- * @param {T[]} data - The `data` parameter is an array of elements of type `T`.
58
+ * @param {E[]} data - The `data` parameter is an array of elements of type `E`.
59
59
  * @returns The `fromArray` function returns a `SinglyLinkedList` object.
60
60
  */
61
61
  static fromArray(data) {
@@ -70,8 +70,8 @@ export class SinglyLinkedList {
70
70
  }
71
71
  /**
72
72
  * The `push` function adds a new node with the given data to the end of a singly linked list.
73
- * @param {T} data - The "data" parameter represents the value that you want to add to the linked list. It can be of
74
- * any type (T) as specified in the generic type declaration of the class or function.
73
+ * @param {E} data - The "data" parameter represents the value that you want to add to the linked list. It can be of
74
+ * any type (E) as specified in the generic type declaration of the class or function.
75
75
  */
76
76
  push(data) {
77
77
  const newNode = new SinglyLinkedListNode(data);
@@ -125,7 +125,7 @@ export class SinglyLinkedList {
125
125
  }
126
126
  /**
127
127
  * The unshift function adds a new node with the given value to the beginning of a singly linked list.
128
- * @param {T} val - The parameter "val" represents the value of the new node that will be added to the beginning of the
128
+ * @param {E} val - The parameter "val" represents the value of the new node that will be added to the beginning of the
129
129
  * linked list.
130
130
  */
131
131
  unshift(val) {
@@ -144,7 +144,7 @@ export class SinglyLinkedList {
144
144
  * The function `getAt` returns the value at a specified index in a linked list, or null if the index is out of range.
145
145
  * @param {number} index - The index parameter is a number that represents the position of the element we want to
146
146
  * retrieve from the list.
147
- * @returns The method `getAt(index: number): T | null` returns the value at the specified index in the linked list, or
147
+ * @returns The method `getAt(index: number): E | null` returns the value at the specified index in the linked list, or
148
148
  * `null` if the index is out of bounds.
149
149
  */
150
150
  getAt(index) {
@@ -160,7 +160,7 @@ export class SinglyLinkedList {
160
160
  * The function `getNodeAt` returns the node at a given index in a singly linked list.
161
161
  * @param {number} index - The `index` parameter is a number that represents the position of the node we want to
162
162
  * retrieve from the linked list. It indicates the zero-based index of the node we want to access.
163
- * @returns The method `getNodeAt(index: number)` returns a `SinglyLinkedListNode<T>` object if the node at the
163
+ * @returns The method `getNodeAt(index: number)` returns a `SinglyLinkedListNode<E>` object if the node at the
164
164
  * specified index exists, or `null` if the index is out of bounds.
165
165
  */
166
166
  getNodeAt(index) {
@@ -192,8 +192,8 @@ export class SinglyLinkedList {
192
192
  }
193
193
  /**
194
194
  * The delete function removes a node with a specific value from a singly linked list.
195
- * @param {T | SinglyLinkedListNode<T>} valueOrNode - The `valueOrNode` parameter can accept either a value of type `T`
196
- * or a `SinglyLinkedListNode<T>` object.
195
+ * @param {E | SinglyLinkedListNode<E>} valueOrNode - The `valueOrNode` parameter can accept either a value of type `E`
196
+ * or a `SinglyLinkedListNode<E>` object.
197
197
  * @returns The `delete` method returns a boolean value. It returns `true` if the value or node is found and
198
198
  * successfully deleted from the linked list, and `false` if the value or node is not found in the linked list.
199
199
  */
@@ -232,7 +232,7 @@ export class SinglyLinkedList {
232
232
  * The `insertAt` function inserts a value at a specified index in a singly linked list.
233
233
  * @param {number} index - The index parameter represents the position at which the new value should be inserted in the
234
234
  * linked list. It is of type number.
235
- * @param {T} val - The `val` parameter represents the value that you want to insert into the linked list at the
235
+ * @param {E} val - The `val` parameter represents the value that you want to insert into the linked list at the
236
236
  * specified index.
237
237
  * @returns The `insert` method returns a boolean value. It returns `true` if the insertion is successful, and `false`
238
238
  * if the index is out of bounds.
@@ -273,7 +273,7 @@ export class SinglyLinkedList {
273
273
  }
274
274
  /**
275
275
  * The `toArray` function converts a linked list into an array.
276
- * @returns The `toArray()` method is returning an array of type `T[]`.
276
+ * @returns The `toArray()` method is returning an array of type `E[]`.
277
277
  */
278
278
  toArray() {
279
279
  const array = [];
@@ -304,7 +304,7 @@ export class SinglyLinkedList {
304
304
  }
305
305
  /**
306
306
  * The `find` function iterates through a linked list and returns the first element that satisfies a given condition.
307
- * @param callback - A function that takes a value of type T as its parameter and returns a boolean value. This
307
+ * @param callback - A function that takes a value of type E as its parameter and returns a boolean value. This
308
308
  * function is used to determine whether a particular value in the linked list satisfies a certain condition.
309
309
  * @returns The method `find` returns the first element in the linked list that satisfies the condition specified by
310
310
  * the callback function. If no element satisfies the condition, it returns `null`.
@@ -321,7 +321,7 @@ export class SinglyLinkedList {
321
321
  }
322
322
  /**
323
323
  * The `indexOf` function returns the index of the first occurrence of a given value in a linked list.
324
- * @param {T} value - The value parameter is the value that you want to find the index of in the linked list.
324
+ * @param {E} value - The value parameter is the value that you want to find the index of in the linked list.
325
325
  * @returns The method is returning the index of the first occurrence of the specified value in the linked list. If the
326
326
  * value is not found, it returns -1.
327
327
  */
@@ -340,8 +340,8 @@ export class SinglyLinkedList {
340
340
  /**
341
341
  * The function finds a node in a singly linked list by its value and returns the node if found, otherwise returns
342
342
  * null.
343
- * @param {T} value - The value parameter is the value that we want to search for in the linked list.
344
- * @returns a `SinglyLinkedListNode<T>` if a node with the specified value is found in the linked list. If no node with
343
+ * @param {E} value - The value parameter is the value that we want to search for in the linked list.
344
+ * @returns a `SinglyLinkedListNode<E>` if a node with the specified value is found in the linked list. If no node with
345
345
  * the specified value is found, the function returns `null`.
346
346
  */
347
347
  findNode(value) {
@@ -356,9 +356,9 @@ export class SinglyLinkedList {
356
356
  }
357
357
  /**
358
358
  * The `insertBefore` function inserts a new value before an existing value in a singly linked list.
359
- * @param {T | SinglyLinkedListNode<T>} existingValueOrNode - The existing value or node that you want to insert the
359
+ * @param {E | SinglyLinkedListNode<E>} existingValueOrNode - The existing value or node that you want to insert the
360
360
  * new value before. It can be either the value itself or a node containing the value in the linked list.
361
- * @param {T} newValue - The `newValue` parameter represents the value that you want to insert into the linked list.
361
+ * @param {E} newValue - The `newValue` parameter represents the value that you want to insert into the linked list.
362
362
  * @returns The method `insertBefore` returns a boolean value. It returns `true` if the new value was successfully
363
363
  * inserted before the existing value, and `false` otherwise.
364
364
  */
@@ -391,9 +391,9 @@ export class SinglyLinkedList {
391
391
  }
392
392
  /**
393
393
  * The `insertAfter` function inserts a new node with a given value after an existing node in a singly linked list.
394
- * @param {T | SinglyLinkedListNode<T>} existingValueOrNode - The existing value or node in the linked list after which
394
+ * @param {E | SinglyLinkedListNode<E>} existingValueOrNode - The existing value or node in the linked list after which
395
395
  * the new value will be inserted. It can be either the value of the existing node or the existing node itself.
396
- * @param {T} newValue - The value that you want to insert into the linked list after the existing value or node.
396
+ * @param {E} newValue - The value that you want to insert into the linked list after the existing value or node.
397
397
  * @returns The method returns a boolean value. It returns true if the new value was successfully inserted after the
398
398
  * existing value or node, and false if the existing value or node was not found in the linked list.
399
399
  */
@@ -419,7 +419,7 @@ export class SinglyLinkedList {
419
419
  }
420
420
  /**
421
421
  * The function counts the number of occurrences of a given value in a linked list.
422
- * @param {T} value - The value parameter is the value that you want to count the occurrences of in the linked list.
422
+ * @param {E} value - The value parameter is the value that you want to count the occurrences of in the linked list.
423
423
  * @returns The count of occurrences of the given value in the linked list.
424
424
  */
425
425
  countOccurrences(value) {
@@ -5,7 +5,7 @@
5
5
  * @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
6
6
  * @license MIT License
7
7
  */
8
- export declare class MatrixNTI2D<T = number> {
8
+ export declare class MatrixNTI2D<V = any> {
9
9
  private readonly _matrix;
10
10
  /**
11
11
  * The constructor creates a matrix with the specified number of rows and columns, and initializes all elements to a
@@ -15,7 +15,7 @@ export declare class MatrixNTI2D<T = number> {
15
15
  constructor(options: {
16
16
  row: number;
17
17
  col: number;
18
- initialVal?: T;
18
+ initialVal?: V;
19
19
  });
20
- toArray(): Array<Array<T>>;
20
+ toArray(): Array<Array<V>>;
21
21
  }
@@ -37,7 +37,7 @@ export declare class Matrix2D {
37
37
  * @returns A new instance of the Vector2D class is being returned. The values of the returned vector are taken from
38
38
  * the first column of the matrix.
39
39
  */
40
- get toVector(): Vector2D;
40
+ toVector(): Vector2D;
41
41
  /**
42
42
  * The function takes two 2D matrices as input and returns their sum as a new 2D matrix.
43
43
  * @param {Matrix2D} matrix1 - Matrix2D - The first matrix to be added.
@@ -59,7 +59,7 @@ export class Matrix2D {
59
59
  * @returns A new instance of the Vector2D class is being returned. The values of the returned vector are taken from
60
60
  * the first column of the matrix.
61
61
  */
62
- get toVector() {
62
+ toVector() {
63
63
  return new Vector2D(this._matrix[0][0], this._matrix[1][0]);
64
64
  }
65
65
  /**
@@ -134,7 +134,8 @@ export class Matrix2D {
134
134
  * @returns a Vector2D.
135
135
  */
136
136
  static multiplyByVector(matrix, vector) {
137
- return Matrix2D.multiply(matrix, new Matrix2D(vector)).toVector;
137
+ const resultMatrix = Matrix2D.multiply(matrix, new Matrix2D(vector));
138
+ return resultMatrix.toVector();
138
139
  }
139
140
  /**
140
141
  * The function returns a 2D matrix that scales and flips a vector around the center of a given width and height.
@@ -7,9 +7,9 @@
7
7
  */
8
8
  import { PriorityQueue } from './priority-queue';
9
9
  import type { PriorityQueueOptions } from '../../types';
10
- export declare class MaxPriorityQueue<T = number> extends PriorityQueue<T> {
10
+ export declare class MaxPriorityQueue<E = any> extends PriorityQueue<E> {
11
11
  constructor(options?: Omit<PriorityQueueOptions<number>, 'comparator'>);
12
- constructor(options: PriorityQueueOptions<T>);
13
- static heapify<T extends number>(options?: Omit<PriorityQueueOptions<T>, 'comparator'>): MaxPriorityQueue<T>;
14
- static heapify<T>(options: PriorityQueueOptions<T>): MaxPriorityQueue<T>;
12
+ constructor(options: PriorityQueueOptions<E>);
13
+ static heapify<E extends number>(options?: Omit<PriorityQueueOptions<E>, 'comparator'>): MaxPriorityQueue<E>;
14
+ static heapify<E>(options: PriorityQueueOptions<E>): MaxPriorityQueue<E>;
15
15
  }
@@ -7,9 +7,9 @@
7
7
  */
8
8
  import { PriorityQueue } from './priority-queue';
9
9
  import type { PriorityQueueOptions } from '../../types';
10
- export declare class MinPriorityQueue<T = number> extends PriorityQueue<T> {
10
+ export declare class MinPriorityQueue<E = any> extends PriorityQueue<E> {
11
11
  constructor(options?: Omit<PriorityQueueOptions<number>, 'comparator'>);
12
- constructor(options: PriorityQueueOptions<T>);
13
- static heapify<T extends number>(options?: Omit<PriorityQueueOptions<T>, 'comparator'>): MinPriorityQueue<T>;
14
- static heapify<T>(options: PriorityQueueOptions<T>): MinPriorityQueue<T>;
12
+ constructor(options: PriorityQueueOptions<E>);
13
+ static heapify<E extends number>(options?: Omit<PriorityQueueOptions<E>, 'comparator'>): MinPriorityQueue<E>;
14
+ static heapify<E>(options: PriorityQueueOptions<E>): MinPriorityQueue<E>;
15
15
  }
@@ -6,15 +6,15 @@
6
6
  * @license MIT License
7
7
  */
8
8
  import type { PriorityQueueComparator, PriorityQueueDFSOrderPattern, PriorityQueueOptions } from '../../types';
9
- export declare class PriorityQueue<T = number> {
9
+ export declare class PriorityQueue<E = any> {
10
10
  /**
11
11
  * The constructor initializes a priority queue with the given options, including an array of nodes and a comparator
12
12
  * function.
13
13
  * @param options - The `options` parameter is an object that contains the following properties:
14
14
  */
15
- constructor(options: PriorityQueueOptions<T>);
16
- protected _nodes: T[];
17
- get nodes(): T[];
15
+ constructor(options: PriorityQueueOptions<E>);
16
+ protected _nodes: E[];
17
+ get nodes(): E[];
18
18
  get size(): number;
19
19
  /**
20
20
  * The `heapify` function creates a new PriorityQueue instance and fixes the heap property.
@@ -23,7 +23,7 @@ export declare class PriorityQueue<T = number> {
23
23
  * the priority queue, and "initialValues" which is an array of initial values to be added to the priority
24
24
  * @returns a new instance of the PriorityQueue class after performing the heapify operation on it.
25
25
  */
26
- static heapify<T>(options: PriorityQueueOptions<T>): PriorityQueue<T>;
26
+ static heapify<E>(options: PriorityQueueOptions<E>): PriorityQueue<E>;
27
27
  /**
28
28
  * The function checks if a priority queue is valid by creating a new priority queue with a fix option and then calling
29
29
  * the isValid method.
@@ -31,41 +31,41 @@ export declare class PriorityQueue<T = number> {
31
31
  * following properties:
32
32
  * @returns the result of calling the `isValid()` method on a new instance of the `PriorityQueue` class.
33
33
  */
34
- static isPriorityQueueified<T>(options: Omit<PriorityQueueOptions<T>, 'isFix'>): boolean;
34
+ static isPriorityQueueified<E>(options: Omit<PriorityQueueOptions<E>, 'isFix'>): boolean;
35
35
  /**
36
36
  * Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
37
37
  */
38
- getNodes(): T[];
38
+ getNodes(): E[];
39
39
  /**
40
40
  * The "add" function adds a node to the heap and ensures that the heap property is maintained.
41
- * @param {T} node - The parameter "node" is of type T, which means it can be any data type. It represents the node
41
+ * @param {E} node - The parameter "node" is of type E, which means it can be any data type. It represents the node
42
42
  * that needs to be added to the heap.
43
43
  */
44
- add(node: T): void;
44
+ add(node: E): void;
45
45
  /**
46
46
  * The "has" function checks if a given node is present in the list of nodes.
47
- * @param {T} node - The parameter `node` is of type `T`, which means it can be any type. It represents the node that
47
+ * @param {E} node - The parameter `node` is of type `E`, which means it can be any type. It represents the node that
48
48
  * we want to check if it exists in the `nodes` array.
49
49
  * @returns a boolean value indicating whether the given node is included in the array of nodes.
50
50
  */
51
- has(node: T): boolean;
51
+ has(node: E): boolean;
52
52
  /**
53
53
  * The `peek` function returns the first element of the `nodes` array if it exists, otherwise it returns `null`.
54
- * @returns The `peek()` function is returning the first element (`T`) of the `nodes` array if the `size` is not zero.
54
+ * @returns The `peek()` function is returning the first element (`E`) of the `nodes` array if the `size` is not zero.
55
55
  * Otherwise, it returns `null`.
56
56
  */
57
- peek(): T | null;
57
+ peek(): E | null;
58
58
  /**
59
59
  * The `poll` function removes and returns the top element from a heap data structure.
60
- * @returns The `poll()` method returns a value of type `T` or `null`.
60
+ * @returns The `poll()` method returns a value of type `E` or `null`.
61
61
  */
62
- poll(): T | null;
62
+ poll(): E | null;
63
63
  /**
64
64
  * The `leaf` function returns the last element in the `nodes` array or `null` if the array is empty.
65
- * @returns The method `leaf()` is returning the last element (`T`) in the `nodes` array if it exists. If the array is
65
+ * @returns The method `leaf()` is returning the last element (`E`) in the `nodes` array if it exists. If the array is
66
66
  * empty or the last element is `null`, then it returns `null`.
67
67
  */
68
- leaf(): T | null;
68
+ leaf(): E | null;
69
69
  /**
70
70
  * The function checks if the size of an object is equal to zero and returns a boolean value indicating whether the
71
71
  * object is empty or not.
@@ -79,16 +79,16 @@ export declare class PriorityQueue<T = number> {
79
79
  clear(): void;
80
80
  /**
81
81
  * The toArray function returns an array containing all the elements in the nodes property.
82
- * @returns An array of type T, which is the elements of the nodes property.
82
+ * @returns An array of type E, which is the elements of the nodes property.
83
83
  */
84
- toArray(): T[];
84
+ toArray(): E[];
85
85
  /**
86
86
  * The `clone` function returns a new instance of the `PriorityQueue` class with the same nodes and comparator as the
87
87
  * original instance.
88
88
  * @returns The `clone()` method is returning a new instance of the `PriorityQueue` class with the same `nodes` and
89
89
  * `comparator` properties as the original instance.
90
90
  */
91
- clone(): PriorityQueue<T>;
91
+ clone(): PriorityQueue<E>;
92
92
  /**
93
93
  * The `isValid` function recursively checks if a binary tree satisfies a certain condition.
94
94
  * @returns The function `isValid()` returns a boolean value.
@@ -100,19 +100,19 @@ export declare class PriorityQueue<T = number> {
100
100
  /**
101
101
  * The function sorts the elements in a data structure and returns them in an array.
102
102
  * Plan to support sorting of duplicate elements.
103
- * @returns The `sort()` method is returning an array of type `T[]`.
103
+ * @returns The `sort()` method is returning an array of type `E[]`.
104
104
  */
105
- sort(): T[];
105
+ sort(): E[];
106
106
  /**
107
107
  * The DFS function performs a depth-first search traversal on a binary tree and returns an array of visited nodes
108
108
  * based on the specified traversal order.
109
109
  * @param {PriorityQueueDFSOrderPattern} dfsMode - The dfsMode parameter is a string that specifies the order in which
110
110
  * the nodes should be visited during the Depth-First Search (DFS) traversal. It can have one of the following values:
111
- * @returns an array of type `(T | null)[]`.
111
+ * @returns an array of type `(E | null)[]`.
112
112
  */
113
- DFS(dfsMode: PriorityQueueDFSOrderPattern): (T | null)[];
114
- protected _setNodes(value: T[]): void;
115
- protected readonly _comparator: PriorityQueueComparator<T>;
113
+ DFS(dfsMode: PriorityQueueDFSOrderPattern): (E | null)[];
114
+ protected _setNodes(value: E[]): void;
115
+ protected readonly _comparator: PriorityQueueComparator<E>;
116
116
  /**
117
117
  * The function compares two numbers using a custom comparator function.
118
118
  * @param {number} a - The parameter "a" is a number that represents the index of a node in an array.
@@ -54,7 +54,7 @@ export class PriorityQueue {
54
54
  }
55
55
  /**
56
56
  * The "add" function adds a node to the heap and ensures that the heap property is maintained.
57
- * @param {T} node - The parameter "node" is of type T, which means it can be any data type. It represents the node
57
+ * @param {E} node - The parameter "node" is of type E, which means it can be any data type. It represents the node
58
58
  * that needs to be added to the heap.
59
59
  */
60
60
  add(node) {
@@ -63,7 +63,7 @@ export class PriorityQueue {
63
63
  }
64
64
  /**
65
65
  * The "has" function checks if a given node is present in the list of nodes.
66
- * @param {T} node - The parameter `node` is of type `T`, which means it can be any type. It represents the node that
66
+ * @param {E} node - The parameter `node` is of type `E`, which means it can be any type. It represents the node that
67
67
  * we want to check if it exists in the `nodes` array.
68
68
  * @returns a boolean value indicating whether the given node is included in the array of nodes.
69
69
  */
@@ -72,7 +72,7 @@ export class PriorityQueue {
72
72
  }
73
73
  /**
74
74
  * The `peek` function returns the first element of the `nodes` array if it exists, otherwise it returns `null`.
75
- * @returns The `peek()` function is returning the first element (`T`) of the `nodes` array if the `size` is not zero.
75
+ * @returns The `peek()` function is returning the first element (`E`) of the `nodes` array if the `size` is not zero.
76
76
  * Otherwise, it returns `null`.
77
77
  */
78
78
  peek() {
@@ -80,7 +80,7 @@ export class PriorityQueue {
80
80
  }
81
81
  /**
82
82
  * The `poll` function removes and returns the top element from a heap data structure.
83
- * @returns The `poll()` method returns a value of type `T` or `null`.
83
+ * @returns The `poll()` method returns a value of type `E` or `null`.
84
84
  */
85
85
  poll() {
86
86
  var _a, _b;
@@ -97,7 +97,7 @@ export class PriorityQueue {
97
97
  }
98
98
  /**
99
99
  * The `leaf` function returns the last element in the `nodes` array or `null` if the array is empty.
100
- * @returns The method `leaf()` is returning the last element (`T`) in the `nodes` array if it exists. If the array is
100
+ * @returns The method `leaf()` is returning the last element (`E`) in the `nodes` array if it exists. If the array is
101
101
  * empty or the last element is `null`, then it returns `null`.
102
102
  */
103
103
  leaf() {
@@ -121,7 +121,7 @@ export class PriorityQueue {
121
121
  }
122
122
  /**
123
123
  * The toArray function returns an array containing all the elements in the nodes property.
124
- * @returns An array of type T, which is the elements of the nodes property.
124
+ * @returns An array of type E, which is the elements of the nodes property.
125
125
  */
126
126
  toArray() {
127
127
  return [...this.nodes];
@@ -162,7 +162,7 @@ export class PriorityQueue {
162
162
  /**
163
163
  * The function sorts the elements in a data structure and returns them in an array.
164
164
  * Plan to support sorting of duplicate elements.
165
- * @returns The `sort()` method is returning an array of type `T[]`.
165
+ * @returns The `sort()` method is returning an array of type `E[]`.
166
166
  */
167
167
  sort() {
168
168
  const visitedNode = [];
@@ -178,7 +178,7 @@ export class PriorityQueue {
178
178
  * based on the specified traversal order.
179
179
  * @param {PriorityQueueDFSOrderPattern} dfsMode - The dfsMode parameter is a string that specifies the order in which
180
180
  * the nodes should be visited during the Depth-First Search (DFS) traversal. It can have one of the following values:
181
- * @returns an array of type `(T | null)[]`.
181
+ * @returns an array of type `(E | null)[]`.
182
182
  */
183
183
  DFS(dfsMode) {
184
184
  const visitedNode = [];