Socket
Socket
Sign inDemoInstall

min-heap-typed

Package Overview
Dependencies
Maintainers
1
Versions
151
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

min-heap-typed - npm Package Compare versions

Comparing version 1.48.9 to 1.49.0

9

dist/data-structures/binary-tree/avl-tree.d.ts

@@ -10,3 +10,3 @@ /**

import type { AVLTreeNested, AVLTreeNodeNested, AVLTreeOptions, BiTreeDeleteResult, BSTNodeKeyOrNode, BTNodeExemplar } from '../../types';
import { BTNCallback } from '../../types';
import { BTNCallback, BTNodeKeyOrNode } from '../../types';
import { IBinaryTree } from '../../interfaces';

@@ -63,2 +63,9 @@ export declare class AVLTreeNode<K = any, V = any, N extends AVLTreeNode<K, V, N> = AVLTreeNodeNested<K, V>> extends BSTNode<K, V, N> {

/**
* The function "isNotNodeInstance" checks if a potential key is a K.
* @param {any} potentialKey - The potentialKey parameter is of type any, which means it can be any
* data type.
* @returns a boolean value indicating whether the potentialKey is of type number or not.
*/
isNotNodeInstance(potentialKey: BTNodeKeyOrNode<K, N>): potentialKey is K;
/**
* Time Complexity: O(log n) - logarithmic time, where "n" is the number of nodes in the tree. The add method of the superclass (BST) has logarithmic time complexity.

@@ -65,0 +72,0 @@ * Space Complexity: O(1) - constant space, as it doesn't use additional data structures that scale with input size.

@@ -75,2 +75,11 @@ "use strict";

/**
* The function "isNotNodeInstance" checks if a potential key is a K.
* @param {any} potentialKey - The potentialKey parameter is of type any, which means it can be any
* data type.
* @returns a boolean value indicating whether the potentialKey is of type number or not.
*/
isNotNodeInstance(potentialKey) {
return !(potentialKey instanceof AVLTreeNode);
}
/**
* Time Complexity: O(log n) - logarithmic time, where "n" is the number of nodes in the tree. The add method of the superclass (BST) has logarithmic time complexity.

@@ -77,0 +86,0 @@ * Space Complexity: O(1) - constant space, as it doesn't use additional data structures that scale with input size.

21

dist/data-structures/binary-tree/binary-tree.d.ts

@@ -388,3 +388,3 @@ /**

*/
isRealNode(node: any): node is N;
isRealNode(node: BTNodeExemplar<K, V, N>): node is N;
/**

@@ -395,3 +395,3 @@ * The function checks if a given node is a BinaryTreeNode instance and has a key value of NaN.

*/
isNIL(node: any): boolean;
isNIL(node: BTNodeExemplar<K, V, N>): boolean;
/**

@@ -402,5 +402,5 @@ * The function checks if a given node is a real node or null.

*/
isNodeOrNull(node: any): node is N | null;
isNodeOrNull(node: BTNodeExemplar<K, V, N>): node is N | null;
/**
* The function "isNotNodeInstance" checks if a potential key is a number.
* The function "isNotNodeInstance" checks if a potential key is a K.
* @param {any} potentialKey - The potentialKey parameter is of type any, which means it can be any

@@ -429,5 +429,14 @@ * data type.

/**
* Time complexity: O(n)
* Space complexity: O(n)
* Time Complexity: O(log n)
* Space Complexity: O(1)
*/
/**
* Time Complexity: O(log n)
* Space Complexity: O(1)
*
* The function returns the predecessor of a given node in a tree.
* @param {N} node - The parameter `node` is of type `RedBlackTreeNode`, which represents a node in a
* tree.
* @returns the predecessor of the given 'node'.
*/
getPredecessor(node: N): N;

