avl-tree-typed 1.51.3 → 1.51.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.
@@ -266,9 +266,9 @@ class BinaryTree extends base_1.IterableEntryBase {
266
266
  * @returns a boolean value.
267
267
  */
268
268
  isRealNode(node) {
269
- if (!this.isNode(node))
269
+ if (node === this.NIL || node === null || node === undefined)
270
270
  return false;
271
- return node !== this.NIL;
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 BSTVariant.MIN, find the rightmost node
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);
@@ -1 +1,2 @@
1
1
  export * from './utils';
2
+ export * from './number';
@@ -15,3 +15,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./utils"), exports);
18
+ __exportStar(require("./number"), exports);
@@ -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",
3
+ "version": "1.51.5",
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.3"
166
+ "data-structure-typed": "^1.51.5"
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 (!this.isNode(node)) return false;
320
- return node !== this.NIL;
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 BSTVariant.MIN, find the rightmost node
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';
@@ -1 +1,2 @@
1
1
  export * from './utils';
2
+ export * from './number';
@@ -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
+ }