Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

max-priority-queue-typed

Package Overview
Dependencies
Maintainers
1
Versions
171
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

max-priority-queue-typed - npm Package Compare versions

Comparing version 1.48.5 to 1.48.6

13

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

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

*
* The function `addMany` takes in an iterable of `BTNodeExemplar` objects, adds each object to the
* current instance, and returns an array of the inserted nodes.
* @param nodes - The `nodes` parameter is an iterable (such as an array or a set) of
* `BTNodeExemplar<K, V,N>` objects.
* @returns The function `addMany` returns an array of values, where each value is either of type
* `N`, `null`, or `undefined`.
* The `addMany` function takes in a collection of nodes and an optional collection of values, and
* adds each node with its corresponding value to the data structure.
* @param nodes - An iterable collection of BTNodeExemplar objects.
* @param [values] - An optional iterable of values that will be assigned to each node being added.
* @returns The function `addMany` returns an array of `N`, `null`, or `undefined` values.
*/
addMany(nodes: Iterable<BTNodeExemplar<K, V, N>>): (N | null | undefined)[];
addMany(nodes: Iterable<BTNodeExemplar<K, V, N>>, values?: Iterable<V | undefined>): (N | null | undefined)[];
/**

@@ -134,0 +133,0 @@ * Time Complexity: O(k * n) "n" is the number of nodes in the tree, and "k" is the number of keys to be inserted.

@@ -116,15 +116,19 @@ /**

*
* The `addMany` function in TypeScript adds multiple nodes to a binary tree, either in a balanced or
* unbalanced manner, and returns an array of the inserted nodes.
* @param keysOrNodesOrEntries - An iterable containing keys, nodes, or entries to be added to the
* binary tree.
* @param [isBalanceAdd=true] - A boolean flag indicating whether the tree should be balanced after
* adding the nodes. The default value is true.
* The `addMany` function in TypeScript adds multiple keys or nodes to a binary tree, optionally
* balancing the tree after each addition.
* @param keysOrNodesOrEntries - An iterable containing the keys, nodes, or entries to be added to
* the binary tree.
* @param [values] - An optional iterable of values to be associated with the keys or nodes being
* added. If provided, the values will be assigned to the corresponding keys or nodes in the same
* order. If not provided, undefined will be assigned as the value for each key or node.
* @param [isBalanceAdd=true] - A boolean flag indicating whether the add operation should be
* balanced or not. If set to true, the add operation will be balanced using a binary search tree
* algorithm. If set to false, the add operation will not be balanced and the elements will be added
* in the order they appear in the input.
* @param iterationType - The `iterationType` parameter is an optional parameter that specifies the
* type of iteration to use when adding multiple keys or nodes to the binary tree. It has a default
* value of `this.iterationType`, which means it will use the iteration type specified by the binary
* tree instance.
* @returns The `addMany` function returns an array of `N` or `undefined` values.
* type of iteration to use when adding multiple keys or nodes. It has a default value of
* `this.iterationType`, which suggests that it is a property of the current object.
* @returns The function `addMany` returns an array of nodes (`N`) or `undefined` values.
*/
addMany(keysOrNodesOrEntries: Iterable<BTNodeExemplar<K, V, N>>, isBalanceAdd?: boolean, iterationType?: IterationType): (N | undefined)[];
addMany(keysOrNodesOrEntries: Iterable<BTNodeExemplar<K, V, N>>, values?: Iterable<V | undefined>, isBalanceAdd?: boolean, iterationType?: IterationType): (N | undefined)[];
/**

@@ -131,0 +135,0 @@ * Time Complexity: O(log n) - Average case for a balanced tree.

@@ -214,19 +214,28 @@ "use strict";

*
* The `addMany` function in TypeScript adds multiple nodes to a binary tree, either in a balanced or
* unbalanced manner, and returns an array of the inserted nodes.
* @param keysOrNodesOrEntries - An iterable containing keys, nodes, or entries to be added to the
* binary tree.
* @param [isBalanceAdd=true] - A boolean flag indicating whether the tree should be balanced after
* adding the nodes. The default value is true.
* The `addMany` function in TypeScript adds multiple keys or nodes to a binary tree, optionally
* balancing the tree after each addition.
* @param keysOrNodesOrEntries - An iterable containing the keys, nodes, or entries to be added to
* the binary tree.
* @param [values] - An optional iterable of values to be associated with the keys or nodes being
* added. If provided, the values will be assigned to the corresponding keys or nodes in the same
* order. If not provided, undefined will be assigned as the value for each key or node.
* @param [isBalanceAdd=true] - A boolean flag indicating whether the add operation should be
* balanced or not. If set to true, the add operation will be balanced using a binary search tree
* algorithm. If set to false, the add operation will not be balanced and the elements will be added
* in the order they appear in the input.
* @param iterationType - The `iterationType` parameter is an optional parameter that specifies the
* type of iteration to use when adding multiple keys or nodes to the binary tree. It has a default
* value of `this.iterationType`, which means it will use the iteration type specified by the binary
* tree instance.
* @returns The `addMany` function returns an array of `N` or `undefined` values.
* type of iteration to use when adding multiple keys or nodes. It has a default value of
* `this.iterationType`, which suggests that it is a property of the current object.
* @returns The function `addMany` returns an array of nodes (`N`) or `undefined` values.
*/
addMany(keysOrNodesOrEntries, isBalanceAdd = true, iterationType = this.iterationType) {
addMany(keysOrNodesOrEntries, values, isBalanceAdd = true, iterationType = this.iterationType) {
const inserted = [];
let valuesIterator;
if (values) {
valuesIterator = values[Symbol.iterator]();
}
if (!isBalanceAdd) {
for (const kve of keysOrNodesOrEntries) {
const nn = this.add(kve);
const value = valuesIterator === null || valuesIterator === void 0 ? void 0 : valuesIterator.next().value;
const nn = this.add(kve, value);
inserted.push(nn);

@@ -245,3 +254,2 @@ }

}
// TODO this addMany function is inefficient, it should be optimized
let sorted = [];

@@ -248,0 +256,0 @@ sorted = realBTNExemplars.sort((a, b) => {

@@ -7,4 +7,4 @@ import { BinaryTree, BinaryTreeNode } from '../data-structures';

add(keyOrNodeOrEntry: BTNodeExemplar<K, V, N>, value?: V, count?: number): N | null | undefined;
addMany(nodes: Iterable<BTNodeExemplar<K, V, N>>): (N | null | undefined)[];
addMany(nodes: Iterable<BTNodeExemplar<K, V, N>>, values?: Iterable<V | undefined>): (N | null | undefined)[];
delete<C extends BTNCallback<N>>(identifier: ReturnType<C> | null, callback: C): BiTreeDeleteResult<N>[];
}
{
"name": "max-priority-queue-typed",
"version": "1.48.5",
"version": "1.48.6",
"description": "Max Priority Queue. Javascript & Typescript Data Structure.",

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

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

@@ -102,3 +102,3 @@ /**

* Space Complexity: O(1) - constant space, as it doesn't use additional data structures that scale with input size.
*
*
* The function overrides the add method of a binary tree node and balances the tree after inserting

@@ -105,0 +105,0 @@ * a new node.

@@ -195,3 +195,3 @@ /**

* Space Complexity: O(1) - Constant space is used.
*
*
* The `add` function adds a new node to a binary tree, updating the value if the key already exists

@@ -260,23 +260,36 @@ * or inserting a new node if the key is unique.

*
* The `addMany` function in TypeScript adds multiple nodes to a binary tree, either in a balanced or
* unbalanced manner, and returns an array of the inserted nodes.
* @param keysOrNodesOrEntries - An iterable containing keys, nodes, or entries to be added to the
* binary tree.
* @param [isBalanceAdd=true] - A boolean flag indicating whether the tree should be balanced after
* adding the nodes. The default value is true.
* The `addMany` function in TypeScript adds multiple keys or nodes to a binary tree, optionally
* balancing the tree after each addition.
* @param keysOrNodesOrEntries - An iterable containing the keys, nodes, or entries to be added to
* the binary tree.
* @param [values] - An optional iterable of values to be associated with the keys or nodes being
* added. If provided, the values will be assigned to the corresponding keys or nodes in the same
* order. If not provided, undefined will be assigned as the value for each key or node.
* @param [isBalanceAdd=true] - A boolean flag indicating whether the add operation should be
* balanced or not. If set to true, the add operation will be balanced using a binary search tree
* algorithm. If set to false, the add operation will not be balanced and the elements will be added
* in the order they appear in the input.
* @param iterationType - The `iterationType` parameter is an optional parameter that specifies the
* type of iteration to use when adding multiple keys or nodes to the binary tree. It has a default
* value of `this.iterationType`, which means it will use the iteration type specified by the binary
* tree instance.
* @returns The `addMany` function returns an array of `N` or `undefined` values.
* type of iteration to use when adding multiple keys or nodes. It has a default value of
* `this.iterationType`, which suggests that it is a property of the current object.
* @returns The function `addMany` returns an array of nodes (`N`) or `undefined` values.
*/
override addMany(
keysOrNodesOrEntries: Iterable<BTNodeExemplar<K, V, N>>,
values?: Iterable<V | undefined>,
isBalanceAdd = true,
iterationType = this.iterationType
): (N | undefined)[] {
const inserted: (N | undefined)[] = []
const inserted: (N | undefined)[] = [];
let valuesIterator: Iterator<V | undefined> | undefined;
if (values) {
valuesIterator = values[Symbol.iterator]();
}
if (!isBalanceAdd) {
for (const kve of keysOrNodesOrEntries) {
const nn = this.add(kve)
const value = valuesIterator?.next().value;
const nn = this.add(kve, value);
inserted.push(nn);

@@ -286,2 +299,3 @@ }

}
const realBTNExemplars: BTNodePureExemplar<K, V, N>[] = [];

@@ -298,3 +312,2 @@

// TODO this addMany function is inefficient, it should be optimized
let sorted: BTNodePureExemplar<K, V, N>[] = [];

@@ -304,14 +317,13 @@

let aR: number, bR: number;
if (this.isEntry(a)) aR = this.extractor(a[0])
else if (this.isRealNode(a)) aR = this.extractor(a.key)
if (this.isEntry(a)) aR = this.extractor(a[0]);
else if (this.isRealNode(a)) aR = this.extractor(a.key);
else aR = this.extractor(a);
if (this.isEntry(b)) bR = this.extractor(b[0])
else if (this.isRealNode(b)) bR = this.extractor(b.key)
if (this.isEntry(b)) bR = this.extractor(b[0]);
else if (this.isRealNode(b)) bR = this.extractor(b.key);
else bR = this.extractor(b);
return aR - bR;
})
});
const _dfs = (arr: BTNodePureExemplar<K, V, N>[]) => {

@@ -326,2 +338,3 @@ if (arr.length === 0) return;

};
const _iterate = () => {

@@ -344,2 +357,3 @@ const n = sorted.length;

};
if (iterationType === IterationType.RECURSIVE) {

@@ -354,2 +368,3 @@ _dfs(sorted);

// /**

@@ -356,0 +371,0 @@ // * Time Complexity: O(n log n) - Adding each element individually in a balanced tree.

@@ -156,3 +156,3 @@ /**

* Space Complexity: O(1)
*
*
* The `add` function adds a new node to a binary search tree and performs necessary rotations and

@@ -159,0 +159,0 @@ * color changes to maintain the red-black tree properties.

@@ -129,3 +129,3 @@ /**

* Space Complexity: O(1) - constant space, as it doesn't use additional data structures that scale with input size.
*
*
* The function overrides the add method of a binary tree node and adds a new node to the tree.

@@ -132,0 +132,0 @@ * @param keyOrNodeOrEntry - The `keyOrNodeOrEntry` parameter can be either a key, a node, or an

@@ -18,5 +18,5 @@ import { BinaryTree, BinaryTreeNode } from '../data-structures';

addMany(nodes: Iterable<BTNodeExemplar<K, V, N>>): (N | null | undefined)[];
addMany(nodes: Iterable<BTNodeExemplar<K, V, N>>, values?: Iterable<V | undefined>): (N | null | undefined)[];
delete<C extends BTNCallback<N>>(identifier: ReturnType<C> | null, callback: C): BiTreeDeleteResult<N>[];
}

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