priority-queue-typed 1.49.4 → 1.49.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/dist/data-structures/base/iterable-base.d.ts +1 -1
  2. package/dist/data-structures/binary-tree/avl-tree.d.ts +53 -48
  3. package/dist/data-structures/binary-tree/avl-tree.js +55 -49
  4. package/dist/data-structures/binary-tree/binary-tree.d.ts +154 -143
  5. package/dist/data-structures/binary-tree/binary-tree.js +211 -198
  6. package/dist/data-structures/binary-tree/bst.d.ts +83 -71
  7. package/dist/data-structures/binary-tree/bst.js +113 -89
  8. package/dist/data-structures/binary-tree/rb-tree.d.ts +37 -35
  9. package/dist/data-structures/binary-tree/rb-tree.js +62 -59
  10. package/dist/data-structures/binary-tree/tree-multimap.d.ts +46 -55
  11. package/dist/data-structures/binary-tree/tree-multimap.js +59 -94
  12. package/dist/data-structures/graph/abstract-graph.d.ts +1 -1
  13. package/dist/data-structures/graph/abstract-graph.js +3 -2
  14. package/dist/data-structures/hash/hash-map.d.ts +1 -1
  15. package/dist/data-structures/hash/hash-map.js +2 -2
  16. package/dist/data-structures/heap/heap.js +2 -3
  17. package/dist/data-structures/linked-list/singly-linked-list.d.ts +2 -2
  18. package/dist/data-structures/matrix/index.d.ts +0 -2
  19. package/dist/data-structures/matrix/index.js +0 -2
  20. package/dist/data-structures/matrix/matrix.d.ts +128 -10
  21. package/dist/data-structures/matrix/matrix.js +400 -15
  22. package/dist/data-structures/queue/deque.d.ts +2 -2
  23. package/dist/data-structures/queue/deque.js +5 -7
  24. package/dist/data-structures/queue/queue.d.ts +1 -1
  25. package/dist/interfaces/binary-tree.d.ts +3 -3
  26. package/dist/types/common.d.ts +3 -3
  27. package/dist/types/common.js +2 -2
  28. package/dist/types/data-structures/base/base.d.ts +1 -1
  29. package/dist/types/data-structures/heap/heap.d.ts +1 -1
  30. package/dist/types/data-structures/priority-queue/priority-queue.d.ts +1 -1
  31. package/dist/utils/utils.d.ts +1 -0
  32. package/dist/utils/utils.js +6 -1
  33. package/package.json +2 -2
  34. package/src/data-structures/base/index.ts +1 -1
  35. package/src/data-structures/base/iterable-base.ts +7 -10
  36. package/src/data-structures/binary-tree/avl-tree.ts +73 -61
  37. package/src/data-structures/binary-tree/binary-tree.ts +301 -270
  38. package/src/data-structures/binary-tree/bst.ts +139 -115
  39. package/src/data-structures/binary-tree/rb-tree.ts +81 -73
  40. package/src/data-structures/binary-tree/tree-multimap.ts +72 -103
  41. package/src/data-structures/graph/abstract-graph.ts +13 -11
  42. package/src/data-structures/graph/directed-graph.ts +1 -3
  43. package/src/data-structures/graph/map-graph.ts +6 -1
  44. package/src/data-structures/graph/undirected-graph.ts +3 -6
  45. package/src/data-structures/hash/hash-map.ts +18 -16
  46. package/src/data-structures/heap/heap.ts +7 -10
  47. package/src/data-structures/heap/max-heap.ts +2 -1
  48. package/src/data-structures/heap/min-heap.ts +2 -1
  49. package/src/data-structures/linked-list/singly-linked-list.ts +2 -3
  50. package/src/data-structures/matrix/index.ts +0 -2
  51. package/src/data-structures/matrix/matrix.ts +442 -13
  52. package/src/data-structures/priority-queue/min-priority-queue.ts +11 -10
  53. package/src/data-structures/queue/deque.ts +18 -39
  54. package/src/data-structures/queue/queue.ts +1 -1
  55. package/src/interfaces/binary-tree.ts +9 -4
  56. package/src/types/common.ts +5 -5
  57. package/src/types/data-structures/base/base.ts +14 -3
  58. package/src/types/data-structures/base/index.ts +1 -1
  59. package/src/types/data-structures/graph/abstract-graph.ts +4 -2
  60. package/src/types/data-structures/hash/hash-map.ts +3 -3
  61. package/src/types/data-structures/heap/heap.ts +2 -2
  62. package/src/types/data-structures/priority-queue/priority-queue.ts +2 -2
  63. package/src/utils/utils.ts +7 -1
  64. package/dist/data-structures/matrix/matrix2d.d.ts +0 -107
  65. package/dist/data-structures/matrix/matrix2d.js +0 -199
  66. package/dist/data-structures/matrix/vector2d.d.ts +0 -200
  67. package/dist/data-structures/matrix/vector2d.js +0 -290
  68. package/src/data-structures/matrix/matrix2d.ts +0 -211
  69. package/src/data-structures/matrix/vector2d.ts +0 -315
