data-structure-typed 0.9.16 → 1.12.9

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 (199) hide show
  1. package/.dependency-cruiser.js +449 -0
  2. package/.idea/data-structure-typed.iml +2 -0
  3. package/README.md +102 -1
  4. package/dist/data-structures/binary-tree/avl-tree.d.ts +57 -0
  5. package/dist/data-structures/binary-tree/avl-tree.js +57 -0
  6. package/dist/data-structures/binary-tree/binary-indexed-tree.d.ts +27 -0
  7. package/dist/data-structures/binary-tree/binary-indexed-tree.js +27 -0
  8. package/dist/data-structures/binary-tree/binary-tree.d.ts +215 -9
  9. package/dist/data-structures/binary-tree/binary-tree.js +283 -15
  10. package/dist/data-structures/binary-tree/bst.d.ts +16 -0
  11. package/dist/data-structures/binary-tree/bst.js +12 -0
  12. package/dist/data-structures/binary-tree/segment-tree.d.ts +4 -0
  13. package/dist/data-structures/binary-tree/segment-tree.js +4 -0
  14. package/dist/data-structures/binary-tree/tree-multiset.d.ts +4 -0
  15. package/dist/data-structures/binary-tree/tree-multiset.js +4 -0
  16. package/dist/data-structures/graph/abstract-graph.d.ts +163 -13
  17. package/dist/data-structures/graph/abstract-graph.js +166 -12
  18. package/dist/data-structures/graph/directed-graph.d.ts +111 -1
  19. package/dist/data-structures/graph/directed-graph.js +122 -0
  20. package/dist/data-structures/graph/undirected-graph.d.ts +63 -0
  21. package/dist/data-structures/graph/undirected-graph.js +67 -0
  22. package/dist/data-structures/hash/coordinate-map.d.ts +32 -0
  23. package/dist/data-structures/hash/coordinate-map.js +32 -0
  24. package/dist/data-structures/hash/coordinate-set.d.ts +25 -0
  25. package/dist/data-structures/hash/coordinate-set.js +25 -0
  26. package/dist/data-structures/heap/heap.d.ts +26 -31
  27. package/dist/data-structures/heap/heap.js +23 -32
  28. package/dist/data-structures/heap/max-heap.d.ts +6 -1
  29. package/dist/data-structures/heap/max-heap.js +6 -1
  30. package/dist/data-structures/heap/min-heap.d.ts +7 -1
  31. package/dist/data-structures/heap/min-heap.js +7 -1
  32. package/dist/data-structures/index.d.ts +0 -1
  33. package/dist/data-structures/index.js +0 -1
  34. package/dist/data-structures/linked-list/doubly-linked-list.d.ts +14 -6
  35. package/dist/data-structures/linked-list/doubly-linked-list.js +45 -8
  36. package/dist/data-structures/linked-list/singly-linked-list.d.ts +11 -8
  37. package/dist/data-structures/linked-list/singly-linked-list.js +4 -0
  38. package/dist/data-structures/matrix/matrix.d.ts +9 -0
  39. package/dist/data-structures/matrix/matrix.js +11 -0
  40. package/dist/data-structures/matrix/matrix2d.d.ts +82 -2
  41. package/dist/data-structures/matrix/matrix2d.js +82 -2
  42. package/dist/data-structures/matrix/navigator.d.ts +32 -0
  43. package/dist/data-structures/matrix/navigator.js +28 -0
  44. package/dist/data-structures/matrix/vector2d.d.ts +139 -15
  45. package/dist/data-structures/matrix/vector2d.js +139 -15
  46. package/dist/data-structures/priority-queue/max-priority-queue.d.ts +8 -0
  47. package/dist/data-structures/priority-queue/max-priority-queue.js +8 -0
  48. package/dist/data-structures/priority-queue/min-priority-queue.d.ts +8 -0
  49. package/dist/data-structures/priority-queue/min-priority-queue.js +8 -0
  50. package/dist/data-structures/priority-queue/priority-queue.d.ts +130 -0
  51. package/dist/data-structures/priority-queue/priority-queue.js +126 -0
  52. package/dist/data-structures/queue/deque.d.ts +69 -0
  53. package/dist/data-structures/queue/deque.js +69 -0
  54. package/dist/data-structures/queue/queue.d.ts +30 -32
  55. package/dist/data-structures/queue/queue.js +30 -32
  56. package/dist/data-structures/stack/stack.d.ts +26 -31
  57. package/dist/data-structures/stack/stack.js +26 -31
  58. package/dist/data-structures/trie/trie.d.ts +26 -6
  59. package/dist/data-structures/trie/trie.js +26 -7
  60. package/dist/data-structures/types/avl-tree.d.ts +1 -1
  61. package/dist/data-structures/types/binary-tree.d.ts +1 -1
  62. package/dist/data-structures/types/index.d.ts +1 -1
  63. package/dist/data-structures/types/index.js +1 -1
  64. package/dist/data-structures/types/singly-linked-list.d.ts +1 -5
  65. package/dist/data-structures/types/tree-multiset.d.ts +1 -1
  66. package/dist/{data-structures → utils}/trampoline.d.ts +5 -7
  67. package/dist/utils/types/index.d.ts +1 -0
  68. package/dist/utils/types/index.js +17 -0
  69. package/dist/{data-structures → utils}/types/utils.d.ts +8 -0
  70. package/dist/{data-structures → utils}/types/utils.js +1 -0
  71. package/dist/utils/utils.d.ts +1 -1
  72. package/docs/.nojekyll +1 -0
  73. package/docs/assets/highlight.css +85 -0
  74. package/docs/assets/main.js +58 -0
  75. package/docs/assets/search.js +1 -0
  76. package/docs/assets/style.css +1367 -0
  77. package/docs/classes/AVLTree.html +2046 -0
  78. package/docs/classes/AVLTreeNode.html +423 -0
  79. package/docs/classes/AaTree.html +117 -0
  80. package/docs/classes/AbstractEdge.html +198 -0
  81. package/docs/classes/AbstractGraph.html +891 -0
  82. package/docs/classes/AbstractVertex.html +164 -0
  83. package/docs/classes/ArrayDeque.html +384 -0
  84. package/docs/classes/BST.html +1893 -0
  85. package/docs/classes/BSTNode.html +425 -0
  86. package/docs/classes/BTree.html +117 -0
  87. package/docs/classes/BinaryIndexedTree.html +244 -0
  88. package/docs/classes/BinaryTree.html +1754 -0
  89. package/docs/classes/BinaryTreeNode.html +396 -0
  90. package/docs/classes/Character.html +165 -0
  91. package/docs/classes/CoordinateMap.html +394 -0
  92. package/docs/classes/CoordinateSet.html +355 -0
  93. package/docs/classes/Deque.html +617 -0
  94. package/docs/classes/DirectedEdge.html +247 -0
  95. package/docs/classes/DirectedGraph.html +1207 -0
  96. package/docs/classes/DirectedVertex.html +154 -0
  97. package/docs/classes/DoublyLinkedList.html +619 -0
  98. package/docs/classes/DoublyLinkedListNode.html +160 -0
  99. package/docs/classes/Heap.html +315 -0
  100. package/docs/classes/Matrix2D.html +447 -0
  101. package/docs/classes/MatrixNTI2D.html +181 -0
  102. package/docs/classes/MaxHeap.html +325 -0
  103. package/docs/classes/MaxPriorityQueue.html +668 -0
  104. package/docs/classes/MinHeap.html +326 -0
  105. package/docs/classes/MinPriorityQueue.html +668 -0
  106. package/docs/classes/Navigator.html +285 -0
  107. package/docs/classes/ObjectDeque.html +289 -0
  108. package/docs/classes/PriorityQueue.html +643 -0
  109. package/docs/classes/Queue.html +337 -0
  110. package/docs/classes/RBTree.html +117 -0
  111. package/docs/classes/SegmentTree.html +234 -0
  112. package/docs/classes/SegmentTreeNode.html +302 -0
  113. package/docs/classes/SinglyLinkedList.html +1035 -0
  114. package/docs/classes/SinglyLinkedListNode.html +304 -0
  115. package/docs/classes/SplayTree.html +117 -0
  116. package/docs/classes/Stack.html +313 -0
  117. package/docs/classes/TreeMultiSet.html +1897 -0
  118. package/docs/classes/Trie.html +317 -0
  119. package/docs/classes/TrieNode.html +221 -0
  120. package/docs/classes/TwoThreeTree.html +117 -0
  121. package/docs/classes/UndirectedEdge.html +220 -0
  122. package/docs/classes/UndirectedGraph.html +1006 -0
  123. package/docs/classes/UndirectedVertex.html +154 -0
  124. package/docs/classes/Vector2D.html +746 -0
  125. package/docs/enums/CP.html +126 -0
  126. package/docs/enums/FamilyPosition.html +126 -0
  127. package/docs/enums/LoopType.html +119 -0
  128. package/docs/index.html +288 -0
  129. package/docs/modules.html +146 -0
  130. package/jest.config.js +5 -0
  131. package/package.json +19 -11
  132. package/rename_clear_files.sh +29 -0
  133. package/src/assets/complexities-diff.jpg +0 -0
  134. package/src/assets/data-structure-complexities.jpg +0 -0
  135. package/src/data-structures/binary-tree/avl-tree.ts +57 -0
  136. package/src/data-structures/binary-tree/binary-indexed-tree.ts +27 -0
  137. package/src/data-structures/binary-tree/binary-tree.ts +288 -18
  138. package/src/data-structures/binary-tree/bst.ts +16 -1
  139. package/src/data-structures/binary-tree/segment-tree.ts +5 -0
  140. package/src/data-structures/binary-tree/tree-multiset.ts +4 -0
  141. package/src/data-structures/diagrams/README.md +5 -7
  142. package/src/data-structures/graph/abstract-graph.ts +167 -15
  143. package/src/data-structures/graph/diagrams/adjacency-list-pros-cons.jpg +0 -0
  144. package/src/data-structures/graph/diagrams/adjacency-list.jpg +0 -0
  145. package/src/data-structures/graph/diagrams/adjacency-matrix-pros-cons.jpg +0 -0
  146. package/src/data-structures/graph/diagrams/adjacency-matrix.jpg +0 -0
  147. package/src/data-structures/graph/diagrams/dfs-can-do.jpg +0 -0
  148. package/src/data-structures/graph/diagrams/edge-list-pros-cons.jpg +0 -0
  149. package/src/data-structures/graph/diagrams/edge-list.jpg +0 -0
  150. package/src/data-structures/graph/diagrams/max-flow.jpg +0 -0
  151. package/src/data-structures/graph/diagrams/mst.jpg +0 -0
  152. package/src/data-structures/graph/diagrams/tarjan.webp +0 -0
  153. package/src/data-structures/graph/directed-graph.ts +127 -5
  154. package/src/data-structures/graph/undirected-graph.ts +67 -1
  155. package/src/data-structures/hash/coordinate-map.ts +32 -0
  156. package/src/data-structures/hash/coordinate-set.ts +25 -0
  157. package/src/data-structures/heap/heap.ts +27 -32
  158. package/src/data-structures/heap/max-heap.ts +6 -1
  159. package/src/data-structures/heap/min-heap.ts +7 -1
  160. package/src/data-structures/index.ts +0 -1
  161. package/src/data-structures/linked-list/doubly-linked-list.ts +49 -8
  162. package/src/data-structures/linked-list/singly-linked-list.ts +39 -8
  163. package/src/data-structures/matrix/matrix.ts +11 -0
  164. package/src/data-structures/matrix/matrix2d.ts +82 -2
  165. package/src/data-structures/matrix/navigator.ts +32 -0
  166. package/src/data-structures/matrix/vector2d.ts +139 -15
  167. package/src/data-structures/priority-queue/max-priority-queue.ts +8 -0
  168. package/src/data-structures/priority-queue/min-priority-queue.ts +8 -0
  169. package/src/data-structures/priority-queue/priority-queue.ts +130 -0
  170. package/src/data-structures/queue/deque.ts +69 -0
  171. package/src/data-structures/queue/queue.ts +30 -32
  172. package/src/data-structures/stack/stack.ts +26 -31
  173. package/src/data-structures/trie/trie.ts +26 -7
  174. package/src/data-structures/types/avl-tree.ts +1 -1
  175. package/src/data-structures/types/binary-tree.ts +1 -1
  176. package/src/data-structures/types/bst.ts +1 -1
  177. package/src/data-structures/types/index.ts +1 -1
  178. package/src/data-structures/types/navigator.ts +1 -0
  179. package/src/data-structures/types/singly-linked-list.ts +1 -15
  180. package/src/data-structures/types/tree-multiset.ts +1 -1
  181. package/src/{data-structures → utils}/trampoline.ts +6 -6
  182. package/src/utils/types/index.ts +1 -0
  183. package/src/{data-structures → utils}/types/utils.ts +7 -0
  184. package/src/utils/utils.ts +12 -2
  185. package/tests/unit/data-structures/binary-tree/bst.test.ts +185 -0
  186. package/tests/unit/data-structures/graph/abstract-graph.ts +0 -0
  187. package/tests/unit/data-structures/graph/directed-graph.test.ts +71 -0
  188. package/tests/unit/data-structures/graph/index.ts +3 -0
  189. package/tests/unit/data-structures/graph/undirected-graph.ts +0 -0
  190. package/src/data-structures/graph/diagrams/adjacency-list-pros-cons.png +0 -0
  191. package/src/data-structures/graph/diagrams/adjacency-list.png +0 -0
  192. package/src/data-structures/graph/diagrams/adjacency-matrix-pros-cons.png +0 -0
  193. package/src/data-structures/graph/diagrams/adjacency-matrix.png +0 -0
  194. package/src/data-structures/graph/diagrams/dfs-can-do.png +0 -0
  195. package/src/data-structures/graph/diagrams/edge-list-pros-cons.png +0 -0
  196. package/src/data-structures/graph/diagrams/edge-list.png +0 -0
  197. package/src/data-structures/graph/diagrams/max-flow.png +0 -0
  198. package/src/data-structures/graph/diagrams/mst.png +0 -0
  199. /package/dist/{data-structures → utils}/trampoline.js +0 -0
