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

undirected-graph-typed

Package Overview
Dependencies
Maintainers
1
Versions
172
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

undirected-graph-typed - npm Package Compare versions

Comparing version 1.49.2 to 1.49.3

14

dist/data-structures/graph/abstract-graph.d.ts

@@ -436,7 +436,2 @@ /**

/**
* The function `getCycles` returns a map of cycles found using the Tarjan algorithm.
* @returns The function `getCycles()` is returning a `Map<number, VO[]>`.
*/
getCycles(): Map<number, VO[]>;
/**
* The function "getCutVertexes" returns an array of cut vertexes using the Tarjan algorithm.

@@ -458,2 +453,7 @@ * @returns an array of VO objects, specifically the cut vertexes.

/**
* O(V+E+C)
* O(V+C)
*/
getCycles(isInclude2Cycle?: boolean): VertexKey[][];
/**
* Time Complexity: O(n)

@@ -498,6 +498,6 @@ * Space Complexity: O(n)

protected _getIterator(): IterableIterator<[VertexKey, V | undefined]>;
protected abstract _addEdgeOnly(edge: EO): boolean;
protected _addVertexOnly(newVertex: VO): boolean;
protected abstract _addEdge(edge: EO): boolean;
protected _addVertex(newVertex: VO): boolean;
protected _getVertex(vertexOrKey: VertexKey | VO): VO | undefined;
protected _getVertexKey(vertexOrKey: VO | VertexKey): VertexKey;
}

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

if (keyOrVertex instanceof AbstractVertex) {
return this._addVertexOnly(keyOrVertex);
return this._addVertex(keyOrVertex);
}
else {
const newVertex = this.createVertex(keyOrVertex, value);
return this._addVertexOnly(newVertex);
return this._addVertex(newVertex);
}

@@ -164,3 +164,3 @@ }

if (srcOrEdge instanceof AbstractEdge) {
return this._addEdgeOnly(srcOrEdge);
return this._addEdge(srcOrEdge);
}

@@ -176,3 +176,3 @@ else {

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

@@ -1008,9 +1008,2 @@ else {

/**
* The function `getCycles` returns a map of cycles found using the Tarjan algorithm.
* @returns The function `getCycles()` is returning a `Map<number, VO[]>`.
*/
getCycles() {
return this.tarjan(false, false, false, true).cycles;
}
/**
* The function "getCutVertexes" returns an array of cut vertexes using the Tarjan algorithm.

@@ -1038,2 +1031,40 @@ * @returns an array of VO objects, specifically the cut vertexes.

/**
* O(V+E+C)
* O(V+C)
*/
getCycles(isInclude2Cycle = false) {
const cycles = [];
const visited = new Set();
const dfs = (vertex, currentPath, visited) => {
if (visited.has(vertex)) {
if ((!isInclude2Cycle && currentPath.length > 2 || isInclude2Cycle && currentPath.length >= 2) && currentPath[0] === vertex.key) {
cycles.push([...currentPath]);
}
return;
}
visited.add(vertex);
currentPath.push(vertex.key);
for (const neighbor of this.getNeighbors(vertex)) {
neighbor && dfs(neighbor, currentPath, visited);
}
visited.delete(vertex);
currentPath.pop();
};
for (const vertex of this.vertexMap.values()) {
dfs(vertex, [], visited);
}
// Use a set to eliminate duplicate cycles
const uniqueCycles = new Map();
for (const cycle of cycles) {
const sorted = [...cycle].sort().toString();
if (uniqueCycles.has(sorted))
continue;
else {
uniqueCycles.set(sorted, cycle);
}
}
// Convert the unique cycles back to an array
return [...uniqueCycles].map(cycleString => cycleString[1]);
}
/**
* Time Complexity: O(n)

@@ -1100,3 +1131,3 @@ * Space Complexity: O(n)

}
_addVertexOnly(newVertex) {
_addVertex(newVertex) {
if (this.hasVertex(newVertex)) {

@@ -1103,0 +1134,0 @@ return false;

@@ -338,3 +338,3 @@ /**

*
* The function `_addEdgeOnly` adds an edge to a graph if the source and destination vertexMap exist.
* The function `_addEdge` adds an edge to a graph if the source and destination vertexMap exist.
* @param {EO} edge - The parameter `edge` is of type `EO`, which represents an edge in a graph. It is the edge that

@@ -345,3 +345,3 @@ * needs to be added to the graph.

*/
protected _addEdgeOnly(edge: EO): boolean;
protected _addEdge(edge: EO): boolean;
}

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

*
* The function `_addEdgeOnly` adds an edge to a graph if the source and destination vertexMap exist.
* The function `_addEdge` adds an edge to a graph if the source and destination vertexMap exist.
* @param {EO} edge - The parameter `edge` is of type `EO`, which represents an edge in a graph. It is the edge that

@@ -541,3 +541,3 @@ * needs to be added to the graph.

