avl-tree-typed 1.51.3 → 1.51.4
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/dist/data-structures/binary-tree/binary-tree.js +2 -2
- package/dist/data-structures/binary-tree/bst.js +1 -1
- package/dist/data-structures/index.d.ts +1 -1
- package/dist/data-structures/index.js +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/number.d.ts +1 -0
- package/dist/utils/number.js +11 -0
- package/package.json +2 -2
- package/src/data-structures/binary-tree/binary-tree.ts +2 -2
- package/src/data-structures/binary-tree/bst.ts +1 -1
- package/src/data-structures/index.ts +1 -1
- package/src/utils/index.ts +1 -0
- package/src/utils/number.ts +9 -0
|
@@ -266,9 +266,9 @@ class BinaryTree extends base_1.IterableEntryBase {
|
|
|
266
266
|
* @returns a boolean value.
|
|
267
267
|
*/
|
|
268
268
|
isRealNode(node) {
|
|
269
|
-
if (
|
|
269
|
+
if (node === this.NIL || node === null || node === undefined)
|
|
270
270
|
return false;
|
|
271
|
-
return
|
|
271
|
+
return this.isNode(node);
|
|
272
272
|
}
|
|
273
273
|
/**
|
|
274
274
|
* The function checks if a given node is a BinaryTreeNode instance and has a key value of NaN.
|
|
@@ -608,7 +608,7 @@ class BST extends binary_tree_1.BinaryTree {
|
|
|
608
608
|
if (!current)
|
|
609
609
|
return undefined;
|
|
610
610
|
if (this._variant === 'STANDARD') {
|
|
611
|
-
// For
|
|
611
|
+
// For 'STANDARD', find the rightmost node
|
|
612
612
|
while (current.right !== undefined) {
|
|
613
613
|
current = current.right;
|
|
614
614
|
}
|
|
@@ -4,9 +4,9 @@ export * from './stack';
|
|
|
4
4
|
export * from './queue';
|
|
5
5
|
export * from './graph';
|
|
6
6
|
export * from './binary-tree';
|
|
7
|
-
export * from './tree';
|
|
8
7
|
export * from './heap';
|
|
9
8
|
export * from './priority-queue';
|
|
10
9
|
export * from './matrix';
|
|
11
10
|
export * from './trie';
|
|
12
11
|
export * from './base';
|
|
12
|
+
export * from './tree';
|
|
@@ -20,9 +20,9 @@ __exportStar(require("./stack"), exports);
|
|
|
20
20
|
__exportStar(require("./queue"), exports);
|
|
21
21
|
__exportStar(require("./graph"), exports);
|
|
22
22
|
__exportStar(require("./binary-tree"), exports);
|
|
23
|
-
__exportStar(require("./tree"), exports);
|
|
24
23
|
__exportStar(require("./heap"), exports);
|
|
25
24
|
__exportStar(require("./priority-queue"), exports);
|
|
26
25
|
__exportStar(require("./matrix"), exports);
|
|
27
26
|
__exportStar(require("./trie"), exports);
|
|
28
27
|
__exportStar(require("./base"), exports);
|
|
28
|
+
__exportStar(require("./tree"), exports);
|
package/dist/utils/index.d.ts
CHANGED
package/dist/utils/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function toBinaryString(num: number, digit?: number): string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toBinaryString = void 0;
|
|
4
|
+
function toBinaryString(num, digit = 32) {
|
|
5
|
+
// Convert number to binary string
|
|
6
|
+
let binaryString = (num >>> 0).toString(2); // Use the unsigned right shift operator to ensure you get a binary representation of a 32-bit unsigned integer
|
|
7
|
+
// Use pad Start to ensure the string length is 32 bits
|
|
8
|
+
binaryString = binaryString.padStart(digit, '0');
|
|
9
|
+
return binaryString;
|
|
10
|
+
}
|
|
11
|
+
exports.toBinaryString = toBinaryString;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "avl-tree-typed",
|
|
3
|
-
"version": "1.51.
|
|
3
|
+
"version": "1.51.4",
|
|
4
4
|
"description": "AVLTree(Adelson-Velsky and Landis Tree). Javascript & Typescript Data Structure.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -163,6 +163,6 @@
|
|
|
163
163
|
"typescript": "^4.9.5"
|
|
164
164
|
},
|
|
165
165
|
"dependencies": {
|
|
166
|
-
"data-structure-typed": "^1.51.
|
|
166
|
+
"data-structure-typed": "^1.51.4"
|
|
167
167
|
}
|
|
168
168
|
}
|
|
@@ -316,8 +316,8 @@ export class BinaryTree<
|
|
|
316
316
|
* @returns a boolean value.
|
|
317
317
|
*/
|
|
318
318
|
isRealNode(node: KeyOrNodeOrEntry<K, V, NODE>): node is NODE {
|
|
319
|
-
if (
|
|
320
|
-
return
|
|
319
|
+
if (node === this.NIL || node === null || node === undefined) return false;
|
|
320
|
+
return this.isNode(node);
|
|
321
321
|
}
|
|
322
322
|
|
|
323
323
|
/**
|
|
@@ -695,7 +695,7 @@ export class BST<
|
|
|
695
695
|
if (!current) return undefined;
|
|
696
696
|
|
|
697
697
|
if (this._variant === 'STANDARD') {
|
|
698
|
-
// For
|
|
698
|
+
// For 'STANDARD', find the rightmost node
|
|
699
699
|
while (current.right !== undefined) {
|
|
700
700
|
current = current.right;
|
|
701
701
|
}
|
|
@@ -4,9 +4,9 @@ export * from './stack';
|
|
|
4
4
|
export * from './queue';
|
|
5
5
|
export * from './graph';
|
|
6
6
|
export * from './binary-tree';
|
|
7
|
-
export * from './tree';
|
|
8
7
|
export * from './heap';
|
|
9
8
|
export * from './priority-queue';
|
|
10
9
|
export * from './matrix';
|
|
11
10
|
export * from './trie';
|
|
12
11
|
export * from './base';
|
|
12
|
+
export * from './tree';
|
package/src/utils/index.ts
CHANGED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export function toBinaryString(num: number, digit = 32) {
|
|
2
|
+
// Convert number to binary string
|
|
3
|
+
let binaryString = (num >>> 0).toString(2); // Use the unsigned right shift operator to ensure you get a binary representation of a 32-bit unsigned integer
|
|
4
|
+
|
|
5
|
+
// Use pad Start to ensure the string length is 32 bits
|
|
6
|
+
binaryString = binaryString.padStart(digit, '0');
|
|
7
|
+
|
|
8
|
+
return binaryString;
|
|
9
|
+
}
|