@@ -16,6 +16,10 @@ var __extends = (this && this.__extends) || (function () {
16
16
  })();
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.CoordinateMap = void 0;
19
+ /**
20
+ * @copyright 2030 Tyler Zeng <zrwusa@gmail.com>
21
+ * @license MIT
22
+ */
19
23
  var CoordinateMap = /** @class */ (function (_super) {
20
24
  __extends(CoordinateMap, _super);
21
25
  function CoordinateMap(joint) {
@@ -25,15 +29,43 @@ var CoordinateMap = /** @class */ (function (_super) {
25
29
  _this._joint = joint;
26
30
  return _this;
27
31
  }
32
+ /**
33
+ * The "has" function overrides the base class's "has" function and checks if a key exists in the map by joining the
34
+ * key array with a specified delimiter.
35
+ * @param {number[]} key - The parameter "key" is an array of numbers.
36
+ * @returns The `has` method is being overridden to return the result of calling the `has` method of the superclass
37
+ * (`super.has`) with the `key` array joined together using the `_joint` property.
38
+ */
28
39
  CoordinateMap.prototype.has = function (key) {
29
40
  return _super.prototype.has.call(this, key.join(this._joint));
30
41
  };
42
+ /**
43
+ * The function overrides the set method of a Map object to convert the key from an array to a string using a specified
44
+ * delimiter before calling the original set method.
45
+ * @param {number[]} key - The key parameter is an array of numbers.
46
+ * @param {V} value - The value parameter is the value that you want to associate with the specified key.
47
+ * @returns The `set` method is returning the result of calling the `set` method of the superclass
48
+ * (`super.set(key.join(this._joint), value)`).
49
+ */
31
50
  CoordinateMap.prototype.set = function (key, value) {
32
51
  return _super.prototype.set.call(this, key.join(this._joint), value);
33
52
  };
53
+ /**
54
+ * The function overrides the get method to join the key array with a specified joint and then calls the super get
55
+ * method.
56
+ * @param {number[]} key - An array of numbers
57
+ * @returns The code is returning the value associated with the specified key in the map.
58
+ */
34
59
  CoordinateMap.prototype.get = function (key) {
35
60
  return _super.prototype.get.call(this, key.join(this._joint));
36
61
  };
62
+ /**
63
+ * The function overrides the delete method and joins the key array using a specified joint character before calling
64
+ * the super delete method.
65
+ * @param {number[]} key - An array of numbers that represents the key to be deleted.
66
+ * @returns The `delete` method is returning the result of calling the `delete` method on the superclass, with the
67
+ * `key` array joined together using the `_joint` property.
68
+ */
37
69
  CoordinateMap.prototype.delete = function (key) {
38
70
  return _super.prototype.delete.call(this, key.join(this._joint));
39
71
  };
@@ -1,7 +1,32 @@
1
+ /**
2
+ * @copyright 2030 Tyler Zeng <zrwusa@gmail.com>
3
+ * @license MIT
4
+ */
1
5
  export declare class CoordinateSet extends Set {
2
6
  private readonly _joint;
3
7
  constructor(joint?: string);
8
+ /**
9
+ * The "has" function overrides the "has" method of the superclass and checks if a value exists in an array after
10
+ * joining its elements with a specified separator.
11
+ * @param {number[]} value - The parameter "value" is an array of numbers.
12
+ * @returns The overridden `has` method is returning the result of calling the `has` method of the superclass, passing
13
+ * in the joined value as an argument.
14
+ */
4
15
  has(value: number[]): boolean;
16
+ /**
17
+ * The "add" function overrides the parent class's "add" function by joining the elements of the input array with a
18
+ * specified delimiter before calling the parent class's "add" function.
19
+ * @param {number[]} value - An array of numbers
20
+ * @returns The overridden `add` method is returning the result of calling the `add` method of the superclass
21
+ * (`super.add`) with the joined string representation of the `value` array (`value.join(this._joint)`).
22
+ */
5
23
  add(value: number[]): this;
24
+ /**
25
+ * The function overrides the delete method and deletes an element from a Set by joining the elements of the input
26
+ * array with a specified joint and then calling the delete method of the parent class.
27
+ * @param {number[]} value - An array of numbers
28
+ * @returns The `delete` method is returning the result of calling the `delete` method of the superclass, with the
29
+ * `value` array joined together using the `_joint` property.
30
+ */
6
31
  delete(value: number[]): boolean;
7
32
  }
@@ -16,6 +16,10 @@ var __extends = (this && this.__extends) || (function () {
16
16
  })();
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.CoordinateSet = void 0;
19
+ /**
20
+ * @copyright 2030 Tyler Zeng <zrwusa@gmail.com>
21
+ * @license MIT
22
+ */
19
23
  var CoordinateSet = /** @class */ (function (_super) {
20
24
  __extends(CoordinateSet, _super);
21
25
  function CoordinateSet(joint) {
@@ -25,12 +29,33 @@ var CoordinateSet = /** @class */ (function (_super) {
25
29
  _this._joint = joint;
26
30
  return _this;
27
31
  }
32
+ /**
33
+ * The "has" function overrides the "has" method of the superclass and checks if a value exists in an array after
34
+ * joining its elements with a specified separator.
35
+ * @param {number[]} value - The parameter "value" is an array of numbers.
36
+ * @returns The overridden `has` method is returning the result of calling the `has` method of the superclass, passing
37
+ * in the joined value as an argument.
38
+ */
28
39
  CoordinateSet.prototype.has = function (value) {
29
40
  return _super.prototype.has.call(this, value.join(this._joint));
30
41
  };
42
+ /**
43
+ * The "add" function overrides the parent class's "add" function by joining the elements of the input array with a
44
+ * specified delimiter before calling the parent class's "add" function.
45
+ * @param {number[]} value - An array of numbers
46
+ * @returns The overridden `add` method is returning the result of calling the `add` method of the superclass
47
+ * (`super.add`) with the joined string representation of the `value` array (`value.join(this._joint)`).
48
+ */
31
49
  CoordinateSet.prototype.add = function (value) {
32
50
  return _super.prototype.add.call(this, value.join(this._joint));
33
51
  };
52
+ /**
53
+ * The function overrides the delete method and deletes an element from a Set by joining the elements of the input
54
+ * array with a specified joint and then calling the delete method of the parent class.
55
+ * @param {number[]} value - An array of numbers
56
+ * @returns The `delete` method is returning the result of calling the `delete` method of the superclass, with the
57
+ * `value` array joined together using the `_joint` property.
58
+ */
34
59
  CoordinateSet.prototype.delete = function (value) {
35
60
  return _super.prototype.delete.call(this, value.join(this._joint));
36
61
  };
@@ -1,66 +1,61 @@
1
- import { PriorityQueue } from '../priority-queue';
2
- import type { HeapItem, HeapOptions } from '../types';
3
1
  /**
4
- * @copyright 2021 Tyler Zeng <zrwusa@gmail.com>
2
+ * @copyright 2030 Tyler Zeng <zrwusa@gmail.com>
5
3
  * @license MIT
6
- *
7
- * @abstract
8
- * @class Heap
9
4
  */
5
+ import { PriorityQueue } from '../priority-queue';
6
+ import type { HeapItem, HeapOptions } from '../types';
10
7
  export declare abstract class Heap<T> {
11
8
  protected abstract _pq: PriorityQueue<HeapItem<T>>;
12
9
  protected _priorityCb: (element: T) => number;
13
10
  /**
14
- * Creates a priority queue
15
- * @public
16
- * @params {object} [options]
11
+ * The function is a constructor for a class that initializes a priority callback function based on the
12
+ * options provided.
13
+ * @param [options] - An optional object that contains configuration options for the Heap.
17
14
  */
18
15
  protected constructor(options?: HeapOptions<T>);
19
16
  /**
20
- * @public
21
- * @returns {number}
17
+ * The function returns the size of a priority queue.
18
+ * @returns The size of the priority queue.
22
19
  */
23
20
  get size(): number;
24
21
  /**
25
- * @public
26
- * @returns {boolean}
22
+ * The function checks if a priority queue is empty.
23
+ * @returns {boolean} A boolean value indicating whether the size of the priority queue is less than 1.
27
24
  */
28
25
  isEmpty(): boolean;
29
26
  /**
30
- * Returns an element with highest priority in the queue
31
- * @public
32
- * @returns {object}
27
+ * The `peek` function returns the top item in the priority queue without removing it.
28
+ * @returns The `peek()` method is returning either a `HeapItem<T>` object or `null`.Returns an element with the highest priority in the queue
33
29
  */
34
30
  peek(): HeapItem<T> | null;
35
31
  /**
36
- * Returns an element with lowest priority in the queue
37
- * @public
38
- * @returns {object}
32
+ * The `peekLast` function returns the last item in the heap.
33
+ * @returns The method `peekLast()` returns either a `HeapItem<T>` object or `null`.Returns an element with the lowest priority in the queue
39
34
  */
40
35
  peekLast(): HeapItem<T> | null;
41
36
  /**
42
- * Adds an element to the queue
43
- * @public
44
- * @param {any} element
45
- * @param priority
37
+ * The `offer` function adds an element to a priority queue with an optional priority value.
38
+ * @param {T} element - The `element` parameter represents the value that you want to add to the heap. It can be of any
39
+ * type.
40
+ * @param {number} [priority] - The `priority` parameter is an optional number that represents the priority of the
41
+ * element being offered to the heap. If the `element` parameter is a number, then the `priority` parameter is set to
42
+ * the value of `element`. If the `element` parameter is not a number, then the
43
+ * @returns The `offer` method returns the instance of the `Heap` class.
46
44
  * @throws {Error} if priority is not a valid number
47
45
  */
48
46
  offer(element: T, priority?: number): Heap<T>;
49
47
  /**
50
- * Removes and returns an element with highest priority in the queue
51
- * @public
52
- * @returns {object}
48
+ * The `poll` function returns the top item from a priority queue or null if the queue is empty.Removes and returns an element with the highest priority in the queue
49
+ * @returns either a HeapItem<T> object or null.
53
50
  */
54
51
  poll(): HeapItem<T> | null;
55
52
  /**
56
- * Returns a sorted list of elements
57
- * @public
58
- * @returns {array}
53
+ * The `toArray` function returns an array of `HeapItem<T>` objects.
54
+ * @returns An array of HeapItem<T> objects.Returns a sorted list of elements
59
55
  */
60
56
  toArray(): HeapItem<T>[];
61
57
  /**
62
- * Clears the queue
63
- * @public
58
+ * The clear function clears the priority queue.
64
59
  */
65
60
  clear(): void;
66
61
  }
@@ -1,18 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Heap = void 0;
4
- /**
5
- * @copyright 2021 Tyler Zeng <zrwusa@gmail.com>
6
- * @license MIT
7
- *
8
- * @abstract
9
- * @class Heap
10
- */
11
4
  var Heap = /** @class */ (function () {
12
5
  /**
13
- * Creates a priority queue
14
- * @public
15
- * @params {object} [options]
6
+ * The function is a constructor for a class that initializes a priority callback function based on the
7
+ * options provided.
8
+ * @param [options] - An optional object that contains configuration options for the Heap.
16
9
  */
17
10
  function Heap(options) {
18
11
  if (options) {
@@ -28,8 +21,8 @@ var Heap = /** @class */ (function () {
28
21
  }
29
22
  Object.defineProperty(Heap.prototype, "size", {
30
23
  /**
31
- * @public
32
- * @returns {number}
24
+ * The function returns the size of a priority queue.
25
+ * @returns The size of the priority queue.
33
26
  */
34
27
  get: function () {
35
28
  return this._pq.size;
@@ -38,33 +31,34 @@ var Heap = /** @class */ (function () {
38
31
  configurable: true
39
32
  });
40
33
  /**
41
- * @public
42
- * @returns {boolean}
34
+ * The function checks if a priority queue is empty.
35
+ * @returns {boolean} A boolean value indicating whether the size of the priority queue is less than 1.
43
36
  */
44
37
  Heap.prototype.isEmpty = function () {
45
38
  return this._pq.size < 1;
46
39
  };
47
40
  /**
48
- * Returns an element with highest priority in the queue
49
- * @public
50
- * @returns {object}
41
+ * The `peek` function returns the top item in the priority queue without removing it.
42
+ * @returns The `peek()` method is returning either a `HeapItem<T>` object or `null`.Returns an element with the highest priority in the queue
51
43
  */
52
44
  Heap.prototype.peek = function () {
53
45
  return this._pq.peek();
54
46
  };
55
47
  /**
56
- * Returns an element with lowest priority in the queue
57
- * @public
58
- * @returns {object}
48
+ * The `peekLast` function returns the last item in the heap.
49
+ * @returns The method `peekLast()` returns either a `HeapItem<T>` object or `null`.Returns an element with the lowest priority in the queue
59
50
  */
60
51
  Heap.prototype.peekLast = function () {
61
52
  return this._pq.leaf();
62
53
  };
63
54
  /**
64
- * Adds an element to the queue
65
- * @public
66
- * @param {any} element
67
- * @param priority
55
+ * The `offer` function adds an element to a priority queue with an optional priority value.
56
+ * @param {T} element - The `element` parameter represents the value that you want to add to the heap. It can be of any
57
+ * type.
58
+ * @param {number} [priority] - The `priority` parameter is an optional number that represents the priority of the
59
+ * element being offered to the heap. If the `element` parameter is a number, then the `priority` parameter is set to
60
+ * the value of `element`. If the `element` parameter is not a number, then the
61
+ * @returns The `offer` method returns the instance of the `Heap` class.
68
62
  * @throws {Error} if priority is not a valid number
69
63
  */
70
64
  Heap.prototype.offer = function (element, priority) {
@@ -88,9 +82,8 @@ var Heap = /** @class */ (function () {
88
82
  return this;
89
83
  };
90
84
  /**
91
- * Removes and returns an element with highest priority in the queue
92
- * @public
93
- * @returns {object}
85
+ * The `poll` function returns the top item from a priority queue or null if the queue is empty.Removes and returns an element with the highest priority in the queue
86
+ * @returns either a HeapItem<T> object or null.
94
87
  */
95
88
  Heap.prototype.poll = function () {
96
89
  var top = this._pq.poll();
@@ -100,16 +93,14 @@ var Heap = /** @class */ (function () {
100
93
  return top;
101
94
  };
102
95
  /**
103
- * Returns a sorted list of elements
104
- * @public
105
- * @returns {array}
96
+ * The `toArray` function returns an array of `HeapItem<T>` objects.
97
+ * @returns An array of HeapItem<T> objects.Returns a sorted list of elements
106
98
  */
107
99
  Heap.prototype.toArray = function () {
108
100
  return this._pq.toArray();
109
101
  };
110
102
  /**
111
- * Clears the queue
112
- * @public
103
+ * The clear function clears the priority queue.
113
104
  */
114
105
  Heap.prototype.clear = function () {
115
106
  this._pq.clear();
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @copyright 2020 Tyler Zeng <zrwusa@gmail.com>
2
+ * @copyright 2030 Tyler Zeng <zrwusa@gmail.com>
3
3
  * @license MIT
4
4
  */
5
5
  import { Heap } from './heap';
@@ -11,5 +11,10 @@ import type { HeapItem, HeapOptions } from '../types';
11
11
  */
12
12
  export declare class MaxHeap<T> extends Heap<T> {
13
13
  protected _pq: PriorityQueue<HeapItem<T>>;
14
+ /**
15
+ * The constructor initializes a PriorityQueue with a custom comparator function.
16
+ * @param [options] - The `options` parameter is an optional object that can be passed to the constructor. It is of
17
+ * type `HeapOptions<T>`, which is a generic type that represents the options for the heap.
18
+ */
14
19
  constructor(options?: HeapOptions<T>);
15
20
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /**
3
- * @copyright 2020 Tyler Zeng <zrwusa@gmail.com>
3
+ * @copyright 2030 Tyler Zeng <zrwusa@gmail.com>
4
4
  * @license MIT
5
5
  */
6
6
  var __extends = (this && this.__extends) || (function () {
@@ -28,6 +28,11 @@ var priority_queue_1 = require("../priority-queue");
28
28
  */
29
29
  var MaxHeap = /** @class */ (function (_super) {
30
30
  __extends(MaxHeap, _super);
31
+ /**
32
+ * The constructor initializes a PriorityQueue with a custom comparator function.
33
+ * @param [options] - The `options` parameter is an optional object that can be passed to the constructor. It is of
34
+ * type `HeapOptions<T>`, which is a generic type that represents the options for the heap.
35
+ */
31
36
  function MaxHeap(options) {
32
37
  var _this = _super.call(this, options) || this;
33
38
  _this._pq = new priority_queue_1.PriorityQueue({
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @copyright 2020 Tyler Zeng <zrwusa@gmail.com>
2
+ * @copyright 2030 Tyler Zeng <zrwusa@gmail.com>
3
3
  * @license MIT
4
4
  */
5
5
  import { Heap } from './heap';
@@ -11,5 +11,11 @@ import type { HeapItem, HeapOptions } from '../types';
11
11
  */
12
12
  export declare class MinHeap<T> extends Heap<T> {
13
13
  protected _pq: PriorityQueue<HeapItem<T>>;
14
+ /**
15
+ * The constructor initializes a PriorityQueue with a comparator function that compares the priority of two HeapItem
16
+ * objects.
17
+ * @param [options] - The `options` parameter is an optional object that can be passed to the constructor. It is of
18
+ * type `HeapOptions<T>`, which is a generic type that represents the options for the heap.
19
+ */
14
20
  constructor(options?: HeapOptions<T>);
15
21
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /**
3
- * @copyright 2020 Tyler Zeng <zrwusa@gmail.com>
3
+ * @copyright 2030 Tyler Zeng <zrwusa@gmail.com>
4
4
  * @license MIT
5
5
  */
6
6
  var __extends = (this && this.__extends) || (function () {
@@ -28,6 +28,12 @@ var priority_queue_1 = require("../priority-queue");
28
28
  */
29
29
  var MinHeap = /** @class */ (function (_super) {
30
30
  __extends(MinHeap, _super);
31
+ /**
32
+ * The constructor initializes a PriorityQueue with a comparator function that compares the priority of two HeapItem
33
+ * objects.
34
+ * @param [options] - The `options` parameter is an optional object that can be passed to the constructor. It is of
35
+ * type `HeapOptions<T>`, which is a generic type that represents the options for the heap.
36
+ */
31
37
  function MinHeap(options) {
32
38
  var _this = _super.call(this, options) || this;
33
39
  _this._pq = new priority_queue_1.PriorityQueue({
@@ -8,4 +8,3 @@ export * from './heap';
8
8
  export * from './priority-queue';
9
9
  export * from './matrix';
10
10
  export * from './trie';
11
- export * from './types';
@@ -24,4 +24,3 @@ __exportStar(require("./heap"), exports);
24
24
  __exportStar(require("./priority-queue"), exports);
25
25
  __exportStar(require("./matrix"), exports);
26
26
  __exportStar(require("./trie"), exports);
27
- __exportStar(require("./types"), exports);
@@ -11,13 +11,17 @@ export declare class DoublyLinkedList<T> {
11
11
  get size(): number;
12
12
  set size(v: number);
13
13
  /**
14
- * Adds a node at the beginning of the linked list
15
- * @param val Value to be stored at the beginning of the linked list
14
+ * The function adds a new node with a given value to the beginning of a doubly linked list.
15
+ * @param {T} val - The `val` parameter represents the value of the element that you want to add to the beginning of
16
+ * the doubly linked list.
17
+ * @returns A boolean value is being returned.
16
18
  */
17
19
  offerFirst(val: T): boolean;
18
20
  /**
19
- * Adds a node to the end of the linked list
20
- * @param val Value to be stored in the Doubly linked list node
21
+ * The function adds a new node with a given value to the end of a doubly linked list.
22
+ * @param {T} val - The `val` parameter represents the value of the element that you want to add to the end of the
23
+ * doubly linked list.
24
+ * @returns a boolean value, which is always true.
21
25
  */
22
26
  offerLast(val: T): boolean;
23
27
  peekFirst(): T | null;
@@ -51,8 +55,12 @@ export declare class DoublyLinkedList<T> {
51
55
  */
52
56
  insert(index: number, val: T): boolean;
53
57
  /**
54
- * Removes a node at the specified index and returns its value.
55
- * @param index Index at which the node has to be removed.
58
+ * The `remove` function removes an element at a specified index from a data structure, updating the links between
59
+ * nodes accordingly.
60
+ * @param {number} index - The index parameter represents the position of the element to be removed in the data
61
+ * structure. It is of type number.
62
+ * @returns The `remove` method returns the value of the removed element (`T`) if the removal is successful, or `null`
63
+ * if the index is out of bounds.
56
64
  */
57
65
  remove(index: number): T | null;
58
66
  }
@@ -28,8 +28,10 @@ var DoublyLinkedList = /** @class */ (function () {
28
28
  configurable: true
29
29
  });
30
30
  /**
31
- * Adds a node at the beginning of the linked list
32
- * @param val Value to be stored at the beginning of the linked list
31
+ * The function adds a new node with a given value to the beginning of a doubly linked list.
32
+ * @param {T} val - The `val` parameter represents the value of the element that you want to add to the beginning of
33
+ * the doubly linked list.
34
+ * @returns A boolean value is being returned.
33
35
  */
34
36
  DoublyLinkedList.prototype.offerFirst = function (val) {
35
37
  var newNode = new DoublyLinkedListNode(val);
@@ -47,8 +49,10 @@ var DoublyLinkedList = /** @class */ (function () {
47
49
  return true;
48
50
  };
49
51
  /**
50
- * Adds a node to the end of the linked list
51
- * @param val Value to be stored in the Doubly linked list node
52
+ * The function adds a new node with a given value to the end of a doubly linked list.
53
+ * @param {T} val - The `val` parameter represents the value of the element that you want to add to the end of the
54
+ * doubly linked list.
55
+ * @returns a boolean value, which is always true.
52
56
  */
53
57
  DoublyLinkedList.prototype.offerLast = function (val) {
54
58
  var newNode = new DoublyLinkedListNode(val);
@@ -65,6 +69,14 @@ var DoublyLinkedList = /** @class */ (function () {
65
69
  this._size++;
66
70
  return true;
67
71
  };
72
+ /**
73
+ * The `peekFirst` function returns the first node or value in a doubly linked list, depending on the specified
74
+ * parameter.
75
+ * @param {DoublyLinkedListGetBy} [by] - The "by" parameter is an optional parameter of type DoublyLinkedListGetBy. It
76
+ * is used to specify whether to return the first node, the value of the first node, or the first node itself.
77
+ * @returns The method `peekFirst` returns either the first node of the doubly linked list (`DoublyLinkedListNode<T>`),
78
+ * the value of the first node (`T`), or `null` depending on the value of the `by` parameter.
79
+ */
68
80
  DoublyLinkedList.prototype.peekFirst = function (by) {
69
81
  var _a, _b, _c, _d, _e;
70
82
  switch (by) {
@@ -76,6 +88,13 @@ var DoublyLinkedList = /** @class */ (function () {
76
88
  return (_e = (_d = this._first) === null || _d === void 0 ? void 0 : _d.val) !== null && _e !== void 0 ? _e : null;
77
89
  }
78
90
  };
91
+ /**
92
+ * The `peekLast` function returns the last node or value in a doubly linked list.
93
+ * @param {DoublyLinkedListGetBy} [by=val] - The "by" parameter is an optional parameter of type DoublyLinkedListGetBy.
94
+ * It specifies whether to return the last node, the value of the last node, or both. The default value is 'val', which
95
+ * means that if no value is provided for the "by" parameter, the method
96
+ * @returns The method `peekLast` returns the last node, value, or null based on the specified `by` parameter.
97
+ */
79
98
  DoublyLinkedList.prototype.peekLast = function (by) {
80
99
  var _a, _b, _c, _d, _e;
81
100
  if (by === void 0) { by = 'val'; }
@@ -89,7 +108,14 @@ var DoublyLinkedList = /** @class */ (function () {
89
108
  }
90
109
  };
91
110
  /**
92
- * Removes a node form the beginning of the linked list and will return the node val
111
+ * The function `pollFirst` removes and returns the first element of a doubly linked list, either as a node or its
112
+ * value, depending on the specified parameter.
113
+ * @param {DoublyLinkedListGetBy} [by=val] - The "by" parameter is an optional parameter of type DoublyLinkedListGetBy.
114
+ * It specifies the criteria by which the first element should be retrieved from the doubly linked list. The default
115
+ * value is 'val', which means the first element will be retrieved by its value. Other possible values for "by
116
+ * @returns The method `pollFirst` returns either the value of the first node in the doubly linked list, the first node
117
+ * itself, or null if the list is empty. The specific return type depends on the value of the `by` parameter. If `by`
118
+ * is set to 'node', the method returns the first node. If `by` is set to 'val', the method returns the value
93
119
  */
94
120
  DoublyLinkedList.prototype.pollFirst = function (by) {
95
121
  var _a, _b, _c;
@@ -119,7 +145,14 @@ var DoublyLinkedList = /** @class */ (function () {
119
145
  }
120
146
  };
121
147
  /**
122
- * Removes a node at the end of the linked list and will return the node value
148
+ * The function `pollLast` removes and returns the last element in a doubly linked list, either as a node or its value,
149
+ * depending on the specified parameter.
150
+ * @param {DoublyLinkedListGetBy} [by=val] - The parameter "by" is of type DoublyLinkedListGetBy, which is an enum that
151
+ * can have two possible values: 'node' or 'val'. It determines the type of value that will be returned by the pollLast
152
+ * method. If 'node' is specified, the method will return the
153
+ * @returns The method `pollLast` returns either a `DoublyLinkedListNode<T>`, the value of the node (`T`), or `null`.
154
+ * The specific type that is returned depends on the value of the `by` parameter. If `by` is set to `'node'`, then a
155
+ * `DoublyLinkedListNode<T>` is returned. If `by` is set to `'
123
156
  */
124
157
  DoublyLinkedList.prototype.pollLast = function (by) {
125
158
  var _a, _b, _c;
@@ -230,8 +263,12 @@ var DoublyLinkedList = /** @class */ (function () {
230
263
  return true;
231
264
  };
232
265
  /**
233
- * Removes a node at the specified index and returns its value.
234
- * @param index Index at which the node has to be removed.
266
+ * The `remove` function removes an element at a specified index from a data structure, updating the links between
267
+ * nodes accordingly.
268
+ * @param {number} index - The index parameter represents the position of the element to be removed in the data
269
+ * structure. It is of type number.
270
+ * @returns The `remove` method returns the value of the removed element (`T`) if the removal is successful, or `null`
271
+ * if the index is out of bounds.
235
272
  */
236
273
  DoublyLinkedList.prototype.remove = function (index) {
237
274
  var _a, _b, _c;
@@ -1,4 +1,7 @@
1
- import type { TMapFunction, TTestFunction } from '../types';
1
+ /**
2
+ * @copyright 2030 Tyler Zeng <zrwusa@gmail.com>
3
+ * @license MIT
4
+ */
2
5
  /**
3
6
  * The class which represents one link or node in a linked list
4
7
  * ```ts
@@ -114,7 +117,7 @@ export declare class SinglyLinkedList<NodeData = any> {
114
117
  * ```
115
118
  * @param f A function to be applied to the val of each node
116
119
  */
117
- findNodeIndex(f: TTestFunction<NodeData>): ({
120
+ findNodeIndex(f: (data: NodeData, index: number, list: SinglyLinkedList<NodeData>) => boolean): ({
118
121
  node: SinglyLinkedListNode<NodeData>;
119
122
  index: number;
120
123
  }) | undefined;
@@ -127,7 +130,7 @@ export declare class SinglyLinkedList<NodeData = any> {
127
130
  * ```
128
131
  * @param f Function to test val against
129
132
  */
130
- findNode(f: TTestFunction<NodeData>): SinglyLinkedListNode<NodeData> | undefined;
133
+ findNode(f: (data: NodeData, index: number, list: SinglyLinkedList<NodeData>) => boolean): SinglyLinkedListNode<NodeData> | undefined;
131
134
  /**
132
135
  * Returns the value of the first element in the list that
133
136
  * satisfies the provided testing function. Otherwise undefined is returned.
@@ -136,7 +139,7 @@ export declare class SinglyLinkedList<NodeData = any> {
136
139
  * ```
137
140
  * @param f Function to test val against
138
141
  */
139
- find(f: TTestFunction<NodeData>): NodeData | undefined;
142
+ find(f: (data: NodeData, index: number, list: SinglyLinkedList<NodeData>) => boolean): NodeData | undefined;
140
143
  /**
141
144
  * Returns the index of the first node in the list that
142
145
  * satisfies the provided testing function. Ohterwise -1 is returned.
@@ -145,7 +148,7 @@ export declare class SinglyLinkedList<NodeData = any> {
145
148
  * ```
146
149
  * @param f Function to test val against
147
150
  */
148
- findIndex(f: TTestFunction<NodeData>): number;
151
+ findIndex(f: (data: NodeData, index: number, list: SinglyLinkedList<NodeData>) => boolean): number;
149
152
  /**
150
153
  * Append one or any number of nodes to the end of the list.
151
154
  * This modifies the list in place and returns the list itself
@@ -295,7 +298,7 @@ export declare class SinglyLinkedList<NodeData = any> {
295
298
  * @param f Function to execute for each element, taking up to three arguments.
296
299
  * @param reverse Indicates if the list should be walked in reverse order, default is false
297
300
  */
298
- forEach(f: TMapFunction<NodeData>, reverse?: boolean): void;
301
+ forEach(f: (data: any, index: number, list: SinglyLinkedList<NodeData>) => any, reverse?: boolean): void;
299
302
  /**
300
303
  * The map() method creates a new list with the results of
301
304
  * calling a provided function on every node in the calling list.
@@ -305,7 +308,7 @@ export declare class SinglyLinkedList<NodeData = any> {
305
308
  * @param f Function that produces an node of the new list, taking up to three arguments
306
309
  * @param reverse Indicates if the list should be mapped in reverse order, default is false
307
310
  */
308
- map(f: TMapFunction<NodeData>, reverse?: boolean): SinglyLinkedList<NodeData | {}>;
311
+ map(f: (data: any, index: number, list: SinglyLinkedList<NodeData>) => any, reverse?: boolean): SinglyLinkedList<NodeData | {}>;
309
312
  /**
310
313
  * The filter() method creates a new list with all nodes
311
314
  * that pass the test implemented by the provided function.
@@ -315,7 +318,7 @@ export declare class SinglyLinkedList<NodeData = any> {
315
318
  * @param f Function to test each node val in the list. Return true to keep the node
316
319
  * @param reverse Indicates if the list should be filtered in reverse order, default is false
317
320
  */
318
- filter(f: TTestFunction<NodeData>, reverse?: boolean): SinglyLinkedList<NodeData | {}>;
321
+ filter(f: (data: NodeData, index: number, list: SinglyLinkedList<NodeData>) => boolean, reverse?: boolean): SinglyLinkedList<NodeData | {}>;
319
322
  /**
320
323
  * Reduce over each node in the list
321
324
  * ```ts
@@ -1,4 +1,8 @@
1
1
  "use strict";
2
+ /**
3
+ * @copyright 2030 Tyler Zeng <zrwusa@gmail.com>
4
+ * @license MIT
5
+ */
2
6
  var __generator = (this && this.__generator) || function (thisArg, body) {
3
7
  var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
4
8
  return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;