@@ -24,16 +24,16 @@ exports.TreeMultimapNode = TreeMultimapNode;
24
24
  * The only distinction between a TreeMultimap and a AVLTree lies in the ability of the former to store duplicate nodes through the utilization of counters.
25
25
  */
26
26
  class TreeMultimap extends avl_tree_1.AVLTree {
27
- constructor(elements, options) {
27
+ constructor(nodes, options) {
28
28
  super([], options);
29
29
  this._count = 0;
30
- if (elements)
31
- this.addMany(elements);
30
+ if (nodes)
31
+ this.addMany(nodes);
32
32
  }
33
33
  // TODO the _count is not accurate after nodes count modified
34
34
  get count() {
35
35
  let sum = 0;
36
- this.subTreeTraverse(node => sum += node.count);
36
+ this.subTreeTraverse(node => (sum += node.count));
37
37
  return sum;
38
38
  }
39
39
  /**
@@ -52,26 +52,8 @@ class TreeMultimap extends avl_tree_1.AVLTree {
52
52
  return new TreeMultimap([], Object.assign({ iterationType: this.iterationType, variant: this.variant }, options));
53
53
  }
54
54
  /**
55
- * The function checks if an exemplar is an instance of the TreeMultimapNode class.
56
- * @param exemplar - The `exemplar` parameter is of type `BTNExemplar<K, V, N>`.
57
- * @returns a boolean value indicating whether the exemplar is an instance of the TreeMultimapNode
58
- * class.
59
- */
60
- isNode(exemplar) {
61
- return exemplar instanceof TreeMultimapNode;
62
- }
63
- /**
64
- * The function "isNotNodeInstance" checks if a potential key is a K.
65
- * @param {any} potentialKey - The potentialKey parameter is of type any, which means it can be any
66
- * data type.
67
- * @returns a boolean value indicating whether the potentialKey is of type number or not.
68
- */
69
- isNotNodeInstance(potentialKey) {
70
- return !(potentialKey instanceof TreeMultimapNode);
71
- }
72
- /**
73
- * The function `exemplarToNode` converts an exemplar object into a node object.
74
- * @param exemplar - The `exemplar` parameter is of type `BTNExemplar<K, V, N>`, which means it
55
+ * The function `exemplarToNode` converts an keyOrNodeOrEntry object into a node object.
56
+ * @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter is of type `KeyOrNodeOrEntry<K, V, N>`, which means it
75
57
  * can be one of the following:
76
58
  * @param {V} [value] - The `value` parameter is an optional argument that represents the value
77
59
  * associated with the node. It is of type `V`, which can be any data type. If no value is provided,
@@ -80,16 +62,16 @@ class TreeMultimap extends avl_tree_1.AVLTree {
80
62
  * times the value should be added to the node. If not provided, it defaults to 1.
81
63
  * @returns a node of type `N` or `undefined`.
82
64
  */
83
- exemplarToNode(exemplar, value, count = 1) {
65
+ exemplarToNode(keyOrNodeOrEntry, value, count = 1) {
84
66
  let node;
85
- if (exemplar === undefined || exemplar === null) {
67
+ if (keyOrNodeOrEntry === undefined || keyOrNodeOrEntry === null) {
86
68
  return;
87
69
  }
88
- else if (this.isNode(exemplar)) {
89
- node = exemplar;
70
+ else if (this.isNode(keyOrNodeOrEntry)) {
71
+ node = keyOrNodeOrEntry;
90
72
  }
91
- else if (this.isEntry(exemplar)) {
92
- const [key, value] = exemplar;
73
+ else if (this.isEntry(keyOrNodeOrEntry)) {
74
+ const [key, value] = keyOrNodeOrEntry;
93
75
  if (key === undefined || key === null) {
94
76
  return;
95
77
  }
@@ -97,8 +79,8 @@ class TreeMultimap extends avl_tree_1.AVLTree {
97
79
  node = this.createNode(key, value, count);
98
80
  }
99
81
  }
100
- else if (this.isNotNodeInstance(exemplar)) {
101
- node = this.createNode(exemplar, value, count);
82
+ else if (this.isNotNodeInstance(keyOrNodeOrEntry)) {
83
+ node = this.createNode(keyOrNodeOrEntry, value, count);
102
84
  }
103
85
  else {
104
86
  return;
@@ -106,12 +88,31 @@ class TreeMultimap extends avl_tree_1.AVLTree {
106
88
  return node;
107
89
  }
108
90
  /**
109
- * Time Complexity: O(log n) - logarithmic time, where "n" is the number of nodes in the tree. The add method of the superclass (AVLTree) has logarithmic time complexity.
110
- * Space Complexity: O(1) - constant space, as it doesn't use additional data structures that scale with input size.
91
+ * The function checks if an keyOrNodeOrEntry is an instance of the TreeMultimapNode class.
92
+ * @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter is of type `KeyOrNodeOrEntry<K, V, N>`.
93
+ * @returns a boolean value indicating whether the keyOrNodeOrEntry is an instance of the TreeMultimapNode
94
+ * class.
95
+ */
96
+ isNode(keyOrNodeOrEntry) {
97
+ return keyOrNodeOrEntry instanceof TreeMultimapNode;
98
+ }
99
+ /**
100
+ * The function "isNotNodeInstance" checks if a potential key is a K.
101
+ * @param {any} potentialKey - The potentialKey parameter is of type any, which means it can be any
102
+ * data type.
103
+ * @returns a boolean value indicating whether the potentialKey is of type number or not.
104
+ */
105
+ isNotNodeInstance(potentialKey) {
106
+ return !(potentialKey instanceof TreeMultimapNode);
107
+ }
108
+ /**
109
+ * Time Complexity: O(log n)
110
+ * Space Complexity: O(1)
111
+ * logarithmic time, where "n" is the number of nodes in the tree. The add method of the superclass (AVLTree) has logarithmic time complexity. constant space, as it doesn't use additional data structures that scale with input size.
111
112
  */
112
113
  /**
113
- * Time Complexity: O(log n) - logarithmic time, where "n" is the number of nodes in the tree. The add method of the superclass (AVLTree) has logarithmic time complexity.
114
- * Space Complexity: O(1) - constant space, as it doesn't use additional data structures that scale with input size.
114
+ * Time Complexity: O(log n)
115
+ * Space Complexity: O(1)
115
116
  *
116
117
  * The function overrides the add method of a binary tree node and adds a new node to the tree.
117
118
  * @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter can be either a key, a node, or an
@@ -128,21 +129,22 @@ class TreeMultimap extends avl_tree_1.AVLTree {
128
129
  add(keyOrNodeOrEntry, value, count = 1) {
129
130
  const newNode = this.exemplarToNode(keyOrNodeOrEntry, value, count);
130
131
  if (newNode === undefined)
131
- return;
132
+ return false;
132
133
  const orgNodeCount = (newNode === null || newNode === void 0 ? void 0 : newNode.count) || 0;
133
134
  const inserted = super.add(newNode);
134
135
  if (inserted) {
135
136
  this._count += orgNodeCount;
136
137
  }
137
- return inserted;
138
+ return true;
138
139
  }
139
140
  /**
140
- * Time Complexity: O(k log n) - logarithmic time, where "n" is the number of nodes in the tree. The add method of the superclass (AVLTree) has logarithmic time complexity.
141
- * Space Complexity: O(1) - constant space, as it doesn't use additional data structures that scale with input size.
141
+ * Time Complexity: O(k log n)
142
+ * Space Complexity: O(1)
143
+ * logarithmic time, where "n" is the number of nodes in the tree. The add method of the superclass (AVLTree) has logarithmic time complexity. constant space, as it doesn't use additional data structures that scale with input size.
142
144
  */
143
145
  /**
144
- * Time Complexity: O(k log n) - logarithmic time, where "n" is the number of nodes in the tree. The add method of the superclass (AVLTree) has logarithmic time complexity.
145
- * Space Complexity: O(1) - constant space, as it doesn't use additional data structures that scale with input size.
146
+ * Time Complexity: O(k log n)
147
+ * Space Complexity: O(1)
146
148
  *
147
149
  * The function overrides the addMany method to add multiple keys, nodes, or entries to a data
148
150
  * structure.
@@ -154,12 +156,13 @@ class TreeMultimap extends avl_tree_1.AVLTree {
154
156
  return super.addMany(keysOrNodesOrEntries);
155
157
  }
156
158
  /**
157
- * Time Complexity: O(1) - constant time, as it performs basic pointer assignments.
158
- * Space Complexity: O(1) - constant space, as it only uses a constant amount of memory.
159
+ * Time Complexity: O(n log n)
160
+ * Space Complexity: O(n)
161
+ * logarithmic time for each insertion, where "n" is the number of nodes in the tree. This is because the method calls the add method for each node. linear space, as it creates an array to store the sorted nodes.
159
162
  */
160
163
  /**
161
- * Time Complexity: O(n log n) - logarithmic time for each insertion, where "n" is the number of nodes in the tree. This is because the method calls the add method for each node.
162
- * Space Complexity: O(n) - linear space, as it creates an array to store the sorted nodes.
164
+ * Time Complexity: O(n log n)
165
+ * Space Complexity: O(n)
163
166
  *
164
167
  * The `perfectlyBalance` function takes a sorted array of nodes and builds a balanced binary search
165
168
  * tree using either a recursive or iterative approach.
@@ -205,12 +208,13 @@ class TreeMultimap extends avl_tree_1.AVLTree {
205
208
  }
206
209
  }
207
210
  /**
208
- * Time Complexity: O(k log n) - logarithmic time for each insertion, where "n" is the number of nodes in the tree, and "k" is the number of keys to be inserted. This is because the method iterates through the keys and calls the add method for each.
209
- * Space Complexity: O(1) - constant space, as it doesn't use additional data structures that scale with input size.
211
+ * Time Complexity: O(k log n)
212
+ * Space Complexity: O(1)
213
+ * logarithmic time for each insertion, where "n" is the number of nodes in the tree, and "k" is the number of keys to be inserted. This is because the method iterates through the keys and calls the add method for each. constant space, as it doesn't use additional data structures that scale with input size.
210
214
  */
211
215
  /**
212
- * Time Complexity: O(log n) - logarithmic time, where "n" is the number of nodes in the tree. The delete method of the superclass (AVLTree) has logarithmic time complexity.
213
- * Space Complexity: O(1) - constant space, as it doesn't use additional data structures that scale with input size.
216
+ * Time Complexity: O(k log n)
217
+ * Space Complexity: O(1)
214
218
  *
215
219
  * The `delete` function in TypeScript is used to remove a node from a binary tree, taking into
216
220
  * account the count of the node and balancing the tree if necessary.
@@ -286,10 +290,13 @@ class TreeMultimap extends avl_tree_1.AVLTree {
286
290
  return deletedResult;
287
291
  }
288
292
  /**
289
- * Time Complexity: O(n log n) - logarithmic time for each insertion, where "n" is the number of nodes in the tree. This is because the method calls the add method for each node.
290
- * Space Complexity: O(n) - linear space, as it creates an array to store the sorted nodes.
293
+ * Time Complexity: O(1)
294
+ * Space Complexity: O(1)
291
295
  */
292
296
  /**
297
+ * Time Complexity: O(1)
298
+ * Space Complexity: O(1)
299
+ *
293
300
  * The clear() function clears the contents of a data structure and sets the count to zero.
294
301
  */
295
302
  clear() {
@@ -312,48 +319,6 @@ class TreeMultimap extends avl_tree_1.AVLTree {
312
319
  this.bfs(node => cloned.add(node.key, node.value, node.count));
313
320
  return cloned;
314
321
  }
315
- /**
316
- * Time Complexity: O(1) - constant time, as it performs basic pointer assignments.
317
- * Space Complexity: O(1) - constant space, as it only uses a constant amount of memory.
318
- *
319
- * The function adds a new node to a binary tree, either as the left child or the right child of a
320
- * given parent node.
321
- * @param {N | undefined} newNode - The `newNode` parameter represents the node that needs to be
322
- * added to the binary tree. It can be of type `N` (which represents a node in the binary tree) or
323
- * `undefined` if there is no node to add.
324
- * @param {K | N | undefined} parent - The `parent` parameter represents the parent node to
325
- * which the new node will be added as a child. It can be either a node object (`N`) or a key value
326
- * (`K`).
327
- * @returns The method `_addTo` returns either the `parent.left` or `parent.right` node that was
328
- * added, or `undefined` if no node was added.
329
- */
330
- _addTo(newNode, parent) {
331
- parent = this.ensureNode(parent);
332
- if (parent) {
333
- if (parent.left === undefined) {
334
- parent.left = newNode;
335
- if (newNode !== undefined) {
336
- this._size = this.size + 1;
337
- this._count += newNode.count;
338
- }
339
- return parent.left;
340
- }
341
- else if (parent.right === undefined) {
342
- parent.right = newNode;
343
- if (newNode !== undefined) {
344
- this._size = this.size + 1;
345
- this._count += newNode.count;
346
- }
347
- return parent.right;
348
- }
349
- else {
350
- return;
351
- }
352
- }
353
- else {
354
- return;
355
- }
356
- }
357
322
  /**
358
323
  * The `_swapProperties` function swaps the key, value, count, and height properties between two nodes.
359
324
  * @param {K | N | undefined} srcNode - The `srcNode` parameter represents the source node from
@@ -6,7 +6,7 @@
6
6
  * @license MIT License
7
7
  */
8
8
  import type { DijkstraResult, EntryCallback, VertexKey } from '../../types';
9
- import { IterableEntryBase } from "../base";
9
+ import { IterableEntryBase } from '../base';
10
10
  import { IGraph } from '../../interfaces';
11
11
  export declare abstract class AbstractVertex<V = any> {
12
12
  key: VertexKey;
@@ -95,7 +95,7 @@ class AbstractGraph extends base_1.IterableEntryBase {
95
95
  }
96
96
  isVertexKey(potentialKey) {
97
97
  const potentialKeyType = typeof potentialKey;
98
- return potentialKeyType === "string" || potentialKeyType === "number";
98
+ return potentialKeyType === 'string' || potentialKeyType === 'number';
99
99
  }
100
100
  /**
101
101
  * Time Complexity: O(K), where K is the number of vertexMap to be removed.
@@ -1015,7 +1015,8 @@ class AbstractGraph extends base_1.IterableEntryBase {
1015
1015
  const visited = new Set();
1016
1016
  const dfs = (vertex, currentPath, visited) => {
1017
1017
  if (visited.has(vertex)) {
1018
- if ((!isInclude2Cycle && currentPath.length > 2 || isInclude2Cycle && currentPath.length >= 2) && currentPath[0] === vertex.key) {
1018
+ if (((!isInclude2Cycle && currentPath.length > 2) || (isInclude2Cycle && currentPath.length >= 2)) &&
1019
+ currentPath[0] === vertex.key) {
1019
1020
  cycles.push([...currentPath]);
1020
1021
  }
1021
1022
  return;
@@ -121,7 +121,7 @@ export declare class HashMap<K = any, V = any> extends IterableEntryBase<K, V> {
121
121
  */
122
122
  protected _getIterator(): IterableIterator<[K, V]>;
123
123
  protected _hashFn: (key: K) => string;
124
- protected _isObjKey(key: any): key is (object | ((...args: any[]) => any));
124
+ protected _isObjKey(key: any): key is object | ((...args: any[]) => any);
125
125
  protected _getNoObjKey(key: K): string;
126
126
  }
127
127
  /**
@@ -219,11 +219,11 @@ class HashMap extends base_1.IterableEntryBase {
219
219
  _getNoObjKey(key) {
220
220
  const keyType = typeof key;
221
221
  let strKey;
222
- if (keyType !== "string" && keyType !== "number" && keyType !== "symbol") {
222
+ if (keyType !== 'string' && keyType !== 'number' && keyType !== 'symbol') {
223
223
  strKey = this._hashFn(key);
224
224
  }
225
225
  else {
226
- if (keyType === "number") {
226
+ if (keyType === 'number') {
227
227
  // TODO numeric key should has its own hash
228
228
  strKey = key;
229
229
  }
@@ -401,11 +401,10 @@ class Heap extends base_1.IterableElementBase {
401
401
  _sinkDown(index, halfLength) {
402
402
  const element = this.elements[index];
403
403
  while (index < halfLength) {
404
- let left = index << 1 | 1;
404
+ let left = (index << 1) | 1;
405
405
  const right = left + 1;
406
406
  let minItem = this.elements[left];
407
- if (right < this.elements.length &&
408
- this.options.comparator(minItem, this.elements[right]) > 0) {
407
+ if (right < this.elements.length && this.options.comparator(minItem, this.elements[right]) > 0) {
409
408
  left = right;
410
409
  minItem = this.elements[right];
411
410
  }
@@ -5,8 +5,8 @@
5
5
  * @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
6
6
  * @license MIT License
7
7
  */
8
- import type { ElementCallback } from "../../types";
9
- import { IterableElementBase } from "../base";
8
+ import type { ElementCallback } from '../../types';
9
+ import { IterableElementBase } from '../base';
10
10
  export declare class SinglyLinkedListNode<E = any> {
11
11
  value: E;
12
12
  next: SinglyLinkedListNode<E> | undefined;
@@ -1,4 +1,2 @@
1
1
  export * from './matrix';
2
- export * from './vector2d';
3
- export * from './matrix2d';
4
2
  export * from './navigator';
@@ -15,6 +15,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./matrix"), exports);
18
- __exportStar(require("./vector2d"), exports);
19
- __exportStar(require("./matrix2d"), exports);
20
18
  __exportStar(require("./navigator"), exports);
@@ -5,17 +5,135 @@
5
5
  * @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
6
6
  * @license MIT License
7
7
  */
8
- export declare class MatrixNTI2D<V = any> {
9
- protected readonly _matrix: Array<Array<V>>;
8
+ export declare class Matrix {
10
9
  /**
11
- * The constructor creates a matrix with the specified number of rows and columns, and initializes all elements to a
12
- * given initial value or 0 if not provided.
13
- * @param options - An object containing the following properties:
10
+ * The constructor function initializes a matrix object with the provided data and options, or with
11
+ * default values if no options are provided.
12
+ * @param {number[][]} data - A 2D array of numbers representing the data for the matrix.
13
+ * @param [options] - The `options` parameter is an optional object that can contain the following
14
+ * properties:
14
15
  */
15
- constructor(options: {
16
- row: number;
17
- col: number;
18
- initialVal?: V;
16
+ constructor(data: number[][], options?: {
17
+ rows?: number;
18
+ cols?: number;
19
+ addFn?: (a: number, b: number) => any;
20
+ subtractFn?: (a: number, b: number) => any;
21
+ multiplyFn?: (a: number, b: number) => any;
19
22
  });
20
- toArray(): Array<Array<V>>;
23
+ protected _rows: number;
24
+ get rows(): number;
25
+ protected _cols: number;
26
+ get cols(): number;
27
+ protected _data: number[][];
28
+ get data(): number[][];
29
+ get addFn(): (a: number | undefined, b: number) => number | undefined;
30
+ get subtractFn(): (a: number, b: number) => number;
31
+ get multiplyFn(): (a: number, b: number) => number;
32
+ /**
33
+ * The `get` function returns the value at the specified row and column index if it is a valid index.
34
+ * @param {number} row - The `row` parameter represents the row index of the element you want to
35
+ * retrieve from the data array.
36
+ * @param {number} col - The parameter "col" represents the column number of the element you want to
37
+ * retrieve from the data array.
38
+ * @returns The `get` function returns a number if the provided row and column indices are valid.
39
+ * Otherwise, it returns `undefined`.
40
+ */
41
+ get(row: number, col: number): number | undefined;
42
+ /**
43
+ * The set function updates the value at a specified row and column in a two-dimensional array.
44
+ * @param {number} row - The "row" parameter represents the row index of the element in a
45
+ * two-dimensional array or matrix. It specifies the row where the value will be set.
46
+ * @param {number} col - The "col" parameter represents the column index of the element in a
47
+ * two-dimensional array.
48
+ * @param {number} value - The value parameter represents the number that you want to set at the
49
+ * specified row and column in the data array.
50
+ * @returns a boolean value. It returns true if the index (row, col) is valid and the value is
51
+ * successfully set in the data array. It returns false if the index is invalid and the value is not
52
+ * set.
53
+ */
54
+ set(row: number, col: number, value: number): boolean;
55
+ /**
56
+ * The function checks if the dimensions of the given matrix match the dimensions of the current
57
+ * matrix.
58
+ * @param {Matrix} matrix - The parameter `matrix` is of type `Matrix`.
59
+ * @returns a boolean value.
60
+ */
61
+ isMatchForCalculate(matrix: Matrix): boolean;
62
+ /**
63
+ * The `add` function adds two matrices together, returning a new matrix with the result.
64
+ * @param {Matrix} matrix - The `matrix` parameter is an instance of the `Matrix` class.
65
+ * @returns The `add` method returns a new `Matrix` object that represents the result of adding the
66
+ * current matrix with the provided `matrix` parameter.
67
+ */
68
+ add(matrix: Matrix): Matrix | undefined;
69
+ /**
70
+ * The `subtract` function performs element-wise subtraction between two matrices and returns a new
71
+ * matrix with the result.
72
+ * @param {Matrix} matrix - The `matrix` parameter is an instance of the `Matrix` class. It
73
+ * represents the matrix that you want to subtract from the current matrix.
74
+ * @returns a new Matrix object with the result of the subtraction operation.
75
+ */
76
+ subtract(matrix: Matrix): Matrix | undefined;
77
+ /**
78
+ * The `multiply` function performs matrix multiplication between two matrices and returns the result
79
+ * as a new matrix.
80
+ * @param {Matrix} matrix - The `matrix` parameter is an instance of the `Matrix` class.
81
+ * @returns a new Matrix object.
82
+ */
83
+ multiply(matrix: Matrix): Matrix | undefined;
84
+ /**
85
+ * The transpose function takes a matrix and returns a new matrix that is the transpose of the
86
+ * original matrix.
87
+ * @returns The transpose() function returns a new Matrix object with the transposed data.
88
+ */
89
+ transpose(): Matrix;
90
+ /**
91
+ * The `inverse` function calculates the inverse of a square matrix using Gaussian elimination.
92
+ * @returns a Matrix object, which represents the inverse of the original matrix.
93
+ */
94
+ inverse(): Matrix | undefined;
95
+ /**
96
+ * The dot function calculates the dot product of two matrices and returns a new matrix.
97
+ * @param {Matrix} matrix - The `matrix` parameter is an instance of the `Matrix` class.
98
+ * @returns a new Matrix object.
99
+ */
100
+ dot(matrix: Matrix): Matrix | undefined;
101
+ protected _addFn(a: number | undefined, b: number): number | undefined;
102
+ protected _subtractFn(a: number, b: number): number;
103
+ protected _multiplyFn(a: number, b: number): number;
104
+ /**
105
+ * The function checks if a given row and column index is valid within a specified range.
106
+ * @param {number} row - The `row` parameter represents the row index of a two-dimensional array or
107
+ * matrix. It is a number that indicates the specific row in the matrix.
108
+ * @param {number} col - The "col" parameter represents the column index in a two-dimensional array
109
+ * or grid. It is used to check if the given column index is valid within the bounds of the grid.
110
+ * @returns A boolean value is being returned.
111
+ */
112
+ protected isValidIndex(row: number, col: number): boolean;
113
+ /**
114
+ * The function `_swapRows` swaps the positions of two rows in an array.
115
+ * @param {number} row1 - The `row1` parameter is the index of the first row that you want to swap.
116
+ * @param {number} row2 - The `row2` parameter is the index of the second row that you want to swap
117
+ * with the first row.
118
+ */
119
+ protected _swapRows(row1: number, row2: number): void;
120
+ /**
121
+ * The function scales a specific row in a matrix by a given scalar value.
122
+ * @param {number} row - The `row` parameter represents the index of the row in the matrix that you
123
+ * want to scale. It is a number that indicates the position of the row within the matrix.
124
+ * @param {number} scalar - The scalar parameter is a number that is used to multiply each element in
125
+ * a specific row of a matrix.
126
+ */
127
+ protected _scaleRow(row: number, scalar: number): void;
128
+ /**
129
+ * The function `_addScaledRow` multiplies a row in a matrix by a scalar value and adds it to another
130
+ * row.
131
+ * @param {number} targetRow - The targetRow parameter represents the index of the row in which the
132
+ * scaled values will be added.
133
+ * @param {number} sourceRow - The sourceRow parameter represents the index of the row from which the
134
+ * values will be scaled and added to the targetRow.
135
+ * @param {number} scalar - The scalar parameter is a number that is used to scale the values in the
136
+ * source row before adding them to the target row.
137
+ */
138
+ protected _addScaledRow(targetRow: number, sourceRow: number, scalar: number): void;
21
139
  }