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

min-heap-typed

Package Overview
Dependencies
Maintainers
1
Versions
158
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.39.5 to 1.39.6

12

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

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

height: number;
constructor(key: BTNKey, val?: V);
constructor(key: BTNKey, value?: V);
}

@@ -29,8 +29,8 @@ export declare class AVLTree<V = any, N extends AVLTreeNode<V, N> = AVLTreeNode<V, AVLTreeNodeNested<V>>> extends BST<V, N> implements IBinaryTree<V, N> {

* the new node. It is used to determine the position of the node in the binary search tree.
* @param [val] - The parameter `val` is an optional value that can be assigned to the node. It is of
* type `V`, which means it can be any value that is assignable to the `val` property of the
* @param [value] - The parameter `value` is an optional value that can be assigned to the node. It is of
* type `V`, which means it can be any value that is assignable to the `value` property of the
* node type `N`.
* @returns a new AVLTreeNode object with the specified key and value.
*/
createNode(key: BTNKey, val?: V): N;
createNode(key: BTNKey, value?: V): N;
/**

@@ -41,7 +41,7 @@ * The function overrides the add method of a binary tree node and balances the tree after inserting

* `BTNKey` or a `N` (which represents a node in the binary tree) or `null`.
* @param [val] - The `val` parameter is the value that you want to assign to the new node that you
* @param [value] - The `value` parameter is the value that you want to assign to the new node that you
* are adding to the binary search tree.
* @returns The method is returning the inserted node (`N`), `null`, or `undefined`.
*/
add(keyOrNode: BTNKey | N | null, val?: V): N | null | undefined;
add(keyOrNode: BTNKey | N | null, value?: V): N | null | undefined;
/**

@@ -48,0 +48,0 @@ * The function overrides the delete method of a binary tree and balances the tree after deleting a

@@ -13,4 +13,4 @@ "use strict";

class AVLTreeNode extends bst_1.BSTNode {
constructor(key, val) {
super(key, val);
constructor(key, value) {
super(key, value);
this.height = 0;

@@ -34,9 +34,9 @@ }

* the new node. It is used to determine the position of the node in the binary search tree.
* @param [val] - The parameter `val` is an optional value that can be assigned to the node. It is of
* type `V`, which means it can be any value that is assignable to the `val` property of the
* @param [value] - The parameter `value` is an optional value that can be assigned to the node. It is of
* type `V`, which means it can be any value that is assignable to the `value` property of the
* node type `N`.
* @returns a new AVLTreeNode object with the specified key and value.
*/
createNode(key, val) {
return new AVLTreeNode(key, val);
createNode(key, value) {
return new AVLTreeNode(key, value);
}

@@ -48,9 +48,9 @@ /**

* `BTNKey` or a `N` (which represents a node in the binary tree) or `null`.
* @param [val] - The `val` parameter is the value that you want to assign to the new node that you
* @param [value] - The `value` parameter is the value that you want to assign to the new node that you
* are adding to the binary search tree.
* @returns The method is returning the inserted node (`N`), `null`, or `undefined`.
*/
add(keyOrNode, val) {
add(keyOrNode, value) {
// TODO support node as a param
const inserted = super.add(keyOrNode, val);
const inserted = super.add(keyOrNode, value);
if (inserted)

@@ -92,11 +92,11 @@ this._balancePath(inserted);

_swap(srcNode, destNode) {
const { key, val, height } = destNode;
const tempNode = this.createNode(key, val);
const { key, value, height } = destNode;
const tempNode = this.createNode(key, value);
if (tempNode) {
tempNode.height = height;
destNode.key = srcNode.key;
destNode.val = srcNode.val;
destNode.value = srcNode.value;
destNode.height = srcNode.height;
srcNode.key = tempNode.key;
srcNode.val = tempNode.val;
srcNode.value = tempNode.value;
srcNode.height = tempNode.height;

@@ -103,0 +103,0 @@ }

@@ -24,3 +24,3 @@ /**

*/
val: V | undefined;
value: V | undefined;
/**

@@ -33,5 +33,5 @@ * The parent node of the current node.

* @param {BTNKey} key - The key associated with the node.
* @param {V} val - The value stored in the node.
* @param {V} value - The value stored in the node.
*/
constructor(key: BTNKey, val?: V);
constructor(key: BTNKey, value?: V);
private _left;

@@ -96,6 +96,6 @@ /**

* @param {BTNKey} key - The key for the new node.
* @param {V} val - The value for the new node.
* @param {V} value - The value for the new node.
* @returns {N} - The newly created BinaryTreeNode.
*/
createNode(key: BTNKey, val?: V): N;
createNode(key: BTNKey, value?: V): N;
/**

@@ -113,6 +113,6 @@ * Clear the binary tree, removing all nodes.

* @param {BTNKey | N | null} keyOrNode - The key or node to add to the binary tree.
* @param {V} val - The value for the new node (optional).
* @param {V} value - The value for the new node (optional).
* @returns {N | null | undefined} - The inserted node, or null if nothing was inserted, or undefined if the operation failed.
*/
add(keyOrNode: BTNKey | N | null, val?: V): N | null | undefined;
add(keyOrNode: BTNKey | N | null, value?: V): N | null | undefined;
/**

@@ -119,0 +119,0 @@ * The `addMany` function takes an array of binary tree node IDs or nodes, and optionally an array of corresponding data

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

* @param {BTNKey} key - The key associated with the node.
* @param {V} val - The value stored in the node.
* @param {V} value - The value stored in the node.
*/
constructor(key, val) {
constructor(key, value) {
this.key = key;
this.val = val;
this.value = value;
}

@@ -127,7 +127,7 @@ /**

* @param {BTNKey} key - The key for the new node.
* @param {V} val - The value for the new node.
* @param {V} value - The value for the new node.
* @returns {N} - The newly created BinaryTreeNode.
*/
createNode(key, val) {
return new BinaryTreeNode(key, val);
createNode(key, value) {
return new BinaryTreeNode(key, value);
}

@@ -151,6 +151,6 @@ /**

* @param {BTNKey | N | null} keyOrNode - The key or node to add to the binary tree.
* @param {V} val - The value for the new node (optional).
* @param {V} value - The value for the new node (optional).
* @returns {N | null | undefined} - The inserted node, or null if nothing was inserted, or undefined if the operation failed.
*/
add(keyOrNode, val) {
add(keyOrNode, value) {
const _bfs = (root, newNode) => {

@@ -181,3 +181,3 @@ const queue = new queue_1.Queue([root]);

else if (typeof keyOrNode === 'number') {
needInsert = this.createNode(keyOrNode, val);
needInsert = this.createNode(keyOrNode, value);
}

@@ -194,3 +194,3 @@ else if (keyOrNode instanceof BinaryTreeNode) {

if (existNode) {
existNode.val = val;
existNode.value = value;
inserted = existNode;

@@ -228,3 +228,3 @@ }

if (keyOrNode instanceof BinaryTreeNode) {
return this.add(keyOrNode.key, keyOrNode.val);
return this.add(keyOrNode.key, keyOrNode.value);
}

@@ -234,4 +234,4 @@ if (keyOrNode === null) {

}
const val = values === null || values === void 0 ? void 0 : values[i];
return this.add(keyOrNode, val);
const value = values === null || values === void 0 ? void 0 : values[i];
return this.add(keyOrNode, value);
});

@@ -1075,9 +1075,9 @@ }

_swap(srcNode, destNode) {
const { key, val } = destNode;
const tempNode = this.createNode(key, val);
const { key, value } = destNode;
const tempNode = this.createNode(key, value);
if (tempNode) {
destNode.key = srcNode.key;
destNode.val = srcNode.val;
destNode.value = srcNode.value;
srcNode.key = tempNode.key;
srcNode.val = tempNode.val;
srcNode.value = tempNode.value;
}

@@ -1084,0 +1084,0 @@ return destNode;

@@ -13,3 +13,3 @@ /**

export declare class BSTNode<V = any, N extends BSTNode<V, N> = BSTNodeNested<V>> extends BinaryTreeNode<V, N> {
constructor(key: BTNKey, val?: V);
constructor(key: BTNKey, value?: V);
}

@@ -28,7 +28,7 @@ export declare class BST<V = any, N extends BSTNode<V, N> = BSTNode<V, BSTNodeNested<V>>> extends BinaryTree<V, N> implements IBinaryTree<V, N> {

* the new node. It is used to determine the position of the node in the binary search tree.
* @param [val] - The parameter `val` is an optional value that can be assigned to the node. It
* @param [value] - The parameter `value` is an optional value that can be assigned to the node. It
* represents the value associated with the node in a binary search tree.
* @returns a new instance of the BSTNode class with the specified key and value.
*/
createNode(key: BTNKey, val?: V): N;
createNode(key: BTNKey, value?: V): N;
/**

@@ -39,3 +39,3 @@ * The `add` function in a binary search tree class inserts a new node with a given key and value

* `BTNKey` (which can be a number or a string), a `BSTNode` object, or `null`.
* @param [val] - The `val` parameter is the value to be assigned to the new node being added to the
* @param [value] - The `value` parameter is the value to be assigned to the new node being added to the
* binary search tree.

@@ -45,7 +45,7 @@ * @returns the inserted node (N) if it was successfully added to the binary search tree. If the node

*/
add(keyOrNode: BTNKey | N | null, val?: V): N | null | undefined;
add(keyOrNode: BTNKey | N | null, value?: V): N | null | undefined;
/**
* The `addMany` function is used to efficiently add multiple nodes to a binary search tree while
* maintaining balance.
* @param {[BTNKey | N, N['val']][]} keysOrNodes - The `arr` parameter in the `addMany` function
* @param {[BTNKey | N, N['value']][]} keysOrNodes - The `arr` parameter in the `addMany` function
* represents an array of keys or nodes that need to be added to the binary search tree. It can be an

@@ -52,0 +52,0 @@ * array of `BTNKey` or `N` (which represents the node type in the binary search tree) or

@@ -8,4 +8,4 @@ "use strict";

class BSTNode extends binary_tree_1.BinaryTreeNode {
constructor(key, val) {
super(key, val);
constructor(key, value) {
super(key, value);
}

@@ -35,8 +35,8 @@ }

* the new node. It is used to determine the position of the node in the binary search tree.
* @param [val] - The parameter `val` is an optional value that can be assigned to the node. It
* @param [value] - The parameter `value` is an optional value that can be assigned to the node. It
* represents the value associated with the node in a binary search tree.
* @returns a new instance of the BSTNode class with the specified key and value.
*/
createNode(key, val) {
return new BSTNode(key, val);
createNode(key, value) {
return new BSTNode(key, value);
}

@@ -48,3 +48,3 @@ /**

* `BTNKey` (which can be a number or a string), a `BSTNode` object, or `null`.
* @param [val] - The `val` parameter is the value to be assigned to the new node being added to the
* @param [value] - The `value` parameter is the value to be assigned to the new node being added to the
* binary search tree.

@@ -54,3 +54,3 @@ * @returns the inserted node (N) if it was successfully added to the binary search tree. If the node

*/
add(keyOrNode, val) {
add(keyOrNode, value) {
// TODO support node as a parameter

@@ -63,3 +63,3 @@ let inserted = null;

else if (typeof keyOrNode === 'number') {
newNode = this.createNode(keyOrNode, val);
newNode = this.createNode(keyOrNode, value);
}

@@ -81,3 +81,3 @@ else if (keyOrNode === null) {

if (newNode) {
cur.val = newNode.val;
cur.value = newNode.value;
}

@@ -135,3 +135,3 @@ //Duplicates are not accepted.

* maintaining balance.
* @param {[BTNKey | N, N['val']][]} keysOrNodes - The `arr` parameter in the `addMany` function
* @param {[BTNKey | N, N['value']][]} keysOrNodes - The `arr` parameter in the `addMany` function
* represents an array of keys or nodes that need to be added to the binary search tree. It can be an

@@ -180,3 +180,3 @@ * array of `BTNKey` or `N` (which represents the node type in the binary search tree) or

sortedKeysOrNodes = sorted.map(([keyOrNode]) => keyOrNode);
sortedData = sorted.map(([, val]) => val);
sortedData = sorted.map(([, value]) => value);
const recursive = (arr, data) => {

@@ -425,3 +425,3 @@ if (arr.length === 0)

const midNode = sorted[m];
this.add(midNode.key, midNode.val);
this.add(midNode.key, midNode.value);
buildBalanceBST(l, m - 1);

@@ -442,3 +442,3 @@ buildBalanceBST(m + 1, r);

const midNode = sorted[m];
this.add(midNode.key, midNode.val);
this.add(midNode.key, midNode.value);
stack.push([m + 1, r]);

@@ -445,0 +445,0 @@ stack.push([l, m - 1]);

@@ -5,3 +5,3 @@ import { BTNKey, RBColor, RBTreeNodeNested, RBTreeOptions } from '../../types';

export declare class RBTreeNode<V = any, N extends RBTreeNode<V, N> = RBTreeNodeNested<V>> extends BSTNode<V, N> {
constructor(key: BTNKey, val?: V);
constructor(key: BTNKey, value?: V);
private _color;

@@ -13,3 +13,3 @@ get color(): RBColor;

constructor(options?: RBTreeOptions);
createNode(key: BTNKey, val?: V): N;
createNode(key: BTNKey, value?: V): N;
}

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

class RBTreeNode extends bst_1.BSTNode {
constructor(key, val) {
super(key, val);
constructor(key, value) {
super(key, value);
this._color = types_1.RBColor.RED;

@@ -24,6 +24,6 @@ }

}
createNode(key, val) {
return new RBTreeNode(key, val);
createNode(key, value) {
return new RBTreeNode(key, value);
}
}
exports.RBTree = RBTree;

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

export declare class SegmentTreeNode {
constructor(start: number, end: number, sum: number, val?: SegmentTreeNodeVal | null);
constructor(start: number, end: number, sum: number, value?: SegmentTreeNodeVal | null);
private _start;

@@ -18,5 +18,5 @@ get start(): number;

set end(v: number);
private _val;
get val(): SegmentTreeNodeVal | null;
set val(v: SegmentTreeNodeVal | null);
private _value;
get value(): SegmentTreeNodeVal | null;
set value(v: SegmentTreeNodeVal | null);
private _sum;

@@ -67,8 +67,8 @@ get sum(): number;

* the `SegmentTreeNode` at the specified `index`.
* @param {SegmentTreeNodeVal} [val] - The `val` parameter is an optional value that can be assigned to the `val`
* @param {SegmentTreeNodeVal} [value] - The `value` parameter is an optional value that can be assigned to the `value`
* property of the `SegmentTreeNode` object. It is not currently used in the code, but you can uncomment the line `//
* cur.val = val;` and pass a value for `val` in the
* cur.value = value;` and pass a value for `value` in the
* @returns The function does not return anything.
*/
updateNode(index: number, sum: number, val?: SegmentTreeNodeVal): void;
updateNode(index: number, sum: number, value?: SegmentTreeNodeVal): void;
/**

@@ -75,0 +75,0 @@ * The function `querySumByRange` calculates the sum of values within a given range in a segment tree.

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

class SegmentTreeNode {
constructor(start, end, sum, val) {
constructor(start, end, sum, value) {
this._start = 0;
this._end = 0;
this._val = null;
this._value = null;
this._sum = 0;

@@ -23,3 +23,3 @@ this._left = null;

this._sum = sum;
this._val = val || null;
this._value = value || null;
}

@@ -38,7 +38,7 @@ get start() {

}
get val() {
return this._val;
get value() {
return this._value;
}
set val(v) {
this._val = v;
set value(v) {
this._value = v;
}

@@ -132,8 +132,8 @@ get sum() {

* the `SegmentTreeNode` at the specified `index`.
* @param {SegmentTreeNodeVal} [val] - The `val` parameter is an optional value that can be assigned to the `val`
* @param {SegmentTreeNodeVal} [value] - The `value` parameter is an optional value that can be assigned to the `value`
* property of the `SegmentTreeNode` object. It is not currently used in the code, but you can uncomment the line `//
* cur.val = val;` and pass a value for `val` in the
* cur.value = value;` and pass a value for `value` in the
* @returns The function does not return anything.
*/
updateNode(index, sum, val) {
updateNode(index, sum, value) {
const root = this.root || null;

@@ -143,7 +143,7 @@ if (!root) {

}
const dfs = (cur, index, sum, val) => {
const dfs = (cur, index, sum, value) => {
if (cur.start === cur.end && cur.start === index) {
cur.sum = sum;
if (val !== undefined)
cur.val = val;
if (value !== undefined)
cur.value = value;
return;

@@ -154,3 +154,3 @@ }

if (cur.left) {
dfs(cur.left, index, sum, val);
dfs(cur.left, index, sum, value);
}

@@ -160,3 +160,3 @@ }

if (cur.right) {
dfs(cur.right, index, sum, val);
dfs(cur.right, index, sum, value);
}

@@ -168,3 +168,3 @@ }

};
dfs(root, index, sum, val);
dfs(root, index, sum, value);
}

@@ -171,0 +171,0 @@ /**

@@ -18,3 +18,3 @@ /**

* of the binary tree node.
* @param {V} [val] - The `val` parameter is an optional parameter of type `V`. It represents the value of the binary
* @param {V} [value] - The `value` parameter is an optional parameter of type `V`. It represents the value of the binary
* tree node. If no value is provided, it will be `undefined`.

@@ -25,3 +25,3 @@ * @param {number} [count=1] - The `count` parameter is a number that represents the number of times a particular value

*/
constructor(key: BTNKey, val?: V, count?: number);
constructor(key: BTNKey, value?: V, count?: number);
}

@@ -45,3 +45,3 @@ /**

* distinguish one node from another in the tree.
* @param {N} val - The `val` parameter represents the value that will be stored in the binary search tree node.
* @param {N} value - The `value` parameter represents the value that will be stored in the binary search tree node.
* @param {number} [count] - The "count" parameter is an optional parameter of type number. It represents the number of

@@ -51,3 +51,3 @@ * occurrences of the value in the binary search tree node. If not provided, the count will default to 1.

*/
createNode(key: BTNKey, val?: V, count?: number): N;
createNode(key: BTNKey, value?: V, count?: number): N;
/**

@@ -59,3 +59,3 @@ * The `add` function adds a new node to a binary search tree, updating the count if the key already

* node to be added), or `null` (which represents a null node).
* @param [val] - The `val` parameter represents the value associated with the key that is being
* @param [value] - The `value` parameter represents the value associated with the key that is being
* added to the binary tree.

@@ -67,3 +67,3 @@ * @param [count=1] - The `count` parameter represents the number of occurrences of the key/value

*/
add(keyOrNode: BTNKey | N | null, val?: V, count?: number): N | null | undefined;
add(keyOrNode: BTNKey | N | null, value?: V, count?: number): N | null | undefined;
/**

@@ -70,0 +70,0 @@ * The function adds a new node to a binary tree if there is an available slot in the parent node.

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

* of the binary tree node.
* @param {V} [val] - The `val` parameter is an optional parameter of type `V`. It represents the value of the binary
* @param {V} [value] - The `value` parameter is an optional parameter of type `V`. It represents the value of the binary
* tree node. If no value is provided, it will be `undefined`.

@@ -18,4 +18,4 @@ * @param {number} [count=1] - The `count` parameter is a number that represents the number of times a particular value

*/
constructor(key, val, count = 1) {
super(key, val);
constructor(key, value, count = 1) {
super(key, value);
this.count = count;

@@ -46,3 +46,3 @@ }

* distinguish one node from another in the tree.
* @param {N} val - The `val` parameter represents the value that will be stored in the binary search tree node.
* @param {N} value - The `value` parameter represents the value that will be stored in the binary search tree node.
* @param {number} [count] - The "count" parameter is an optional parameter of type number. It represents the number of

@@ -52,4 +52,4 @@ * occurrences of the value in the binary search tree node. If not provided, the count will default to 1.

*/
createNode(key, val, count) {
return new TreeMultisetNode(key, val, count);
createNode(key, value, count) {
return new TreeMultisetNode(key, value, count);
}

@@ -62,3 +62,3 @@ /**

* node to be added), or `null` (which represents a null node).
* @param [val] - The `val` parameter represents the value associated with the key that is being
* @param [value] - The `value` parameter represents the value associated with the key that is being
* added to the binary tree.

@@ -70,6 +70,6 @@ * @param [count=1] - The `count` parameter represents the number of occurrences of the key/value

*/
add(keyOrNode, val, count = 1) {
add(keyOrNode, value, count = 1) {
let inserted = undefined, newNode;
if (keyOrNode instanceof TreeMultisetNode) {
newNode = this.createNode(keyOrNode.key, keyOrNode.val, keyOrNode.count);
newNode = this.createNode(keyOrNode.key, keyOrNode.value, keyOrNode.count);
}

@@ -80,3 +80,3 @@ else if (keyOrNode === null) {

else {
newNode = this.createNode(keyOrNode, val, count);
newNode = this.createNode(keyOrNode, value, count);
}

@@ -96,3 +96,3 @@ if (!this.root) {

if (this._compare(cur.key, newNode.key) === types_1.CP.eq) {
cur.val = newNode.val;
cur.value = newNode.value;
cur.count += newNode.count;

@@ -198,3 +198,3 @@ this._setCount(this.count + newNode.count);

if (keyOrNode instanceof TreeMultisetNode) {
inserted.push(this.add(keyOrNode.key, keyOrNode.val, keyOrNode.count));
inserted.push(this.add(keyOrNode.key, keyOrNode.value, keyOrNode.count));
continue;

@@ -229,3 +229,3 @@ }

const midNode = sorted[m];
this.add(midNode.key, midNode.val, midNode.count);
this.add(midNode.key, midNode.value, midNode.count);
buildBalanceBST(l, m - 1);

@@ -246,3 +246,3 @@ buildBalanceBST(m + 1, r);

const midNode = sorted[m];
this.add(midNode.key, midNode.val, midNode.count);
this.add(midNode.key, midNode.value, midNode.count);
stack.push([m + 1, r]);

@@ -343,12 +343,12 @@ stack.push([l, m - 1]);

_swap(srcNode, destNode) {
const { key, val, count, height } = destNode;
const tempNode = this.createNode(key, val, count);
const { key, value, count, height } = destNode;
const tempNode = this.createNode(key, value, count);
if (tempNode) {
tempNode.height = height;
destNode.key = srcNode.key;
destNode.val = srcNode.val;
destNode.value = srcNode.value;
destNode.count = srcNode.count;
destNode.height = srcNode.height;
srcNode.key = tempNode.key;
srcNode.val = tempNode.val;
srcNode.value = tempNode.value;
srcNode.count = tempNode.count;

@@ -355,0 +355,0 @@ srcNode.height = tempNode.height;

@@ -8,14 +8,14 @@ import type { DijkstraResult, VertexKey } from '../../types';

* used to uniquely identify the vertex object.
* @param {V} [val] - The parameter "val" is an optional parameter of type V. It is used to assign a value to the
* @param {V} [value] - The parameter "value" is an optional parameter of type V. It is used to assign a value to the
* vertex. If no value is provided, it will be set to undefined.
*/
protected constructor(key: VertexKey, val?: V);
protected constructor(key: VertexKey, value?: V);
private _key;
get key(): VertexKey;
set key(v: VertexKey);
private _val;
get val(): V | undefined;
set val(value: V | undefined);
private _value;
get value(): V | undefined;
set value(value: V | undefined);
}
export declare abstract class AbstractEdge<VO = any> {
export declare abstract class AbstractEdge<E = any> {
/**

@@ -27,9 +27,9 @@ * The above function is a protected constructor that initializes the weight, value, and hash code properties of an

* will be assigned.
* @param {VO} [val] - The `val` parameter is of type `VO`, which means it can be any type. It is an optional parameter,
* @param {VO} [value] - The `value` parameter is of type `VO`, which means it can be any type. It is an optional parameter,
* meaning it can be omitted when creating an instance of the class.
*/
protected constructor(weight?: number, val?: VO);
private _val;
get val(): VO | undefined;
set val(value: VO | undefined);
protected constructor(weight?: number, value?: E);
private _value;
get value(): E | undefined;
set value(value: E | undefined);
private _weight;

@@ -58,5 +58,5 @@ get weight(): number;

* @param key
* @param val
* @param value
*/
abstract createVertex(key: VertexKey, val?: V): VO;
abstract createVertex(key: VertexKey, value?: V): VO;
/**

@@ -68,5 +68,5 @@ * In TypeScript, a subclass inherits the interface implementation of its parent class, without needing to implement the same interface again in the subclass. This behavior differs from Java's approach. In Java, if a parent class implements an interface, the subclass needs to explicitly implement the same interface, even if the parent class has already implemented it.

* @param weight
* @param val
* @param value
*/
abstract createEdge(srcOrV1: VertexKey | string, destOrV2: VertexKey | string, weight?: number, val?: E): EO;
abstract createEdge(srcOrV1: VertexKey, destOrV2: VertexKey, weight?: number, value?: E): EO;
abstract deleteEdge(edge: EO): EO | null;

@@ -95,3 +95,3 @@ abstract getEdge(srcOrKey: VO | VertexKey, destOrKey: VO | VertexKey): EO | null;

addVertex(vertex: VO): boolean;
addVertex(key: VertexKey, val?: V): boolean;
addVertex(key: VertexKey, value?: V): boolean;
/**

@@ -122,3 +122,3 @@ * The `deleteVertex` function removes a vertex from a graph by its ID or by the vertex object itself.

addEdge(edge: EO): boolean;
addEdge(src: VO | VertexKey, dest: VO | VertexKey, weight?: number, val?: E): boolean;
addEdge(src: VO | VertexKey, dest: VO | VertexKey, weight?: number, value?: E): boolean;
/**

@@ -125,0 +125,0 @@ * The function sets the weight of an edge between two vertices in a graph.

@@ -19,8 +19,8 @@ "use strict";

* used to uniquely identify the vertex object.
* @param {V} [val] - The parameter "val" is an optional parameter of type V. It is used to assign a value to the
* @param {V} [value] - The parameter "value" is an optional parameter of type V. It is used to assign a value to the
* vertex. If no value is provided, it will be set to undefined.
*/
constructor(key, val) {
constructor(key, value) {
this._key = key;
this._val = val;
this._value = value;
}

@@ -33,7 +33,7 @@ get key() {

}
get val() {
return this._val;
get value() {
return this._value;
}
set val(value) {
this._val = value;
set value(value) {
this._value = value;
}

@@ -49,15 +49,15 @@ }

* will be assigned.
* @param {VO} [val] - The `val` parameter is of type `VO`, which means it can be any type. It is an optional parameter,
* @param {VO} [value] - The `value` parameter is of type `VO`, which means it can be any type. It is an optional parameter,
* meaning it can be omitted when creating an instance of the class.
*/
constructor(weight, val) {
constructor(weight, value) {
this._weight = weight !== undefined ? weight : 1;
this._val = val;
this._value = value;
this._hashCode = (0, utils_1.uuidV4)();
}
get val() {
return this._val;
get value() {
return this._value;
}
set val(value) {
this._val = value;
set value(value) {
this._value = value;
}

@@ -113,3 +113,3 @@ get weight() {

}
addVertex(keyOrVertex, val) {
addVertex(keyOrVertex, value) {
if (keyOrVertex instanceof AbstractVertex) {

@@ -119,3 +119,3 @@ return this._addVertexOnly(keyOrVertex);

else {
const newVertex = this.createVertex(keyOrVertex, val);
const newVertex = this.createVertex(keyOrVertex, value);
return this._addVertexOnly(newVertex);

@@ -160,3 +160,3 @@ }

}
addEdge(srcOrEdge, dest, weight, val) {
addEdge(srcOrEdge, dest, weight, value) {
if (srcOrEdge instanceof AbstractEdge) {

@@ -173,3 +173,3 @@ return this._addEdgeOnly(srcOrEdge);

dest = dest.key;
const newEdge = this.createEdge(srcOrEdge, dest, weight, val);
const newEdge = this.createEdge(srcOrEdge, dest, weight, value);
return this._addEdgeOnly(newEdge);

@@ -416,6 +416,6 @@ }

let minV = null;
for (const [key, val] of distMap) {
for (const [key, value] of distMap) {
if (!seen.has(key)) {
if (val < min) {
min = val;
if (value < min) {
min = value;
minV = key;

@@ -541,3 +541,3 @@ }

const heap = new priority_queue_1.PriorityQueue({ comparator: (a, b) => a.key - b.key });
heap.add({ key: 0, val: srcVertex });
heap.add({ key: 0, value: srcVertex });
distMap.set(srcVertex, 0);

@@ -570,3 +570,3 @@ preMap.set(srcVertex, null);

const dist = curHeapNode === null || curHeapNode === void 0 ? void 0 : curHeapNode.key;
const cur = curHeapNode === null || curHeapNode === void 0 ? void 0 : curHeapNode.val;
const cur = curHeapNode === null || curHeapNode === void 0 ? void 0 : curHeapNode.value;
if (dist !== undefined) {

@@ -592,3 +592,3 @@ if (cur) {

if (dist + weight < distSrcToNeighbor) {
heap.add({ key: dist + weight, val: neighbor });
heap.add({ key: dist + weight, value: neighbor });
preMap.set(neighbor, cur);

@@ -595,0 +595,0 @@ distMap.set(neighbor, dist + weight);

@@ -9,6 +9,6 @@ import { AbstractEdge, AbstractGraph, AbstractVertex } from './abstract-graph';

* used to uniquely identify the vertex within a graph or data structure.
* @param {V} [val] - The "val" parameter is an optional parameter of type V. It is used to initialize the value of the
* @param {V} [value] - The "value" parameter is an optional parameter of type V. It is used to initialize the value of the
* vertex. If no value is provided, the vertex will be initialized with a default value.
*/
constructor(key: VertexKey, val?: V);
constructor(key: VertexKey, value?: V);
}

@@ -24,6 +24,6 @@ export declare class DirectedEdge<E = any> extends AbstractEdge<E> {

* @param {number} [weight] - The weight parameter is an optional number that represents the weight of the edge.
* @param {E} [val] - The `val` parameter is an optional parameter of type `E`. It represents the value associated with
* @param {E} [value] - The `value` parameter is an optional parameter of type `E`. It represents the value associated with
* the edge.
*/
constructor(src: VertexKey, dest: VertexKey, weight?: number, val?: E);
constructor(src: VertexKey, dest: VertexKey, weight?: number, value?: E);
private _src;

@@ -53,8 +53,8 @@ get src(): VertexKey;

* could be a number or a string depending on how you want to identify your vertices.
* @param [val] - The 'val' parameter is an optional value that can be assigned to the vertex. If a value is provided,
* it will be assigned to the 'val' property of the vertex. If no value is provided, the 'val' property will be
* @param [value] - The 'value' parameter is an optional value that can be assigned to the vertex. If a value is provided,
* it will be assigned to the 'value' property of the vertex. If no value is provided, the 'value' property will be
* assigned the same value as the 'key' parameter
* @returns a new instance of a DirectedVertex object, casted as type VO.
*/
createVertex(key: VertexKey, val?: V): VO;
createVertex(key: VertexKey, value?: V): VO;
/**

@@ -70,11 +70,11 @@ * In TypeScript, a subclass inherits the interface implementation of its parent class, without needing to implement the same interface again in the subclass. This behavior differs from Java's approach. In Java, if a parent class implements an interface, the subclass needs to explicitly implement the same interface, even if the parent class has already implemented it.

* weight is provided, it defaults to 1.
* @param [val] - The 'val' parameter is an optional value that can be assigned to the edge. It can be of any type and
* @param [value] - The 'value' parameter is an optional value that can be assigned to the edge. It can be of any type and
* is used to store additional information or data associated with the edge.
* @returns a new instance of a DirectedEdge object, casted as type EO.
*/
createEdge(src: VertexKey, dest: VertexKey, weight?: number, val?: E): EO;
createEdge(src: VertexKey, dest: VertexKey, weight?: number, value?: E): EO;
/**
* The `getEdge` function retrieves an edge between two vertices based on their source and destination IDs.
* @param {VO | null | VertexKey} srcOrKey - The source vertex or its ID. It can be either a vertex object or a vertex ID.
* @param {VO | null | VertexKey} destOrKey - The `destOrKey` parameter in the `getEdge` function represents the
* @param {VO | VertexKey | null} srcOrKey - The source vertex or its ID. It can be either a vertex object or a vertex ID.
* @param {VO | VertexKey | null} destOrKey - The `destOrKey` parameter in the `getEdge` function represents the
* destination vertex of the edge. It can be either a vertex object (`VO`), a vertex ID (`VertexKey`), or `null` if the

@@ -84,3 +84,3 @@ * destination is not specified.

*/
getEdge(srcOrKey: VO | null | VertexKey, destOrKey: VO | null | VertexKey): EO | null;
getEdge(srcOrKey: VO | VertexKey | null, destOrKey: VO | VertexKey | null): EO | null;
/**

@@ -87,0 +87,0 @@ * The function removes an edge between two vertices in a graph and returns the removed edge.

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

* used to uniquely identify the vertex within a graph or data structure.
* @param {V} [val] - The "val" parameter is an optional parameter of type V. It is used to initialize the value of the
* @param {V} [value] - The "value" parameter is an optional parameter of type V. It is used to initialize the value of the
* vertex. If no value is provided, the vertex will be initialized with a default value.
*/
constructor(key, val) {
super(key, val);
constructor(key, value) {
super(key, value);
}

@@ -36,7 +36,7 @@ }

* @param {number} [weight] - The weight parameter is an optional number that represents the weight of the edge.
* @param {E} [val] - The `val` parameter is an optional parameter of type `E`. It represents the value associated with
* @param {E} [value] - The `value` parameter is an optional parameter of type `E`. It represents the value associated with
* the edge.
*/
constructor(src, dest, weight, val) {
super(weight, val);
constructor(src, dest, weight, value) {
super(weight, value);
this._src = src;

@@ -82,9 +82,9 @@ this._dest = dest;

* could be a number or a string depending on how you want to identify your vertices.
* @param [val] - The 'val' parameter is an optional value that can be assigned to the vertex. If a value is provided,
* it will be assigned to the 'val' property of the vertex. If no value is provided, the 'val' property will be
* @param [value] - The 'value' parameter is an optional value that can be assigned to the vertex. If a value is provided,
* it will be assigned to the 'value' property of the vertex. If no value is provided, the 'value' property will be
* assigned the same value as the 'key' parameter
* @returns a new instance of a DirectedVertex object, casted as type VO.
*/
createVertex(key, val) {
return new DirectedVertex(key, val !== null && val !== void 0 ? val : key);
createVertex(key, value) {
return new DirectedVertex(key, value !== null && value !== void 0 ? value : key);
}

@@ -101,13 +101,13 @@ /**

* weight is provided, it defaults to 1.
* @param [val] - The 'val' parameter is an optional value that can be assigned to the edge. It can be of any type and
* @param [value] - The 'value' parameter is an optional value that can be assigned to the edge. It can be of any type and
* is used to store additional information or data associated with the edge.
* @returns a new instance of a DirectedEdge object, casted as type EO.
*/
createEdge(src, dest, weight, val) {
return new DirectedEdge(src, dest, weight !== null && weight !== void 0 ? weight : 1, val);
createEdge(src, dest, weight, value) {
return new DirectedEdge(src, dest, weight !== null && weight !== void 0 ? weight : 1, value);
}
/**
* The `getEdge` function retrieves an edge between two vertices based on their source and destination IDs.
* @param {VO | null | VertexKey} srcOrKey - The source vertex or its ID. It can be either a vertex object or a vertex ID.
* @param {VO | null | VertexKey} destOrKey - The `destOrKey` parameter in the `getEdge` function represents the
* @param {VO | VertexKey | null} srcOrKey - The source vertex or its ID. It can be either a vertex object or a vertex ID.
* @param {VO | VertexKey | null} destOrKey - The `destOrKey` parameter in the `getEdge` function represents the
* destination vertex of the edge. It can be either a vertex object (`VO`), a vertex ID (`VertexKey`), or `null` if the

@@ -114,0 +114,0 @@ * destination is not specified.

@@ -13,6 +13,6 @@ import { MapGraphCoordinate, VertexKey } from '../../types';

* values ranging from -180 to 180.
* @param {V} [val] - The "val" parameter is an optional value of type V. It is not required to be provided when
* @param {V} [value] - The "value" parameter is an optional value of type V. It is not required to be provided when
* creating an instance of the class.
*/
constructor(key: VertexKey, val: V, lat: number, long: number);
constructor(key: VertexKey, value: V, lat: number, long: number);
private _lat;

@@ -33,6 +33,6 @@ get lat(): number;

* @param {number} [weight] - The weight parameter is an optional number that represents the weight of the edge.
* @param {E} [val] - The "val" parameter is an optional parameter of type E. It is used to store additional
* @param {E} [value] - The "value" parameter is an optional parameter of type E. It is used to store additional
* information or data associated with the edge.
*/
constructor(src: VertexKey, dest: VertexKey, weight?: number, val?: E);
constructor(src: VertexKey, dest: VertexKey, weight?: number, value?: E);
}

@@ -60,4 +60,4 @@ export declare class MapGraph<V = any, E = any, VO extends MapVertex<V> = MapVertex<V>, EO extends MapEdge<E> = MapEdge<E>> extends DirectedGraph<V, E, VO, EO> {

* be a string or a number depending on how you define it in your code.
* @param [val] - The `val` parameter is an optional value that can be assigned to the `val` property of the vertex. It
* is of type `V`, which means it should be of the same type as the `val` property of the vertex class `VO`.
* @param [value] - The `value` parameter is an optional value that can be assigned to the `value` property of the vertex. It
* is of type `V`, which means it should be of the same type as the `value` property of the vertex class `VO`.
* @param {number} lat - The `lat` parameter represents the latitude of the vertex. It is a number that specifies the

@@ -68,3 +68,3 @@ * position of the vertex on the Earth's surface in the north-south direction.

*/
createVertex(key: VertexKey, val?: V, lat?: number, long?: number): VO;
createVertex(key: VertexKey, value?: V, lat?: number, long?: number): VO;
/**

@@ -78,7 +78,7 @@ * The function creates a new instance of a MapEdge with the given source, destination, weight, and value.

* If the weight is not provided, it can be set to a default value or left undefined.
* @param [val] - The `val` parameter is an optional value that can be assigned to the edge. It can be of any type,
* @param [value] - The `value` parameter is an optional value that can be assigned to the edge. It can be of any type,
* depending on the specific implementation of the `MapEdge` class.
* @returns a new instance of the `MapEdge` class, cast as type `EO`.
*/
createEdge(src: VertexKey, dest: VertexKey, weight?: number, val?: E): EO;
createEdge(src: VertexKey, dest: VertexKey, weight?: number, value?: E): EO;
}

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

* values ranging from -180 to 180.
* @param {V} [val] - The "val" parameter is an optional value of type V. It is not required to be provided when
* @param {V} [value] - The "value" parameter is an optional value of type V. It is not required to be provided when
* creating an instance of the class.
*/
constructor(key, val, lat, long) {
super(key, val);
constructor(key, value, lat, long) {
super(key, value);
this._lat = lat;

@@ -46,7 +46,7 @@ this._long = long;

* @param {number} [weight] - The weight parameter is an optional number that represents the weight of the edge.
* @param {E} [val] - The "val" parameter is an optional parameter of type E. It is used to store additional
* @param {E} [value] - The "value" parameter is an optional parameter of type E. It is used to store additional
* information or data associated with the edge.
*/
constructor(src, dest, weight, val) {
super(src, dest, weight, val);
constructor(src, dest, weight, value) {
super(src, dest, weight, value);
}

@@ -87,4 +87,4 @@ }

* be a string or a number depending on how you define it in your code.
* @param [val] - The `val` parameter is an optional value that can be assigned to the `val` property of the vertex. It
* is of type `V`, which means it should be of the same type as the `val` property of the vertex class `VO`.
* @param [value] - The `value` parameter is an optional value that can be assigned to the `value` property of the vertex. It
* is of type `V`, which means it should be of the same type as the `value` property of the vertex class `VO`.
* @param {number} lat - The `lat` parameter represents the latitude of the vertex. It is a number that specifies the

@@ -95,4 +95,4 @@ * position of the vertex on the Earth's surface in the north-south direction.

*/
createVertex(key, val, lat = this.origin[0], long = this.origin[1]) {
return new MapVertex(key, val, lat, long);
createVertex(key, value, lat = this.origin[0], long = this.origin[1]) {
return new MapVertex(key, value, lat, long);
}

@@ -107,10 +107,10 @@ /**

* If the weight is not provided, it can be set to a default value or left undefined.
* @param [val] - The `val` parameter is an optional value that can be assigned to the edge. It can be of any type,
* @param [value] - The `value` parameter is an optional value that can be assigned to the edge. It can be of any type,
* depending on the specific implementation of the `MapEdge` class.
* @returns a new instance of the `MapEdge` class, cast as type `EO`.
*/
createEdge(src, dest, weight, val) {
return new MapEdge(src, dest, weight, val);
createEdge(src, dest, weight, value) {
return new MapEdge(src, dest, weight, value);
}
}
exports.MapGraph = MapGraph;

@@ -9,6 +9,6 @@ import { AbstractEdge, AbstractGraph, AbstractVertex } from './abstract-graph';

* used to uniquely identify the vertex within a graph or network.
* @param {V} [val] - The "val" parameter is an optional parameter of type V. It is used to initialize the value of the
* @param {V} [value] - The "value" parameter is an optional parameter of type V. It is used to initialize the value of the
* vertex. If no value is provided, the vertex will be initialized with a default value.
*/
constructor(key: VertexKey, val?: V);
constructor(key: VertexKey, value?: V);
}

@@ -23,6 +23,6 @@ export declare class UndirectedEdge<E = number> extends AbstractEdge<E> {

* @param {number} [weight] - The weight parameter is an optional number that represents the weight of the edge.
* @param {E} [val] - The "val" parameter is an optional parameter of type E. It is used to store a value associated
* @param {E} [value] - The "value" parameter is an optional parameter of type E. It is used to store a value associated
* with the edge.
*/
constructor(v1: VertexKey, v2: VertexKey, weight?: number, val?: E);
constructor(v1: VertexKey, v2: VertexKey, weight?: number, value?: E);
private _vertices;

@@ -43,3 +43,3 @@ get vertices(): [VertexKey, VertexKey];

* vertex from another in the graph.
* @param [val] - The `val` parameter is an optional value that can be assigned to the vertex. If a value is provided,
* @param [value] - The `value` parameter is an optional value that can be assigned to the vertex. If a value is provided,
* it will be used as the value of the vertex. If no value is provided, the `key` parameter will be used as the value of

@@ -49,3 +49,3 @@ * the vertex.

*/
createVertex(key: VertexKey, val?: VO['val']): VO;
createVertex(key: VertexKey, value?: VO['value']): VO;
/**

@@ -57,16 +57,16 @@ * The function creates an undirected edge between two vertices with an optional weight and value.

* no weight is provided, it defaults to 1.
* @param [val] - The `val` parameter is an optional value that can be assigned to the edge. It can be of any type and
* @param [value] - The `value` parameter is an optional value that can be assigned to the edge. It can be of any type and
* is used to store additional information or data associated with the edge.
* @returns a new instance of the `UndirectedEdge` class, which is casted as type `EO`.
*/
createEdge(v1: VertexKey, v2: VertexKey, weight?: number, val?: EO['val']): EO;
createEdge(v1: VertexKey, v2: VertexKey, weight?: number, value?: EO['value']): EO;
/**
* The function `getEdge` returns the first edge that connects two vertices, or null if no such edge exists.
* @param {VO | null | VertexKey} v1 - The parameter `v1` represents a vertex or vertex ID. It can be of type `VO` (vertex
* @param {VO | VertexKey | null} v1 - The parameter `v1` represents a vertex or vertex ID. It can be of type `VO` (vertex
* object), `null`, or `VertexKey` (a string or number representing the ID of a vertex).
* @param {VO | null | VertexKey} v2 - The parameter `v2` represents a vertex or vertex ID. It can be of type `VO` (vertex
* @param {VO | VertexKey | null} v2 - The parameter `v2` represents a vertex or vertex ID. It can be of type `VO` (vertex
* object), `null`, or `VertexKey` (vertex ID).
* @returns an edge (EO) or null.
*/
getEdge(v1: VO | null | VertexKey, v2: VO | null | VertexKey): EO | null;
getEdge(v1: VO | VertexKey | null, v2: VO | VertexKey | null): EO | null;
/**

@@ -73,0 +73,0 @@ * The function removes an edge between two vertices in a graph and returns the removed edge.

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

* used to uniquely identify the vertex within a graph or network.
* @param {V} [val] - The "val" parameter is an optional parameter of type V. It is used to initialize the value of the
* @param {V} [value] - The "value" parameter is an optional parameter of type V. It is used to initialize the value of the
* vertex. If no value is provided, the vertex will be initialized with a default value.
*/
constructor(key, val) {
super(key, val);
constructor(key, value) {
super(key, value);
}

@@ -35,7 +35,7 @@ }

* @param {number} [weight] - The weight parameter is an optional number that represents the weight of the edge.
* @param {E} [val] - The "val" parameter is an optional parameter of type E. It is used to store a value associated
* @param {E} [value] - The "value" parameter is an optional parameter of type E. It is used to store a value associated
* with the edge.
*/
constructor(v1, v2, weight, val) {
super(weight, val);
constructor(v1, v2, weight, value) {
super(weight, value);
this._vertices = [v1, v2];

@@ -66,3 +66,3 @@ }

* vertex from another in the graph.
* @param [val] - The `val` parameter is an optional value that can be assigned to the vertex. If a value is provided,
* @param [value] - The `value` parameter is an optional value that can be assigned to the vertex. If a value is provided,
* it will be used as the value of the vertex. If no value is provided, the `key` parameter will be used as the value of

@@ -72,4 +72,4 @@ * the vertex.

*/
createVertex(key, val) {
return new UndirectedVertex(key, val !== null && val !== void 0 ? val : key);
createVertex(key, value) {
return new UndirectedVertex(key, value !== null && value !== void 0 ? value : key);
}

@@ -82,14 +82,14 @@ /**

* no weight is provided, it defaults to 1.
* @param [val] - The `val` parameter is an optional value that can be assigned to the edge. It can be of any type and
* @param [value] - The `value` parameter is an optional value that can be assigned to the edge. It can be of any type and
* is used to store additional information or data associated with the edge.
* @returns a new instance of the `UndirectedEdge` class, which is casted as type `EO`.
*/
createEdge(v1, v2, weight, val) {
return new UndirectedEdge(v1, v2, weight !== null && weight !== void 0 ? weight : 1, val);
createEdge(v1, v2, weight, value) {
return new UndirectedEdge(v1, v2, weight !== null && weight !== void 0 ? weight : 1, value);
}
/**
* The function `getEdge` returns the first edge that connects two vertices, or null if no such edge exists.
* @param {VO | null | VertexKey} v1 - The parameter `v1` represents a vertex or vertex ID. It can be of type `VO` (vertex
* @param {VO | VertexKey | null} v1 - The parameter `v1` represents a vertex or vertex ID. It can be of type `VO` (vertex
* object), `null`, or `VertexKey` (a string or number representing the ID of a vertex).
* @param {VO | null | VertexKey} v2 - The parameter `v2` represents a vertex or vertex ID. It can be of type `VO` (vertex
* @param {VO | VertexKey | null} v2 - The parameter `v2` represents a vertex or vertex ID. It can be of type `VO` (vertex
* object), `null`, or `VertexKey` (vertex ID).

@@ -96,0 +96,0 @@ * @returns an edge (EO) or null.

@@ -10,5 +10,5 @@ /**

key: K;
val: V;
value: V;
next: HashTableNode<K, V> | null;
constructor(key: K, val: V);
constructor(key: K, value: V);
}

@@ -35,3 +35,3 @@ import { HashFunction } from '../../types';

* table. It is of type K, which is a generic type representing the key's data type.
* @param {V} val - The parameter `val` represents the value that you want to associate with the given key in the hash
* @param {V} value - The parameter `value` represents the value that you want to associate with the given key in the hash
* table.

@@ -41,3 +41,3 @@ * @returns Nothing is being returned. The return type of the `put` method is `void`, which means it does not return any

*/
set(key: K, val: V): void;
set(key: K, value: V): void;
/**

@@ -44,0 +44,0 @@ * The `get` function retrieves the value associated with a given key from a hash table.

@@ -12,5 +12,5 @@ "use strict";

class HashTableNode {
constructor(key, val) {
constructor(key, value) {
this.key = key;
this.val = val;
this.value = value;
this.next = null;

@@ -52,3 +52,3 @@ }

* table. It is of type K, which is a generic type representing the key's data type.
* @param {V} val - The parameter `val` represents the value that you want to associate with the given key in the hash
* @param {V} value - The parameter `value` represents the value that you want to associate with the given key in the hash
* table.

@@ -58,5 +58,5 @@ * @returns Nothing is being returned. The return type of the `put` method is `void`, which means it does not return any

*/
set(key, val) {
set(key, value) {
const index = this._hash(key);
const newNode = new HashTableNode(key, val);
const newNode = new HashTableNode(key, value);
if (!this._buckets[index]) {

@@ -71,3 +71,3 @@ this._buckets[index] = newNode;

// If the key already exists, update the value
currentNode.val = val;
currentNode.value = value;
return;

@@ -101,3 +101,3 @@ }

if (currentNode.key === key) {
return currentNode.val;
return currentNode.value;
}

@@ -230,3 +230,3 @@ currentNode = currentNode.next;

const newIndex = this._hash(currentNode.key);
const newNode = new HashTableNode(currentNode.key, currentNode.val);
const newNode = new HashTableNode(currentNode.key, currentNode.value);
if (!newBuckets[newIndex]) {

@@ -233,0 +233,0 @@ newBuckets[newIndex] = newNode;

@@ -11,9 +11,9 @@ /**

* The constructor function initializes the value, next, and previous properties of an object.
* @param {E} val - The "val" parameter is the value that will be stored in the node. It can be of any data type, as it
* @param {E} value - The "value" parameter is the value that will be stored in the node. It can be of any data type, as it
* is defined as a generic type "E".
*/
constructor(val: E);
private _val;
get val(): E;
set val(value: E);
constructor(value: E);
private _value;
get value(): E;
set value(value: E);
private _next;

@@ -49,13 +49,13 @@ get next(): DoublyLinkedListNode<E> | null;

* The push function adds a new node with the given value to the end of the doubly linked list.
* @param {E} val - The value to be added to the linked list.
* @param {E} value - The value to be added to the linked list.
*/
push(val: E): void;
push(value: E): void;
/**
* The addLast function adds a new node with the given value to the end of the doubly linked list.
* @param {E} val - The value to be added to the linked list.
* @param {E} value - The value to be added to the linked list.
*/
addLast(val: E): void;
addLast(value: E): void;
/**
* The `pop()` 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.val) if the list is not empty. If the
* @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 null.

@@ -66,3 +66,3 @@ */

* The `popLast()` 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.val) if the list is not empty. If the
* @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 null.

@@ -85,12 +85,12 @@ */

* The unshift function adds a new node with the given value to the beginning of a doubly linked list.
* @param {E} val - The `val` parameter represents the value of the new node that will be added to the beginning of the
* @param {E} value - The `value` parameter represents the value of the new node that will be added to the beginning of the
* doubly linked list.
*/
unshift(val: E): void;
unshift(value: E): void;
/**
* The addFirst function adds a new node with the given value to the beginning of a doubly linked list.
* @param {E} val - The `val` parameter represents the value of the new node that will be added to the beginning of the
* @param {E} value - The `value` parameter represents the value of the new node that will be added to the beginning of the
* doubly linked list.
*/
addFirst(val: E): void;
addFirst(value: E): void;
/**

@@ -126,7 +126,7 @@ * The `getFirst` function returns the first node in a doubly linked list, or null if the list is empty.

* node if found, otherwise it returns null.
* @param {E} val - The `val` parameter is the value that we want to search for in the doubly linked list.
* @returns The function `findNodeByValue` returns a `DoublyLinkedListNode<E>` if a node with the specified value `val`
* @param {E} value - The `value` parameter is the value that we want to search for in the doubly linked list.
* @returns The function `findNodeByValue` returns a `DoublyLinkedListNode<E>` if a node with the specified value `value`
* is found in the linked list. If no such node is found, it returns `null`.
*/
getNode(val: E | null): DoublyLinkedListNode<E> | null;
getNode(value: E | null): DoublyLinkedListNode<E> | null;
/**

@@ -136,3 +136,3 @@ * The `insert` function inserts a value at a specified index in a doubly linked list.

* DoublyLinkedList. It is of type number.
* @param {E} val - The `val` parameter represents the value that you want to insert into the Doubly Linked List at the
* @param {E} value - The `value` parameter represents the value that you want to insert into the Doubly Linked List at the
* specified index.

@@ -142,3 +142,3 @@ * @returns The `insert` method returns a boolean value. It returns `true` if the insertion is successful, and `false`

*/
insertAt(index: number, val: E): boolean;
insertAt(index: number, value: E): boolean;
/**

@@ -192,11 +192,11 @@ * The `insertBefore` function inserts a new value before an existing value or node in a doubly linked list.

*/
find(callback: (val: E) => boolean): E | null;
find(callback: (value: E) => boolean): E | null;
/**
* The function returns the index of the first occurrence of a given value in a linked list.
* @param {E} val - The parameter `val` is of type `E`, which means it can be any data type. It represents the value
* @param {E} value - The parameter `value` is of type `E`, which means it can be any data type. It represents the value
* that we are searching for in the linked list.
* @returns The method `indexOf` returns the index of the first occurrence of the specified value `val` in the linked
* @returns The method `indexOf` returns the index of the first occurrence of the specified value `value` in the linked
* list. If the value is not found, it returns -1.
*/
indexOf(val: E): number;
indexOf(value: E): number;
/**

@@ -210,3 +210,3 @@ * The `findBackward` function iterates through a linked list from the last node to the first node and returns the last

*/
findBackward(callback: (val: E) => boolean): E | null;
findBackward(callback: (value: E) => boolean): E | null;
/**

@@ -223,7 +223,7 @@ * The `toArrayBackward` function converts a doubly linked list into an array in reverse order.

* The `forEach` function iterates over each element in a linked list and applies a callback function to each element.
* @param callback - The callback parameter is a function that takes two arguments: val and index. The val argument
* @param callback - The callback parameter is a function that takes two arguments: value and index. The value argument
* represents the value of the current node in the linked list, and the index argument represents the index of the
* current node in the linked list.
*/
forEach(callback: (val: E, index: number) => void): void;
forEach(callback: (value: E, index: number) => void): void;
/**

@@ -237,3 +237,3 @@ * The `map` function takes a callback function and applies it to each element in the DoublyLinkedList, returning a new

*/
map<U>(callback: (val: E) => U): DoublyLinkedList<U>;
map<U>(callback: (value: E) => U): DoublyLinkedList<U>;
/**

@@ -246,7 +246,7 @@ * The `filter` function iterates through a DoublyLinkedList and returns a new DoublyLinkedList containing only the

*/
filter(callback: (val: E) => boolean): DoublyLinkedList<E>;
filter(callback: (value: E) => boolean): DoublyLinkedList<E>;
/**
* The `reduce` function iterates over a linked list and applies a callback function to each element, accumulating a
* single value.
* @param callback - The `callback` parameter is a function that takes two arguments: `accumulator` and `val`. It is
* @param callback - The `callback` parameter is a function that takes two arguments: `accumulator` and `value`. It is
* used to perform a specific operation on each element of the linked list.

@@ -258,3 +258,3 @@ * @param {U} initialValue - The `initialValue` parameter is the initial value of the accumulator. It is the starting

*/
reduce<U>(callback: (accumulator: U, val: E) => U, initialValue: U): U;
reduce<U>(callback: (accumulator: U, value: E) => U, initialValue: U): U;
/**

@@ -261,0 +261,0 @@ * The `insertAfter` function inserts a new node with a given value after an existing node in a doubly linked list.

@@ -14,15 +14,15 @@ "use strict";

* The constructor function initializes the value, next, and previous properties of an object.
* @param {E} val - The "val" parameter is the value that will be stored in the node. It can be of any data type, as it
* @param {E} value - The "value" parameter is the value that will be stored in the node. It can be of any data type, as it
* is defined as a generic type "E".
*/
constructor(val) {
this._val = val;
constructor(value) {
this._value = value;
this._next = null;
this._prev = null;
}
get val() {
return this._val;
get value() {
return this._value;
}
set val(value) {
this._val = value;
set value(value) {
this._value = value;
}

@@ -85,6 +85,6 @@ get next() {

* The push function adds a new node with the given value to the end of the doubly linked list.
* @param {E} val - The value to be added to the linked list.
* @param {E} value - The value to be added to the linked list.
*/
push(val) {
const newNode = new DoublyLinkedListNode(val);
push(value) {
const newNode = new DoublyLinkedListNode(value);
if (!this.head) {

@@ -103,10 +103,10 @@ this.head = newNode;

* The addLast function adds a new node with the given value to the end of the doubly linked list.
* @param {E} val - The value to be added to the linked list.
* @param {E} value - The value to be added to the linked list.
*/
addLast(val) {
this.push(val);
addLast(value) {
this.push(value);
}
/**
* The `pop()` 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.val) if the list is not empty. If the
* @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 null.

@@ -127,7 +127,7 @@ */

this._length--;
return removedNode.val;
return removedNode.value;
}
/**
* The `popLast()` 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.val) if the list is not empty. If the
* @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 null.

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

this._length--;
return removedNode.val;
return removedNode.value;
}

@@ -169,7 +169,7 @@ /**

* The unshift function adds a new node with the given value to the beginning of a doubly linked list.
* @param {E} val - The `val` parameter represents the value of the new node that will be added to the beginning of the
* @param {E} value - The `value` parameter represents the value of the new node that will be added to the beginning of the
* doubly linked list.
*/
unshift(val) {
const newNode = new DoublyLinkedListNode(val);
unshift(value) {
const newNode = new DoublyLinkedListNode(value);
if (!this.head) {

@@ -188,7 +188,7 @@ this.head = newNode;

* The addFirst function adds a new node with the given value to the beginning of a doubly linked list.
* @param {E} val - The `val` parameter represents the value of the new node that will be added to the beginning of the
* @param {E} value - The `value` parameter represents the value of the new node that will be added to the beginning of the
* doubly linked list.
*/
addFirst(val) {
this.unshift(val);
addFirst(value) {
this.unshift(value);
}

@@ -201,3 +201,3 @@ /**

var _a;
return (_a = this.head) === null || _a === void 0 ? void 0 : _a.val;
return (_a = this.head) === null || _a === void 0 ? void 0 : _a.value;
}

@@ -210,3 +210,3 @@ /**

var _a;
return (_a = this.tail) === null || _a === void 0 ? void 0 : _a.val;
return (_a = this.tail) === null || _a === void 0 ? void 0 : _a.value;
}

@@ -227,3 +227,3 @@ /**

}
return current.val;
return current.value;
}

@@ -250,10 +250,10 @@ /**

* node if found, otherwise it returns null.
* @param {E} val - The `val` parameter is the value that we want to search for in the doubly linked list.
* @returns The function `findNodeByValue` returns a `DoublyLinkedListNode<E>` if a node with the specified value `val`
* @param {E} value - The `value` parameter is the value that we want to search for in the doubly linked list.
* @returns The function `findNodeByValue` returns a `DoublyLinkedListNode<E>` if a node with the specified value `value`
* is found in the linked list. If no such node is found, it returns `null`.
*/
getNode(val) {
getNode(value) {
let current = this.head;
while (current) {
if (current.val === val) {
if (current.value === value) {
return current;

@@ -269,3 +269,3 @@ }

* DoublyLinkedList. It is of type number.
* @param {E} val - The `val` parameter represents the value that you want to insert into the Doubly Linked List at the
* @param {E} value - The `value` parameter represents the value that you want to insert into the Doubly Linked List at the
* specified index.

@@ -275,14 +275,14 @@ * @returns The `insert` method returns a boolean value. It returns `true` if the insertion is successful, and `false`

*/
insertAt(index, val) {
insertAt(index, value) {
if (index < 0 || index > this.length)
return false;
if (index === 0) {
this.unshift(val);
this.unshift(value);
return true;
}
if (index === this.length) {
this.push(val);
this.push(value);
return true;
}
const newNode = new DoublyLinkedListNode(val);
const newNode = new DoublyLinkedListNode(value);
const prevNode = this.getNodeAt(index - 1);

@@ -351,3 +351,3 @@ const nextNode = prevNode.next;

this._length--;
return removedNode.val;
return removedNode.value;
}

@@ -395,3 +395,3 @@ /**

while (current) {
array.push(current.val);
array.push(current.value);
current = current.next;

@@ -426,4 +426,4 @@ }

while (current) {
if (callback(current.val)) {
return current.val;
if (callback(current.value)) {
return current.value;
}

@@ -436,12 +436,12 @@ current = current.next;

* The function returns the index of the first occurrence of a given value in a linked list.
* @param {E} val - The parameter `val` is of type `E`, which means it can be any data type. It represents the value
* @param {E} value - The parameter `value` is of type `E`, which means it can be any data type. It represents the value
* that we are searching for in the linked list.
* @returns The method `indexOf` returns the index of the first occurrence of the specified value `val` in the linked
* @returns The method `indexOf` returns the index of the first occurrence of the specified value `value` in the linked
* list. If the value is not found, it returns -1.
*/
indexOf(val) {
indexOf(value) {
let index = 0;
let current = this.head;
while (current) {
if (current.val === val) {
if (current.value === value) {
return index;

@@ -465,4 +465,4 @@ }

while (current) {
if (callback(current.val)) {
return current.val;
if (callback(current.value)) {
return current.value;
}

@@ -481,3 +481,3 @@ current = current.prev;

while (current) {
array.push(current.val);
array.push(current.value);
current = current.prev;

@@ -501,3 +501,3 @@ }

* The `forEach` function iterates over each element in a linked list and applies a callback function to each element.
* @param callback - The callback parameter is a function that takes two arguments: val and index. The val argument
* @param callback - The callback parameter is a function that takes two arguments: value and index. The value argument
* represents the value of the current node in the linked list, and the index argument represents the index of the

@@ -510,3 +510,3 @@ * current node in the linked list.

while (current) {
callback(current.val, index);
callback(current.value, index);
current = current.next;

@@ -528,3 +528,3 @@ index++;

while (current) {
mappedList.push(callback(current.val));
mappedList.push(callback(current.value));
current = current.next;

@@ -545,4 +545,4 @@ }

while (current) {
if (callback(current.val)) {
filteredList.push(current.val);
if (callback(current.value)) {
filteredList.push(current.value);
}

@@ -556,3 +556,3 @@ current = current.next;

* single value.
* @param callback - The `callback` parameter is a function that takes two arguments: `accumulator` and `val`. It is
* @param callback - The `callback` parameter is a function that takes two arguments: `accumulator` and `value`. It is
* used to perform a specific operation on each element of the linked list.

@@ -568,3 +568,3 @@ * @param {U} initialValue - The `initialValue` parameter is the initial value of the accumulator. It is the starting

while (current) {
accumulator = callback(accumulator, current.val);
accumulator = callback(accumulator, current.value);
current = current.next;

@@ -613,3 +613,3 @@ }

while (current) {
yield current.val;
yield current.value;
current = current.next;

@@ -616,0 +616,0 @@ }

@@ -11,9 +11,9 @@ /**

* The constructor function initializes an instance of a class with a given value and sets the next property to null.
* @param {E} val - The "val" parameter is of type E, which means it can be any data type. It represents the value that
* @param {E} value - The "value" parameter is of type E, which means it can be any data type. It represents the value that
* will be stored in the node of a linked list.
*/
constructor(val: E);
private _val;
get val(): E;
set val(value: E);
constructor(value: E);
private _value;
get value(): E;
set value(value: E);
private _next;

@@ -44,13 +44,13 @@ get next(): SinglyLinkedListNode<E> | null;

/**
* The `push` function adds a new node with the given val to the end of a singly linked list.
* @param {E} val - The "val" parameter represents the value that you want to add to the linked list. It can be of
* The `push` function adds a new node with the given value to the end of a singly linked list.
* @param {E} value - The "value" parameter represents the value that you want to add to the linked list. It can be of
* any type (E) as specified in the generic type declaration of the class or function.
*/
push(val: E): void;
push(value: E): void;
/**
* The `push` function adds a new node with the given val to the end of a singly linked list.
* @param {E} val - The "val" parameter represents the value that you want to add to the linked list. It can be of
* The `push` function adds a new node with the given value to the end of a singly linked list.
* @param {E} value - The "value" parameter represents the value that you want to add to the linked list. It can be of
* any type (E) as specified in the generic type declaration of the class or function.
*/
addLast(val: E): void;
addLast(value: E): void;
/**

@@ -82,12 +82,12 @@ * The `pop()` function removes and returns the value of the last element in a linked list, updating the head and tail

* The unshift function adds a new node with the given value to the beginning of a singly linked list.
* @param {E} val - The parameter "val" represents the value of the new node that will be added to the beginning of the
* @param {E} value - The parameter "value" represents the value of the new node that will be added to the beginning of the
* linked list.
*/
unshift(val: E): void;
unshift(value: E): void;
/**
* The addFirst function adds a new node with the given value to the beginning of a singly linked list.
* @param {E} val - The parameter "val" represents the value of the new node that will be added to the beginning of the
* @param {E} value - The parameter "value" represents the value of the new node that will be added to the beginning of the
* linked list.
*/
addFirst(val: E): void;
addFirst(value: E): void;
/**

@@ -129,3 +129,3 @@ * The function `getAt` returns the value at a specified index in a linked list, or null if the index is out of range.

* linked list. It is of type number.
* @param {E} val - The `val` parameter represents the value that you want to insert into the linked list at the
* @param {E} value - The `value` parameter represents the value that you want to insert into the linked list at the
* specified index.

@@ -135,3 +135,3 @@ * @returns The `insert` method returns a boolean value. It returns `true` if the insertion is successful, and `false`

*/
insertAt(index: number, val: E): boolean;
insertAt(index: number, value: E): boolean;
/**

@@ -164,3 +164,3 @@ * The function checks if the length of a data structure is equal to zero and returns a boolean value indicating

*/
find(callback: (val: E) => boolean): E | null;
find(callback: (value: E) => boolean): E | null;
/**

@@ -207,7 +207,7 @@ * The `indexOf` function returns the index of the first occurrence of a given value in a linked list.

* The `forEach` function iterates over each element in a linked list and applies a callback function to each element.
* @param callback - The callback parameter is a function that takes two arguments: val and index. The val argument
* @param callback - The callback parameter is a function that takes two arguments: value and index. The value argument
* represents the value of the current node in the linked list, and the index argument represents the index of the
* current node in the linked list.
*/
forEach(callback: (val: E, index: number) => void): void;
forEach(callback: (value: E, index: number) => void): void;
/**

@@ -221,3 +221,3 @@ * The `map` function takes a callback function and applies it to each element in the SinglyLinkedList, returning a new

*/
map<U>(callback: (val: E) => U): SinglyLinkedList<U>;
map<U>(callback: (value: E) => U): SinglyLinkedList<U>;
/**

@@ -230,7 +230,7 @@ * The `filter` function iterates through a SinglyLinkedList and returns a new SinglyLinkedList containing only the

*/
filter(callback: (val: E) => boolean): SinglyLinkedList<E>;
filter(callback: (value: E) => boolean): SinglyLinkedList<E>;
/**
* The `reduce` function iterates over a linked list and applies a callback function to each element, accumulating a
* single value.
* @param callback - The `callback` parameter is a function that takes two arguments: `accumulator` and `val`. It is
* @param callback - The `callback` parameter is a function that takes two arguments: `accumulator` and `value`. It is
* used to perform a specific operation on each element of the linked list.

@@ -242,3 +242,3 @@ * @param {U} initialValue - The `initialValue` parameter is the initial value of the accumulator. It is the starting

*/
reduce<U>(callback: (accumulator: U, val: E) => U, initialValue: U): U;
reduce<U>(callback: (accumulator: U, value: E) => U, initialValue: U): U;
/**

@@ -245,0 +245,0 @@ * The function returns an iterator that iterates over the values of a linked list.

@@ -14,14 +14,14 @@ "use strict";

* The constructor function initializes an instance of a class with a given value and sets the next property to null.
* @param {E} val - The "val" parameter is of type E, which means it can be any data type. It represents the value that
* @param {E} value - The "value" parameter is of type E, which means it can be any data type. It represents the value that
* will be stored in the node of a linked list.
*/
constructor(val) {
this._val = val;
constructor(value) {
this._value = value;
this._next = null;
}
get val() {
return this._val;
get value() {
return this._value;
}
set val(value) {
this._val = value;
set value(value) {
this._value = value;
}

@@ -74,8 +74,8 @@ get next() {

/**
* The `push` function adds a new node with the given val to the end of a singly linked list.
* @param {E} val - The "val" parameter represents the value that you want to add to the linked list. It can be of
* The `push` function adds a new node with the given value to the end of a singly linked list.
* @param {E} value - The "value" parameter represents the value that you want to add to the linked list. It can be of
* any type (E) as specified in the generic type declaration of the class or function.
*/
push(val) {
const newNode = new SinglyLinkedListNode(val);
push(value) {
const newNode = new SinglyLinkedListNode(value);
if (!this.head) {

@@ -92,8 +92,8 @@ this.head = newNode;

/**
* The `push` function adds a new node with the given val to the end of a singly linked list.
* @param {E} val - The "val" parameter represents the value that you want to add to the linked list. It can be of
* The `push` function adds a new node with the given value to the end of a singly linked list.
* @param {E} value - The "value" parameter represents the value that you want to add to the linked list. It can be of
* any type (E) as specified in the generic type declaration of the class or function.
*/
addLast(val) {
this.push(val);
addLast(value) {
this.push(value);
}

@@ -110,7 +110,7 @@ /**

if (this.head === this.tail) {
const val = this.head.val;
const value = this.head.value;
this.head = null;
this.tail = null;
this._length--;
return val;
return value;
}

@@ -121,7 +121,7 @@ let current = this.head;

}
const val = this.tail.val;
const value = this.tail.value;
current.next = null;
this.tail = current;
this._length--;
return val;
return value;
}

@@ -147,3 +147,3 @@ /**

this._length--;
return removedNode.val;
return removedNode.value;
}

@@ -159,7 +159,7 @@ /**

* The unshift function adds a new node with the given value to the beginning of a singly linked list.
* @param {E} val - The parameter "val" represents the value of the new node that will be added to the beginning of the
* @param {E} value - The parameter "value" represents the value of the new node that will be added to the beginning of the
* linked list.
*/
unshift(val) {
const newNode = new SinglyLinkedListNode(val);
unshift(value) {
const newNode = new SinglyLinkedListNode(value);
if (!this.head) {

@@ -177,7 +177,7 @@ this.head = newNode;

* The addFirst function adds a new node with the given value to the beginning of a singly linked list.
* @param {E} val - The parameter "val" represents the value of the new node that will be added to the beginning of the
* @param {E} value - The parameter "value" represents the value of the new node that will be added to the beginning of the
* linked list.
*/
addFirst(val) {
this.unshift(val);
addFirst(value) {
this.unshift(value);
}

@@ -198,3 +198,3 @@ /**

}
return current.val;
return current.value;
}

@@ -233,3 +233,3 @@ /**

this._length--;
return removedNode.val;
return removedNode.value;
}

@@ -248,3 +248,3 @@ /**

if (valueOrNode instanceof SinglyLinkedListNode) {
value = valueOrNode.val;
value = valueOrNode.value;
}

@@ -256,3 +256,3 @@ else {

while (current) {
if (current.val === value) {
if (current.value === value) {
if (prev === null) {

@@ -282,3 +282,3 @@ this.head = current.next;

* linked list. It is of type number.
* @param {E} val - The `val` parameter represents the value that you want to insert into the linked list at the
* @param {E} value - The `value` parameter represents the value that you want to insert into the linked list at the
* specified index.

@@ -288,14 +288,14 @@ * @returns The `insert` method returns a boolean value. It returns `true` if the insertion is successful, and `false`

*/
insertAt(index, val) {
insertAt(index, value) {
if (index < 0 || index > this.length)
return false;
if (index === 0) {
this.unshift(val);
this.unshift(value);
return true;
}
if (index === this.length) {
this.push(val);
this.push(value);
return true;
}
const newNode = new SinglyLinkedListNode(val);
const newNode = new SinglyLinkedListNode(value);
const prevNode = this.getNodeAt(index - 1);

@@ -331,3 +331,3 @@ newNode.next = prevNode.next;

while (current) {
array.push(current.val);
array.push(current.value);
current = current.next;

@@ -365,4 +365,4 @@ }

while (current) {
if (callback(current.val)) {
return current.val;
if (callback(current.value)) {
return current.value;
}

@@ -383,3 +383,3 @@ current = current.next;

while (current) {
if (current.val === value) {
if (current.value === value) {
return index;

@@ -402,3 +402,3 @@ }

while (current) {
if (current.val === value) {
if (current.value === value) {
return current;

@@ -423,3 +423,3 @@ }

if (existingValueOrNode instanceof SinglyLinkedListNode) {
existingValue = existingValueOrNode.val;
existingValue = existingValueOrNode.value;
}

@@ -429,3 +429,3 @@ else {

}
if (this.head.val === existingValue) {
if (this.head.value === existingValue) {
this.unshift(newValue);

@@ -436,3 +436,3 @@ return true;

while (current.next) {
if (current.next.val === existingValue) {
if (current.next.value === existingValue) {
const newNode = new SinglyLinkedListNode(newValue);

@@ -485,3 +485,3 @@ newNode.next = current.next;

while (current) {
if (current.val === value) {
if (current.value === value) {
count++;

@@ -495,3 +495,3 @@ }

* The `forEach` function iterates over each element in a linked list and applies a callback function to each element.
* @param callback - The callback parameter is a function that takes two arguments: val and index. The val argument
* @param callback - The callback parameter is a function that takes two arguments: value and index. The value argument
* represents the value of the current node in the linked list, and the index argument represents the index of the

@@ -504,3 +504,3 @@ * current node in the linked list.

while (current) {
callback(current.val, index);
callback(current.value, index);
current = current.next;

@@ -522,3 +522,3 @@ index++;

while (current) {
mappedList.push(callback(current.val));
mappedList.push(callback(current.value));
current = current.next;

@@ -539,4 +539,4 @@ }

while (current) {
if (callback(current.val)) {
filteredList.push(current.val);
if (callback(current.value)) {
filteredList.push(current.value);
}

@@ -550,3 +550,3 @@ current = current.next;

* single value.
* @param callback - The `callback` parameter is a function that takes two arguments: `accumulator` and `val`. It is
* @param callback - The `callback` parameter is a function that takes two arguments: `accumulator` and `value`. It is
* used to perform a specific operation on each element of the linked list.

@@ -562,3 +562,3 @@ * @param {U} initialValue - The `initialValue` parameter is the initial value of the accumulator. It is the starting

while (current) {
accumulator = callback(accumulator, current.val);
accumulator = callback(accumulator, current.value);
current = current.next;

@@ -574,3 +574,3 @@ }

while (current) {
yield current.val;
yield current.value;
current = current.next;

@@ -577,0 +577,0 @@ }

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

var _a;
return (_a = this.head) === null || _a === void 0 ? void 0 : _a.val;
return (_a = this.head) === null || _a === void 0 ? void 0 : _a.value;
}

@@ -34,0 +34,0 @@ }

import { BinaryTreeNode } from '../data-structures';
import { BinaryTreeDeletedResult, BTNKey, BinaryTreeNodeNested, BTNCallback } from '../types';
export interface IBinaryTree<V = any, N extends BinaryTreeNode<V, N> = BinaryTreeNodeNested<V>> {
createNode(key: BTNKey, val?: N['val']): N;
add(keyOrNode: BTNKey | N | null, val?: N['val']): N | null | undefined;
createNode(key: BTNKey, value?: N['value']): N;
add(keyOrNode: BTNKey | N | null, value?: N['value']): N | null | undefined;
delete<C extends BTNCallback<N>>(identifier: ReturnType<C> | null, callback: C): BinaryTreeDeletedResult<N>[];
}
import { VertexKey } from '../types';
export interface IGraph<V, E, VO, EO> {
createVertex(key: VertexKey, val?: V): VO;
createEdge(srcOrV1: VertexKey | string, destOrV2: VertexKey | string, weight?: number, val?: E): EO;
createVertex(key: VertexKey, value?: V): VO;
createEdge(srcOrV1: VertexKey, destOrV2: VertexKey, weight?: number, value?: E): EO;
}
{
"name": "min-heap-typed",
"version": "1.39.5",
"version": "1.39.6",
"description": "Min Heap. Javascript & Typescript Data Structure.",

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

"dependencies": {
"data-structure-typed": "^1.39.5"
"data-structure-typed": "^1.39.6"
}
}

@@ -16,4 +16,4 @@ /**

constructor(key: BTNKey, val?: V) {
super(key, val);
constructor(key: BTNKey, value?: V) {
super(key, value);
this.height = 0;

@@ -41,9 +41,9 @@ }

* the new node. It is used to determine the position of the node in the binary search tree.
* @param [val] - The parameter `val` is an optional value that can be assigned to the node. It is of
* type `V`, which means it can be any value that is assignable to the `val` property of the
* @param [value] - The parameter `value` is an optional value that can be assigned to the node. It is of
* type `V`, which means it can be any value that is assignable to the `value` property of the
* node type `N`.
* @returns a new AVLTreeNode object with the specified key and value.
*/
override createNode(key: BTNKey, val?: V): N {
return new AVLTreeNode<V, N>(key, val) as N;
override createNode(key: BTNKey, value?: V): N {
return new AVLTreeNode<V, N>(key, value) as N;
}

@@ -56,9 +56,9 @@

* `BTNKey` or a `N` (which represents a node in the binary tree) or `null`.
* @param [val] - The `val` parameter is the value that you want to assign to the new node that you
* @param [value] - The `value` parameter is the value that you want to assign to the new node that you
* are adding to the binary search tree.
* @returns The method is returning the inserted node (`N`), `null`, or `undefined`.
*/
override add(keyOrNode: BTNKey | N | null, val?: V): N | null | undefined {
override add(keyOrNode: BTNKey | N | null, value?: V): N | null | undefined {
// TODO support node as a param
const inserted = super.add(keyOrNode, val);
const inserted = super.add(keyOrNode, value);
if (inserted) this._balancePath(inserted);

@@ -103,4 +103,4 @@ return inserted;

protected override _swap(srcNode: N, destNode: N): N {
const {key, val, height} = destNode;
const tempNode = this.createNode(key, val);
const {key, value, height} = destNode;
const tempNode = this.createNode(key, value);

@@ -111,7 +111,7 @@ if (tempNode) {

destNode.key = srcNode.key;
destNode.val = srcNode.val;
destNode.value = srcNode.value;
destNode.height = srcNode.height;
srcNode.key = tempNode.key;
srcNode.val = tempNode.val;
srcNode.value = tempNode.value;
srcNode.height = tempNode.height;

@@ -118,0 +118,0 @@ }

@@ -29,3 +29,3 @@ /**

*/
val: V | undefined;
value: V | undefined;

@@ -40,7 +40,7 @@ /**

* @param {BTNKey} key - The key associated with the node.
* @param {V} val - The value stored in the node.
* @param {V} value - The value stored in the node.
*/
constructor(key: BTNKey, val?: V) {
constructor(key: BTNKey, value?: V) {
this.key = key;
this.val = val;
this.value = value;
}

@@ -164,7 +164,7 @@

* @param {BTNKey} key - The key for the new node.
* @param {V} val - The value for the new node.
* @param {V} value - The value for the new node.
* @returns {N} - The newly created BinaryTreeNode.
*/
createNode(key: BTNKey, val?: V): N {
return new BinaryTreeNode<V, N>(key, val) as N;
createNode(key: BTNKey, value?: V): N {
return new BinaryTreeNode<V, N>(key, value) as N;
}

@@ -191,6 +191,6 @@

* @param {BTNKey | N | null} keyOrNode - The key or node to add to the binary tree.
* @param {V} val - The value for the new node (optional).
* @param {V} value - The value for the new node (optional).
* @returns {N | null | undefined} - The inserted node, or null if nothing was inserted, or undefined if the operation failed.
*/
add(keyOrNode: BTNKey | N | null, val?: V): N | null | undefined {
add(keyOrNode: BTNKey | N | null, value?: V): N | null | undefined {
const _bfs = (root: N, newNode: N | null): N | undefined | null => {

@@ -216,3 +216,3 @@ const queue = new Queue<N | null>([root]);

} else if (typeof keyOrNode === 'number') {
needInsert = this.createNode(keyOrNode, val);
needInsert = this.createNode(keyOrNode, value);
} else if (keyOrNode instanceof BinaryTreeNode) {

@@ -229,3 +229,3 @@ needInsert = keyOrNode;

if (existNode) {
existNode.val = val;
existNode.value = value;
inserted = existNode;

@@ -261,3 +261,3 @@ } else {

if (keyOrNode instanceof BinaryTreeNode) {
return this.add(keyOrNode.key, keyOrNode.val);
return this.add(keyOrNode.key, keyOrNode.value);
}

@@ -269,4 +269,4 @@

const val = values?.[i];
return this.add(keyOrNode, val);
const value = values?.[i];
return this.add(keyOrNode, value);
});

@@ -1223,11 +1223,11 @@ }

protected _swap(srcNode: N, destNode: N): N {
const {key, val} = destNode;
const tempNode = this.createNode(key, val);
const {key, value} = destNode;
const tempNode = this.createNode(key, value);
if (tempNode) {
destNode.key = srcNode.key;
destNode.val = srcNode.val;
destNode.value = srcNode.value;
srcNode.key = tempNode.key;
srcNode.val = tempNode.val;
srcNode.value = tempNode.value;
}

@@ -1234,0 +1234,0 @@

@@ -15,4 +15,4 @@ /**

export class BSTNode<V = any, N extends BSTNode<V, N> = BSTNodeNested<V>> extends BinaryTreeNode<V, N> {
constructor(key: BTNKey, val?: V) {
super(key, val);
constructor(key: BTNKey, value?: V) {
super(key, value);
}

@@ -45,8 +45,8 @@ }

* the new node. It is used to determine the position of the node in the binary search tree.
* @param [val] - The parameter `val` is an optional value that can be assigned to the node. It
* @param [value] - The parameter `value` is an optional value that can be assigned to the node. It
* represents the value associated with the node in a binary search tree.
* @returns a new instance of the BSTNode class with the specified key and value.
*/
override createNode(key: BTNKey, val?: V): N {
return new BSTNode<V, N>(key, val) as N;
override createNode(key: BTNKey, value?: V): N {
return new BSTNode<V, N>(key, value) as N;
}

@@ -59,3 +59,3 @@

* `BTNKey` (which can be a number or a string), a `BSTNode` object, or `null`.
* @param [val] - The `val` parameter is the value to be assigned to the new node being added to the
* @param [value] - The `value` parameter is the value to be assigned to the new node being added to the
* binary search tree.

@@ -65,3 +65,3 @@ * @returns the inserted node (N) if it was successfully added to the binary search tree. If the node

*/
override add(keyOrNode: BTNKey | N | null, val?: V): N | null | undefined {
override add(keyOrNode: BTNKey | N | null, value?: V): N | null | undefined {
// TODO support node as a parameter

@@ -73,3 +73,3 @@ let inserted: N | null = null;

} else if (typeof keyOrNode === 'number') {
newNode = this.createNode(keyOrNode, val);
newNode = this.createNode(keyOrNode, value);
} else if (keyOrNode === null) {

@@ -89,3 +89,3 @@ newNode = null;

if (newNode) {
cur.val = newNode.val;
cur.value = newNode.value;
}

@@ -137,3 +137,3 @@ //Duplicates are not accepted.

* maintaining balance.
* @param {[BTNKey | N, N['val']][]} keysOrNodes - The `arr` parameter in the `addMany` function
* @param {[BTNKey | N, N['value']][]} keysOrNodes - The `arr` parameter in the `addMany` function
* represents an array of keys or nodes that need to be added to the binary search tree. It can be an

@@ -164,6 +164,6 @@ * array of `BTNKey` or `N` (which represents the node type in the binary search tree) or

const inserted: (N | null | undefined)[] = [];
const combinedArr: [BTNKey | N, N['val']][] = keysOrNodes.map((value, index) => [value, data?.[index]]);
const combinedArr: [BTNKey | N, N['value']][] = keysOrNodes.map((value, index) => [value, data?.[index]]);
let sorted = [];
function isNodeOrNullTuple(arr: [BTNKey | N, N['val']][]): arr is [N, N['val']][] {
function isNodeOrNullTuple(arr: [BTNKey | N, N['value']][]): arr is [N, N['value']][] {
for (const [keyOrNode] of arr) if (keyOrNode instanceof BSTNode) return true;

@@ -173,3 +173,3 @@ return false;

function isBinaryTreeKeyOrNullTuple(arr: [BTNKey | N, N['val']][]): arr is [BTNKey, N['val']][] {
function isBinaryTreeKeyOrNullTuple(arr: [BTNKey | N, N['value']][]): arr is [BTNKey, N['value']][] {
for (const [keyOrNode] of arr) if (typeof keyOrNode === 'number') return true;

@@ -190,3 +190,3 @@ return false;

sortedKeysOrNodes = sorted.map(([keyOrNode]) => keyOrNode);
sortedData = sorted.map(([, val]) => val);
sortedData = sorted.map(([, value]) => value);
const recursive = (arr: (BTNKey | null | N)[], data?: (V | undefined)[]) => {

@@ -439,3 +439,3 @@ if (arr.length === 0) return;

const midNode = sorted[m];
this.add(midNode.key, midNode.val);
this.add(midNode.key, midNode.value);
buildBalanceBST(l, m - 1);

@@ -456,3 +456,3 @@ buildBalanceBST(m + 1, r);

const midNode = sorted[m];
this.add(midNode.key, midNode.val);
this.add(midNode.key, midNode.value);
stack.push([m + 1, r]);

@@ -459,0 +459,0 @@ stack.push([l, m - 1]);

@@ -6,4 +6,4 @@ import {BTNKey, RBColor, RBTreeNodeNested, RBTreeOptions} from '../../types';

export class RBTreeNode<V = any, N extends RBTreeNode<V, N> = RBTreeNodeNested<V>> extends BSTNode<V, N> {
constructor(key: BTNKey, val?: V) {
super(key, val);
constructor(key: BTNKey, value?: V) {
super(key, value);
this._color = RBColor.RED;

@@ -31,8 +31,8 @@ }

override createNode(key: BTNKey, val?: V): N {
return new RBTreeNode(key, val) as N;
override createNode(key: BTNKey, value?: V): N {
return new RBTreeNode(key, value) as N;
}
// override add(keyOrNode: BTNKey | N | null, val?: V): N | null | undefined {
// const inserted = super.add(keyOrNode, val);
// override add(keyOrNode: BTNKey | N | null, value?: V): N | null | undefined {
// const inserted = super.add(keyOrNode, value);
// if (inserted) this._fixInsertViolation(inserted);

@@ -39,0 +39,0 @@ // return inserted;

@@ -12,7 +12,7 @@ /**

export class SegmentTreeNode {
constructor(start: number, end: number, sum: number, val?: SegmentTreeNodeVal | null) {
constructor(start: number, end: number, sum: number, value?: SegmentTreeNodeVal | null) {
this._start = start;
this._end = end;
this._sum = sum;
this._val = val || null;
this._value = value || null;
}

@@ -39,10 +39,10 @@

private _val: SegmentTreeNodeVal | null = null;
private _value: SegmentTreeNodeVal | null = null;
get val(): SegmentTreeNodeVal | null {
return this._val;
get value(): SegmentTreeNodeVal | null {
return this._value;
}
set val(v: SegmentTreeNodeVal | null) {
this._val = v;
set value(v: SegmentTreeNodeVal | null) {
this._value = v;
}

@@ -159,8 +159,8 @@

* the `SegmentTreeNode` at the specified `index`.
* @param {SegmentTreeNodeVal} [val] - The `val` parameter is an optional value that can be assigned to the `val`
* @param {SegmentTreeNodeVal} [value] - The `value` parameter is an optional value that can be assigned to the `value`
* property of the `SegmentTreeNode` object. It is not currently used in the code, but you can uncomment the line `//
* cur.val = val;` and pass a value for `val` in the
* cur.value = value;` and pass a value for `value` in the
* @returns The function does not return anything.
*/
updateNode(index: number, sum: number, val?: SegmentTreeNodeVal) {
updateNode(index: number, sum: number, value?: SegmentTreeNodeVal) {
const root = this.root || null;

@@ -170,6 +170,6 @@ if (!root) {

}
const dfs = (cur: SegmentTreeNode, index: number, sum: number, val?: SegmentTreeNodeVal) => {
const dfs = (cur: SegmentTreeNode, index: number, sum: number, value?: SegmentTreeNodeVal) => {
if (cur.start === cur.end && cur.start === index) {
cur.sum = sum;
if (val !== undefined) cur.val = val;
if (value !== undefined) cur.value = value;
return;

@@ -180,7 +180,7 @@ }

if (cur.left) {
dfs(cur.left, index, sum, val);
dfs(cur.left, index, sum, value);
}
} else {
if (cur.right) {
dfs(cur.right, index, sum, val);
dfs(cur.right, index, sum, value);
}

@@ -193,3 +193,3 @@ }

dfs(root, index, sum, val);
dfs(root, index, sum, value);
}

@@ -196,0 +196,0 @@

@@ -23,3 +23,3 @@ /**

* of the binary tree node.
* @param {V} [val] - The `val` parameter is an optional parameter of type `V`. It represents the value of the binary
* @param {V} [value] - The `value` parameter is an optional parameter of type `V`. It represents the value of the binary
* tree node. If no value is provided, it will be `undefined`.

@@ -30,4 +30,4 @@ * @param {number} [count=1] - The `count` parameter is a number that represents the number of times a particular value

*/
constructor(key: BTNKey, val?: V, count = 1) {
super(key, val);
constructor(key: BTNKey, value?: V, count = 1) {
super(key, value);
this.count = count;

@@ -64,3 +64,3 @@ }

* distinguish one node from another in the tree.
* @param {N} val - The `val` parameter represents the value that will be stored in the binary search tree node.
* @param {N} value - The `value` parameter represents the value that will be stored in the binary search tree node.
* @param {number} [count] - The "count" parameter is an optional parameter of type number. It represents the number of

@@ -70,4 +70,4 @@ * occurrences of the value in the binary search tree node. If not provided, the count will default to 1.

*/
override createNode(key: BTNKey, val?: V, count?: number): N {
return new TreeMultisetNode(key, val, count) as N;
override createNode(key: BTNKey, value?: V, count?: number): N {
return new TreeMultisetNode(key, value, count) as N;
}

@@ -81,3 +81,3 @@

* node to be added), or `null` (which represents a null node).
* @param [val] - The `val` parameter represents the value associated with the key that is being
* @param [value] - The `value` parameter represents the value associated with the key that is being
* added to the binary tree.

@@ -89,11 +89,11 @@ * @param [count=1] - The `count` parameter represents the number of occurrences of the key/value

*/
override add(keyOrNode: BTNKey | N | null, val?: V, count = 1): N | null | undefined {
override add(keyOrNode: BTNKey | N | null, value?: V, count = 1): N | null | undefined {
let inserted: N | null | undefined = undefined,
newNode: N | null;
if (keyOrNode instanceof TreeMultisetNode) {
newNode = this.createNode(keyOrNode.key, keyOrNode.val, keyOrNode.count);
newNode = this.createNode(keyOrNode.key, keyOrNode.value, keyOrNode.count);
} else if (keyOrNode === null) {
newNode = null;
} else {
newNode = this.createNode(keyOrNode, val, count);
newNode = this.createNode(keyOrNode, value, count);
}

@@ -112,3 +112,3 @@ if (!this.root) {

if (this._compare(cur.key, newNode.key) === CP.eq) {
cur.val = newNode.val;
cur.value = newNode.value;
cur.count += newNode.count;

@@ -209,3 +209,3 @@ this._setCount(this.count + newNode.count);

if (keyOrNode instanceof TreeMultisetNode) {
inserted.push(this.add(keyOrNode.key, keyOrNode.val, keyOrNode.count));
inserted.push(this.add(keyOrNode.key, keyOrNode.value, keyOrNode.count));
continue;

@@ -244,3 +244,3 @@ }

const midNode = sorted[m];
this.add(midNode.key, midNode.val, midNode.count);
this.add(midNode.key, midNode.value, midNode.count);
buildBalanceBST(l, m - 1);

@@ -261,3 +261,3 @@ buildBalanceBST(m + 1, r);

const midNode = sorted[m];
this.add(midNode.key, midNode.val, midNode.count);
this.add(midNode.key, midNode.value, midNode.count);
stack.push([m + 1, r]);

@@ -364,4 +364,4 @@ stack.push([l, m - 1]);

protected override _swap(srcNode: N, destNode: N): N {
const {key, val, count, height} = destNode;
const tempNode = this.createNode(key, val, count);
const {key, value, count, height} = destNode;
const tempNode = this.createNode(key, value, count);
if (tempNode) {

@@ -371,3 +371,3 @@ tempNode.height = height;

destNode.key = srcNode.key;
destNode.val = srcNode.val;
destNode.value = srcNode.value;
destNode.count = srcNode.count;

@@ -377,3 +377,3 @@ destNode.height = srcNode.height;

srcNode.key = tempNode.key;
srcNode.val = tempNode.val;
srcNode.value = tempNode.value;
srcNode.count = tempNode.count;

@@ -380,0 +380,0 @@ srcNode.height = tempNode.height;

@@ -19,8 +19,8 @@ /**

* used to uniquely identify the vertex object.
* @param {V} [val] - The parameter "val" is an optional parameter of type V. It is used to assign a value to the
* @param {V} [value] - The parameter "value" is an optional parameter of type V. It is used to assign a value to the
* vertex. If no value is provided, it will be set to undefined.
*/
protected constructor(key: VertexKey, val?: V) {
protected constructor(key: VertexKey, value?: V) {
this._key = key;
this._val = val;
this._value = value;
}

@@ -38,14 +38,14 @@

private _val: V | undefined;
private _value: V | undefined;
get val(): V | undefined {
return this._val;
get value(): V | undefined {
return this._value;
}
set val(value: V | undefined) {
this._val = value;
set value(value: V | undefined) {
this._value = value;
}
}
export abstract class AbstractEdge<VO = any> {
export abstract class AbstractEdge<E = any> {
/**

@@ -57,19 +57,19 @@ * The above function is a protected constructor that initializes the weight, value, and hash code properties of an

* will be assigned.
* @param {VO} [val] - The `val` parameter is of type `VO`, which means it can be any type. It is an optional parameter,
* @param {VO} [value] - The `value` parameter is of type `VO`, which means it can be any type. It is an optional parameter,
* meaning it can be omitted when creating an instance of the class.
*/
protected constructor(weight?: number, val?: VO) {
protected constructor(weight?: number, value?: E) {
this._weight = weight !== undefined ? weight : 1;
this._val = val;
this._value = value;
this._hashCode = uuidV4();
}
private _val: VO | undefined;
private _value: E | undefined;
get val(): VO | undefined {
return this._val;
get value(): E | undefined {
return this._value;
}
set val(value: VO | undefined) {
this._val = value;
set value(value: E | undefined) {
this._value = value;
}

@@ -125,5 +125,5 @@

* @param key
* @param val
* @param value
*/
abstract createVertex(key: VertexKey, val?: V): VO;
abstract createVertex(key: VertexKey, value?: V): VO;

@@ -136,5 +136,5 @@ /**

* @param weight
* @param val
* @param value
*/
abstract createEdge(srcOrV1: VertexKey | string, destOrV2: VertexKey | string, weight?: number, val?: E): EO;
abstract createEdge(srcOrV1: VertexKey, destOrV2: VertexKey, weight?: number, value?: E): EO;

@@ -178,9 +178,9 @@ abstract deleteEdge(edge: EO): EO | null;

addVertex(key: VertexKey, val?: V): boolean;
addVertex(key: VertexKey, value?: V): boolean;
addVertex(keyOrVertex: VertexKey | VO, val?: V): boolean {
addVertex(keyOrVertex: VertexKey | VO, value?: V): boolean {
if (keyOrVertex instanceof AbstractVertex) {
return this._addVertexOnly(keyOrVertex);
} else {
const newVertex = this.createVertex(keyOrVertex, val);
const newVertex = this.createVertex(keyOrVertex, value);
return this._addVertexOnly(newVertex);

@@ -231,5 +231,5 @@ }

addEdge(src: VO | VertexKey, dest: VO | VertexKey, weight?: number, val?: E): boolean;
addEdge(src: VO | VertexKey, dest: VO | VertexKey, weight?: number, value?: E): boolean;
addEdge(srcOrEdge: VO | VertexKey | EO, dest?: VO | VertexKey, weight?: number, val?: E): boolean {
addEdge(srcOrEdge: VO | VertexKey | EO, dest?: VO | VertexKey, weight?: number, value?: E): boolean {
if (srcOrEdge instanceof AbstractEdge) {

@@ -242,3 +242,3 @@ return this._addEdgeOnly(srcOrEdge);

if (dest instanceof AbstractVertex) dest = dest.key;
const newEdge = this.createEdge(srcOrEdge, dest, weight, val);
const newEdge = this.createEdge(srcOrEdge, dest, weight, value);
return this._addEdgeOnly(newEdge);

@@ -504,6 +504,6 @@ } else {

let minV: VO | null = null;
for (const [key, val] of distMap) {
for (const [key, value] of distMap) {
if (!seen.has(key)) {
if (val < min) {
min = val;
if (value < min) {
min = value;
minV = key;

@@ -637,4 +637,4 @@ }

const heap = new PriorityQueue<{key: number; val: VO}>({comparator: (a, b) => a.key - b.key});
heap.add({key: 0, val: srcVertex});
const heap = new PriorityQueue<{key: number; value: VO}>({comparator: (a, b) => a.key - b.key});
heap.add({key: 0, value: srcVertex});

@@ -669,3 +669,3 @@ distMap.set(srcVertex, 0);

const dist = curHeapNode?.key;
const cur = curHeapNode?.val;
const cur = curHeapNode?.value;
if (dist !== undefined) {

@@ -691,3 +691,3 @@ if (cur) {

if (dist + weight < distSrcToNeighbor) {
heap.add({key: dist + weight, val: neighbor});
heap.add({key: dist + weight, value: neighbor});
preMap.set(neighbor, cur);

@@ -694,0 +694,0 @@ distMap.set(neighbor, dist + weight);

@@ -18,7 +18,7 @@ /**

* used to uniquely identify the vertex within a graph or data structure.
* @param {V} [val] - The "val" parameter is an optional parameter of type V. It is used to initialize the value of the
* @param {V} [value] - The "value" parameter is an optional parameter of type V. It is used to initialize the value of the
* vertex. If no value is provided, the vertex will be initialized with a default value.
*/
constructor(key: VertexKey, val?: V) {
super(key, val);
constructor(key: VertexKey, value?: V) {
super(key, value);
}

@@ -36,7 +36,7 @@ }

* @param {number} [weight] - The weight parameter is an optional number that represents the weight of the edge.
* @param {E} [val] - The `val` parameter is an optional parameter of type `E`. It represents the value associated with
* @param {E} [value] - The `value` parameter is an optional parameter of type `E`. It represents the value associated with
* the edge.
*/
constructor(src: VertexKey, dest: VertexKey, weight?: number, val?: E) {
super(weight, val);
constructor(src: VertexKey, dest: VertexKey, weight?: number, value?: E) {
super(weight, value);
this._src = src;

@@ -104,9 +104,9 @@ this._dest = dest;

* could be a number or a string depending on how you want to identify your vertices.
* @param [val] - The 'val' parameter is an optional value that can be assigned to the vertex. If a value is provided,
* it will be assigned to the 'val' property of the vertex. If no value is provided, the 'val' property will be
* @param [value] - The 'value' parameter is an optional value that can be assigned to the vertex. If a value is provided,
* it will be assigned to the 'value' property of the vertex. If no value is provided, the 'value' property will be
* assigned the same value as the 'key' parameter
* @returns a new instance of a DirectedVertex object, casted as type VO.
*/
createVertex(key: VertexKey, val?: V): VO {
return new DirectedVertex(key, val ?? key) as VO;
createVertex(key: VertexKey, value?: V): VO {
return new DirectedVertex(key, value ?? key) as VO;
}

@@ -125,8 +125,8 @@

* weight is provided, it defaults to 1.
* @param [val] - The 'val' parameter is an optional value that can be assigned to the edge. It can be of any type and
* @param [value] - The 'value' parameter is an optional value that can be assigned to the edge. It can be of any type and
* is used to store additional information or data associated with the edge.
* @returns a new instance of a DirectedEdge object, casted as type EO.
*/
createEdge(src: VertexKey, dest: VertexKey, weight?: number, val?: E): EO {
return new DirectedEdge(src, dest, weight ?? 1, val) as EO;
createEdge(src: VertexKey, dest: VertexKey, weight?: number, value?: E): EO {
return new DirectedEdge(src, dest, weight ?? 1, value) as EO;
}

@@ -136,4 +136,4 @@

* The `getEdge` function retrieves an edge between two vertices based on their source and destination IDs.
* @param {VO | null | VertexKey} srcOrKey - The source vertex or its ID. It can be either a vertex object or a vertex ID.
* @param {VO | null | VertexKey} destOrKey - The `destOrKey` parameter in the `getEdge` function represents the
* @param {VO | VertexKey | null} srcOrKey - The source vertex or its ID. It can be either a vertex object or a vertex ID.
* @param {VO | VertexKey | null} destOrKey - The `destOrKey` parameter in the `getEdge` function represents the
* destination vertex of the edge. It can be either a vertex object (`VO`), a vertex ID (`VertexKey`), or `null` if the

@@ -143,3 +143,3 @@ * destination is not specified.

*/
getEdge(srcOrKey: VO | null | VertexKey, destOrKey: VO | null | VertexKey): EO | null {
getEdge(srcOrKey: VO | VertexKey | null, destOrKey: VO | VertexKey | null): EO | null {
let edges: EO[] = [];

@@ -146,0 +146,0 @@

@@ -14,7 +14,7 @@ import {MapGraphCoordinate, VertexKey} from '../../types';

* values ranging from -180 to 180.
* @param {V} [val] - The "val" parameter is an optional value of type V. It is not required to be provided when
* @param {V} [value] - The "value" parameter is an optional value of type V. It is not required to be provided when
* creating an instance of the class.
*/
constructor(key: VertexKey, val: V, lat: number, long: number) {
super(key, val);
constructor(key: VertexKey, value: V, lat: number, long: number) {
super(key, value);
this._lat = lat;

@@ -53,7 +53,7 @@ this._long = long;

* @param {number} [weight] - The weight parameter is an optional number that represents the weight of the edge.
* @param {E} [val] - The "val" parameter is an optional parameter of type E. It is used to store additional
* @param {E} [value] - The "value" parameter is an optional parameter of type E. It is used to store additional
* information or data associated with the edge.
*/
constructor(src: VertexKey, dest: VertexKey, weight?: number, val?: E) {
super(src, dest, weight, val);
constructor(src: VertexKey, dest: VertexKey, weight?: number, value?: E) {
super(src, dest, weight, value);
}

@@ -107,4 +107,4 @@ }

* be a string or a number depending on how you define it in your code.
* @param [val] - The `val` parameter is an optional value that can be assigned to the `val` property of the vertex. It
* is of type `V`, which means it should be of the same type as the `val` property of the vertex class `VO`.
* @param [value] - The `value` parameter is an optional value that can be assigned to the `value` property of the vertex. It
* is of type `V`, which means it should be of the same type as the `value` property of the vertex class `VO`.
* @param {number} lat - The `lat` parameter represents the latitude of the vertex. It is a number that specifies the

@@ -115,4 +115,4 @@ * position of the vertex on the Earth's surface in the north-south direction.

*/
override createVertex(key: VertexKey, val?: V, lat: number = this.origin[0], long: number = this.origin[1]): VO {
return new MapVertex(key, val, lat, long) as VO;
override createVertex(key: VertexKey, value?: V, lat: number = this.origin[0], long: number = this.origin[1]): VO {
return new MapVertex(key, value, lat, long) as VO;
}

@@ -128,9 +128,9 @@

* If the weight is not provided, it can be set to a default value or left undefined.
* @param [val] - The `val` parameter is an optional value that can be assigned to the edge. It can be of any type,
* @param [value] - The `value` parameter is an optional value that can be assigned to the edge. It can be of any type,
* depending on the specific implementation of the `MapEdge` class.
* @returns a new instance of the `MapEdge` class, cast as type `EO`.
*/
override createEdge(src: VertexKey, dest: VertexKey, weight?: number, val?: E): EO {
return new MapEdge(src, dest, weight, val) as EO;
override createEdge(src: VertexKey, dest: VertexKey, weight?: number, value?: E): EO {
return new MapEdge(src, dest, weight, value) as EO;
}
}

@@ -18,7 +18,7 @@ /**

* used to uniquely identify the vertex within a graph or network.
* @param {V} [val] - The "val" parameter is an optional parameter of type V. It is used to initialize the value of the
* @param {V} [value] - The "value" parameter is an optional parameter of type V. It is used to initialize the value of the
* vertex. If no value is provided, the vertex will be initialized with a default value.
*/
constructor(key: VertexKey, val?: V) {
super(key, val);
constructor(key: VertexKey, value?: V) {
super(key, value);
}

@@ -35,7 +35,7 @@ }

* @param {number} [weight] - The weight parameter is an optional number that represents the weight of the edge.
* @param {E} [val] - The "val" parameter is an optional parameter of type E. It is used to store a value associated
* @param {E} [value] - The "value" parameter is an optional parameter of type E. It is used to store a value associated
* with the edge.
*/
constructor(v1: VertexKey, v2: VertexKey, weight?: number, val?: E) {
super(weight, val);
constructor(v1: VertexKey, v2: VertexKey, weight?: number, value?: E) {
super(weight, value);
this._vertices = [v1, v2];

@@ -82,3 +82,3 @@ }

* vertex from another in the graph.
* @param [val] - The `val` parameter is an optional value that can be assigned to the vertex. If a value is provided,
* @param [value] - The `value` parameter is an optional value that can be assigned to the vertex. If a value is provided,
* it will be used as the value of the vertex. If no value is provided, the `key` parameter will be used as the value of

@@ -88,4 +88,4 @@ * the vertex.

*/
override createVertex(key: VertexKey, val?: VO['val']): VO {
return new UndirectedVertex(key, val ?? key) as VO;
override createVertex(key: VertexKey, value?: VO['value']): VO {
return new UndirectedVertex(key, value ?? key) as VO;
}

@@ -99,8 +99,8 @@

* no weight is provided, it defaults to 1.
* @param [val] - The `val` parameter is an optional value that can be assigned to the edge. It can be of any type and
* @param [value] - The `value` parameter is an optional value that can be assigned to the edge. It can be of any type and
* is used to store additional information or data associated with the edge.
* @returns a new instance of the `UndirectedEdge` class, which is casted as type `EO`.
*/
override createEdge(v1: VertexKey, v2: VertexKey, weight?: number, val?: EO['val']): EO {
return new UndirectedEdge(v1, v2, weight ?? 1, val) as EO;
override createEdge(v1: VertexKey, v2: VertexKey, weight?: number, value?: EO['value']): EO {
return new UndirectedEdge(v1, v2, weight ?? 1, value) as EO;
}

@@ -110,9 +110,9 @@

* The function `getEdge` returns the first edge that connects two vertices, or null if no such edge exists.
* @param {VO | null | VertexKey} v1 - The parameter `v1` represents a vertex or vertex ID. It can be of type `VO` (vertex
* @param {VO | VertexKey | null} v1 - The parameter `v1` represents a vertex or vertex ID. It can be of type `VO` (vertex
* object), `null`, or `VertexKey` (a string or number representing the ID of a vertex).
* @param {VO | null | VertexKey} v2 - The parameter `v2` represents a vertex or vertex ID. It can be of type `VO` (vertex
* @param {VO | VertexKey | null} v2 - The parameter `v2` represents a vertex or vertex ID. It can be of type `VO` (vertex
* object), `null`, or `VertexKey` (vertex ID).
* @returns an edge (EO) or null.
*/
getEdge(v1: VO | null | VertexKey, v2: VO | null | VertexKey): EO | null {
getEdge(v1: VO | VertexKey | null, v2: VO | VertexKey | null): EO | null {
let edges: EO[] | undefined = [];

@@ -119,0 +119,0 @@

@@ -11,8 +11,8 @@ /**

key: K;
val: V;
value: V;
next: HashTableNode<K, V> | null;
constructor(key: K, val: V) {
constructor(key: K, value: V) {
this.key = key;
this.val = val;
this.value = value;
this.next = null;

@@ -75,3 +75,3 @@ }

* table. It is of type K, which is a generic type representing the key's data type.
* @param {V} val - The parameter `val` represents the value that you want to associate with the given key in the hash
* @param {V} value - The parameter `value` represents the value that you want to associate with the given key in the hash
* table.

@@ -81,5 +81,5 @@ * @returns Nothing is being returned. The return type of the `put` method is `void`, which means it does not return any

*/
set(key: K, val: V): void {
set(key: K, value: V): void {
const index = this._hash(key);
const newNode = new HashTableNode<K, V>(key, val);
const newNode = new HashTableNode<K, V>(key, value);

@@ -94,3 +94,3 @@ if (!this._buckets[index]) {

// If the key already exists, update the value
currentNode.val = val;
currentNode.value = value;
return;

@@ -127,3 +127,3 @@ }

if (currentNode.key === key) {
return currentNode.val;
return currentNode.value;
}

@@ -267,3 +267,3 @@ currentNode = currentNode.next;

const newIndex = this._hash(currentNode.key);
const newNode = new HashTableNode<K, V>(currentNode.key, currentNode.val);
const newNode = new HashTableNode<K, V>(currentNode.key, currentNode.value);

@@ -270,0 +270,0 @@ if (!newBuckets[newIndex]) {

@@ -11,7 +11,7 @@ /**

* The constructor function initializes the value, next, and previous properties of an object.
* @param {E} val - The "val" parameter is the value that will be stored in the node. It can be of any data type, as it
* @param {E} value - The "value" parameter is the value that will be stored in the node. It can be of any data type, as it
* is defined as a generic type "E".
*/
constructor(val: E) {
this._val = val;
constructor(value: E) {
this._value = value;
this._next = null;

@@ -21,10 +21,10 @@ this._prev = null;

private _val: E;
private _value: E;
get val(): E {
return this._val;
get value(): E {
return this._value;
}
set val(value: E) {
this._val = value;
set value(value: E) {
this._value = value;
}

@@ -109,6 +109,6 @@

* The push function adds a new node with the given value to the end of the doubly linked list.
* @param {E} val - The value to be added to the linked list.
* @param {E} value - The value to be added to the linked list.
*/
push(val: E): void {
const newNode = new DoublyLinkedListNode(val);
push(value: E): void {
const newNode = new DoublyLinkedListNode(value);
if (!this.head) {

@@ -127,6 +127,6 @@ this.head = newNode;

* The addLast function adds a new node with the given value to the end of the doubly linked list.
* @param {E} val - The value to be added to the linked list.
* @param {E} value - The value to be added to the linked list.
*/
addLast(val: E): void {
this.push(val);
addLast(value: E): void {
this.push(value);
}

@@ -136,3 +136,3 @@

* The `pop()` 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.val) if the list is not empty. If the
* @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 null.

@@ -151,3 +151,3 @@ */

this._length--;
return removedNode.val;
return removedNode.value;
}

@@ -157,3 +157,3 @@

* The `popLast()` 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.val) if the list is not empty. If the
* @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 null.

@@ -181,3 +181,3 @@ */

this._length--;
return removedNode.val;
return removedNode.value;
}

@@ -196,7 +196,7 @@

* The unshift function adds a new node with the given value to the beginning of a doubly linked list.
* @param {E} val - The `val` parameter represents the value of the new node that will be added to the beginning of the
* @param {E} value - The `value` parameter represents the value of the new node that will be added to the beginning of the
* doubly linked list.
*/
unshift(val: E): void {
const newNode = new DoublyLinkedListNode(val);
unshift(value: E): void {
const newNode = new DoublyLinkedListNode(value);
if (!this.head) {

@@ -215,7 +215,7 @@ this.head = newNode;

* The addFirst function adds a new node with the given value to the beginning of a doubly linked list.
* @param {E} val - The `val` parameter represents the value of the new node that will be added to the beginning of the
* @param {E} value - The `value` parameter represents the value of the new node that will be added to the beginning of the
* doubly linked list.
*/
addFirst(val: E): void {
this.unshift(val);
addFirst(value: E): void {
this.unshift(value);
}

@@ -228,3 +228,3 @@

getFirst(): E | undefined {
return this.head?.val;
return this.head?.value;
}

@@ -237,3 +237,3 @@

getLast(): E | undefined {
return this.tail?.val;
return this.tail?.value;
}

@@ -254,3 +254,3 @@

}
return current!.val;
return current!.value;
}

@@ -278,11 +278,11 @@

* node if found, otherwise it returns null.
* @param {E} val - The `val` parameter is the value that we want to search for in the doubly linked list.
* @returns The function `findNodeByValue` returns a `DoublyLinkedListNode<E>` if a node with the specified value `val`
* @param {E} value - The `value` parameter is the value that we want to search for in the doubly linked list.
* @returns The function `findNodeByValue` returns a `DoublyLinkedListNode<E>` if a node with the specified value `value`
* is found in the linked list. If no such node is found, it returns `null`.
*/
getNode(val: E | null): DoublyLinkedListNode<E> | null {
getNode(value: E | null): DoublyLinkedListNode<E> | null {
let current = this.head;
while (current) {
if (current.val === val) {
if (current.value === value) {
return current;

@@ -300,3 +300,3 @@ }

* DoublyLinkedList. It is of type number.
* @param {E} val - The `val` parameter represents the value that you want to insert into the Doubly Linked List at the
* @param {E} value - The `value` parameter represents the value that you want to insert into the Doubly Linked List at the
* specified index.

@@ -306,14 +306,14 @@ * @returns The `insert` method returns a boolean value. It returns `true` if the insertion is successful, and `false`

*/
insertAt(index: number, val: E): boolean {
insertAt(index: number, value: E): boolean {
if (index < 0 || index > this.length) return false;
if (index === 0) {
this.unshift(val);
this.unshift(value);
return true;
}
if (index === this.length) {
this.push(val);
this.push(value);
return true;
}
const newNode = new DoublyLinkedListNode(val);
const newNode = new DoublyLinkedListNode(value);
const prevNode = this.getNodeAt(index - 1);

@@ -384,3 +384,3 @@ const nextNode = prevNode!.next;

this._length--;
return removedNode!.val;
return removedNode!.value;
}

@@ -429,3 +429,3 @@

while (current) {
array.push(current.val);
array.push(current.value);
current = current.next;

@@ -460,7 +460,7 @@ }

*/
find(callback: (val: E) => boolean): E | null {
find(callback: (value: E) => boolean): E | null {
let current = this.head;
while (current) {
if (callback(current.val)) {
return current.val;
if (callback(current.value)) {
return current.value;
}

@@ -474,12 +474,12 @@ current = current.next;

* The function returns the index of the first occurrence of a given value in a linked list.
* @param {E} val - The parameter `val` is of type `E`, which means it can be any data type. It represents the value
* @param {E} value - The parameter `value` is of type `E`, which means it can be any data type. It represents the value
* that we are searching for in the linked list.
* @returns The method `indexOf` returns the index of the first occurrence of the specified value `val` in the linked
* @returns The method `indexOf` returns the index of the first occurrence of the specified value `value` in the linked
* list. If the value is not found, it returns -1.
*/
indexOf(val: E): number {
indexOf(value: E): number {
let index = 0;
let current = this.head;
while (current) {
if (current.val === val) {
if (current.value === value) {
return index;

@@ -501,7 +501,7 @@ }

*/
findBackward(callback: (val: E) => boolean): E | null {
findBackward(callback: (value: E) => boolean): E | null {
let current = this.tail;
while (current) {
if (callback(current.val)) {
return current.val;
if (callback(current.value)) {
return current.value;
}

@@ -521,3 +521,3 @@ current = current.prev;

while (current) {
array.push(current.val);
array.push(current.value);
current = current.prev;

@@ -543,11 +543,11 @@ }

* The `forEach` function iterates over each element in a linked list and applies a callback function to each element.
* @param callback - The callback parameter is a function that takes two arguments: val and index. The val argument
* @param callback - The callback parameter is a function that takes two arguments: value and index. The value argument
* represents the value of the current node in the linked list, and the index argument represents the index of the
* current node in the linked list.
*/
forEach(callback: (val: E, index: number) => void): void {
forEach(callback: (value: E, index: number) => void): void {
let current = this.head;
let index = 0;
while (current) {
callback(current.val, index);
callback(current.value, index);
current = current.next;

@@ -566,7 +566,7 @@ index++;

*/
map<U>(callback: (val: E) => U): DoublyLinkedList<U> {
map<U>(callback: (value: E) => U): DoublyLinkedList<U> {
const mappedList = new DoublyLinkedList<U>();
let current = this.head;
while (current) {
mappedList.push(callback(current.val));
mappedList.push(callback(current.value));
current = current.next;

@@ -584,8 +584,8 @@ }

*/
filter(callback: (val: E) => boolean): DoublyLinkedList<E> {
filter(callback: (value: E) => boolean): DoublyLinkedList<E> {
const filteredList = new DoublyLinkedList<E>();
let current = this.head;
while (current) {
if (callback(current.val)) {
filteredList.push(current.val);
if (callback(current.value)) {
filteredList.push(current.value);
}

@@ -600,3 +600,3 @@ current = current.next;

* single value.
* @param callback - The `callback` parameter is a function that takes two arguments: `accumulator` and `val`. It is
* @param callback - The `callback` parameter is a function that takes two arguments: `accumulator` and `value`. It is
* used to perform a specific operation on each element of the linked list.

@@ -608,7 +608,7 @@ * @param {U} initialValue - The `initialValue` parameter is the initial value of the accumulator. It is the starting

*/
reduce<U>(callback: (accumulator: U, val: E) => U, initialValue: U): U {
reduce<U>(callback: (accumulator: U, value: E) => U, initialValue: U): U {
let accumulator = initialValue;
let current = this.head;
while (current) {
accumulator = callback(accumulator, current.val);
accumulator = callback(accumulator, current.value);
current = current.next;

@@ -662,3 +662,3 @@ }

while (current) {
yield current.val;
yield current.value;
current = current.next;

@@ -665,0 +665,0 @@ }

@@ -11,18 +11,18 @@ /**

* The constructor function initializes an instance of a class with a given value and sets the next property to null.
* @param {E} val - The "val" parameter is of type E, which means it can be any data type. It represents the value that
* @param {E} value - The "value" parameter is of type E, which means it can be any data type. It represents the value that
* will be stored in the node of a linked list.
*/
constructor(val: E) {
this._val = val;
constructor(value: E) {
this._value = value;
this._next = null;
}
private _val: E;
private _value: E;
get val(): E {
return this._val;
get value(): E {
return this._value;
}
set val(value: E) {
this._val = value;
set value(value: E) {
this._value = value;
}

@@ -92,8 +92,8 @@

/**
* The `push` function adds a new node with the given val to the end of a singly linked list.
* @param {E} val - The "val" parameter represents the value that you want to add to the linked list. It can be of
* The `push` function adds a new node with the given value to the end of a singly linked list.
* @param {E} value - The "value" parameter represents the value that you want to add to the linked list. It can be of
* any type (E) as specified in the generic type declaration of the class or function.
*/
push(val: E): void {
const newNode = new SinglyLinkedListNode(val);
push(value: E): void {
const newNode = new SinglyLinkedListNode(value);
if (!this.head) {

@@ -110,8 +110,8 @@ this.head = newNode;

/**
* The `push` function adds a new node with the given val to the end of a singly linked list.
* @param {E} val - The "val" parameter represents the value that you want to add to the linked list. It can be of
* The `push` function adds a new node with the given value to the end of a singly linked list.
* @param {E} value - The "value" parameter represents the value that you want to add to the linked list. It can be of
* any type (E) as specified in the generic type declaration of the class or function.
*/
addLast(val: E): void {
this.push(val);
addLast(value: E): void {
this.push(value);
}

@@ -128,7 +128,7 @@

if (this.head === this.tail) {
const val = this.head.val;
const value = this.head.value;
this.head = null;
this.tail = null;
this._length--;
return val;
return value;
}

@@ -140,7 +140,7 @@

}
const val = this.tail!.val;
const value = this.tail!.value;
current.next = null;
this.tail = current;
this._length--;
return val;
return value;
}

@@ -167,3 +167,3 @@

this._length--;
return removedNode.val;
return removedNode.value;
}

@@ -181,7 +181,7 @@

* The unshift function adds a new node with the given value to the beginning of a singly linked list.
* @param {E} val - The parameter "val" represents the value of the new node that will be added to the beginning of the
* @param {E} value - The parameter "value" represents the value of the new node that will be added to the beginning of the
* linked list.
*/
unshift(val: E): void {
const newNode = new SinglyLinkedListNode(val);
unshift(value: E): void {
const newNode = new SinglyLinkedListNode(value);
if (!this.head) {

@@ -199,7 +199,7 @@ this.head = newNode;

* The addFirst function adds a new node with the given value to the beginning of a singly linked list.
* @param {E} val - The parameter "val" represents the value of the new node that will be added to the beginning of the
* @param {E} value - The parameter "value" represents the value of the new node that will be added to the beginning of the
* linked list.
*/
addFirst(val: E): void {
this.unshift(val);
addFirst(value: E): void {
this.unshift(value);
}

@@ -220,3 +220,3 @@

}
return current!.val;
return current!.value;
}

@@ -255,3 +255,3 @@

this._length--;
return removedNode!.val;
return removedNode!.value;
}

@@ -270,3 +270,3 @@

if (valueOrNode instanceof SinglyLinkedListNode) {
value = valueOrNode.val;
value = valueOrNode.value;
} else {

@@ -279,3 +279,3 @@ value = valueOrNode;

while (current) {
if (current.val === value) {
if (current.value === value) {
if (prev === null) {

@@ -306,3 +306,3 @@ this.head = current.next;

* linked list. It is of type number.
* @param {E} val - The `val` parameter represents the value that you want to insert into the linked list at the
* @param {E} value - The `value` parameter represents the value that you want to insert into the linked list at the
* specified index.

@@ -312,14 +312,14 @@ * @returns The `insert` method returns a boolean value. It returns `true` if the insertion is successful, and `false`

*/
insertAt(index: number, val: E): boolean {
insertAt(index: number, value: E): boolean {
if (index < 0 || index > this.length) return false;
if (index === 0) {
this.unshift(val);
this.unshift(value);
return true;
}
if (index === this.length) {
this.push(val);
this.push(value);
return true;
}
const newNode = new SinglyLinkedListNode(val);
const newNode = new SinglyLinkedListNode(value);
const prevNode = this.getNodeAt(index - 1);

@@ -358,3 +358,3 @@ newNode.next = prevNode!.next;

while (current) {
array.push(current.val);
array.push(current.value);
current = current.next;

@@ -393,7 +393,7 @@ }

*/
find(callback: (val: E) => boolean): E | null {
find(callback: (value: E) => boolean): E | null {
let current = this.head;
while (current) {
if (callback(current.val)) {
return current.val;
if (callback(current.value)) {
return current.value;
}

@@ -416,3 +416,3 @@ current = current.next;

while (current) {
if (current.val === value) {
if (current.value === value) {
return index;

@@ -438,3 +438,3 @@ }

while (current) {
if (current.val === value) {
if (current.value === value) {
return current;

@@ -461,7 +461,7 @@ }

if (existingValueOrNode instanceof SinglyLinkedListNode) {
existingValue = existingValueOrNode.val;
existingValue = existingValueOrNode.value;
} else {
existingValue = existingValueOrNode;
}
if (this.head.val === existingValue) {
if (this.head.value === existingValue) {
this.unshift(newValue);

@@ -473,3 +473,3 @@ return true;

while (current.next) {
if (current.next.val === existingValue) {
if (current.next.value === existingValue) {
const newNode = new SinglyLinkedListNode(newValue);

@@ -528,3 +528,3 @@ newNode.next = current.next;

while (current) {
if (current.val === value) {
if (current.value === value) {
count++;

@@ -540,11 +540,11 @@ }

* The `forEach` function iterates over each element in a linked list and applies a callback function to each element.
* @param callback - The callback parameter is a function that takes two arguments: val and index. The val argument
* @param callback - The callback parameter is a function that takes two arguments: value and index. The value argument
* represents the value of the current node in the linked list, and the index argument represents the index of the
* current node in the linked list.
*/
forEach(callback: (val: E, index: number) => void): void {
forEach(callback: (value: E, index: number) => void): void {
let current = this.head;
let index = 0;
while (current) {
callback(current.val, index);
callback(current.value, index);
current = current.next;

@@ -563,7 +563,7 @@ index++;

*/
map<U>(callback: (val: E) => U): SinglyLinkedList<U> {
map<U>(callback: (value: E) => U): SinglyLinkedList<U> {
const mappedList = new SinglyLinkedList<U>();
let current = this.head;
while (current) {
mappedList.push(callback(current.val));
mappedList.push(callback(current.value));
current = current.next;

@@ -581,8 +581,8 @@ }

*/
filter(callback: (val: E) => boolean): SinglyLinkedList<E> {
filter(callback: (value: E) => boolean): SinglyLinkedList<E> {
const filteredList = new SinglyLinkedList<E>();
let current = this.head;
while (current) {
if (callback(current.val)) {
filteredList.push(current.val);
if (callback(current.value)) {
filteredList.push(current.value);
}

@@ -597,3 +597,3 @@ current = current.next;

* single value.
* @param callback - The `callback` parameter is a function that takes two arguments: `accumulator` and `val`. It is
* @param callback - The `callback` parameter is a function that takes two arguments: `accumulator` and `value`. It is
* used to perform a specific operation on each element of the linked list.

@@ -605,7 +605,7 @@ * @param {U} initialValue - The `initialValue` parameter is the initial value of the accumulator. It is the starting

*/
reduce<U>(callback: (accumulator: U, val: E) => U, initialValue: U): U {
reduce<U>(callback: (accumulator: U, value: E) => U, initialValue: U): U {
let accumulator = initialValue;
let current = this.head;
while (current) {
accumulator = callback(accumulator, current.val);
accumulator = callback(accumulator, current.value);
current = current.next;

@@ -623,3 +623,3 @@ }

while (current) {
yield current.val;
yield current.value;
current = current.next;

@@ -626,0 +626,0 @@ }

@@ -30,3 +30,3 @@ /**

peek(): E | undefined {
return this.head?.val;
return this.head?.value;
}

@@ -33,0 +33,0 @@ }

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

export interface IBinaryTree<V = any, N extends BinaryTreeNode<V, N> = BinaryTreeNodeNested<V>> {
createNode(key: BTNKey, val?: N['val']): N;
createNode(key: BTNKey, value?: N['value']): N;
add(keyOrNode: BTNKey | N | null, val?: N['val']): N | null | undefined;
add(keyOrNode: BTNKey | N | null, value?: N['value']): N | null | undefined;
delete<C extends BTNCallback<N>>(identifier: ReturnType<C> | null, callback: C): BinaryTreeDeletedResult<N>[];
}
import {VertexKey} from '../types';
export interface IGraph<V, E, VO, EO> {
createVertex(key: VertexKey, val?: V): VO;
createVertex(key: VertexKey, value?: V): VO;
createEdge(srcOrV1: VertexKey | string, destOrV2: VertexKey | string, weight?: number, val?: E): EO;
createEdge(srcOrV1: VertexKey, destOrV2: VertexKey, weight?: number, value?: E): EO;
}
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