@@ -434,0 +443,0 @@ /**

@@ -9,3 +9,3 @@ /**

import type { BSTNested, BSTNodeKeyOrNode, BSTNodeNested, BSTOptions, BTNCallback, BTNodeExemplar } from '../../types';
import { BSTVariant, CP, IterationType } from '../../types';
import { BSTVariant, BTNodeKeyOrNode, CP, IterationType } from '../../types';
import { BinaryTree, BinaryTreeNode } from './binary-tree';

@@ -174,2 +174,9 @@ import { IBinaryTree } from '../../interfaces';

/**
* The function "isNotNodeInstance" checks if a potential key is a K.
* @param {any} potentialKey - The potentialKey parameter is of type any, which means it can be any
* data type.
* @returns a boolean value indicating whether the potentialKey is of type number or not.
*/
isNotNodeInstance(potentialKey: BTNodeKeyOrNode<K, N>): potentialKey is K;
/**
* Time Complexity: O(log n) - Average case for a balanced tree.

@@ -176,0 +183,0 @@ * Space Complexity: O(log n) - Space for the recursive call stack in the worst case.

@@ -391,2 +391,11 @@ "use strict";

/**
* The function "isNotNodeInstance" checks if a potential key is a K.
* @param {any} potentialKey - The potentialKey parameter is of type any, which means it can be any
* data type.
* @returns a boolean value indicating whether the potentialKey is of type number or not.
*/
isNotNodeInstance(potentialKey) {
return !(potentialKey instanceof BSTNode);
}
/**
* Time Complexity: O(log n) - Average case for a balanced tree.

@@ -393,0 +402,0 @@ * Space Complexity: O(log n) - Space for the recursive call stack in the worst case.

@@ -8,3 +8,3 @@ /**

*/
import { BiTreeDeleteResult, BTNCallback, BTNodeExemplar, IterationType, RBTNColor, RBTreeOptions, RedBlackTreeNested, RedBlackTreeNodeNested } from '../../types';
import { BiTreeDeleteResult, BTNCallback, BTNodeExemplar, BTNodeKeyOrNode, IterationType, RBTNColor, RBTreeOptions, RedBlackTreeNested, RedBlackTreeNodeNested } from '../../types';
import { BST, BSTNode } from './bst';

@@ -70,2 +70,9 @@ import { IBinaryTree } from '../../interfaces';

