data-structure-typed 1.49.4 → 1.49.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.
- package/CHANGELOG.md +1 -1
- package/README.md +1 -3
- package/README_zh-CN.md +1 -1
- package/dist/cjs/data-structures/base/iterable-base.d.ts +1 -1
- package/dist/cjs/data-structures/base/iterable-base.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/avl-tree.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/binary-tree.d.ts +1 -13
- package/dist/cjs/data-structures/binary-tree/binary-tree.js +19 -49
- package/dist/cjs/data-structures/binary-tree/binary-tree.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/bst.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/rb-tree.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/tree-multimap.d.ts +0 -16
- package/dist/cjs/data-structures/binary-tree/tree-multimap.js +1 -43
- package/dist/cjs/data-structures/binary-tree/tree-multimap.js.map +1 -1
- package/dist/cjs/data-structures/graph/abstract-graph.d.ts +1 -1
- package/dist/cjs/data-structures/graph/abstract-graph.js +3 -2
- package/dist/cjs/data-structures/graph/abstract-graph.js.map +1 -1
- package/dist/cjs/data-structures/graph/directed-graph.js.map +1 -1
- package/dist/cjs/data-structures/graph/map-graph.js.map +1 -1
- package/dist/cjs/data-structures/graph/undirected-graph.js.map +1 -1
- package/dist/cjs/data-structures/hash/hash-map.d.ts +1 -1
- package/dist/cjs/data-structures/hash/hash-map.js +2 -2
- package/dist/cjs/data-structures/hash/hash-map.js.map +1 -1
- package/dist/cjs/data-structures/heap/heap.js +2 -3
- package/dist/cjs/data-structures/heap/heap.js.map +1 -1
- package/dist/cjs/data-structures/heap/max-heap.js.map +1 -1
- package/dist/cjs/data-structures/heap/min-heap.js.map +1 -1
- package/dist/cjs/data-structures/linked-list/singly-linked-list.d.ts +2 -2
- package/dist/cjs/data-structures/linked-list/singly-linked-list.js.map +1 -1
- package/dist/cjs/data-structures/matrix/index.d.ts +0 -2
- package/dist/cjs/data-structures/matrix/index.js +0 -2
- package/dist/cjs/data-structures/matrix/index.js.map +1 -1
- package/dist/cjs/data-structures/matrix/matrix.d.ts +128 -10
- package/dist/cjs/data-structures/matrix/matrix.js +400 -15
- package/dist/cjs/data-structures/matrix/matrix.js.map +1 -1
- package/dist/cjs/data-structures/priority-queue/min-priority-queue.js.map +1 -1
- package/dist/cjs/data-structures/queue/deque.d.ts +2 -2
- package/dist/cjs/data-structures/queue/deque.js +5 -7
- package/dist/cjs/data-structures/queue/deque.js.map +1 -1
- package/dist/cjs/data-structures/queue/queue.d.ts +1 -1
- package/dist/cjs/types/data-structures/base/base.d.ts +1 -1
- package/dist/cjs/types/data-structures/heap/heap.d.ts +1 -1
- package/dist/cjs/types/data-structures/priority-queue/priority-queue.d.ts +1 -1
- package/dist/cjs/utils/utils.d.ts +1 -0
- package/dist/cjs/utils/utils.js +6 -1
- package/dist/cjs/utils/utils.js.map +1 -1
- package/dist/mjs/data-structures/base/iterable-base.d.ts +1 -1
- package/dist/mjs/data-structures/binary-tree/avl-tree.js +2 -1
- package/dist/mjs/data-structures/binary-tree/binary-tree.d.ts +1 -13
- package/dist/mjs/data-structures/binary-tree/binary-tree.js +20 -50
- package/dist/mjs/data-structures/binary-tree/bst.js +2 -1
- package/dist/mjs/data-structures/binary-tree/rb-tree.js +2 -1
- package/dist/mjs/data-structures/binary-tree/tree-multimap.d.ts +0 -16
- package/dist/mjs/data-structures/binary-tree/tree-multimap.js +3 -44
- package/dist/mjs/data-structures/graph/abstract-graph.d.ts +1 -1
- package/dist/mjs/data-structures/graph/abstract-graph.js +4 -3
- package/dist/mjs/data-structures/hash/hash-map.d.ts +1 -1
- package/dist/mjs/data-structures/hash/hash-map.js +2 -2
- package/dist/mjs/data-structures/heap/heap.js +2 -3
- package/dist/mjs/data-structures/linked-list/singly-linked-list.d.ts +2 -2
- package/dist/mjs/data-structures/linked-list/singly-linked-list.js +1 -1
- package/dist/mjs/data-structures/matrix/index.d.ts +0 -2
- package/dist/mjs/data-structures/matrix/index.js +0 -2
- package/dist/mjs/data-structures/matrix/matrix.d.ts +128 -10
- package/dist/mjs/data-structures/matrix/matrix.js +399 -16
- package/dist/mjs/data-structures/queue/deque.d.ts +2 -2
- package/dist/mjs/data-structures/queue/deque.js +7 -9
- package/dist/mjs/data-structures/queue/queue.d.ts +1 -1
- package/dist/mjs/data-structures/queue/queue.js +1 -1
- package/dist/mjs/types/data-structures/base/base.d.ts +1 -1
- package/dist/mjs/types/data-structures/heap/heap.d.ts +1 -1
- package/dist/mjs/types/data-structures/priority-queue/priority-queue.d.ts +1 -1
- package/dist/mjs/utils/utils.d.ts +1 -0
- package/dist/mjs/utils/utils.js +4 -0
- package/dist/umd/data-structure-typed.js +356 -524
- package/dist/umd/data-structure-typed.min.js +2 -2
- package/dist/umd/data-structure-typed.min.js.map +1 -1
- package/package.json +4 -3
- package/src/data-structures/base/index.ts +1 -1
- package/src/data-structures/base/iterable-base.ts +7 -10
- package/src/data-structures/binary-tree/avl-tree.ts +15 -8
- package/src/data-structures/binary-tree/binary-tree.ts +57 -74
- package/src/data-structures/binary-tree/bst.ts +16 -13
- package/src/data-structures/binary-tree/rb-tree.ts +16 -10
- package/src/data-structures/binary-tree/tree-multimap.ts +11 -48
- package/src/data-structures/graph/abstract-graph.ts +13 -11
- package/src/data-structures/graph/directed-graph.ts +1 -3
- package/src/data-structures/graph/map-graph.ts +6 -1
- package/src/data-structures/graph/undirected-graph.ts +3 -6
- package/src/data-structures/hash/hash-map.ts +18 -16
- package/src/data-structures/heap/heap.ts +7 -10
- package/src/data-structures/heap/max-heap.ts +2 -1
- package/src/data-structures/heap/min-heap.ts +2 -1
- package/src/data-structures/linked-list/singly-linked-list.ts +2 -3
- package/src/data-structures/matrix/index.ts +0 -2
- package/src/data-structures/matrix/matrix.ts +442 -13
- package/src/data-structures/priority-queue/min-priority-queue.ts +11 -10
- package/src/data-structures/queue/deque.ts +18 -39
- package/src/data-structures/queue/queue.ts +1 -1
- package/src/interfaces/binary-tree.ts +7 -2
- package/src/types/common.ts +4 -4
- package/src/types/data-structures/base/base.ts +14 -3
- package/src/types/data-structures/base/index.ts +1 -1
- package/src/types/data-structures/graph/abstract-graph.ts +4 -2
- package/src/types/data-structures/hash/hash-map.ts +3 -3
- package/src/types/data-structures/heap/heap.ts +2 -2
- package/src/types/data-structures/priority-queue/priority-queue.ts +2 -2
- package/src/utils/utils.ts +7 -1
- package/test/integration/avl-tree.test.ts +18 -1
- package/test/integration/bst.test.ts +2 -2
- package/test/performance/data-structures/binary-tree/rb-tree.test.ts +1 -1
- package/test/performance/data-structures/comparison/comparison.test.ts +6 -11
- package/test/performance/data-structures/hash/hash-map.test.ts +3 -4
- package/test/performance/data-structures/linked-list/doubly-linked-list.test.ts +0 -1
- package/test/performance/data-structures/queue/deque.test.ts +6 -7
- package/test/performance/data-structures/queue/queue.test.ts +10 -9
- package/test/performance/reportor.ts +14 -15
- package/test/unit/data-structures/binary-tree/avl-tree.test.ts +14 -3
- package/test/unit/data-structures/binary-tree/binary-tree.test.ts +59 -24
- package/test/unit/data-structures/binary-tree/bst.test.ts +52 -26
- package/test/unit/data-structures/binary-tree/overall.test.ts +16 -18
- package/test/unit/data-structures/binary-tree/rb-tree.test.ts +17 -6
- package/test/unit/data-structures/binary-tree/tree-multimap.test.ts +37 -21
- package/test/unit/data-structures/graph/directed-graph.test.ts +104 -45
- package/test/unit/data-structures/graph/undirected-graph.test.ts +57 -40
- package/test/unit/data-structures/hash/hash-map.test.ts +48 -28
- package/test/unit/data-structures/hash/hash-table.test.ts +0 -4
- package/test/unit/data-structures/heap/heap.test.ts +0 -1
- package/test/unit/data-structures/heap/min-heap.test.ts +6 -5
- package/test/unit/data-structures/linked-list/doubly-linked-list.test.ts +10 -11
- package/test/unit/data-structures/linked-list/singly-linked-list.test.ts +3 -4
- package/test/unit/data-structures/matrix/matrix.test.ts +345 -52
- package/test/unit/data-structures/priority-queue/max-priority-queue.test.ts +1 -1
- package/test/unit/data-structures/priority-queue/priority-queue.test.ts +0 -1
- package/test/unit/data-structures/queue/deque.test.ts +0 -6
- package/test/unit/data-structures/queue/queue.test.ts +1 -1
- package/test/unit/data-structures/stack/stack.test.ts +3 -4
- package/test/unit/unrestricted-interconversion.test.ts +50 -44
- package/test/utils/performanc.ts +1 -1
- package/typedoc.json +30 -0
- package/dist/cjs/data-structures/matrix/matrix2d.d.ts +0 -107
- package/dist/cjs/data-structures/matrix/matrix2d.js +0 -200
- package/dist/cjs/data-structures/matrix/matrix2d.js.map +0 -1
- package/dist/cjs/data-structures/matrix/vector2d.d.ts +0 -200
- package/dist/cjs/data-structures/matrix/vector2d.js +0 -291
- package/dist/cjs/data-structures/matrix/vector2d.js.map +0 -1
- package/dist/mjs/data-structures/matrix/matrix2d.d.ts +0 -107
- package/dist/mjs/data-structures/matrix/matrix2d.js +0 -196
- package/dist/mjs/data-structures/matrix/vector2d.d.ts +0 -200
- package/dist/mjs/data-structures/matrix/vector2d.js +0 -289
- package/src/data-structures/matrix/matrix2d.ts +0 -211
- package/src/data-structures/matrix/vector2d.ts +0 -315
- package/test/unit/data-structures/matrix/matrix2d.test.ts +0 -345
- package/test/unit/data-structures/matrix/vector2d.test.ts +0 -171
|
@@ -15,7 +15,5 @@ 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);
|
|
21
19
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/data-structures/matrix/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/data-structures/matrix/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,8CAA4B"}
|
|
@@ -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
|
|
9
|
-
protected readonly _matrix: Array<Array<V>>;
|
|
8
|
+
export declare class Matrix {
|
|
10
9
|
/**
|
|
11
|
-
* The constructor
|
|
12
|
-
*
|
|
13
|
-
* @param
|
|
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(
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
|
|
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
|
}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MatrixNTI2D = void 0;
|
|
4
2
|
/**
|
|
5
3
|
* data-structure-typed
|
|
6
4
|
*
|
|
@@ -8,22 +6,409 @@ exports.MatrixNTI2D = void 0;
|
|
|
8
6
|
* @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
|
|
9
7
|
* @license MIT License
|
|
10
8
|
*/
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.Matrix = void 0;
|
|
11
|
+
class Matrix {
|
|
13
12
|
/**
|
|
14
|
-
* The constructor
|
|
15
|
-
*
|
|
16
|
-
* @param
|
|
13
|
+
* The constructor function initializes a matrix object with the provided data and options, or with
|
|
14
|
+
* default values if no options are provided.
|
|
15
|
+
* @param {number[][]} data - A 2D array of numbers representing the data for the matrix.
|
|
16
|
+
* @param [options] - The `options` parameter is an optional object that can contain the following
|
|
17
|
+
* properties:
|
|
17
18
|
*/
|
|
18
|
-
constructor(options) {
|
|
19
|
-
|
|
20
|
-
this.
|
|
19
|
+
constructor(data, options) {
|
|
20
|
+
var _a, _b, _c;
|
|
21
|
+
this._rows = 0;
|
|
22
|
+
this._cols = 0;
|
|
23
|
+
if (options) {
|
|
24
|
+
const { rows, cols, addFn, subtractFn, multiplyFn } = options;
|
|
25
|
+
if (typeof rows === 'number' && rows > 0)
|
|
26
|
+
this._rows = rows;
|
|
27
|
+
else
|
|
28
|
+
this._rows = data.length;
|
|
29
|
+
if (typeof cols === 'number' && cols > 0)
|
|
30
|
+
this._cols = cols;
|
|
31
|
+
else
|
|
32
|
+
this._cols = ((_a = data[0]) === null || _a === void 0 ? void 0 : _a.length) || 0;
|
|
33
|
+
if (addFn)
|
|
34
|
+
this._addFn = addFn;
|
|
35
|
+
if (subtractFn)
|
|
36
|
+
this._subtractFn = subtractFn;
|
|
37
|
+
if (multiplyFn)
|
|
38
|
+
this._multiplyFn = multiplyFn;
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
this._rows = data.length;
|
|
42
|
+
this._cols = (_c = (_b = data[0]) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0;
|
|
43
|
+
}
|
|
44
|
+
if (data.length > 0) {
|
|
45
|
+
this._data = data;
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
this._data = [];
|
|
49
|
+
for (let i = 0; i < this.rows; i++) {
|
|
50
|
+
this._data[i] = new Array(this.cols).fill(0);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
get rows() {
|
|
55
|
+
return this._rows;
|
|
56
|
+
}
|
|
57
|
+
get cols() {
|
|
58
|
+
return this._cols;
|
|
59
|
+
}
|
|
60
|
+
get data() {
|
|
61
|
+
return this._data;
|
|
62
|
+
}
|
|
63
|
+
get addFn() {
|
|
64
|
+
return this._addFn;
|
|
65
|
+
}
|
|
66
|
+
get subtractFn() {
|
|
67
|
+
return this._subtractFn;
|
|
21
68
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
69
|
+
get multiplyFn() {
|
|
70
|
+
return this._multiplyFn;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* The `get` function returns the value at the specified row and column index if it is a valid index.
|
|
74
|
+
* @param {number} row - The `row` parameter represents the row index of the element you want to
|
|
75
|
+
* retrieve from the data array.
|
|
76
|
+
* @param {number} col - The parameter "col" represents the column number of the element you want to
|
|
77
|
+
* retrieve from the data array.
|
|
78
|
+
* @returns The `get` function returns a number if the provided row and column indices are valid.
|
|
79
|
+
* Otherwise, it returns `undefined`.
|
|
80
|
+
*/
|
|
81
|
+
get(row, col) {
|
|
82
|
+
if (this.isValidIndex(row, col)) {
|
|
83
|
+
return this.data[row][col];
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* The set function updates the value at a specified row and column in a two-dimensional array.
|
|
88
|
+
* @param {number} row - The "row" parameter represents the row index of the element in a
|
|
89
|
+
* two-dimensional array or matrix. It specifies the row where the value will be set.
|
|
90
|
+
* @param {number} col - The "col" parameter represents the column index of the element in a
|
|
91
|
+
* two-dimensional array.
|
|
92
|
+
* @param {number} value - The value parameter represents the number that you want to set at the
|
|
93
|
+
* specified row and column in the data array.
|
|
94
|
+
* @returns a boolean value. It returns true if the index (row, col) is valid and the value is
|
|
95
|
+
* successfully set in the data array. It returns false if the index is invalid and the value is not
|
|
96
|
+
* set.
|
|
97
|
+
*/
|
|
98
|
+
set(row, col, value) {
|
|
99
|
+
if (this.isValidIndex(row, col)) {
|
|
100
|
+
this.data[row][col] = value;
|
|
101
|
+
return true;
|
|
102
|
+
}
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* The function checks if the dimensions of the given matrix match the dimensions of the current
|
|
107
|
+
* matrix.
|
|
108
|
+
* @param {Matrix} matrix - The parameter `matrix` is of type `Matrix`.
|
|
109
|
+
* @returns a boolean value.
|
|
110
|
+
*/
|
|
111
|
+
isMatchForCalculate(matrix) {
|
|
112
|
+
return this.rows === matrix.rows && this.cols === matrix.cols;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* The `add` function adds two matrices together, returning a new matrix with the result.
|
|
116
|
+
* @param {Matrix} matrix - The `matrix` parameter is an instance of the `Matrix` class.
|
|
117
|
+
* @returns The `add` method returns a new `Matrix` object that represents the result of adding the
|
|
118
|
+
* current matrix with the provided `matrix` parameter.
|
|
119
|
+
*/
|
|
120
|
+
add(matrix) {
|
|
121
|
+
if (!this.isMatchForCalculate(matrix)) {
|
|
122
|
+
throw new Error('Matrix dimensions must match for addition.');
|
|
123
|
+
}
|
|
124
|
+
const resultData = [];
|
|
125
|
+
for (let i = 0; i < this.rows; i++) {
|
|
126
|
+
resultData[i] = [];
|
|
127
|
+
for (let j = 0; j < this.cols; j++) {
|
|
128
|
+
const a = this.get(i, j), b = matrix.get(i, j);
|
|
129
|
+
if (a !== undefined && b !== undefined) {
|
|
130
|
+
const added = this._addFn(a, b);
|
|
131
|
+
if (added) {
|
|
132
|
+
resultData[i][j] = added;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return new Matrix(resultData, {
|
|
138
|
+
rows: this.rows,
|
|
139
|
+
cols: this.cols,
|
|
140
|
+
addFn: this.addFn,
|
|
141
|
+
subtractFn: this.subtractFn,
|
|
142
|
+
multiplyFn: this.multiplyFn
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* The `subtract` function performs element-wise subtraction between two matrices and returns a new
|
|
147
|
+
* matrix with the result.
|
|
148
|
+
* @param {Matrix} matrix - The `matrix` parameter is an instance of the `Matrix` class. It
|
|
149
|
+
* represents the matrix that you want to subtract from the current matrix.
|
|
150
|
+
* @returns a new Matrix object with the result of the subtraction operation.
|
|
151
|
+
*/
|
|
152
|
+
subtract(matrix) {
|
|
153
|
+
if (!this.isMatchForCalculate(matrix)) {
|
|
154
|
+
throw new Error('Matrix dimensions must match for subtraction.');
|
|
155
|
+
}
|
|
156
|
+
const resultData = [];
|
|
157
|
+
for (let i = 0; i < this.rows; i++) {
|
|
158
|
+
resultData[i] = [];
|
|
159
|
+
for (let j = 0; j < this.cols; j++) {
|
|
160
|
+
const a = this.get(i, j), b = matrix.get(i, j);
|
|
161
|
+
if (a !== undefined && b !== undefined) {
|
|
162
|
+
const subtracted = this._subtractFn(a, b);
|
|
163
|
+
if (subtracted) {
|
|
164
|
+
resultData[i][j] = subtracted;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return new Matrix(resultData, {
|
|
170
|
+
rows: this.rows,
|
|
171
|
+
cols: this.cols,
|
|
172
|
+
addFn: this.addFn,
|
|
173
|
+
subtractFn: this.subtractFn,
|
|
174
|
+
multiplyFn: this.multiplyFn
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* The `multiply` function performs matrix multiplication between two matrices and returns the result
|
|
179
|
+
* as a new matrix.
|
|
180
|
+
* @param {Matrix} matrix - The `matrix` parameter is an instance of the `Matrix` class.
|
|
181
|
+
* @returns a new Matrix object.
|
|
182
|
+
*/
|
|
183
|
+
multiply(matrix) {
|
|
184
|
+
if (this.cols !== matrix.rows) {
|
|
185
|
+
throw new Error('Matrix dimensions must be compatible for multiplication (A.cols = B.rows).');
|
|
186
|
+
}
|
|
187
|
+
const resultData = [];
|
|
188
|
+
for (let i = 0; i < this.rows; i++) {
|
|
189
|
+
resultData[i] = [];
|
|
190
|
+
for (let j = 0; j < matrix.cols; j++) {
|
|
191
|
+
let sum;
|
|
192
|
+
for (let k = 0; k < this.cols; k++) {
|
|
193
|
+
const a = this.get(i, k), b = matrix.get(k, j);
|
|
194
|
+
if (a !== undefined && b !== undefined) {
|
|
195
|
+
const multiplied = this.multiplyFn(a, b);
|
|
196
|
+
if (multiplied !== undefined) {
|
|
197
|
+
sum = this.addFn(sum, multiplied);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
if (sum !== undefined)
|
|
202
|
+
resultData[i][j] = sum;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
return new Matrix(resultData, {
|
|
206
|
+
rows: this.rows,
|
|
207
|
+
cols: matrix.cols,
|
|
208
|
+
addFn: this.addFn,
|
|
209
|
+
subtractFn: this.subtractFn,
|
|
210
|
+
multiplyFn: this.multiplyFn
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* The transpose function takes a matrix and returns a new matrix that is the transpose of the
|
|
215
|
+
* original matrix.
|
|
216
|
+
* @returns The transpose() function returns a new Matrix object with the transposed data.
|
|
217
|
+
*/
|
|
218
|
+
transpose() {
|
|
219
|
+
if (this.data.some(row => row.length !== this.rows)) {
|
|
220
|
+
throw new Error('Matrix must be rectangular for transposition.');
|
|
221
|
+
}
|
|
222
|
+
const resultData = [];
|
|
223
|
+
for (let j = 0; j < this.cols; j++) {
|
|
224
|
+
resultData[j] = [];
|
|
225
|
+
for (let i = 0; i < this.rows; i++) {
|
|
226
|
+
const trans = this.get(i, j);
|
|
227
|
+
if (trans !== undefined)
|
|
228
|
+
resultData[j][i] = trans;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
return new Matrix(resultData, {
|
|
232
|
+
rows: this.cols,
|
|
233
|
+
cols: this.rows,
|
|
234
|
+
addFn: this.addFn,
|
|
235
|
+
subtractFn: this.subtractFn,
|
|
236
|
+
multiplyFn: this.multiplyFn
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* The `inverse` function calculates the inverse of a square matrix using Gaussian elimination.
|
|
241
|
+
* @returns a Matrix object, which represents the inverse of the original matrix.
|
|
242
|
+
*/
|
|
243
|
+
inverse() {
|
|
244
|
+
var _a;
|
|
245
|
+
// Check if the matrix is square
|
|
246
|
+
if (this.rows !== this.cols) {
|
|
247
|
+
throw new Error('Matrix must be square for inversion.');
|
|
248
|
+
}
|
|
249
|
+
// Create an augmented matrix [this | I]
|
|
250
|
+
const augmentedMatrixData = [];
|
|
251
|
+
for (let i = 0; i < this.rows; i++) {
|
|
252
|
+
augmentedMatrixData[i] = this.data[i].slice(); // Copy the original matrix
|
|
253
|
+
for (let j = 0; j < this.cols; j++) {
|
|
254
|
+
augmentedMatrixData[i][this.cols + j] = i === j ? 1 : 0; // Append the identity matrix
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
const augmentedMatrix = new Matrix(augmentedMatrixData, {
|
|
258
|
+
rows: this.rows,
|
|
259
|
+
cols: this.cols * 2,
|
|
260
|
+
addFn: this.addFn,
|
|
261
|
+
subtractFn: this.subtractFn,
|
|
262
|
+
multiplyFn: this.multiplyFn
|
|
263
|
+
});
|
|
264
|
+
// Apply Gaussian elimination to transform the left half into the identity matrix
|
|
265
|
+
for (let i = 0; i < this.rows; i++) {
|
|
266
|
+
// Find pivot
|
|
267
|
+
let pivotRow = i;
|
|
268
|
+
while (pivotRow < this.rows && augmentedMatrix.get(pivotRow, i) === 0) {
|
|
269
|
+
pivotRow++;
|
|
270
|
+
}
|
|
271
|
+
if (pivotRow === this.rows) {
|
|
272
|
+
// Matrix is singular, and its inverse does not exist
|
|
273
|
+
throw new Error('Matrix is singular, and its inverse does not exist.');
|
|
274
|
+
}
|
|
275
|
+
// Swap rows to make the pivot the current row
|
|
276
|
+
augmentedMatrix._swapRows(i, pivotRow);
|
|
277
|
+
// Scale the pivot row to make the pivot element 1
|
|
278
|
+
const pivotElement = (_a = augmentedMatrix.get(i, i)) !== null && _a !== void 0 ? _a : 1;
|
|
279
|
+
if (pivotElement === 0) {
|
|
280
|
+
// Handle division by zero
|
|
281
|
+
throw new Error('Matrix is singular, and its inverse does not exist (division by zero).');
|
|
282
|
+
}
|
|
283
|
+
augmentedMatrix._scaleRow(i, 1 / pivotElement);
|
|
284
|
+
// Eliminate other rows to make elements in the current column zero
|
|
285
|
+
for (let j = 0; j < this.rows; j++) {
|
|
286
|
+
if (j !== i) {
|
|
287
|
+
let factor = augmentedMatrix.get(j, i);
|
|
288
|
+
if (factor === undefined)
|
|
289
|
+
factor = 0;
|
|
290
|
+
augmentedMatrix._addScaledRow(j, i, -factor);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
// Extract the right half of the augmented matrix as the inverse
|
|
295
|
+
const inverseData = [];
|
|
296
|
+
for (let i = 0; i < this.rows; i++) {
|
|
297
|
+
inverseData[i] = augmentedMatrix.data[i].slice(this.cols);
|
|
298
|
+
}
|
|
299
|
+
return new Matrix(inverseData, {
|
|
300
|
+
rows: this.rows,
|
|
301
|
+
cols: this.cols,
|
|
302
|
+
addFn: this.addFn,
|
|
303
|
+
subtractFn: this.subtractFn,
|
|
304
|
+
multiplyFn: this.multiplyFn
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* The dot function calculates the dot product of two matrices and returns a new matrix.
|
|
309
|
+
* @param {Matrix} matrix - The `matrix` parameter is an instance of the `Matrix` class.
|
|
310
|
+
* @returns a new Matrix object.
|
|
311
|
+
*/
|
|
312
|
+
dot(matrix) {
|
|
313
|
+
if (this.cols !== matrix.rows) {
|
|
314
|
+
throw new Error('Number of columns in the first matrix must be equal to the number of rows in the second matrix for dot product.');
|
|
315
|
+
}
|
|
316
|
+
const resultData = [];
|
|
317
|
+
for (let i = 0; i < this.rows; i++) {
|
|
318
|
+
resultData[i] = [];
|
|
319
|
+
for (let j = 0; j < matrix.cols; j++) {
|
|
320
|
+
let sum;
|
|
321
|
+
for (let k = 0; k < this.cols; k++) {
|
|
322
|
+
const a = this.get(i, k), b = matrix.get(k, j);
|
|
323
|
+
if (a !== undefined && b !== undefined) {
|
|
324
|
+
const multiplied = this.multiplyFn(a, b);
|
|
325
|
+
if (multiplied !== undefined) {
|
|
326
|
+
sum = this.addFn(sum, multiplied);
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
if (sum !== undefined)
|
|
331
|
+
resultData[i][j] = sum;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
return new Matrix(resultData, {
|
|
335
|
+
rows: this.rows,
|
|
336
|
+
cols: matrix.cols,
|
|
337
|
+
addFn: this.addFn,
|
|
338
|
+
subtractFn: this.subtractFn,
|
|
339
|
+
multiplyFn: this.multiplyFn
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
_addFn(a, b) {
|
|
343
|
+
if (a === undefined)
|
|
344
|
+
return b;
|
|
345
|
+
return a + b;
|
|
346
|
+
}
|
|
347
|
+
_subtractFn(a, b) {
|
|
348
|
+
return a - b;
|
|
349
|
+
}
|
|
350
|
+
_multiplyFn(a, b) {
|
|
351
|
+
return a * b;
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* The function checks if a given row and column index is valid within a specified range.
|
|
355
|
+
* @param {number} row - The `row` parameter represents the row index of a two-dimensional array or
|
|
356
|
+
* matrix. It is a number that indicates the specific row in the matrix.
|
|
357
|
+
* @param {number} col - The "col" parameter represents the column index in a two-dimensional array
|
|
358
|
+
* or grid. It is used to check if the given column index is valid within the bounds of the grid.
|
|
359
|
+
* @returns A boolean value is being returned.
|
|
360
|
+
*/
|
|
361
|
+
isValidIndex(row, col) {
|
|
362
|
+
return row >= 0 && row < this.rows && col >= 0 && col < this.cols;
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* The function `_swapRows` swaps the positions of two rows in an array.
|
|
366
|
+
* @param {number} row1 - The `row1` parameter is the index of the first row that you want to swap.
|
|
367
|
+
* @param {number} row2 - The `row2` parameter is the index of the second row that you want to swap
|
|
368
|
+
* with the first row.
|
|
369
|
+
*/
|
|
370
|
+
_swapRows(row1, row2) {
|
|
371
|
+
const temp = this.data[row1];
|
|
372
|
+
this.data[row1] = this.data[row2];
|
|
373
|
+
this.data[row2] = temp;
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* The function scales a specific row in a matrix by a given scalar value.
|
|
377
|
+
* @param {number} row - The `row` parameter represents the index of the row in the matrix that you
|
|
378
|
+
* want to scale. It is a number that indicates the position of the row within the matrix.
|
|
379
|
+
* @param {number} scalar - The scalar parameter is a number that is used to multiply each element in
|
|
380
|
+
* a specific row of a matrix.
|
|
381
|
+
*/
|
|
382
|
+
_scaleRow(row, scalar) {
|
|
383
|
+
for (let j = 0; j < this.cols; j++) {
|
|
384
|
+
let multiplied = this.multiplyFn(this.data[row][j], scalar);
|
|
385
|
+
if (multiplied === undefined)
|
|
386
|
+
multiplied = 0;
|
|
387
|
+
this.data[row][j] = multiplied;
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
/**
|
|
391
|
+
* The function `_addScaledRow` multiplies a row in a matrix by a scalar value and adds it to another
|
|
392
|
+
* row.
|
|
393
|
+
* @param {number} targetRow - The targetRow parameter represents the index of the row in which the
|
|
394
|
+
* scaled values will be added.
|
|
395
|
+
* @param {number} sourceRow - The sourceRow parameter represents the index of the row from which the
|
|
396
|
+
* values will be scaled and added to the targetRow.
|
|
397
|
+
* @param {number} scalar - The scalar parameter is a number that is used to scale the values in the
|
|
398
|
+
* source row before adding them to the target row.
|
|
399
|
+
*/
|
|
400
|
+
_addScaledRow(targetRow, sourceRow, scalar) {
|
|
401
|
+
for (let j = 0; j < this.cols; j++) {
|
|
402
|
+
let multiplied = this.multiplyFn(this.data[sourceRow][j], scalar);
|
|
403
|
+
if (multiplied === undefined)
|
|
404
|
+
multiplied = 0;
|
|
405
|
+
const scaledValue = multiplied;
|
|
406
|
+
let added = this.addFn(this.data[targetRow][j], scaledValue);
|
|
407
|
+
if (added === undefined)
|
|
408
|
+
added = 0;
|
|
409
|
+
this.data[targetRow][j] = added;
|
|
410
|
+
}
|
|
26
411
|
}
|
|
27
412
|
}
|
|
28
|
-
exports.
|
|
413
|
+
exports.Matrix = Matrix;
|
|
29
414
|
//# sourceMappingURL=matrix.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"matrix.js","sourceRoot":"","sources":["../../../../src/data-structures/matrix/matrix.ts"],"names":[],"mappings":";;;AAAA;;;;;;GAMG;AACH,2BAA2B;AAC3B,MAAa,WAAW;IAGtB;;;;OAIG;IACH,YAAY,OAAqD;QAC/D,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;QACzC,IAAI,CAAC,OAAO,GAAG,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,UAAU,IAAI,CAAC,CAAC,CAAC,CAAC;IAChG,CAAC;IAED;mGAC+F;IAC/F,OAAO;QACL,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;CACF;AAlBD,kCAkBC"}
|
|
1
|
+
{"version":3,"file":"matrix.js","sourceRoot":"","sources":["../../../../src/data-structures/matrix/matrix.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,MAAa,MAAM;IACjB;;;;;;OAMG;IACH,YACE,IAAgB,EAChB,OAMC;;QA0BO,UAAK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AAE,MAAM,CAAC,CAAC;YAC5D,IAAI,UAAU,KAAK,SAAS;gBAAE,UAAU,GAAG,CAAC,CAAC;YAC7C,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC;QACjC,CAAC;IACH,CAAC;IAED;;;;;;;;;OASG;IACO,aAAa,CAAC,SAAiB,EAAE,SAAiB,EAAE,MAAc;QAC1E,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC;YACnC,IAAI,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;YAClE,IAAI,UAAU,KAAK,SAAS;gBAAE,UAAU,GAAG,CAAC,CAAC;YAC7C,MAAM,WAAW,GAAG,UAAU,CAAC;YAC/B,IAAI,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC;YAC7D,IAAI,KAAK,KAAK,SAAS;gBAAE,KAAK,GAAG,CAAC,CAAC;YACnC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC;QAClC,CAAC;IACH,CAAC;CACF;AA/bD,wBA+bC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"min-priority-queue.js","sourceRoot":"","sources":["../../../../src/data-structures/priority-queue/min-priority-queue.ts"],"names":[],"mappings":";;;AAQA,qDAAiD;AAEjD,MAAa,gBAA0B,SAAQ,8BAAgB;IAC7D,
|
|
1
|
+
{"version":3,"file":"min-priority-queue.js","sourceRoot":"","sources":["../../../../src/data-structures/priority-queue/min-priority-queue.ts"],"names":[],"mappings":";;;AAQA,qDAAiD;AAEjD,MAAa,gBAA0B,SAAQ,8BAAgB;IAC7D,YACE,QAAsB,EACtB,UAAmC;QACjC,UAAU,EAAE,CAAC,CAAI,EAAE,CAAI,EAAE,EAAE;YACzB,IAAI,CAAC,CAAC,OAAO,CAAC,KAAK,QAAQ,IAAI,OAAO,CAAC,KAAK,QAAQ,CAAC,EAAE,CAAC;gBACtD,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;YACxE,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,GAAG,CAAC,CAAC;YACf,CAAC;QACH,CAAC;KACF;QAED,KAAK,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAC3B,CAAC;CACF;AAfD,4CAeC"}
|
|
@@ -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, IterableWithSizeOrLength } from
|
|
9
|
-
import { IterableElementBase } from
|
|
8
|
+
import type { ElementCallback, IterableWithSizeOrLength } from '../../types';
|
|
9
|
+
import { IterableElementBase } from '../base';
|
|
10
10
|
/**
|
|
11
11
|
* 1. Operations at Both Ends: Supports adding and removing elements at both the front and back of the queue. This allows it to be used as a stack (last in, first out) and a queue (first in, first out).
|
|
12
12
|
* 2. Efficient Random Access: Being based on an array, it offers fast random access capability, allowing constant time access to any element.
|