umt 2.6.0 → 2.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -0
- package/module/Crypto/decodeBase32.d.ts +7 -0
- package/module/Crypto/decodeBase32.js +27 -0
- package/module/Crypto/decodeBase32.js.map +1 -0
- package/module/Crypto/decodeBase32ToString.d.ts +7 -0
- package/module/Crypto/decodeBase32ToString.js +11 -0
- package/module/Crypto/decodeBase32ToString.js.map +1 -0
- package/module/Crypto/decodeBase58.d.ts +7 -0
- package/module/Crypto/decodeBase58.js +34 -0
- package/module/Crypto/decodeBase58.js.map +1 -0
- package/module/Crypto/decodeBase58ToString.d.ts +7 -0
- package/module/Crypto/decodeBase58ToString.js +11 -0
- package/module/Crypto/decodeBase58ToString.js.map +1 -0
- package/module/Crypto/encodeBase32.d.ts +7 -0
- package/module/Crypto/encodeBase32.js +28 -0
- package/module/Crypto/encodeBase32.js.map +1 -0
- package/module/Crypto/encodeBase58.d.ts +7 -0
- package/module/Crypto/encodeBase58.js +29 -0
- package/module/Crypto/encodeBase58.js.map +1 -0
- package/module/Crypto/index.d.ts +6 -0
- package/module/Crypto/index.js +7 -0
- package/module/Crypto/index.js.map +1 -0
- package/module/DataStructure/index.d.ts +1 -0
- package/module/DataStructure/index.js +2 -0
- package/module/DataStructure/index.js.map +1 -0
- package/module/DataStructure/priorityQueue.d.ts +241 -0
- package/module/DataStructure/priorityQueue.js +327 -0
- package/module/DataStructure/priorityQueue.js.map +1 -0
- package/module/Math/correlationCoefficient.d.ts +11 -0
- package/module/Math/correlationCoefficient.js +40 -0
- package/module/Math/correlationCoefficient.js.map +1 -0
- package/module/Math/index.d.ts +3 -0
- package/module/Math/index.js +3 -0
- package/module/Math/index.js.map +1 -1
- package/module/Math/mode.d.ts +10 -0
- package/module/Math/mode.js +31 -0
- package/module/Math/mode.js.map +1 -0
- package/module/Math/percentile.d.ts +11 -0
- package/module/Math/percentile.js +31 -0
- package/module/Math/percentile.js.map +1 -0
- package/module/Math/solveEquation.js +1 -1
- package/module/Math/solveEquation.js.map +1 -1
- package/module/String/fuzzySearch.d.ts +14 -0
- package/module/String/fuzzySearch.js +27 -0
- package/module/String/fuzzySearch.js.map +1 -0
- package/module/String/index.d.ts +4 -0
- package/module/String/index.js +4 -0
- package/module/String/index.js.map +1 -1
- package/module/String/reverseString.js +1 -1
- package/module/String/reverseString.js.map +1 -1
- package/module/String/slugify.d.ts +10 -0
- package/module/String/slugify.js +21 -0
- package/module/String/slugify.js.map +1 -0
- package/module/String/truncate.d.ts +12 -0
- package/module/String/truncate.js +21 -0
- package/module/String/truncate.js.map +1 -0
- package/module/String/unescapeHtml.d.ts +17 -0
- package/module/String/unescapeHtml.js +45 -0
- package/module/String/unescapeHtml.js.map +1 -0
- package/module/Validate/index.d.ts +1 -0
- package/module/Validate/index.js +1 -0
- package/module/Validate/index.js.map +1 -1
- package/module/Validate/isDeepEqual.d.ts +28 -0
- package/module/Validate/isDeepEqual.js +148 -0
- package/module/Validate/isDeepEqual.js.map +1 -0
- package/module/Validate/isNode.js +3 -2
- package/module/Validate/isNode.js.map +1 -1
- package/module/Validate/string/email.js +8 -0
- package/module/Validate/string/email.js.map +1 -1
- package/module/es5/Crypto/decodeBase32.d.ts +7 -0
- package/module/es5/Crypto/decodeBase32.js +44 -0
- package/module/es5/Crypto/decodeBase32ToString.d.ts +7 -0
- package/module/es5/Crypto/decodeBase32ToString.js +16 -0
- package/module/es5/Crypto/decodeBase58.d.ts +7 -0
- package/module/es5/Crypto/decodeBase58.js +63 -0
- package/module/es5/Crypto/decodeBase58ToString.d.ts +7 -0
- package/module/es5/Crypto/decodeBase58ToString.js +16 -0
- package/module/es5/Crypto/encodeBase32.d.ts +7 -0
- package/module/es5/Crypto/encodeBase32.js +45 -0
- package/module/es5/Crypto/encodeBase58.d.ts +7 -0
- package/module/es5/Crypto/encodeBase58.js +55 -0
- package/module/es5/Crypto/index.d.ts +6 -0
- package/module/es5/Crypto/index.js +71 -0
- package/module/es5/DataStructure/index.d.ts +1 -0
- package/module/es5/DataStructure/index.js +16 -0
- package/module/es5/DataStructure/priorityQueue.d.ts +241 -0
- package/module/es5/DataStructure/priorityQueue.js +405 -0
- package/module/es5/Error/retry.js +2 -2
- package/module/es5/Math/correlationCoefficient.d.ts +11 -0
- package/module/es5/Math/correlationCoefficient.js +63 -0
- package/module/es5/Math/index.d.ts +3 -0
- package/module/es5/Math/index.js +33 -0
- package/module/es5/Math/mode.d.ts +10 -0
- package/module/es5/Math/mode.js +67 -0
- package/module/es5/Math/percentile.d.ts +11 -0
- package/module/es5/Math/percentile.js +42 -0
- package/module/es5/Math/solveEquation.js +1 -1
- package/module/es5/String/fuzzySearch.d.ts +14 -0
- package/module/es5/String/fuzzySearch.js +50 -0
- package/module/es5/String/index.d.ts +4 -0
- package/module/es5/String/index.js +44 -0
- package/module/es5/String/reverseString.js +1 -1
- package/module/es5/String/slugify.d.ts +10 -0
- package/module/es5/String/slugify.js +18 -0
- package/module/es5/String/truncate.d.ts +12 -0
- package/module/es5/String/truncate.js +27 -0
- package/module/es5/String/unescapeHtml.d.ts +17 -0
- package/module/es5/String/unescapeHtml.js +51 -0
- package/module/es5/Validate/index.d.ts +1 -0
- package/module/es5/Validate/index.js +11 -0
- package/module/es5/Validate/isDeepEqual.d.ts +28 -0
- package/module/es5/Validate/isDeepEqual.js +232 -0
- package/module/es5/Validate/isNode.js +5 -2
- package/module/es5/Validate/string/email.js +10 -0
- package/module/es5/index.d.ts +2 -0
- package/module/es5/index.js +22 -0
- package/module/es5/tsconfig.tsbuildinfo +1 -1
- package/module/index.d.ts +2 -0
- package/module/index.js +2 -0
- package/module/index.js.map +1 -1
- package/package.json +31 -31
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.encodeBase32 = void 0;
|
|
7
|
+
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
8
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
9
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
10
|
+
/**
|
|
11
|
+
* Encodes a string or Uint8Array to Base32 format
|
|
12
|
+
* @param {string | Uint8Array} input - The input to encode
|
|
13
|
+
* @returns {string} Base32 encoded string
|
|
14
|
+
* @example encodeBase32("Hello"); // "JBSWY3DP"
|
|
15
|
+
*/
|
|
16
|
+
var encodeBase32 = exports.encodeBase32 = function encodeBase32(input) {
|
|
17
|
+
var alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
|
|
18
|
+
var bytes = typeof input === "string" ? new TextEncoder().encode(input) : input;
|
|
19
|
+
var result = "";
|
|
20
|
+
var buffer = 0;
|
|
21
|
+
var bufferLength = 0;
|
|
22
|
+
var _iterator = _createForOfIteratorHelper(bytes),
|
|
23
|
+
_step;
|
|
24
|
+
try {
|
|
25
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
26
|
+
var _byte = _step.value;
|
|
27
|
+
buffer = buffer << 8 | _byte;
|
|
28
|
+
bufferLength += 8;
|
|
29
|
+
while (bufferLength >= 5) {
|
|
30
|
+
bufferLength -= 5;
|
|
31
|
+
result += alphabet[buffer >> bufferLength & 0x1f];
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
} catch (err) {
|
|
35
|
+
_iterator.e(err);
|
|
36
|
+
} finally {
|
|
37
|
+
_iterator.f();
|
|
38
|
+
}
|
|
39
|
+
if (bufferLength > 0) {
|
|
40
|
+
result += alphabet[buffer << 5 - bufferLength & 0x1f];
|
|
41
|
+
}
|
|
42
|
+
var paddingLength = (8 - result.length % 8) % 8;
|
|
43
|
+
result += "=".repeat(paddingLength);
|
|
44
|
+
return result;
|
|
45
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Encodes a string or Uint8Array to Base58 format
|
|
3
|
+
* @param {string | Uint8Array} input - The input to encode
|
|
4
|
+
* @returns {string} Base58 encoded string
|
|
5
|
+
* @example encodeBase58("Hello"); // "9Ajdvzr"
|
|
6
|
+
*/
|
|
7
|
+
export declare const encodeBase58: (input: string | Uint8Array) => string;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.encodeBase58 = void 0;
|
|
7
|
+
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
8
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
9
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
10
|
+
/**
|
|
11
|
+
* Encodes a string or Uint8Array to Base58 format
|
|
12
|
+
* @param {string | Uint8Array} input - The input to encode
|
|
13
|
+
* @returns {string} Base58 encoded string
|
|
14
|
+
* @example encodeBase58("Hello"); // "9Ajdvzr"
|
|
15
|
+
*/
|
|
16
|
+
var encodeBase58 = exports.encodeBase58 = function encodeBase58(input) {
|
|
17
|
+
var alphabet = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
18
|
+
var bytes = typeof input === "string" ? new TextEncoder().encode(input) : input;
|
|
19
|
+
var encoded = "";
|
|
20
|
+
var bigNumber = BigInt(0);
|
|
21
|
+
var _iterator = _createForOfIteratorHelper(bytes),
|
|
22
|
+
_step;
|
|
23
|
+
try {
|
|
24
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
25
|
+
var _byte = _step.value;
|
|
26
|
+
bigNumber = bigNumber * BigInt(256) + BigInt(_byte);
|
|
27
|
+
}
|
|
28
|
+
} catch (err) {
|
|
29
|
+
_iterator.e(err);
|
|
30
|
+
} finally {
|
|
31
|
+
_iterator.f();
|
|
32
|
+
}
|
|
33
|
+
while (bigNumber > 0) {
|
|
34
|
+
var remainder = Number(bigNumber % BigInt(58));
|
|
35
|
+
encoded = alphabet[remainder] + encoded;
|
|
36
|
+
bigNumber /= BigInt(58);
|
|
37
|
+
}
|
|
38
|
+
var leadingZeros = 0;
|
|
39
|
+
var _iterator2 = _createForOfIteratorHelper(bytes),
|
|
40
|
+
_step2;
|
|
41
|
+
try {
|
|
42
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
43
|
+
var _byte2 = _step2.value;
|
|
44
|
+
if (_byte2 !== 0) {
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
leadingZeros++;
|
|
48
|
+
}
|
|
49
|
+
} catch (err) {
|
|
50
|
+
_iterator2.e(err);
|
|
51
|
+
} finally {
|
|
52
|
+
_iterator2.f();
|
|
53
|
+
}
|
|
54
|
+
return "1".repeat(leadingZeros) + encoded;
|
|
55
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _decodeBase = require("./decodeBase32");
|
|
7
|
+
Object.keys(_decodeBase).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _decodeBase[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function get() {
|
|
13
|
+
return _decodeBase[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
var _decodeBase32ToString = require("./decodeBase32ToString");
|
|
18
|
+
Object.keys(_decodeBase32ToString).forEach(function (key) {
|
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (key in exports && exports[key] === _decodeBase32ToString[key]) return;
|
|
21
|
+
Object.defineProperty(exports, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function get() {
|
|
24
|
+
return _decodeBase32ToString[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
var _decodeBase2 = require("./decodeBase58");
|
|
29
|
+
Object.keys(_decodeBase2).forEach(function (key) {
|
|
30
|
+
if (key === "default" || key === "__esModule") return;
|
|
31
|
+
if (key in exports && exports[key] === _decodeBase2[key]) return;
|
|
32
|
+
Object.defineProperty(exports, key, {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function get() {
|
|
35
|
+
return _decodeBase2[key];
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
var _decodeBase58ToString = require("./decodeBase58ToString");
|
|
40
|
+
Object.keys(_decodeBase58ToString).forEach(function (key) {
|
|
41
|
+
if (key === "default" || key === "__esModule") return;
|
|
42
|
+
if (key in exports && exports[key] === _decodeBase58ToString[key]) return;
|
|
43
|
+
Object.defineProperty(exports, key, {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function get() {
|
|
46
|
+
return _decodeBase58ToString[key];
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
var _encodeBase = require("./encodeBase32");
|
|
51
|
+
Object.keys(_encodeBase).forEach(function (key) {
|
|
52
|
+
if (key === "default" || key === "__esModule") return;
|
|
53
|
+
if (key in exports && exports[key] === _encodeBase[key]) return;
|
|
54
|
+
Object.defineProperty(exports, key, {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
get: function get() {
|
|
57
|
+
return _encodeBase[key];
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
var _encodeBase2 = require("./encodeBase58");
|
|
62
|
+
Object.keys(_encodeBase2).forEach(function (key) {
|
|
63
|
+
if (key === "default" || key === "__esModule") return;
|
|
64
|
+
if (key in exports && exports[key] === _encodeBase2[key]) return;
|
|
65
|
+
Object.defineProperty(exports, key, {
|
|
66
|
+
enumerable: true,
|
|
67
|
+
get: function get() {
|
|
68
|
+
return _encodeBase2[key];
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./priorityQueue";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _priorityQueue = require("./priorityQueue");
|
|
7
|
+
Object.keys(_priorityQueue).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _priorityQueue[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function get() {
|
|
13
|
+
return _priorityQueue[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A priority queue implementation using a binary heap.
|
|
3
|
+
* Higher priority values are dequeued first.
|
|
4
|
+
*
|
|
5
|
+
* ## Features
|
|
6
|
+
* - **enqueue(value, priority)**: Add element with priority
|
|
7
|
+
* - **enqueueBack(value)**: Add element to the back with lowest priority
|
|
8
|
+
* - **dequeue()**: Remove and return highest priority element
|
|
9
|
+
* - **peek()**: View highest priority element without removing
|
|
10
|
+
* - **peekPriority()**: View highest priority value
|
|
11
|
+
* - **size**: Get number of elements
|
|
12
|
+
* - **isEmpty**: Check if queue is empty
|
|
13
|
+
* - **clear()**: Remove all elements
|
|
14
|
+
* - **toArray()**: Get all elements as array
|
|
15
|
+
* - **toArrayWithPriorities()**: Get all elements with priorities
|
|
16
|
+
*
|
|
17
|
+
* ## Time Complexity
|
|
18
|
+
* - enqueue: O(log n)
|
|
19
|
+
* - enqueueBack: O(log n)
|
|
20
|
+
* - dequeue: O(log n)
|
|
21
|
+
* - peek: O(1)
|
|
22
|
+
* - peekPriority: O(1)
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* const queue = new PriorityQueue<string>();
|
|
27
|
+
* queue.enqueue("low", 1);
|
|
28
|
+
* queue.enqueue("high", 3);
|
|
29
|
+
* queue.enqueue("medium", 2);
|
|
30
|
+
*
|
|
31
|
+
* console.log(queue.dequeue()); // "high"
|
|
32
|
+
* console.log(queue.dequeue()); // "medium"
|
|
33
|
+
* console.log(queue.dequeue()); // "low"
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```typescript
|
|
38
|
+
* // Initialize with elements
|
|
39
|
+
* const queue = new PriorityQueue([
|
|
40
|
+
* { value: "task1", priority: 1 },
|
|
41
|
+
* { value: "task2", priority: 3 },
|
|
42
|
+
* { value: "task3", priority: 2 }
|
|
43
|
+
* ]);
|
|
44
|
+
*
|
|
45
|
+
* console.log(queue.peek()); // "task2"
|
|
46
|
+
* console.log(queue.peekPriority()); // 3
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* @template T - The type of elements stored in the queue
|
|
50
|
+
*/
|
|
51
|
+
export declare class PriorityQueue<T> {
|
|
52
|
+
private heap;
|
|
53
|
+
private minPriority;
|
|
54
|
+
/**
|
|
55
|
+
* Creates a new PriorityQueue instance.
|
|
56
|
+
* @param initialElements - Optional array of initial elements with priorities
|
|
57
|
+
* @example
|
|
58
|
+
* ```typescript
|
|
59
|
+
* const queue = new PriorityQueue<string>();
|
|
60
|
+
* // or
|
|
61
|
+
* const queue = new PriorityQueue([
|
|
62
|
+
* { value: "item1", priority: 10 },
|
|
63
|
+
* { value: "item2", priority: 5 }
|
|
64
|
+
* ]);
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
constructor(initialElements?: Array<{
|
|
68
|
+
value: T;
|
|
69
|
+
priority: number;
|
|
70
|
+
}>);
|
|
71
|
+
/**
|
|
72
|
+
* Returns the number of elements in the queue.
|
|
73
|
+
* @returns The number of elements in the queue
|
|
74
|
+
* @example
|
|
75
|
+
* ```typescript
|
|
76
|
+
* const queue = new PriorityQueue<string>();
|
|
77
|
+
* queue.enqueue("item", 1);
|
|
78
|
+
* console.log(queue.size); // 1
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
get size(): number;
|
|
82
|
+
/**
|
|
83
|
+
* Checks if the queue is empty.
|
|
84
|
+
* @returns True if the queue is empty, false otherwise
|
|
85
|
+
* @example
|
|
86
|
+
* ```typescript
|
|
87
|
+
* const queue = new PriorityQueue<string>();
|
|
88
|
+
* console.log(queue.isEmpty); // true
|
|
89
|
+
* queue.enqueue("item", 1);
|
|
90
|
+
* console.log(queue.isEmpty); // false
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
get isEmpty(): boolean;
|
|
94
|
+
/**
|
|
95
|
+
* Adds an element to the queue with a specified priority.
|
|
96
|
+
* Higher priority values are dequeued first.
|
|
97
|
+
* @param value - The value to add
|
|
98
|
+
* @param priority - The priority value (higher values have higher priority)
|
|
99
|
+
* @example
|
|
100
|
+
* ```typescript
|
|
101
|
+
* const queue = new PriorityQueue<string>();
|
|
102
|
+
* queue.enqueue("low", 1);
|
|
103
|
+
* queue.enqueue("high", 10);
|
|
104
|
+
* queue.enqueue("medium", 5);
|
|
105
|
+
* console.log(queue.dequeue()); // "high"
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
108
|
+
enqueue(value: T, priority: number): void;
|
|
109
|
+
/**
|
|
110
|
+
* Adds an element to the end of the queue with lowest priority.
|
|
111
|
+
* This element will be dequeued last (FIFO for equal lowest priority).
|
|
112
|
+
*
|
|
113
|
+
* @param value - The value to add
|
|
114
|
+
* @example
|
|
115
|
+
* ```typescript
|
|
116
|
+
* const queue = new PriorityQueue<string>();
|
|
117
|
+
* queue.enqueue("high", 10);
|
|
118
|
+
* queue.enqueue("medium", 5);
|
|
119
|
+
* queue.enqueueBack("back1");
|
|
120
|
+
* queue.enqueueBack("back2");
|
|
121
|
+
* console.log(queue.dequeue()); // "high"
|
|
122
|
+
* console.log(queue.dequeue()); // "medium"
|
|
123
|
+
* console.log(queue.dequeue()); // "back1"
|
|
124
|
+
* console.log(queue.dequeue()); // "back2"
|
|
125
|
+
* ```
|
|
126
|
+
*/
|
|
127
|
+
enqueueBack(value: T): void;
|
|
128
|
+
/**
|
|
129
|
+
* Removes and returns the element with the highest priority.
|
|
130
|
+
* @returns The element with highest priority, or undefined if queue is empty
|
|
131
|
+
* @example
|
|
132
|
+
* ```typescript
|
|
133
|
+
* const queue = new PriorityQueue<string>();
|
|
134
|
+
* queue.enqueue("low", 1);
|
|
135
|
+
* queue.enqueue("high", 10);
|
|
136
|
+
* console.log(queue.dequeue()); // "high"
|
|
137
|
+
* console.log(queue.dequeue()); // "low"
|
|
138
|
+
* console.log(queue.dequeue()); // undefined
|
|
139
|
+
* ```
|
|
140
|
+
*/
|
|
141
|
+
dequeue(): T | undefined;
|
|
142
|
+
/**
|
|
143
|
+
* Returns the element with the highest priority without removing it.
|
|
144
|
+
* @returns The element with highest priority, or undefined if queue is empty
|
|
145
|
+
* @example
|
|
146
|
+
* ```typescript
|
|
147
|
+
* const queue = new PriorityQueue<string>();
|
|
148
|
+
* queue.enqueue("low", 1);
|
|
149
|
+
* queue.enqueue("high", 10);
|
|
150
|
+
* console.log(queue.peek()); // "high"
|
|
151
|
+
* console.log(queue.size); // 2 (element not removed)
|
|
152
|
+
* ```
|
|
153
|
+
*/
|
|
154
|
+
peek(): T | undefined;
|
|
155
|
+
/**
|
|
156
|
+
* Returns the priority of the element with the highest priority.
|
|
157
|
+
* @returns The highest priority value, or undefined if queue is empty
|
|
158
|
+
* @example
|
|
159
|
+
* ```typescript
|
|
160
|
+
* const queue = new PriorityQueue<string>();
|
|
161
|
+
* queue.enqueue("low", 1);
|
|
162
|
+
* queue.enqueue("high", 10);
|
|
163
|
+
* console.log(queue.peekPriority()); // 10
|
|
164
|
+
* ```
|
|
165
|
+
*/
|
|
166
|
+
peekPriority(): number | undefined;
|
|
167
|
+
/**
|
|
168
|
+
* Removes all elements from the queue.
|
|
169
|
+
* @example
|
|
170
|
+
* ```typescript
|
|
171
|
+
* const queue = new PriorityQueue<string>();
|
|
172
|
+
* queue.enqueue("item1", 1);
|
|
173
|
+
* queue.enqueue("item2", 2);
|
|
174
|
+
* console.log(queue.size); // 2
|
|
175
|
+
* queue.clear();
|
|
176
|
+
* console.log(queue.size); // 0
|
|
177
|
+
* console.log(queue.isEmpty); // true
|
|
178
|
+
* ```
|
|
179
|
+
*/
|
|
180
|
+
clear(): void;
|
|
181
|
+
/**
|
|
182
|
+
* Returns an array of all elements in the queue (without removing them).
|
|
183
|
+
* The order is not guaranteed to be sorted by priority.
|
|
184
|
+
* @returns Array of all elements in the queue
|
|
185
|
+
* @example
|
|
186
|
+
* ```typescript
|
|
187
|
+
* const queue = new PriorityQueue<string>();
|
|
188
|
+
* queue.enqueue("low", 1);
|
|
189
|
+
* queue.enqueue("high", 10);
|
|
190
|
+
* queue.enqueue("medium", 5);
|
|
191
|
+
* console.log(queue.toArray()); // ["high", "medium", "low"] (order may vary)
|
|
192
|
+
* ```
|
|
193
|
+
*/
|
|
194
|
+
toArray(): T[];
|
|
195
|
+
/**
|
|
196
|
+
* Returns an array of all elements with their priorities.
|
|
197
|
+
* The order is not guaranteed to be sorted by priority.
|
|
198
|
+
* @returns Array of all elements with their priorities
|
|
199
|
+
* @example
|
|
200
|
+
* ```typescript
|
|
201
|
+
* const queue = new PriorityQueue<string>();
|
|
202
|
+
* queue.enqueue("low", 1);
|
|
203
|
+
* queue.enqueue("high", 10);
|
|
204
|
+
* console.log(queue.toArrayWithPriorities());
|
|
205
|
+
* // [{ value: "high", priority: 10 }, { value: "low", priority: 1 }] (order may vary)
|
|
206
|
+
* ```
|
|
207
|
+
*/
|
|
208
|
+
toArrayWithPriorities(): Array<{
|
|
209
|
+
value: T;
|
|
210
|
+
priority: number;
|
|
211
|
+
}>;
|
|
212
|
+
/**
|
|
213
|
+
* Updates the minimum priority when adding elements.
|
|
214
|
+
* @param priority - The priority being added
|
|
215
|
+
*/
|
|
216
|
+
private updateMinPriorityOnAdd;
|
|
217
|
+
/**
|
|
218
|
+
* Updates the minimum priority from all elements (used in constructor).
|
|
219
|
+
*/
|
|
220
|
+
private updateMinPriority;
|
|
221
|
+
/**
|
|
222
|
+
* Builds a max heap from the current heap array.
|
|
223
|
+
*/
|
|
224
|
+
private buildHeap;
|
|
225
|
+
/**
|
|
226
|
+
* Moves an element up the heap to maintain heap property.
|
|
227
|
+
* @param index - The index of the element to move up
|
|
228
|
+
*/
|
|
229
|
+
private heapifyUp;
|
|
230
|
+
/**
|
|
231
|
+
* Moves an element down the heap to maintain heap property.
|
|
232
|
+
* @param index - The index of the element to move down
|
|
233
|
+
*/
|
|
234
|
+
private heapifyDown;
|
|
235
|
+
/**
|
|
236
|
+
* Swaps two elements in the heap.
|
|
237
|
+
* @param i - First index
|
|
238
|
+
* @param j - Second index
|
|
239
|
+
*/
|
|
240
|
+
private swap;
|
|
241
|
+
}
|