/**
* The function "isNotNodeInstance" checks if a potential key is a K.
* @param {any} potentialKey - The potentialKey parameter is of type any, which means it can be any
* data type.
* @returns a boolean value indicating whether the potentialKey is of type number or not.
*/
isNotNodeInstance(potentialKey: BTNodeKeyOrNode<K, N>): potentialKey is K;
/**
* The function `exemplarToNode` takes an exemplar and converts it into a node object if possible.

@@ -125,22 +132,9 @@ * @param exemplar - The `exemplar` parameter is of type `BTNodeExemplar<K, V, N>`, where:

/**
* Time Complexity: O(log n) on average (where n is the number of nodes in the tree)
* Time Complexity: O(log n)
* Space Complexity: O(1)
*/
/**
* Time Complexity: O(log n) on average (where n is the number of nodes in the tree)
* Time Complexity: O(log n)
* Space Complexity: O(1)
*
* The function returns the successor of a given node in a red-black tree.
* @param {RedBlackTreeNode} x - RedBlackTreeNode - The node for which we want to find the successor.
* @returns the successor of the given RedBlackTreeNode.
*/
getSuccessor(x: N): N | undefined;
/**
* Time Complexity: O(log n) on average (where n is the number of nodes in the tree)
* Space Complexity: O(1)
*/
/**
* Time Complexity: O(log n) on average (where n is the number of nodes in the tree)
* Space Complexity: O(1)
*
* The function returns the predecessor of a given node in a red-black tree.

@@ -147,0 +141,0 @@ * @param {RedBlackTreeNode} x - The parameter `x` is of type `RedBlackTreeNode`, which represents a node in a

@@ -89,2 +89,11 @@ "use strict";

/**
* The function "isNotNodeInstance" checks if a potential key is a K.
* @param {any} potentialKey - The potentialKey parameter is of type any, which means it can be any
* data type.
* @returns a boolean value indicating whether the potentialKey is of type number or not.
*/
isNotNodeInstance(potentialKey) {
return !(potentialKey instanceof RedBlackTreeNode);
}
/**
* The function `exemplarToNode` takes an exemplar and converts it into a node object if possible.

@@ -267,3 +276,5 @@ * @param exemplar - The `exemplar` parameter is of type `BTNodeExemplar<K, V, N>`, where:

isRealNode(node) {
return node !== this.Sentinel && node !== undefined;
if (node === this.Sentinel || node === undefined)
return false;
return node instanceof RedBlackTreeNode;
}

@@ -303,33 +314,9 @@ /**

/**
* Time Complexity: O(log n) on average (where n is the number of nodes in the tree)
* Time Complexity: O(log n)
* Space Complexity: O(1)
*/
/**
* Time Complexity: O(log n) on average (where n is the number of nodes in the tree)
* Time Complexity: O(log n)
* Space Complexity: O(1)
*
* The function returns the successor of a given node in a red-black tree.
* @param {RedBlackTreeNode} x - RedBlackTreeNode - The node for which we want to find the successor.
* @returns the successor of the given RedBlackTreeNode.
*/
getSuccessor(x) {
var _a;
if (x.right !== this.Sentinel) {
return (_a = this.getLeftMost(x.right)) !== null && _a !== void 0 ? _a : undefined;
}
let y = x.parent;
while (y !== this.Sentinel && y !== undefined && x === y.right) {
x = y;
y = y.parent;
}
return y;
}
/**
* Time Complexity: O(log n) on average (where n is the number of nodes in the tree)
* Space Complexity: O(1)
*/
/**
* Time Complexity: O(log n) on average (where n is the number of nodes in the tree)
* Space Complexity: O(1)
*
* The function returns the predecessor of a given node in a red-black tree.

@@ -341,7 +328,7 @@ * @param {RedBlackTreeNode} x - The parameter `x` is of type `RedBlackTreeNode`, which represents a node in a

getPredecessor(x) {
if (x.left !== this.Sentinel) {
if (this.isRealNode(x.left)) {
return this.getRightMost(x.left);
}
let y = x.parent;
while (y !== this.Sentinel && x === y.left) {
while (this.isRealNode(y) && x === y.left) {
x = y;

@@ -348,0 +335,0 @@ y = y.parent;

@@ -9,3 +9,3 @@ /**

import type { BSTNodeKeyOrNode, BTNodeExemplar, TreeMultimapNodeNested, TreeMultimapOptions } from '../../types';
import { BiTreeDeleteResult, BTNCallback, IterationType, TreeMultimapNested } from '../../types';
import { BiTreeDeleteResult, BTNCallback, BTNodeKeyOrNode, IterationType, TreeMultimapNested } from '../../types';
import { IBinaryTree } from '../../interfaces';

@@ -53,2 +53,9 @@ import { AVLTree, AVLTreeNode } from './avl-tree';

/**
* The function "isNotNodeInstance" checks if a potential key is a K.
* @param {any} potentialKey - The potentialKey parameter is of type any, which means it can be any
* data type.
* @returns a boolean value indicating whether the potentialKey is of type number or not.
*/
isNotNodeInstance(potentialKey: BTNodeKeyOrNode<K, N>): potentialKey is K;
/**
* The function `exemplarToNode` converts an exemplar object into a node object.

@@ -55,0 +62,0 @@ * @param exemplar - The `exemplar` parameter is of type `BTNodeExemplar<K, V, N>`, which means it

@@ -64,2 +64,11 @@ "use strict";

/**
* The function "isNotNodeInstance" checks if a potential key is a K.
* @param {any} potentialKey - The potentialKey parameter is of type any, which means it can be any
* data type.
* @returns a boolean value indicating whether the potentialKey is of type number or not.
*/
isNotNodeInstance(potentialKey) {
return !(potentialKey instanceof TreeMultimapNode);
}
/**
* The function `exemplarToNode` converts an exemplar object into a node object.

@@ -66,0 +75,0 @@ * @param exemplar - The `exemplar` parameter is of type `BTNodeExemplar<K, V, N>`, which means it

{
"name": "min-heap-typed",
"version": "1.48.9",
"version": "1.49.0",
"description": "Min Heap. Javascript & Typescript Data Structure.",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -17,3 +17,3 @@ /**

} from '../../types';
import { BTNCallback } from '../../types';
import { BTNCallback, BTNodeKeyOrNode } from '../../types';
import { IBinaryTree } from '../../interfaces';

@@ -95,2 +95,12 @@

/**
* The function "isNotNodeInstance" checks if a potential key is a K.
* @param {any} potentialKey - The potentialKey parameter is of type any, which means it can be any
* data type.
* @returns a boolean value indicating whether the potentialKey is of type number or not.
*/
override isNotNodeInstance(potentialKey: BTNodeKeyOrNode<K, N>): potentialKey is K {
return !(potentialKey instanceof AVLTreeNode)
}
/**
* Time Complexity: O(log n) - logarithmic time, where "n" is the number of nodes in the tree. The add method of the superclass (BST) has logarithmic time complexity.

@@ -97,0 +107,0 @@ * Space Complexity: O(1) - constant space, as it doesn't use additional data structures that scale with input size.

@@ -17,3 +17,3 @@ /**

} from '../../types';
import { BSTVariant, CP, IterationType } from '../../types';
import { BSTVariant, BTNodeKeyOrNode, CP, IterationType } from '../../types';
import { BinaryTree, BinaryTreeNode } from './binary-tree';

@@ -447,2 +447,12 @@ import { IBinaryTree } from '../../interfaces';

/**
* The function "isNotNodeInstance" checks if a potential key is a K.
* @param {any} potentialKey - The potentialKey parameter is of type any, which means it can be any
* data type.
* @returns a boolean value indicating whether the potentialKey is of type number or not.
*/
override isNotNodeInstance(potentialKey: BTNodeKeyOrNode<K, N>): potentialKey is K {
return !(potentialKey instanceof BSTNode)
}
/**
* Time Complexity: O(log n) - Average case for a balanced tree.

@@ -449,0 +459,0 @@ * Space Complexity: O(log n) - Space for the recursive call stack in the worst case.

@@ -14,2 +14,3 @@ /**

BTNodeExemplar,
BTNodeKeyOrNode,
IterationType,

@@ -120,2 +121,12 @@ RBTNColor,

/**
* The function "isNotNodeInstance" checks if a potential key is a K.
* @param {any} potentialKey - The potentialKey parameter is of type any, which means it can be any
* data type.
* @returns a boolean value indicating whether the potentialKey is of type number or not.
*/
override isNotNodeInstance(potentialKey: BTNodeKeyOrNode<K, N>): potentialKey is K {
return !(potentialKey instanceof RedBlackTreeNode)
}
/**
* The function `exemplarToNode` takes an exemplar and converts it into a node object if possible.

@@ -305,3 +316,4 @@ * @param exemplar - The `exemplar` parameter is of type `BTNodeExemplar<K, V, N>`, where:

override isRealNode(node: N | undefined): node is N {
return node !== this.Sentinel && node !== undefined;
if (node === this.Sentinel || node === undefined) return false;
return node instanceof RedBlackTreeNode;
}

@@ -368,3 +380,3 @@

/**
* Time Complexity: O(log n) on average (where n is the number of nodes in the tree)
* Time Complexity: O(log n)
* Space Complexity: O(1)

@@ -374,31 +386,5 @@ */