*/
_addEdgeOnly(edge) {
_addEdge(edge) {
if (!(this.hasVertex(edge.src) && this.hasVertex(edge.dest))) {

@@ -544,0 +544,0 @@ return false;

@@ -208,3 +208,3 @@ /**

*/
protected _addEdgeOnly(edge: EO): boolean;
protected _addEdge(edge: EO): boolean;
}

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

*/
_addEdgeOnly(edge) {
_addEdge(edge) {
for (const end of edge.vertexMap) {

@@ -343,0 +343,0 @@ const endVertex = this._getVertex(end);

@@ -43,2 +43,26 @@ /**

/**
* Time Complexity: O(n), where n is the number of elements in the linked list.
* Space Complexity: O(1)
*
* The `get first` function returns the first node in a doubly linked list, or undefined if the list is empty.
* @returns The method `get first()` returns the first node of the doubly linked list, or `undefined` if the list is empty.
*/
get first(): E | undefined;
/**
* Time Complexity: O(1)
* Space Complexity: O(1)
*/
/**
* Time Complexity: O(n), where n is the number of elements in the linked list.
* Space Complexity: O(1)
*
* The `get last` function returns the last node in a doubly linked list, or undefined if the list is empty.
* @returns The method `get last()` returns the last node of the doubly linked list, or `undefined` if the list is empty.
*/
get last(): E | undefined;
/**
* Time Complexity: O(1)
* Space Complexity: O(1)
*/
/**
* Time Complexity: O(n), where n is the size of the input array.

@@ -79,3 +103,3 @@ * Space Complexity: O(n)

/**
* Time Complexity: O(1)
* Time Complexity: O(n), where n is the number of elements in the linked list.
* Space Complexity: O(1)

@@ -93,3 +117,3 @@ */

/**
* Time Complexity: O(1)
* Time Complexity: O(n), where n is the number of elements in the linked list.
* Space Complexity: O(1)

@@ -207,6 +231,2 @@ */

* Space Complexity: O(1)
*/
/**
* Time Complexity: O(n), where n is the number of elements in the linked list.
* Space Complexity: O(1)
*

@@ -223,6 +243,2 @@ * The `deleteAt` function removes an element at a specified index from a linked list and returns the removed element.

* Space Complexity: O(1)
*/
/**
* Time Complexity: O(n), where n is the number of elements in the linked list.
* Space Complexity: O(1)
*

@@ -237,2 +253,6 @@ * The `delete` function removes a node from a doubly linked list based on either the node itself or its value.

/**
* Time Complexity: O(n), where n is the number of elements in the linked list.
* Space Complexity: O(1)
*/
/**
* The function checks if a variable has a size greater than zero and returns a boolean value.

@@ -243,2 +263,6 @@ * @returns A boolean value is being returned.

/**
* Time Complexity: O(n), where n is the number of elements in the linked list.
* Space Complexity: O(1)
*/
/**
* The `clear` function resets the linked list by setting the head, tail, and size to undefined and 0 respectively.

@@ -279,3 +303,3 @@ */

* Time Complexity: O(n), where n is the number of elements in the linked list.
* Space Complexity: O(1)
* Space Complexity: O(n)
*/

@@ -296,3 +320,3 @@ /**

* Time Complexity: O(n), where n is the number of elements in the linked list.
* Space Complexity: O(1)
* Space Complexity: O(n)
*/

@@ -307,3 +331,3 @@ /**

/**
* Time Complexity: O(n), where n is the number of elements in the linked list.
* Time Complexity: O(n)
* Space Complexity: O(n)

@@ -332,4 +356,4 @@ */

/**
* Time Complexity: O(n)
* Space Complexity: O(n)
* Time Complexity: O(1)
* Space Complexity: O(1)
*/

@@ -355,4 +379,4 @@ /**

/**
* Time Complexity: O(n), where n is the number of elements in the linked list.
* Space Complexity: O(n)
* Time Complexity: O(1)
* Space Complexity: O(1)
*/

@@ -403,3 +427,3 @@ /**

/**
* Time Complexity: O(1)
* Time Complexity: O(n), where n is the number of elements in the linked list.
* Space Complexity: O(1)

@@ -417,3 +441,3 @@ */

/**
* Time Complexity: O(1)
* Time Complexity: O(n), where n is the number of elements in the linked list.
* Space Complexity: O(1)

@@ -431,26 +455,2 @@ */

/**
* Time Complexity: O(n), where n is the number of elements in the linked list.
* Space Complexity: O(1)
*/
/**
* Time Complexity: O(n), where n is the number of elements in the linked list.
* Space Complexity: O(1)
*
* The `get first` function returns the first node in a doubly linked list, or undefined if the list is empty.
* @returns The method `get first()` returns the first node of the doubly linked list, or `undefined` if the list is empty.
*/
get first(): E | undefined;
/**
* Time Complexity: O(n), where n is the number of elements in the linked list.
* Space Complexity: O(1)
*/
/**
* Time Complexity: O(n), where n is the number of elements in the linked list.
* Space Complexity: O(1)
*
* The `get last` function returns the last node in a doubly linked list, or undefined if the list is empty.
* @returns The method `get last()` returns the last node of the doubly linked list, or `undefined` if the list is empty.
*/
get last(): E | undefined;
/**
* The function returns an iterator that iterates over the values of a linked list.

@@ -457,0 +457,0 @@ */

@@ -53,2 +53,32 @@ "use strict";

/**
* Time Complexity: O(n), where n is the number of elements in the linked list.
* Space Complexity: O(1)
*
* The `get first` function returns the first node in a doubly linked list, or undefined if the list is empty.
* @returns The method `get first()` returns the first node of the doubly linked list, or `undefined` if the list is empty.
*/
get first() {
var _a;
return (_a = this.head) === null || _a === void 0 ? void 0 : _a.value;
}
/**
* Time Complexity: O(1)
* Space Complexity: O(1)
*/
/**
* Time Complexity: O(n), where n is the number of elements in the linked list.
* Space Complexity: O(1)
*
* The `get last` function returns the last node in a doubly linked list, or undefined if the list is empty.
* @returns The method `get last()` returns the last node of the doubly linked list, or `undefined` if the list is empty.
*/
get last() {
var _a;
return (_a = this.tail) === null || _a === void 0 ? void 0 : _a.value;
}
/**
* Time Complexity: O(1)
* Space Complexity: O(1)
*/
/**
* Time Complexity: O(n), where n is the size of the input array.

@@ -122,3 +152,3 @@ * Space Complexity: O(n)

/**
* Time Complexity: O(1)
* Time Complexity: O(n), where n is the number of elements in the linked list.
* Space Complexity: O(1)

@@ -150,3 +180,3 @@ */

/**
* Time Complexity: O(1)
* Time Complexity: O(n), where n is the number of elements in the linked list.
* Space Complexity: O(1)

@@ -368,6 +398,2 @@ */

* Space Complexity: O(1)
*/
/**
* Time Complexity: O(n), where n is the number of elements in the linked list.
* Space Complexity: O(1)
*

@@ -402,6 +428,2 @@ * The `deleteAt` function removes an element at a specified index from a linked list and returns the removed element.

* Space Complexity: O(1)
*/
/**
* Time Complexity: O(n), where n is the number of elements in the linked list.
* Space Complexity: O(1)
*

@@ -441,2 +463,6 @@ * The `delete` function removes a node from a doubly linked list based on either the node itself or its value.

/**
* Time Complexity: O(n), where n is the number of elements in the linked list.
* Space Complexity: O(1)
*/
/**
* The function checks if a variable has a size greater than zero and returns a boolean value.

@@ -449,2 +475,6 @@ * @returns A boolean value is being returned.

/**
* Time Complexity: O(n), where n is the number of elements in the linked list.
* Space Complexity: O(1)
*/
/**
* The `clear` function resets the linked list by setting the head, tail, and size to undefined and 0 respectively.

@@ -509,3 +539,3 @@ */

* Time Complexity: O(n), where n is the number of elements in the linked list.
* Space Complexity: O(1)
* Space Complexity: O(n)
*/

@@ -535,3 +565,3 @@ /**

* Time Complexity: O(n), where n is the number of elements in the linked list.
* Space Complexity: O(1)
* Space Complexity: O(n)
*/

@@ -555,3 +585,3 @@ /**

/**
* Time Complexity: O(n), where n is the number of elements in the linked list.
* Time Complexity: O(n)
* Space Complexity: O(n)

@@ -596,4 +626,4 @@ */

/**
* Time Complexity: O(n)
* Space Complexity: O(n)
* Time Complexity: O(1)
* Space Complexity: O(1)
*/

@@ -629,4 +659,4 @@ /**

/**
* Time Complexity: O(n), where n is the number of elements in the linked list.
* Space Complexity: O(n)
* Time Complexity: O(1)
* Space Complexity: O(1)
*/

@@ -689,3 +719,3 @@ /**

/**
* Time Complexity: O(1)
* Time Complexity: O(n), where n is the number of elements in the linked list.
* Space Complexity: O(1)

@@ -705,3 +735,3 @@ */

/**
* Time Complexity: O(1)
* Time Complexity: O(n), where n is the number of elements in the linked list.
* Space Complexity: O(1)

@@ -721,32 +751,2 @@ */

/**
* Time Complexity: O(n), where n is the number of elements in the linked list.
* Space Complexity: O(1)
*/
/**
* Time Complexity: O(n), where n is the number of elements in the linked list.
* Space Complexity: O(1)
*
* The `get first` function returns the first node in a doubly linked list, or undefined if the list is empty.
* @returns The method `get first()` returns the first node of the doubly linked list, or `undefined` if the list is empty.
*/
get first() {
var _a;
return (_a = this.head) === null || _a === void 0 ? void 0 : _a.value;
}
/**
* Time Complexity: O(n), where n is the number of elements in the linked list.
* Space Complexity: O(1)
*/
/**
* Time Complexity: O(n), where n is the number of elements in the linked list.
* Space Complexity: O(1)
*
* The `get last` function returns the last node in a doubly linked list, or undefined if the list is empty.
* @returns The method `get last()` returns the last node of the doubly linked list, or `undefined` if the list is empty.
*/
get last() {
var _a;
return (_a = this.tail) === null || _a === void 0 ? void 0 : _a.value;
}
/**
* The function returns an iterator that iterates over the values of a linked list.

@@ -753,0 +753,0 @@ */

@@ -36,5 +36,29 @@ /**

/**
* Time Complexity: O(1) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
* Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
*
* Get the value of the first element (the smallest element) in the Skip List.
* @returns The value of the first element, or undefined if the Skip List is empty.
*/
get first(): V | undefined;
/**
* Time Complexity: O(log n) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
* Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
*/
/**
* Time Complexity: O(log n) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
* Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
*
* Get the value of the last element (the largest element) in the Skip List.
* @returns The value of the last element, or undefined if the Skip List is empty.
*/
get last(): V | undefined;
/**
* Time Complexity: O(log n) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
* Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
*/
/**
* Time Complexity: O(log n) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
* Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
*
* The add function adds a new node with a given key and value to a Skip List data structure.

@@ -61,3 +85,3 @@ * @param {K} key - The key parameter represents the key of the node that needs to be added to the skip list.

/**
* Time Complexity: O(log n) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
* Time Complexity: O(1) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
* Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.

@@ -85,14 +109,2 @@ */

/**
* Time Complexity: O(1) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
* Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
*/
/**
* Time Complexity: O(1) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
* Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
*
* Get the value of the first element (the smallest element) in the Skip List.
* @returns The value of the first element, or undefined if the Skip List is empty.
*/
get first(): V | undefined;
/**
* Time Complexity: O(log n) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.

@@ -105,14 +117,2 @@ * Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.

*
* Get the value of the last element (the largest element) in the Skip List.
* @returns The value of the last element, or undefined if the Skip List is empty.
*/
get last(): V | undefined;
/**
* Time Complexity: O(log n) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
* Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
*/
/**
* Time Complexity: O(log n) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
* Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
*
* Get the value of the first element in the Skip List that is greater than the given key.

@@ -119,0 +119,0 @@ * @param key - the given key.

@@ -50,5 +50,40 @@ "use strict";

/**
* Time Complexity: O(1) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
* Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
*
* Get the value of the first element (the smallest element) in the Skip List.
* @returns The value of the first element, or undefined if the Skip List is empty.
*/
get first() {
const firstNode = this.head.forward[0];
return firstNode ? firstNode.value : undefined;
}
/**
* Time Complexity: O(log n) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
* Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
*/
/**
* Time Complexity: O(log n) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
* Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
*
* Get the value of the last element (the largest element) in the Skip List.
* @returns The value of the last element, or undefined if the Skip List is empty.
*/
get last() {
let current = this.head;
for (let i = this.level - 1; i >= 0; i--) {
while (current.forward[i]) {
current = current.forward[i];
}
}
return current.value;
}
/**
* Time Complexity: O(log n) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
* Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
*/
/**
* Time Complexity: O(log n) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
* Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
*
* The add function adds a new node with a given key and value to a Skip List data structure.

@@ -104,3 +139,3 @@ * @param {K} key - The key parameter represents the key of the node that needs to be added to the skip list.

/**
* Time Complexity: O(log n) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
* Time Complexity: O(1) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
* Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.

@@ -153,17 +188,2 @@ */

/**
* Time Complexity: O(1) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
* Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
*/
/**
* Time Complexity: O(1) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
* Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
*
* Get the value of the first element (the smallest element) in the Skip List.
* @returns The value of the first element, or undefined if the Skip List is empty.
*/
get first() {
const firstNode = this.head.forward[0];
return firstNode ? firstNode.value : undefined;
}
/**
* Time Complexity: O(log n) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.

@@ -176,22 +196,2 @@ * Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.

*
* Get the value of the last element (the largest element) in the Skip List.
* @returns The value of the last element, or undefined if the Skip List is empty.
*/
get last() {
let current = this.head;
for (let i = this.level - 1; i >= 0; i--) {
while (current.forward[i]) {
current = current.forward[i];
}
}
return current.value;
}
/**
* Time Complexity: O(log n) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
* Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
*/
/**
* Time Complexity: O(log n) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
* Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
*
* Get the value of the first element in the Skip List that is greater than the given key.

@@ -198,0 +198,0 @@ * @param key - the given key.

@@ -36,2 +36,28 @@ /**

/**
* Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
* Space Complexity: O(1) - no additional space is used.
*
* The `first` function returns the first element of the array `_nodes` if it exists, otherwise it returns `undefined`.
* @returns The `get first()` method returns the first element of the data structure, represented by the `_nodes` array at
* the `_offset` index. If the data structure is empty (size is 0), it returns `undefined`.
*/
get first(): E | undefined;
/**
* Time Complexity: O(1) - constant time as it adds an element to the end of the array.
* Space Complexity: O(1) - no additional space is used.
*/
/**
* Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
* Space Complexity: O(1) - no additional space is used.
*
* The `last` function returns the last element in an array-like data structure, or undefined if the structure is empty.
* @returns The method `get last()` returns the last element of the `_nodes` array if the array is not empty. If the
* array is empty, it returns `undefined`.
*/
get last(): E | undefined;
/**
* Time Complexity: O(n) - where n is the number of elements in the queue. In the worst case, it may need to shift all elements to update the offset.
* Space Complexity: O(1) - no additional space is used.
*/
/**
* The function "fromArray" creates a new Queue object from an array of elements.Creates a queue from an existing array.

@@ -46,3 +72,3 @@ * @public

/**
* Time Complexity: O(1) - constant time as it adds an element to the end of the array.
* Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
* Space Complexity: O(1) - no additional space is used.

@@ -60,3 +86,3 @@ */

/**
* Time Complexity: O(n) - where n is the number of elements in the queue. In the worst case, it may need to shift all elements to update the offset.
* Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
* Space Complexity: O(1) - no additional space is used.

@@ -81,15 +107,2 @@ */

*
* The `first` function returns the first element of the array `_nodes` if it exists, otherwise it returns `undefined`.
* @returns The `get first()` method returns the first element of the data structure, represented by the `_nodes` array at
* the `_offset` index. If the data structure is empty (size is 0), it returns `undefined`.
*/
get first(): E | undefined;
/**
* Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
* Space Complexity: O(1) - no additional space is used.
*/
/**
* Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
* Space Complexity: O(1) - no additional space is used.
*
* The `peek` function returns the first element of the array `_nodes` if it exists, otherwise it returns `undefined`.

@@ -108,15 +121,2 @@ * @returns The `peek()` method returns the first element of the data structure, represented by the `_nodes` array at

*
* The `last` function returns the last element in an array-like data structure, or undefined if the structure is empty.
* @returns The method `get last()` returns the last element of the `_nodes` array if the array is not empty. If the
* array is empty, it returns `undefined`.
*/
get last(): E | undefined;
/**
* Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
* Space Complexity: O(1) - no additional space is used.
*/
/**
* Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
* Space Complexity: O(1) - no additional space is used.
*
* The `peekLast` function returns the last element in an array-like data structure, or undefined if the structure is empty.

@@ -256,2 +256,7 @@ * @returns The method `peekLast()` returns the last element of the `_nodes` array if the array is not empty. If the

/**
* The `get first` function returns the value of the head node in a linked list, or `undefined` if the list is empty.
* @returns The `get first()` method is returning the value of the `head` node if it exists, otherwise it returns `undefined`.
*/
get first(): E | undefined;
/**
* The enqueue function adds a value to the end of an array.

@@ -267,7 +272,2 @@ * @param {E} value - The value parameter represents the value that you want to add to the queue.

/**
* The `get first` function returns the value of the head node in a linked list, or `undefined` if the list is empty.
* @returns The `get first()` method is returning the value of the `head` node if it exists, otherwise it returns `undefined`.
*/
get first(): E | undefined;
/**
* The `peek` function returns the value of the head node in a linked list, or `undefined` if the list is empty.

@@ -274,0 +274,0 @@ * @returns The `peek()` method is returning the value of the `head` node if it exists, otherwise it returns `undefined`.

@@ -41,2 +41,32 @@ "use strict";

/**
* Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
* Space Complexity: O(1) - no additional space is used.
*
* The `first` function returns the first element of the array `_nodes` if it exists, otherwise it returns `undefined`.
* @returns The `get first()` method returns the first element of the data structure, represented by the `_nodes` array at
* the `_offset` index. If the data structure is empty (size is 0), it returns `undefined`.
*/
get first() {
return this.size > 0 ? this.nodes[this.offset] : undefined;
}
/**
* Time Complexity: O(1) - constant time as it adds an element to the end of the array.
* Space Complexity: O(1) - no additional space is used.
*/
/**
* Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
* Space Complexity: O(1) - no additional space is used.
*
* The `last` function returns the last element in an array-like data structure, or undefined if the structure is empty.
* @returns The method `get last()` returns the last element of the `_nodes` array if the array is not empty. If the
* array is empty, it returns `undefined`.
*/
get last() {
return this.size > 0 ? this.nodes[this.nodes.length - 1] : undefined;
}
/**
* Time Complexity: O(n) - where n is the number of elements in the queue. In the worst case, it may need to shift all elements to update the offset.
* Space Complexity: O(1) - no additional space is used.
*/
/**
* The function "fromArray" creates a new Queue object from an array of elements.Creates a queue from an existing array.

@@ -53,3 +83,3 @@ * @public

/**
* Time Complexity: O(1) - constant time as it adds an element to the end of the array.
* Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
* Space Complexity: O(1) - no additional space is used.

@@ -70,3 +100,3 @@ */

/**
* Time Complexity: O(n) - where n is the number of elements in the queue. In the worst case, it may need to shift all elements to update the offset.
* Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
* Space Complexity: O(1) - no additional space is used.

@@ -103,17 +133,2 @@ */

*
* The `first` function returns the first element of the array `_nodes` if it exists, otherwise it returns `undefined`.
* @returns The `get first()` method returns the first element of the data structure, represented by the `_nodes` array at
* the `_offset` index. If the data structure is empty (size is 0), it returns `undefined`.
*/
get first() {
return this.size > 0 ? this.nodes[this.offset] : undefined;
}
/**
* Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
* Space Complexity: O(1) - no additional space is used.
*/
/**
* Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
* Space Complexity: O(1) - no additional space is used.
*
* The `peek` function returns the first element of the array `_nodes` if it exists, otherwise it returns `undefined`.

@@ -134,17 +149,2 @@ * @returns The `peek()` method returns the first element of the data structure, represented by the `_nodes` array at

*
* The `last` function returns the last element in an array-like data structure, or undefined if the structure is empty.
* @returns The method `get last()` returns the last element of the `_nodes` array if the array is not empty. If the
* array is empty, it returns `undefined`.
*/
get last() {
return this.size > 0 ? this.nodes[this.nodes.length - 1] : undefined;
}
/**
* Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
* Space Complexity: O(1) - no additional space is used.
*/
/**
* Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
* Space Complexity: O(1) - no additional space is used.
*
* The `peekLast` function returns the last element in an array-like data structure, or undefined if the structure is empty.

@@ -324,2 +324,10 @@ * @returns The method `peekLast()` returns the last element of the `_nodes` array if the array is not empty. If the

/**
* The `get first` function returns the value of the head node in a linked list, or `undefined` if the list is empty.
* @returns The `get first()` method is returning the value of the `head` node if it exists, otherwise it returns `undefined`.
*/
get first() {
var _a;
return (_a = this.head) === null || _a === void 0 ? void 0 : _a.value;
}
/**
* The enqueue function adds a value to the end of an array.

@@ -339,10 +347,2 @@ * @param {E} value - The value parameter represents the value that you want to add to the queue.

/**
* The `get first` function returns the value of the head node in a linked list, or `undefined` if the list is empty.
* @returns The `get first()` method is returning the value of the `head` node if it exists, otherwise it returns `undefined`.
*/
get first() {
var _a;
return (_a = this.head) === null || _a === void 0 ? void 0 : _a.value;
}
/**
* The `peek` function returns the value of the head node in a linked list, or `undefined` if the list is empty.

@@ -349,0 +349,0 @@ * @returns The `peek()` method is returning the value of the `head` node if it exists, otherwise it returns `undefined`.

{
"name": "undirected-graph-typed",
"version": "1.49.2",
"version": "1.49.3",
"description": "Undirected Graph. Javascript & Typescript Data Structure.",

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

"dependencies": {
"data-structure-typed": "^1.49.1"
"data-structure-typed": "^1.49.3"
}
}

@@ -159,6 +159,6 @@ /**

if (keyOrVertex instanceof AbstractVertex) {
return this._addVertexOnly(keyOrVertex);
return this._addVertex(keyOrVertex);
} else {
const newVertex = this.createVertex(keyOrVertex, value);
return this._addVertexOnly(newVertex);
return this._addVertex(newVertex);
}

@@ -246,3 +246,3 @@ }

if (srcOrEdge instanceof AbstractEdge) {
return this._addEdgeOnly(srcOrEdge);
return this._addEdge(srcOrEdge);
} else {

@@ -254,3 +254,3 @@ if (dest instanceof AbstractVertex || typeof dest === 'string' || typeof dest === 'number') {

const newEdge = this.createEdge(srcOrEdge, dest, weight, value);
return this._addEdgeOnly(newEdge);
return this._addEdge(newEdge);
} else {

@@ -1154,10 +1154,2 @@ throw new Error('dest must be a Vertex or vertex key while srcOrEdge is an Edge');

/**
* The function `getCycles` returns a map of cycles found using the Tarjan algorithm.
* @returns The function `getCycles()` is returning a `Map<number, VO[]>`.
*/
getCycles(): Map<number, VO[]> {
return this.tarjan(false, false, false, true).cycles;
}
/**
* The function "getCutVertexes" returns an array of cut vertexes using the Tarjan algorithm.

@@ -1188,2 +1180,51 @@ * @returns an array of VO objects, specifically the cut vertexes.

/**
* O(V+E+C)
* O(V+C)
*/
getCycles(isInclude2Cycle: boolean = false): VertexKey[][] {
const cycles: VertexKey[][] = [];
const visited: Set<VO> = new Set();
const dfs = (vertex: VO, currentPath: VertexKey[], visited: Set<VO>) => {
if (visited.has(vertex)) {
if ((!isInclude2Cycle && currentPath.length > 2 || isInclude2Cycle && currentPath.length >= 2) && currentPath[0] === vertex.key) {
cycles.push([...currentPath]);
}
return;
}
visited.add(vertex);
currentPath.push(vertex.key);
for (const neighbor of this.getNeighbors(vertex)) {
neighbor && dfs(neighbor, currentPath, visited);
}
visited.delete(vertex);
currentPath.pop();
};
for (const vertex of this.vertexMap.values()) {
dfs(vertex, [], visited);
}
// Use a set to eliminate duplicate cycles
const uniqueCycles = new Map<string, VertexKey[]>();
for (const cycle of cycles) {
const sorted = [...cycle].sort().toString()
if (uniqueCycles.has(sorted)) continue
else {
uniqueCycles.set(sorted, cycle)
}
}
// Convert the unique cycles back to an array
return [...uniqueCycles].map(cycleString =>
cycleString[1]
);
}
/**
* Time Complexity: O(n)

@@ -1255,5 +1296,5 @@ * Space Complexity: O(n)

protected abstract _addEdgeOnly(edge: EO): boolean;
protected abstract _addEdge(edge: EO): boolean;
protected _addVertexOnly(newVertex: VO): boolean {
protected _addVertex(newVertex: VO): boolean {
if (this.hasVertex(newVertex)) {

@@ -1260,0 +1301,0 @@ return false;

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

/**

@@ -609,3 +610,3 @@ * Time Complexity: O(1)

*
* The function `_addEdgeOnly` adds an edge to a graph if the source and destination vertexMap exist.
* The function `_addEdge` adds an edge to a graph if the source and destination vertexMap exist.
* @param {EO} edge - The parameter `edge` is of type `EO`, which represents an edge in a graph. It is the edge that

@@ -616,3 +617,3 @@ * needs to be added to the graph.

*/
protected _addEdgeOnly(edge: EO): boolean {
protected _addEdge(edge: EO): boolean {
if (!(this.hasVertex(edge.src) && this.hasVertex(edge.dest))) {

@@ -619,0 +620,0 @@ return false;

@@ -384,3 +384,3 @@ /**

*/
protected _addEdgeOnly(edge: EO): boolean {
protected _addEdge(edge: EO): boolean {
for (const end of edge.vertexMap) {

@@ -387,0 +387,0 @@ const endVertex = this._getVertex(end);

@@ -74,2 +74,34 @@ /**

/**
* Time Complexity: O(n), where n is the number of elements in the linked list.
* Space Complexity: O(1)
*
* The `get first` function returns the first node in a doubly linked list, or undefined if the list is empty.
* @returns The method `get first()` returns the first node of the doubly linked list, or `undefined` if the list is empty.
*/
get first(): E | undefined {
return this.head?.value;
}
/**
* Time Complexity: O(1)
* Space Complexity: O(1)
*/
/**
* Time Complexity: O(n), where n is the number of elements in the linked list.
* Space Complexity: O(1)
*
* The `get last` function returns the last node in a doubly linked list, or undefined if the list is empty.
* @returns The method `get last()` returns the last node of the doubly linked list, or `undefined` if the list is empty.
*/
get last(): E | undefined {
return this.tail?.value;
}
/**
* Time Complexity: O(1)
* Space Complexity: O(1)
*/
/**
* Time Complexity: O(n), where n is the size of the input array.

@@ -145,3 +177,3 @@ * Space Complexity: O(n)

/**
* Time Complexity: O(1)
* Time Complexity: O(n), where n is the number of elements in the linked list.
* Space Complexity: O(1)

@@ -173,3 +205,3 @@ */

/**
* Time Complexity: O(1)
* Time Complexity: O(n), where n is the number of elements in the linked list.
* Space Complexity: O(1)

@@ -408,7 +440,2 @@ */

* Space Complexity: O(1)
*/
/**
* Time Complexity: O(n), where n is the number of elements in the linked list.
* Space Complexity: O(1)
*

@@ -444,7 +471,2 @@ * The `deleteAt` function removes an element at a specified index from a linked list and returns the removed element.

* Space Complexity: O(1)
*/
/**
* Time Complexity: O(n), where n is the number of elements in the linked list.
* Space Complexity: O(1)
*

@@ -484,2 +506,7 @@ * The `delete` function removes a node from a doubly linked list based on either the node itself or its value.

/**
* Time Complexity: O(n), where n is the number of elements in the linked list.
* Space Complexity: O(1)
*/
/**
* The function checks if a variable has a size greater than zero and returns a boolean value.

@@ -493,2 +520,7 @@ * @returns A boolean value is being returned.

/**
* Time Complexity: O(n), where n is the number of elements in the linked list.
* Space Complexity: O(1)
*/
/**
* The `clear` function resets the linked list by setting the head, tail, and size to undefined and 0 respectively.

@@ -558,3 +590,3 @@ */

* Time Complexity: O(n), where n is the number of elements in the linked list.
* Space Complexity: O(1)
* Space Complexity: O(n)
*/

@@ -586,3 +618,3 @@

* Time Complexity: O(n), where n is the number of elements in the linked list.
* Space Complexity: O(1)
* Space Complexity: O(n)
*/

@@ -608,3 +640,3 @@

/**
* Time Complexity: O(n), where n is the number of elements in the linked list.
* Time Complexity: O(n)
* Space Complexity: O(n)

@@ -653,4 +685,4 @@ */

/**
* Time Complexity: O(n)
* Space Complexity: O(n)
* Time Complexity: O(1)
* Space Complexity: O(1)
*/

@@ -688,4 +720,4 @@

/**
* Time Complexity: O(n), where n is the number of elements in the linked list.
* Space Complexity: O(n)
* Time Complexity: O(1)
* Space Complexity: O(1)
*/

@@ -755,3 +787,3 @@

/**
* Time Complexity: O(1)
* Time Complexity: O(n), where n is the number of elements in the linked list.
* Space Complexity: O(1)

@@ -773,3 +805,3 @@ */

/**
* Time Complexity: O(1)
* Time Complexity: O(n), where n is the number of elements in the linked list.
* Space Complexity: O(1)

@@ -791,34 +823,2 @@ */

/**
* Time Complexity: O(n), where n is the number of elements in the linked list.
* Space Complexity: O(1)
*/
/**
* Time Complexity: O(n), where n is the number of elements in the linked list.
* Space Complexity: O(1)
*
* The `get first` function returns the first node in a doubly linked list, or undefined if the list is empty.
* @returns The method `get first()` returns the first node of the doubly linked list, or `undefined` if the list is empty.
*/
get first(): E | undefined {
return this.head?.value;
}
/**
* Time Complexity: O(n), where n is the number of elements in the linked list.
* Space Complexity: O(1)
*/
/**
* Time Complexity: O(n), where n is the number of elements in the linked list.
* Space Complexity: O(1)
*
* The `get last` function returns the last node in a doubly linked list, or undefined if the list is empty.
* @returns The method `get last()` returns the last node of the doubly linked list, or `undefined` if the list is empty.
*/
get last(): E | undefined {
return this.tail?.value;
}
/**
* The function returns an iterator that iterates over the values of a linked list.

@@ -825,0 +825,0 @@ */

@@ -351,3 +351,3 @@ /**

*/
delete(valueOrNode: E | SinglyLinkedListNode<E> | undefined ): boolean {
delete(valueOrNode: E | SinglyLinkedListNode<E> | undefined): boolean {
if (!valueOrNode) return false;

@@ -354,0 +354,0 @@ let value: E;

@@ -66,5 +66,44 @@ /**

/**
* Time Complexity: O(1) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
* Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
*
* Get the value of the first element (the smallest element) in the Skip List.
* @returns The value of the first element, or undefined if the Skip List is empty.
*/
get first(): V | undefined {
const firstNode = this.head.forward[0];
return firstNode ? firstNode.value : undefined;
}
/**
* Time Complexity: O(log n) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
* Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
*/
/**
* Time Complexity: O(log n) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
* Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
*
* Get the value of the last element (the largest element) in the Skip List.
* @returns The value of the last element, or undefined if the Skip List is empty.
*/
get last(): V | undefined {
let current = this.head;
for (let i = this.level - 1; i >= 0; i--) {
while (current.forward[i]) {
current = current.forward[i];
}
}
return current.value;
}
/**
* Time Complexity: O(log n) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
* Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
*/
/**
* Time Complexity: O(log n) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
* Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
*
* The add function adds a new node with a given key and value to a Skip List data structure.

@@ -129,3 +168,3 @@ * @param {K} key - The key parameter represents the key of the node that needs to be added to the skip list.

/**
* Time Complexity: O(log n) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
* Time Complexity: O(1) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
* Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.

@@ -187,19 +226,2 @@ */

/**
* Time Complexity: O(1) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
* Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
*/
/**
* Time Complexity: O(1) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
* Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
*
* Get the value of the first element (the smallest element) in the Skip List.
* @returns The value of the first element, or undefined if the Skip List is empty.
*/
get first(): V | undefined {
const firstNode = this.head.forward[0];
return firstNode ? firstNode.value : undefined;
}
/**
* Time Complexity: O(log n) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.

@@ -213,24 +235,2 @@ * Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.

*
* Get the value of the last element (the largest element) in the Skip List.
* @returns The value of the last element, or undefined if the Skip List is empty.
*/
get last(): V | undefined {
let current = this.head;
for (let i = this.level - 1; i >= 0; i--) {
while (current.forward[i]) {
current = current.forward[i];
}
}
return current.value;
}
/**
* Time Complexity: O(log n) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
* Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
*/
/**
* Time Complexity: O(log n) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
* Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
*
* Get the value of the first element in the Skip List that is greater than the given key.

@@ -237,0 +237,0 @@ * @param key - the given key.

@@ -53,2 +53,36 @@ /**

/**
* Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
* Space Complexity: O(1) - no additional space is used.
*
* The `first` function returns the first element of the array `_nodes` if it exists, otherwise it returns `undefined`.
* @returns The `get first()` method returns the first element of the data structure, represented by the `_nodes` array at
* the `_offset` index. If the data structure is empty (size is 0), it returns `undefined`.
*/
get first(): E | undefined {
return this.size > 0 ? this.nodes[this.offset] : undefined;
}
/**
* Time Complexity: O(1) - constant time as it adds an element to the end of the array.
* Space Complexity: O(1) - no additional space is used.
*/
/**
* Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
* Space Complexity: O(1) - no additional space is used.
*
* The `last` function returns the last element in an array-like data structure, or undefined if the structure is empty.
* @returns The method `get last()` returns the last element of the `_nodes` array if the array is not empty. If the
* array is empty, it returns `undefined`.
*/
get last(): E | undefined {
return this.size > 0 ? this.nodes[this.nodes.length - 1] : undefined;
}
/**
* Time Complexity: O(n) - where n is the number of elements in the queue. In the worst case, it may need to shift all elements to update the offset.
* Space Complexity: O(1) - no additional space is used.
*/
/**
* The function "fromArray" creates a new Queue object from an array of elements.Creates a queue from an existing array.

@@ -66,3 +100,3 @@ * @public

/**
* Time Complexity: O(1) - constant time as it adds an element to the end of the array.
* Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
* Space Complexity: O(1) - no additional space is used.

@@ -85,3 +119,3 @@ */

/**
* Time Complexity: O(n) - where n is the number of elements in the queue. In the worst case, it may need to shift all elements to update the offset.
* Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
* Space Complexity: O(1) - no additional space is used.

@@ -122,19 +156,2 @@ */

*
* The `first` function returns the first element of the array `_nodes` if it exists, otherwise it returns `undefined`.
* @returns The `get first()` method returns the first element of the data structure, represented by the `_nodes` array at
* the `_offset` index. If the data structure is empty (size is 0), it returns `undefined`.
*/
get first(): E | undefined {
return this.size > 0 ? this.nodes[this.offset] : undefined;
}
/**
* Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
* Space Complexity: O(1) - no additional space is used.
*/
/**
* Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
* Space Complexity: O(1) - no additional space is used.
*
* The `peek` function returns the first element of the array `_nodes` if it exists, otherwise it returns `undefined`.

@@ -157,19 +174,2 @@ * @returns The `peek()` method returns the first element of the data structure, represented by the `_nodes` array at

*
* The `last` function returns the last element in an array-like data structure, or undefined if the structure is empty.
* @returns The method `get last()` returns the last element of the `_nodes` array if the array is not empty. If the
* array is empty, it returns `undefined`.
*/
get last(): E | undefined {
return this.size > 0 ? this.nodes[this.nodes.length - 1] : undefined;
}
/**
* Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
* Space Complexity: O(1) - no additional space is used.
*/
/**
* Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
* Space Complexity: O(1) - no additional space is used.
*
* The `peekLast` function returns the last element in an array-like data structure, or undefined if the structure is empty.

@@ -367,2 +367,10 @@ * @returns The method `peekLast()` returns the last element of the `_nodes` array if the array is not empty. If the

/**
* The `get first` function returns the value of the head node in a linked list, or `undefined` if the list is empty.
* @returns The `get first()` method is returning the value of the `head` node if it exists, otherwise it returns `undefined`.
*/
get first(): E | undefined {
return this.head?.value;
}
/**
* The enqueue function adds a value to the end of an array.

@@ -372,3 +380,3 @@ * @param {E} value - The value parameter represents the value that you want to add to the queue.

enqueue(value: E): boolean {
return this.push(value);
return this.push(value);
}

@@ -385,10 +393,2 @@

/**
* The `get first` function returns the value of the head node in a linked list, or `undefined` if the list is empty.
* @returns The `get first()` method is returning the value of the `head` node if it exists, otherwise it returns `undefined`.
*/
get first(): E | undefined {
return this.head?.value;
}
/**
* The `peek` function returns the value of the head node in a linked list, or `undefined` if the list is empty.

@@ -395,0 +395,0 @@ * @returns The `peek()` method is returning the value of the `head` node if it exists, otherwise it returns `undefined`.

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