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.6 to 1.48.7

10

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

@@ -135,15 +135,7 @@ /**

*/
refill(nodesOrKeysOrEntries: Iterable<BTNodeExemplar<K, V, N>>, values?: Iterable<V | undefined>): void;
/**
* Time Complexity: O(k * n) "n" is the number of nodes in the tree, and "k" is the number of keys to be inserted.
* Space Complexity: O(1)
*
* The `refill` function clears the current collection and adds new nodes, keys, or entries to it.
* @param nodesOrKeysOrEntries - The parameter `nodesOrKeysOrEntries` is an iterable object that can
* contain either `BTNodeExemplar` objects, keys, or entries.
*/
refill(nodesOrKeysOrEntries: Iterable<BTNodeExemplar<K, V, N>>): void;
/**
* Time Complexity: O(k * n) "n" is the number of nodes in the tree, and "k" is the number of keys to be inserted.
* Space Complexity: O(1)
*/
delete<C extends BTNCallback<N, K>>(identifier: K, callback?: C): BiTreeDeleteResult<N>[];

@@ -150,0 +142,0 @@ delete<C extends BTNCallback<N, N>>(identifier: N | null | undefined, callback?: C): BiTreeDeleteResult<N>[];

20

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

@@ -134,7 +134,27 @@ /**

/**
* Time Complexity: O(n log n) - Adding each element individually in a balanced tree.
* Space Complexity: O(n) - Additional space is required for the sorted array.
*/
/**
* Time Complexity: O(log n) - Average case for a balanced tree.
* Space Complexity: O(1) - Constant space is used.
*
* The `lastKey` function returns the key of the rightmost node in a binary tree, or the key of the
* leftmost node if the comparison result is greater than.
* @param {K | N | undefined} beginRoot - The `beginRoot` parameter is optional and can be of
* type `K`, `N`, or `undefined`. It represents the starting point for finding the last key in
* the binary tree. If not provided, it defaults to the root of the binary tree (`this.root`).
* @param iterationType - The `iterationType` parameter is used to specify the type of iteration to
* be performed. It can have one of the following values:
* @returns the key of the rightmost node in the binary tree if the comparison result is less than,
* the key of the leftmost node if the comparison result is greater than, and the key of the
* rightmost node otherwise. If no node is found, it returns 0.
*/
lastKey(beginRoot?: BSTNodeKeyOrNode<K, N>): K | undefined;
/**
* Time Complexity: O(log n) - Average case for a balanced tree.
* Space Complexity: O(1) - Constant space is used.
*/
/**
* Time Complexity: O(log n) - Average case for a balanced tree.
* Space Complexity: O(log n) - Space for the recursive call stack in the worst case.

@@ -141,0 +161,0 @@ *

@@ -304,33 +304,45 @@ "use strict";

}
// /**
// * Time Complexity: O(n log n) - Adding each element individually in a balanced tree.
// * Space Complexity: O(n) - Additional space is required for the sorted array.
// */
//
// /**
// * Time Complexity: O(log n) - Average case for a balanced tree.
// * Space Complexity: O(1) - Constant space is used.
// *
// * The `lastKey` function returns the key of the rightmost node in a binary tree, or the key of the
// * leftmost node if the comparison result is greater than.
// * @param {K | N | undefined} beginRoot - The `beginRoot` parameter is optional and can be of
// * type `K`, `N`, or `undefined`. It represents the starting point for finding the last key in
// * the binary tree. If not provided, it defaults to the root of the binary tree (`this.root`).
// * @param iterationType - The `iterationType` parameter is used to specify the type of iteration to
// * be performed. It can have one of the following values:
// * @returns the key of the rightmost node in the binary tree if the comparison result is less than,
// * the key of the leftmost node if the comparison result is greater than, and the key of the
// * rightmost node otherwise. If no node is found, it returns 0.
// */
// lastKey(beginRoot: BSTNodeKeyOrNode<K,N> = this.root, iterationType = this.iterationType): K {
// if (this._compare(0, 1) === CP.lt) return this.getRightMost(beginRoot, iterationType)?.key ?? 0;
// else if (this._compare(0, 1) === CP.gt) return this.getLeftMost(beginRoot, iterationType)?.key ?? 0;
// else return this.getRightMost(beginRoot, iterationType)?.key ?? 0;
// }
/**
* Time Complexity: O(n log n) - Adding each element individually in a balanced tree.
* Space Complexity: O(n) - Additional space is required for the sorted array.
*/
/**
* Time Complexity: O(log n) - Average case for a balanced tree.
* Space Complexity: O(1) - Constant space is used.
*
* The `lastKey` function returns the key of the rightmost node in a binary tree, or the key of the
* leftmost node if the comparison result is greater than.
* @param {K | N | undefined} beginRoot - The `beginRoot` parameter is optional and can be of
* type `K`, `N`, or `undefined`. It represents the starting point for finding the last key in
* the binary tree. If not provided, it defaults to the root of the binary tree (`this.root`).
* @param iterationType - The `iterationType` parameter is used to specify the type of iteration to
* be performed. It can have one of the following values:
* @returns the key of the rightmost node in the binary tree if the comparison result is less than,
* the key of the leftmost node if the comparison result is greater than, and the key of the
* rightmost node otherwise. If no node is found, it returns 0.
*/
lastKey(beginRoot = this.root) {
let current = this.ensureNode(beginRoot);
if (!current)
return undefined;
if (this._variant === types_1.BSTVariant.MIN) {
// For BSTVariant.MIN, find the rightmost node
while (current.right !== undefined) {
current = current.right;
}
}
else {
// For BSTVariant.MAX, find the leftmost node
while (current.left !== undefined) {
current = current.left;
}
}
return current.key;
}
/**
* Time Complexity: O(log n) - Average case for a balanced tree.
* Space Complexity: O(1) - Constant space is used.
*/
/**
* Time Complexity: O(log n) - Average case for a balanced tree.
* Space Complexity: O(log n) - Space for the recursive call stack in the worst case.

@@ -581,3 +593,2 @@ *

const midNode = sorted[m];
debugger;
this.add([midNode.key, midNode.value]);

@@ -584,0 +595,0 @@ stack.push([m + 1, r]);

@@ -92,7 +92,7 @@ import { IterableElementBase } from "../base";

*
* The `popLast()` function removes and returns the value of the last node in a doubly linked list.
* The `pollLast()` function removes and returns the value of the last node in a doubly linked list.
* @returns The method is returning the value of the removed node (removedNode.value) if the list is not empty. If the
* list is empty, it returns undefined.
*/
popLast(): E | undefined;
pollLast(): E | undefined;
/**

@@ -119,7 +119,7 @@ * Time Complexity: O(1)

*
* The `popFirst()` function removes and returns the value of the first node in a doubly linked list.
* The `pollFirst()` function removes and returns the value of the first node in a doubly linked list.
* @returns The method `shift()` returns the value of the node that is removed from the beginning of the doubly linked
* list.
*/
popFirst(): E | undefined;
pollFirst(): E | undefined;
/**

@@ -126,0 +126,0 @@ * Time Complexity: O(1)

@@ -145,7 +145,7 @@ "use strict";

*
* The `popLast()` function removes and returns the value of the last node in a doubly linked list.
* The `pollLast()` function removes and returns the value of the last node in a doubly linked list.
* @returns The method is returning the value of the removed node (removedNode.value) if the list is not empty. If the
* list is empty, it returns undefined.
*/
popLast() {
pollLast() {
return this.pop();

@@ -188,7 +188,7 @@ }

*
* The `popFirst()` function removes and returns the value of the first node in a doubly linked list.
* The `pollFirst()` function removes and returns the value of the first node in a doubly linked list.
* @returns The method `shift()` returns the value of the node that is removed from the beginning of the doubly linked
* list.
*/
popFirst() {
pollFirst() {
return this.shift();

@@ -195,0 +195,0 @@ }

@@ -93,3 +93,3 @@ import { IterableElementBase } from "../base";

*
* The `popLast()` function removes and returns the value of the last element in a linked list, updating the head and tail
* The `pollLast()` function removes and returns the value of the last element in a linked list, updating the head and tail
* pointers accordingly.

@@ -99,3 +99,3 @@ * @returns The method `pop()` returns the value of the node that is being removed from the end of the linked list. If

*/
popLast(): E | undefined;
pollLast(): E | undefined;
/**

@@ -121,6 +121,6 @@ * Time Complexity: O(1) - Constant time, as it involves adjusting pointers at the head.

*
* The `popFirst()` function removes and returns the value of the first node in a linked list.
* The `pollFirst()` function removes and returns the value of the first node in a linked list.
* @returns The value of the node that is being removed from the beginning of the linked list.
*/
popFirst(): E | undefined;
pollFirst(): E | undefined;
/**

@@ -127,0 +127,0 @@ * Time Complexity: O(1) - Constant time, as it involves adjusting pointers at the head.

@@ -147,3 +147,3 @@ "use strict";

*
* The `popLast()` function removes and returns the value of the last element in a linked list, updating the head and tail
* The `pollLast()` function removes and returns the value of the last element in a linked list, updating the head and tail
* pointers accordingly.

@@ -153,3 +153,3 @@ * @returns The method `pop()` returns the value of the node that is being removed from the end of the linked list. If

*/
popLast() {
pollLast() {
return this.pop();

@@ -184,6 +184,6 @@ }

*
* The `popFirst()` function removes and returns the value of the first node in a linked list.
* The `pollFirst()` function removes and returns the value of the first node in a linked list.
* @returns The value of the node that is being removed from the beginning of the linked list.
*/
popFirst() {
pollFirst() {
return this.shift();

@@ -190,0 +190,0 @@ }

@@ -70,6 +70,6 @@ /**

*
* The function "popLast" removes and returns the last element of an array.
* The function "pollLast" removes and returns the last element of an array.
* @returns The last element of the array is being returned.
*/
popLast(): E | undefined;
pollLast(): E | undefined;
/**

@@ -88,7 +88,7 @@ * Time Complexity: O(1).

*
* The function "popFirst" removes and returns the first element of an array.
* @returns The method `popFirst()` is returning the first element of the array after removing it
* The function "pollFirst" removes and returns the first element of an array.
* @returns The method `pollFirst()` is returning the first element of the array after removing it
* from the beginning. If the array is empty, it will return `undefined`.
*/
popFirst(): E | undefined;
pollFirst(): E | undefined;
/**

@@ -493,6 +493,6 @@ * The clear() function resets the state of the object by initializing all variables to their default

*
* The function `popFirst()` removes and returns the first element in a data structure.
* The function `pollFirst()` removes and returns the first element in a data structure.
* @returns The element of the first element in the data structure.
*/
popFirst(): E | undefined;
pollFirst(): E | undefined;
/**

@@ -518,6 +518,6 @@ * Time Complexity: O(1)

*
* The `popLast()` function removes and returns the last element in a data structure.
* The `pollLast()` function removes and returns the last element in a data structure.
* @returns The element that was removed from the data structure.
*/
popLast(): E | undefined;
pollLast(): E | undefined;
/**

@@ -524,0 +524,0 @@ * Time Complexity: O(1)

@@ -114,6 +114,6 @@ "use strict";

*
* The function "popLast" removes and returns the last element of an array.
* The function "pollLast" removes and returns the last element of an array.
* @returns The last element of the array is being returned.
*/
popLast() {
pollLast() {
return this.pop();

@@ -136,7 +136,7 @@ }

*
* The function "popFirst" removes and returns the first element of an array.
* @returns The method `popFirst()` is returning the first element of the array after removing it
* The function "pollFirst" removes and returns the first element of an array.
* @returns The method `pollFirst()` is returning the first element of the array after removing it
* from the beginning. If the array is empty, it will return `undefined`.
*/
popFirst() {
pollFirst() {
return this.shift();

@@ -880,6 +880,6 @@ }

*
* The function `popFirst()` removes and returns the first element in a data structure.
* The function `pollFirst()` removes and returns the first element in a data structure.
* @returns The element of the first element in the data structure.
*/
popFirst() {
pollFirst() {
if (!this.size)

@@ -916,6 +916,6 @@ return;

*
* The `popLast()` function removes and returns the last element in a data structure.
* The `pollLast()` function removes and returns the last element in a data structure.
* @returns The element that was removed from the data structure.
*/
popLast() {
pollLast() {
if (!this.size)

@@ -922,0 +922,0 @@ return;

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

@@ -135,4 +135,4 @@ "main": "dist/index.js",

"dependencies": {
"data-structure-typed": "^1.48.6"
"data-structure-typed": "^1.48.7"
}
}

@@ -362,27 +362,6 @@ /**

// /**
// * Time Complexity: O(n log n) - Adding each element individually in a balanced tree.
// * Space Complexity: O(n) - Additional space is required for the sorted array.
// */
//
// /**
// * Time Complexity: O(log n) - Average case for a balanced tree.
// * Space Complexity: O(1) - Constant space is used.
// *
// * The `lastKey` function returns the key of the rightmost node in a binary tree, or the key of the
// * leftmost node if the comparison result is greater than.
// * @param {K | N | undefined} beginRoot - The `beginRoot` parameter is optional and can be of
// * type `K`, `N`, or `undefined`. It represents the starting point for finding the last key in
// * the binary tree. If not provided, it defaults to the root of the binary tree (`this.root`).
// * @param iterationType - The `iterationType` parameter is used to specify the type of iteration to
// * be performed. It can have one of the following values:
// * @returns the key of the rightmost node in the binary tree if the comparison result is less than,
// * the key of the leftmost node if the comparison result is greater than, and the key of the
// * rightmost node otherwise. If no node is found, it returns 0.
// */
// lastKey(beginRoot: BSTNodeKeyOrNode<K,N> = this.root, iterationType = this.iterationType): K {
// if (this._compare(0, 1) === CP.lt) return this.getRightMost(beginRoot, iterationType)?.key ?? 0;
// else if (this._compare(0, 1) === CP.gt) return this.getLeftMost(beginRoot, iterationType)?.key ?? 0;
// else return this.getRightMost(beginRoot, iterationType)?.key ?? 0;
// }
/**
* Time Complexity: O(n log n) - Adding each element individually in a balanced tree.
* Space Complexity: O(n) - Additional space is required for the sorted array.
*/

@@ -392,6 +371,40 @@ /**

* Space Complexity: O(1) - Constant space is used.
*
* The `lastKey` function returns the key of the rightmost node in a binary tree, or the key of the
* leftmost node if the comparison result is greater than.
* @param {K | N | undefined} beginRoot - The `beginRoot` parameter is optional and can be of
* type `K`, `N`, or `undefined`. It represents the starting point for finding the last key in
* the binary tree. If not provided, it defaults to the root of the binary tree (`this.root`).
* @param iterationType - The `iterationType` parameter is used to specify the type of iteration to
* be performed. It can have one of the following values:
* @returns the key of the rightmost node in the binary tree if the comparison result is less than,
* the key of the leftmost node if the comparison result is greater than, and the key of the
* rightmost node otherwise. If no node is found, it returns 0.
*/
lastKey(beginRoot: BSTNodeKeyOrNode<K, N> = this.root): K | undefined {
let current = this.ensureNode(beginRoot);
if (!current) return undefined;
if (this._variant === BSTVariant.MIN) {
// For BSTVariant.MIN, find the rightmost node
while (current.right !== undefined) {
current = current.right;
}
} else {
// For BSTVariant.MAX, find the leftmost node
while (current.left !== undefined) {
current = current.left;
}
}
return current.key;
}
/**
* Time Complexity: O(log n) - Average case for a balanced tree.
* Space Complexity: O(1) - Constant space is used.
*/
/**
* Time Complexity: O(log n) - Average case for a balanced tree.
* Space Complexity: O(log n) - Space for the recursive call stack in the worst case.

@@ -641,3 +654,2 @@ *

const midNode = sorted[m];
debugger;
this.add([midNode.key, midNode.value]);

@@ -644,0 +656,0 @@ stack.push([m + 1, r]);

@@ -628,3 +628,3 @@ /**

while (node !== this._sentinel) {
yield <[K, V]>[node.key, node.value];
yield [node.key, node.value] as [K, V];
node = node.next;

@@ -631,0 +631,0 @@ }

@@ -165,7 +165,7 @@ import { IterableElementBase } from "../base";

*
* The `popLast()` function removes and returns the value of the last node in a doubly linked list.
* The `pollLast()` function removes and returns the value of the last node in a doubly linked list.
* @returns The method is returning the value of the removed node (removedNode.value) if the list is not empty. If the
* list is empty, it returns undefined.
*/
popLast(): E | undefined {
pollLast(): E | undefined {
return this.pop();

@@ -210,7 +210,7 @@ }

*
* The `popFirst()` function removes and returns the value of the first node in a doubly linked list.
* The `pollFirst()` function removes and returns the value of the first node in a doubly linked list.
* @returns The method `shift()` returns the value of the node that is removed from the beginning of the doubly linked
* list.
*/
popFirst(): E | undefined {
pollFirst(): E | undefined {
return this.shift();

@@ -217,0 +217,0 @@ }

@@ -167,3 +167,3 @@ import { IterableElementBase } from "../base";

*
* The `popLast()` function removes and returns the value of the last element in a linked list, updating the head and tail
* The `pollLast()` function removes and returns the value of the last element in a linked list, updating the head and tail
* pointers accordingly.

@@ -173,3 +173,3 @@ * @returns The method `pop()` returns the value of the node that is being removed from the end of the linked list. If

*/
popLast(): E | undefined {
pollLast(): E | undefined {
return this.pop();

@@ -207,6 +207,6 @@ }

*
* The `popFirst()` function removes and returns the value of the first node in a linked list.
* The `pollFirst()` function removes and returns the value of the first node in a linked list.
* @returns The value of the node that is being removed from the beginning of the linked list.
*/
popFirst(): E | undefined {
pollFirst(): E | undefined {
return this.shift();

@@ -213,0 +213,0 @@ }

@@ -123,6 +123,6 @@ /**

*
* The function "popLast" removes and returns the last element of an array.
* The function "pollLast" removes and returns the last element of an array.
* @returns The last element of the array is being returned.
*/
popLast(): E | undefined {
pollLast(): E | undefined {
return this.pop();

@@ -147,7 +147,7 @@ }

*
* The function "popFirst" removes and returns the first element of an array.
* @returns The method `popFirst()` is returning the first element of the array after removing it
* The function "pollFirst" removes and returns the first element of an array.
* @returns The method `pollFirst()` is returning the first element of the array after removing it
* from the beginning. If the array is empty, it will return `undefined`.
*/
popFirst(): E | undefined {
pollFirst(): E | undefined {
return this.shift();

@@ -952,6 +952,6 @@ }

*
* The function `popFirst()` removes and returns the first element in a data structure.
* The function `pollFirst()` removes and returns the first element in a data structure.
* @returns The element of the first element in the data structure.
*/
popFirst() {
pollFirst() {
if (!this.size) return;

@@ -990,6 +990,6 @@ const element = this.getFirst();

*
* The `popLast()` function removes and returns the last element in a data structure.
* The `pollLast()` function removes and returns the last element in a data structure.
* @returns The element that was removed from the data structure.
*/
popLast() {
pollLast() {
if (!this.size) return;

@@ -1046,2 +1046,2 @@ const element = this.getLast();

}
}
}

@@ -381,2 +381,2 @@ /**

}
}
}

@@ -10,2 +10,2 @@ import { RedBlackTree, RedBlackTreeNode } from '../../../data-structures';

export type RBTreeOptions<K> = BSTOptions<K> & {};
export type RBTreeOptions<K> = BSTOptions<K> & {};
import { Comparator } from "../../common";
export type HeapOptions<T> = { comparator: Comparator<T> }
export type HeapOptions<T> = { comparator: Comparator<T> }
import { HeapOptions } from "../heap";
export type PriorityQueueOptions<T> = HeapOptions<T> & {}
export type PriorityQueueOptions<T> = HeapOptions<T> & {}

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