/**
* Time Complexity: O(log n) on average (where n is the number of nodes in the tree)
* Time Complexity: O(log n)
* Space Complexity: O(1)
*
* The function returns the successor of a given node in a red-black tree.
* @param {RedBlackTreeNode} x - RedBlackTreeNode - The node for which we want to find the successor.
* @returns the successor of the given RedBlackTreeNode.
*/
override getSuccessor(x: N): N | undefined {
if (x.right !== this.Sentinel) {
return this.getLeftMost(x.right) ?? undefined;
}
let y: N | undefined = x.parent;
while (y !== this.Sentinel && y !== undefined && x === y.right) {
x = y;
y = y.parent;
}
return y;
}
/**
* Time Complexity: O(log n) on average (where n is the number of nodes in the tree)
* Space Complexity: O(1)
*/
/**
* Time Complexity: O(log n) on average (where n is the number of nodes in the tree)
* Space Complexity: O(1)
*
* The function returns the predecessor of a given node in a red-black tree.

@@ -410,8 +396,8 @@ * @param {RedBlackTreeNode} x - The parameter `x` is of type `RedBlackTreeNode`, which represents a node in a

override getPredecessor(x: N): N {
if (x.left !== this.Sentinel) {
return this.getRightMost(x.left!)!;
if (this.isRealNode(x.left)) {
return this.getRightMost(x.left)!;
}
let y: N | undefined = x.parent;
while (y !== this.Sentinel && x === y!.left) {
while (this.isRealNode(y) && x === y.left) {
x = y!;

@@ -418,0 +404,0 @@ y = y!.parent;

@@ -9,3 +9,10 @@ /**

import type { BSTNodeKeyOrNode, BTNodeExemplar, TreeMultimapNodeNested, TreeMultimapOptions } from '../../types';
import { BiTreeDeleteResult, BTNCallback, FamilyPosition, IterationType, TreeMultimapNested } from '../../types';
import {
BiTreeDeleteResult,
BTNCallback,
BTNodeKeyOrNode,
FamilyPosition,
IterationType,
TreeMultimapNested
} from '../../types';
import { IBinaryTree } from '../../interfaces';

@@ -89,2 +96,11 @@ import { AVLTree, AVLTreeNode } from './avl-tree';

/**
* The function "isNotNodeInstance" checks if a potential key is a K.
* @param {any} potentialKey - The potentialKey parameter is of type any, which means it can be any
* data type.
* @returns a boolean value indicating whether the potentialKey is of type number or not.
*/
override isNotNodeInstance(potentialKey: BTNodeKeyOrNode<K, N>): potentialKey is K {
return !(potentialKey instanceof TreeMultimapNode)
}

@@ -91,0 +107,0 @@ /**

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc