min-heap-typed 1.39.4 → 1.39.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/data-structures/binary-tree/avl-tree.d.ts +6 -6
- package/dist/data-structures/binary-tree/avl-tree.js +13 -13
- package/dist/data-structures/binary-tree/binary-tree.d.ts +7 -7
- package/dist/data-structures/binary-tree/binary-tree.js +17 -17
- package/dist/data-structures/binary-tree/bst.d.ts +6 -6
- package/dist/data-structures/binary-tree/bst.js +13 -13
- package/dist/data-structures/binary-tree/rb-tree.d.ts +2 -2
- package/dist/data-structures/binary-tree/rb-tree.js +4 -4
- package/dist/data-structures/binary-tree/segment-tree.d.ts +7 -7
- package/dist/data-structures/binary-tree/segment-tree.js +16 -16
- package/dist/data-structures/binary-tree/tree-multiset.d.ts +6 -6
- package/dist/data-structures/binary-tree/tree-multiset.js +18 -18
- package/dist/data-structures/graph/abstract-graph.d.ts +96 -96
- package/dist/data-structures/graph/abstract-graph.js +64 -64
- package/dist/data-structures/graph/directed-graph.d.ts +68 -68
- package/dist/data-structures/graph/directed-graph.js +48 -48
- package/dist/data-structures/graph/map-graph.d.ts +13 -13
- package/dist/data-structures/graph/map-graph.js +15 -15
- package/dist/data-structures/graph/undirected-graph.d.ts +42 -42
- package/dist/data-structures/graph/undirected-graph.js +32 -32
- package/dist/data-structures/hash/hash-table.d.ts +4 -4
- package/dist/data-structures/hash/hash-table.js +8 -8
- package/dist/data-structures/linked-list/doubly-linked-list.d.ts +31 -31
- package/dist/data-structures/linked-list/doubly-linked-list.js +54 -54
- package/dist/data-structures/linked-list/singly-linked-list.d.ts +24 -24
- package/dist/data-structures/linked-list/singly-linked-list.js +52 -52
- package/dist/data-structures/queue/queue.d.ts +1 -1
- package/dist/data-structures/queue/queue.js +4 -4
- package/dist/interfaces/binary-tree.d.ts +2 -2
- package/dist/interfaces/graph.d.ts +3 -3
- package/package.json +2 -2
- package/src/data-structures/binary-tree/avl-tree.ts +13 -13
- package/src/data-structures/binary-tree/binary-tree.ts +18 -18
- package/src/data-structures/binary-tree/bst.ts +16 -16
- package/src/data-structures/binary-tree/rb-tree.ts +6 -6
- package/src/data-structures/binary-tree/segment-tree.ts +15 -15
- package/src/data-structures/binary-tree/tree-multiset.ts +18 -18
- package/src/data-structures/graph/abstract-graph.ts +156 -154
- package/src/data-structures/graph/directed-graph.ts +99 -94
- package/src/data-structures/graph/map-graph.ts +22 -25
- package/src/data-structures/graph/undirected-graph.ts +62 -60
- package/src/data-structures/hash/hash-table.ts +9 -9
- package/src/data-structures/linked-list/doubly-linked-list.ts +61 -61
- package/src/data-structures/linked-list/singly-linked-list.ts +58 -58
- package/src/data-structures/queue/queue.ts +2 -2
- package/src/interfaces/binary-tree.ts +2 -2
- package/src/interfaces/graph.ts +3 -3
|
@@ -15,11 +15,11 @@ class UndirectedVertex extends abstract_graph_1.AbstractVertex {
|
|
|
15
15
|
* The constructor function initializes a vertex with an optional value.
|
|
16
16
|
* @param {VertexKey} key - The `key` parameter is of type `VertexKey` and represents the identifier of the vertex. It is
|
|
17
17
|
* used to uniquely identify the vertex within a graph or network.
|
|
18
|
-
* @param {V} [
|
|
18
|
+
* @param {V} [value] - The "value" parameter is an optional parameter of type V. It is used to initialize the value of the
|
|
19
19
|
* vertex. If no value is provided, the vertex will be initialized with a default value.
|
|
20
20
|
*/
|
|
21
|
-
constructor(key,
|
|
22
|
-
super(key,
|
|
21
|
+
constructor(key, value) {
|
|
22
|
+
super(key, value);
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
exports.UndirectedVertex = UndirectedVertex;
|
|
@@ -31,11 +31,11 @@ class UndirectedEdge extends abstract_graph_1.AbstractEdge {
|
|
|
31
31
|
* @param {VertexKey} v2 - The parameter `v2` is a `VertexKey`, which represents the identifier of the second vertex in a
|
|
32
32
|
* graph edge.
|
|
33
33
|
* @param {number} [weight] - The weight parameter is an optional number that represents the weight of the edge.
|
|
34
|
-
* @param {
|
|
34
|
+
* @param {E} [value] - The "value" parameter is an optional parameter of type E. It is used to store a value associated
|
|
35
35
|
* with the edge.
|
|
36
36
|
*/
|
|
37
|
-
constructor(v1, v2, weight,
|
|
38
|
-
super(weight,
|
|
37
|
+
constructor(v1, v2, weight, value) {
|
|
38
|
+
super(weight, value);
|
|
39
39
|
this._vertices = [v1, v2];
|
|
40
40
|
}
|
|
41
41
|
get vertices() {
|
|
@@ -61,13 +61,13 @@ class UndirectedGraph extends abstract_graph_1.AbstractGraph {
|
|
|
61
61
|
* The function creates a new vertex with an optional value and returns it.
|
|
62
62
|
* @param {VertexKey} key - The `key` parameter is the unique identifier for the vertex. It is used to distinguish one
|
|
63
63
|
* vertex from another in the graph.
|
|
64
|
-
* @param [
|
|
64
|
+
* @param [value] - The `value` parameter is an optional value that can be assigned to the vertex. If a value is provided,
|
|
65
65
|
* 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
|
|
66
66
|
* the vertex.
|
|
67
|
-
* @returns The method is returning a new instance of the `UndirectedVertex` class, casted as type `
|
|
67
|
+
* @returns The method is returning a new instance of the `UndirectedVertex` class, casted as type `VO`.
|
|
68
68
|
*/
|
|
69
|
-
createVertex(key,
|
|
70
|
-
return new UndirectedVertex(key,
|
|
69
|
+
createVertex(key, value) {
|
|
70
|
+
return new UndirectedVertex(key, value !== null && value !== void 0 ? value : key);
|
|
71
71
|
}
|
|
72
72
|
/**
|
|
73
73
|
* The function creates an undirected edge between two vertices with an optional weight and value.
|
|
@@ -75,20 +75,20 @@ class UndirectedGraph extends abstract_graph_1.AbstractGraph {
|
|
|
75
75
|
* @param {VertexKey} v2 - The parameter `v2` represents the second vertex of the edge.
|
|
76
76
|
* @param {number} [weight] - The `weight` parameter is an optional number that represents the weight of the edge. If
|
|
77
77
|
* no weight is provided, it defaults to 1.
|
|
78
|
-
* @param [
|
|
78
|
+
* @param [value] - The `value` parameter is an optional value that can be assigned to the edge. It can be of any type and
|
|
79
79
|
* is used to store additional information or data associated with the edge.
|
|
80
|
-
* @returns a new instance of the `UndirectedEdge` class, which is casted as type `
|
|
80
|
+
* @returns a new instance of the `UndirectedEdge` class, which is casted as type `EO`.
|
|
81
81
|
*/
|
|
82
|
-
createEdge(v1, v2, weight,
|
|
83
|
-
return new UndirectedEdge(v1, v2, weight !== null && weight !== void 0 ? weight : 1,
|
|
82
|
+
createEdge(v1, v2, weight, value) {
|
|
83
|
+
return new UndirectedEdge(v1, v2, weight !== null && weight !== void 0 ? weight : 1, value);
|
|
84
84
|
}
|
|
85
85
|
/**
|
|
86
86
|
* The function `getEdge` returns the first edge that connects two vertices, or null if no such edge exists.
|
|
87
|
-
* @param {
|
|
87
|
+
* @param {VO | VertexKey | null} v1 - The parameter `v1` represents a vertex or vertex ID. It can be of type `VO` (vertex
|
|
88
88
|
* object), `null`, or `VertexKey` (a string or number representing the ID of a vertex).
|
|
89
|
-
* @param {
|
|
89
|
+
* @param {VO | VertexKey | null} v2 - The parameter `v2` represents a vertex or vertex ID. It can be of type `VO` (vertex
|
|
90
90
|
* object), `null`, or `VertexKey` (vertex ID).
|
|
91
|
-
* @returns an edge (
|
|
91
|
+
* @returns an edge (EO) or null.
|
|
92
92
|
*/
|
|
93
93
|
getEdge(v1, v2) {
|
|
94
94
|
var _a;
|
|
@@ -104,10 +104,10 @@ class UndirectedGraph extends abstract_graph_1.AbstractGraph {
|
|
|
104
104
|
}
|
|
105
105
|
/**
|
|
106
106
|
* The function removes an edge between two vertices in a graph and returns the removed edge.
|
|
107
|
-
* @param {
|
|
108
|
-
* @param {
|
|
107
|
+
* @param {VO | VertexKey} v1 - The parameter `v1` represents either a vertex object (`VO`) or a vertex ID (`VertexKey`).
|
|
108
|
+
* @param {VO | VertexKey} v2 - VO | VertexKey - This parameter can be either a vertex object (VO) or a vertex ID
|
|
109
109
|
* (VertexKey). It represents the second vertex of the edge that needs to be removed.
|
|
110
|
-
* @returns the removed edge (
|
|
110
|
+
* @returns the removed edge (EO) if it exists, or null if either of the vertices (VO) does not exist.
|
|
111
111
|
*/
|
|
112
112
|
deleteEdgeBetween(v1, v2) {
|
|
113
113
|
const vertex1 = this._getVertex(v1);
|
|
@@ -128,8 +128,8 @@ class UndirectedGraph extends abstract_graph_1.AbstractGraph {
|
|
|
128
128
|
}
|
|
129
129
|
/**
|
|
130
130
|
* The deleteEdge function removes an edge between two vertices in a graph.
|
|
131
|
-
* @param {
|
|
132
|
-
* @returns The method is returning either the removed edge (of type
|
|
131
|
+
* @param {EO} edge - The parameter "edge" is of type EO, which represents an edge in a graph.
|
|
132
|
+
* @returns The method is returning either the removed edge (of type EO) or null if the edge was not found.
|
|
133
133
|
*/
|
|
134
134
|
deleteEdge(edge) {
|
|
135
135
|
return this.deleteEdgeBetween(edge.vertices[0], edge.vertices[1]);
|
|
@@ -137,7 +137,7 @@ class UndirectedGraph extends abstract_graph_1.AbstractGraph {
|
|
|
137
137
|
/**
|
|
138
138
|
* The function `degreeOf` returns the degree of a vertex in a graph, which is the number of edges connected to that
|
|
139
139
|
* vertex.
|
|
140
|
-
* @param {VertexKey |
|
|
140
|
+
* @param {VertexKey | VO} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `VO`.
|
|
141
141
|
* @returns The function `degreeOf` returns the degree of a vertex in a graph. The degree of a vertex is the number of
|
|
142
142
|
* edges connected to that vertex.
|
|
143
143
|
*/
|
|
@@ -153,8 +153,8 @@ class UndirectedGraph extends abstract_graph_1.AbstractGraph {
|
|
|
153
153
|
}
|
|
154
154
|
/**
|
|
155
155
|
* The function returns the edges of a given vertex or vertex ID.
|
|
156
|
-
* @param {VertexKey |
|
|
157
|
-
* unique identifier for a vertex in a graph, while `
|
|
156
|
+
* @param {VertexKey | VO} vertexOrKey - The parameter `vertexOrKey` can be either a `VertexKey` or a `VO`. A `VertexKey` is a
|
|
157
|
+
* unique identifier for a vertex in a graph, while `VO` represents the type of the vertex.
|
|
158
158
|
* @returns an array of edges.
|
|
159
159
|
*/
|
|
160
160
|
edgesOf(vertexOrKey) {
|
|
@@ -168,7 +168,7 @@ class UndirectedGraph extends abstract_graph_1.AbstractGraph {
|
|
|
168
168
|
}
|
|
169
169
|
/**
|
|
170
170
|
* The function "edgeSet" returns an array of unique edges from a set of edges.
|
|
171
|
-
* @returns The method `edgeSet()` returns an array of type `
|
|
171
|
+
* @returns The method `edgeSet()` returns an array of type `EO[]`.
|
|
172
172
|
*/
|
|
173
173
|
edgeSet() {
|
|
174
174
|
const edgeSet = new Set();
|
|
@@ -181,9 +181,9 @@ class UndirectedGraph extends abstract_graph_1.AbstractGraph {
|
|
|
181
181
|
}
|
|
182
182
|
/**
|
|
183
183
|
* The function "getNeighbors" returns an array of neighboring vertices for a given vertex or vertex ID.
|
|
184
|
-
* @param {
|
|
184
|
+
* @param {VO | VertexKey} vertexOrKey - The parameter `vertexOrKey` can be either a vertex object (`VO`) or a vertex ID
|
|
185
185
|
* (`VertexKey`).
|
|
186
|
-
* @returns an array of vertices (
|
|
186
|
+
* @returns an array of vertices (VO[]).
|
|
187
187
|
*/
|
|
188
188
|
getNeighbors(vertexOrKey) {
|
|
189
189
|
const neighbors = [];
|
|
@@ -202,8 +202,8 @@ class UndirectedGraph extends abstract_graph_1.AbstractGraph {
|
|
|
202
202
|
/**
|
|
203
203
|
* The function "getEndsOfEdge" returns the vertices at the ends of an edge if the edge exists in the graph, otherwise
|
|
204
204
|
* it returns null.
|
|
205
|
-
* @param {
|
|
206
|
-
* @returns The function `getEndsOfEdge` returns an array containing two vertices `[
|
|
205
|
+
* @param {EO} edge - The parameter "edge" is of type EO, which represents an edge in a graph.
|
|
206
|
+
* @returns The function `getEndsOfEdge` returns an array containing two vertices `[VO, VO]` if the edge exists in the
|
|
207
207
|
* graph. If the edge does not exist, it returns `null`.
|
|
208
208
|
*/
|
|
209
209
|
getEndsOfEdge(edge) {
|
|
@@ -221,7 +221,7 @@ class UndirectedGraph extends abstract_graph_1.AbstractGraph {
|
|
|
221
221
|
}
|
|
222
222
|
/**
|
|
223
223
|
* The function adds an edge to the graph by updating the adjacency list with the vertices of the edge.
|
|
224
|
-
* @param {
|
|
224
|
+
* @param {EO} edge - The parameter "edge" is of type EO, which represents an edge in a graph.
|
|
225
225
|
* @returns a boolean value.
|
|
226
226
|
*/
|
|
227
227
|
_addEdgeOnly(edge) {
|
|
@@ -243,7 +243,7 @@ class UndirectedGraph extends abstract_graph_1.AbstractGraph {
|
|
|
243
243
|
}
|
|
244
244
|
/**
|
|
245
245
|
* The function sets the edges of a graph.
|
|
246
|
-
* @param v - A map where the keys are of type
|
|
246
|
+
* @param v - A map where the keys are of type VO and the values are arrays of type EO.
|
|
247
247
|
*/
|
|
248
248
|
_setEdges(v) {
|
|
249
249
|
this._edges = v;
|
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
*/
|
|
8
8
|
export declare class HashTableNode<K, V> {
|
|
9
9
|
key: K;
|
|
10
|
-
|
|
10
|
+
value: V;
|
|
11
11
|
next: HashTableNode<K, V> | null;
|
|
12
|
-
constructor(key: K,
|
|
12
|
+
constructor(key: K, value: V);
|
|
13
13
|
}
|
|
14
14
|
import { HashFunction } from '../../types';
|
|
15
15
|
export declare class HashTable<K, V> {
|
|
@@ -31,12 +31,12 @@ export declare class HashTable<K, V> {
|
|
|
31
31
|
* The set function adds a key-value pair to the hash table, handling collisions and resizing if necessary.
|
|
32
32
|
* @param {K} key - The key parameter represents the key of the key-value pair that you want to insert into the hash
|
|
33
33
|
* table. It is of type K, which is a generic type representing the key's data type.
|
|
34
|
-
* @param {V}
|
|
34
|
+
* @param {V} value - The parameter `value` represents the value that you want to associate with the given key in the hash
|
|
35
35
|
* table.
|
|
36
36
|
* @returns Nothing is being returned. The return type of the `put` method is `void`, which means it does not return any
|
|
37
37
|
* value.
|
|
38
38
|
*/
|
|
39
|
-
set(key: K,
|
|
39
|
+
set(key: K, value: V): void;
|
|
40
40
|
/**
|
|
41
41
|
* The `get` function retrieves the value associated with a given key from a hash table.
|
|
42
42
|
* @param {K} key - The `key` parameter represents the key of the element that we want to retrieve from the data
|
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.HashTable = exports.HashTableNode = void 0;
|
|
11
11
|
class HashTableNode {
|
|
12
|
-
constructor(key,
|
|
12
|
+
constructor(key, value) {
|
|
13
13
|
this.key = key;
|
|
14
|
-
this.
|
|
14
|
+
this.value = value;
|
|
15
15
|
this.next = null;
|
|
16
16
|
}
|
|
17
17
|
}
|
|
@@ -48,14 +48,14 @@ class HashTable {
|
|
|
48
48
|
* The set function adds a key-value pair to the hash table, handling collisions and resizing if necessary.
|
|
49
49
|
* @param {K} key - The key parameter represents the key of the key-value pair that you want to insert into the hash
|
|
50
50
|
* table. It is of type K, which is a generic type representing the key's data type.
|
|
51
|
-
* @param {V}
|
|
51
|
+
* @param {V} value - The parameter `value` represents the value that you want to associate with the given key in the hash
|
|
52
52
|
* table.
|
|
53
53
|
* @returns Nothing is being returned. The return type of the `put` method is `void`, which means it does not return any
|
|
54
54
|
* value.
|
|
55
55
|
*/
|
|
56
|
-
set(key,
|
|
56
|
+
set(key, value) {
|
|
57
57
|
const index = this._hash(key);
|
|
58
|
-
const newNode = new HashTableNode(key,
|
|
58
|
+
const newNode = new HashTableNode(key, value);
|
|
59
59
|
if (!this._buckets[index]) {
|
|
60
60
|
this._buckets[index] = newNode;
|
|
61
61
|
}
|
|
@@ -65,7 +65,7 @@ class HashTable {
|
|
|
65
65
|
while (currentNode) {
|
|
66
66
|
if (currentNode.key === key) {
|
|
67
67
|
// If the key already exists, update the value
|
|
68
|
-
currentNode.
|
|
68
|
+
currentNode.value = value;
|
|
69
69
|
return;
|
|
70
70
|
}
|
|
71
71
|
if (!currentNode.next) {
|
|
@@ -94,7 +94,7 @@ class HashTable {
|
|
|
94
94
|
let currentNode = this._buckets[index];
|
|
95
95
|
while (currentNode) {
|
|
96
96
|
if (currentNode.key === key) {
|
|
97
|
-
return currentNode.
|
|
97
|
+
return currentNode.value;
|
|
98
98
|
}
|
|
99
99
|
currentNode = currentNode.next;
|
|
100
100
|
}
|
|
@@ -222,7 +222,7 @@ class HashTable {
|
|
|
222
222
|
let currentNode = bucket;
|
|
223
223
|
while (currentNode) {
|
|
224
224
|
const newIndex = this._hash(currentNode.key);
|
|
225
|
-
const newNode = new HashTableNode(currentNode.key, currentNode.
|
|
225
|
+
const newNode = new HashTableNode(currentNode.key, currentNode.value);
|
|
226
226
|
if (!newBuckets[newIndex]) {
|
|
227
227
|
newBuckets[newIndex] = newNode;
|
|
228
228
|
}
|
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
export declare class DoublyLinkedListNode<E = any> {
|
|
9
9
|
/**
|
|
10
10
|
* The constructor function initializes the value, next, and previous properties of an object.
|
|
11
|
-
* @param {E}
|
|
11
|
+
* @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
|
|
12
12
|
* is defined as a generic type "E".
|
|
13
13
|
*/
|
|
14
|
-
constructor(
|
|
15
|
-
private
|
|
16
|
-
get
|
|
17
|
-
set
|
|
14
|
+
constructor(value: E);
|
|
15
|
+
private _value;
|
|
16
|
+
get value(): E;
|
|
17
|
+
set value(value: E);
|
|
18
18
|
private _next;
|
|
19
19
|
get next(): DoublyLinkedListNode<E> | null;
|
|
20
20
|
set next(value: DoublyLinkedListNode<E> | null);
|
|
@@ -45,23 +45,23 @@ export declare class DoublyLinkedList<E = any> {
|
|
|
45
45
|
static fromArray<E>(data: E[]): DoublyLinkedList<E>;
|
|
46
46
|
/**
|
|
47
47
|
* The push function adds a new node with the given value to the end of the doubly linked list.
|
|
48
|
-
* @param {E}
|
|
48
|
+
* @param {E} value - The value to be added to the linked list.
|
|
49
49
|
*/
|
|
50
|
-
push(
|
|
50
|
+
push(value: E): void;
|
|
51
51
|
/**
|
|
52
52
|
* The addLast function adds a new node with the given value to the end of the doubly linked list.
|
|
53
|
-
* @param {E}
|
|
53
|
+
* @param {E} value - The value to be added to the linked list.
|
|
54
54
|
*/
|
|
55
|
-
addLast(
|
|
55
|
+
addLast(value: E): void;
|
|
56
56
|
/**
|
|
57
57
|
* The `pop()` function removes and returns the value of the last node in a doubly linked list.
|
|
58
|
-
* @returns The method is returning the value of the removed node (removedNode.
|
|
58
|
+
* @returns The method is returning the value of the removed node (removedNode.value) if the list is not empty. If the
|
|
59
59
|
* list is empty, it returns null.
|
|
60
60
|
*/
|
|
61
61
|
pop(): E | undefined;
|
|
62
62
|
/**
|
|
63
63
|
* The `popLast()` function removes and returns the value of the last node in a doubly linked list.
|
|
64
|
-
* @returns The method is returning the value of the removed node (removedNode.
|
|
64
|
+
* @returns The method is returning the value of the removed node (removedNode.value) if the list is not empty. If the
|
|
65
65
|
* list is empty, it returns null.
|
|
66
66
|
*/
|
|
67
67
|
popLast(): E | undefined;
|
|
@@ -79,16 +79,16 @@ export declare class DoublyLinkedList<E = any> {
|
|
|
79
79
|
popFirst(): E | undefined;
|
|
80
80
|
/**
|
|
81
81
|
* The unshift function adds a new node with the given value to the beginning of a doubly linked list.
|
|
82
|
-
* @param {E}
|
|
82
|
+
* @param {E} value - The `value` parameter represents the value of the new node that will be added to the beginning of the
|
|
83
83
|
* doubly linked list.
|
|
84
84
|
*/
|
|
85
|
-
unshift(
|
|
85
|
+
unshift(value: E): void;
|
|
86
86
|
/**
|
|
87
87
|
* The addFirst function adds a new node with the given value to the beginning of a doubly linked list.
|
|
88
|
-
* @param {E}
|
|
88
|
+
* @param {E} value - The `value` parameter represents the value of the new node that will be added to the beginning of the
|
|
89
89
|
* doubly linked list.
|
|
90
90
|
*/
|
|
91
|
-
addFirst(
|
|
91
|
+
addFirst(value: E): void;
|
|
92
92
|
/**
|
|
93
93
|
* The `getFirst` function returns the first node in a doubly linked list, or null if the list is empty.
|
|
94
94
|
* @returns The method `getFirst()` returns the first node of the doubly linked list, or `null` if the list is empty.
|
|
@@ -119,21 +119,21 @@ export declare class DoublyLinkedList<E = any> {
|
|
|
119
119
|
/**
|
|
120
120
|
* The function `findNodeByValue` searches for a node with a specific value in a doubly linked list and returns the
|
|
121
121
|
* node if found, otherwise it returns null.
|
|
122
|
-
* @param {E}
|
|
123
|
-
* @returns The function `findNodeByValue` returns a `DoublyLinkedListNode<E>` if a node with the specified value `
|
|
122
|
+
* @param {E} value - The `value` parameter is the value that we want to search for in the doubly linked list.
|
|
123
|
+
* @returns The function `findNodeByValue` returns a `DoublyLinkedListNode<E>` if a node with the specified value `value`
|
|
124
124
|
* is found in the linked list. If no such node is found, it returns `null`.
|
|
125
125
|
*/
|
|
126
|
-
getNode(
|
|
126
|
+
getNode(value: E | null): DoublyLinkedListNode<E> | null;
|
|
127
127
|
/**
|
|
128
128
|
* The `insert` function inserts a value at a specified index in a doubly linked list.
|
|
129
129
|
* @param {number} index - The index parameter represents the position at which the new value should be inserted in the
|
|
130
130
|
* DoublyLinkedList. It is of type number.
|
|
131
|
-
* @param {E}
|
|
131
|
+
* @param {E} value - The `value` parameter represents the value that you want to insert into the Doubly Linked List at the
|
|
132
132
|
* specified index.
|
|
133
133
|
* @returns The `insert` method returns a boolean value. It returns `true` if the insertion is successful, and `false`
|
|
134
134
|
* if the index is out of bounds.
|
|
135
135
|
*/
|
|
136
|
-
insertAt(index: number,
|
|
136
|
+
insertAt(index: number, value: E): boolean;
|
|
137
137
|
/**
|
|
138
138
|
* The `insertBefore` function inserts a new value before an existing value or node in a doubly linked list.
|
|
139
139
|
* @param {E | DoublyLinkedListNode<E>} existingValueOrNode - The existing value or node in the doubly linked list
|
|
@@ -182,15 +182,15 @@ export declare class DoublyLinkedList<E = any> {
|
|
|
182
182
|
* @returns The method `find` returns the first element in the linked list that satisfies the condition specified by
|
|
183
183
|
* the callback function. If no element satisfies the condition, it returns `null`.
|
|
184
184
|
*/
|
|
185
|
-
find(callback: (
|
|
185
|
+
find(callback: (value: E) => boolean): E | null;
|
|
186
186
|
/**
|
|
187
187
|
* The function returns the index of the first occurrence of a given value in a linked list.
|
|
188
|
-
* @param {E}
|
|
188
|
+
* @param {E} value - The parameter `value` is of type `E`, which means it can be any data type. It represents the value
|
|
189
189
|
* that we are searching for in the linked list.
|
|
190
|
-
* @returns The method `indexOf` returns the index of the first occurrence of the specified value `
|
|
190
|
+
* @returns The method `indexOf` returns the index of the first occurrence of the specified value `value` in the linked
|
|
191
191
|
* list. If the value is not found, it returns -1.
|
|
192
192
|
*/
|
|
193
|
-
indexOf(
|
|
193
|
+
indexOf(value: E): number;
|
|
194
194
|
/**
|
|
195
195
|
* The `findBackward` function iterates through a linked list from the last node to the first node and returns the last
|
|
196
196
|
* value that satisfies the given callback function, or null if no value satisfies the callback.
|
|
@@ -199,7 +199,7 @@ export declare class DoublyLinkedList<E = any> {
|
|
|
199
199
|
* @returns The method `findBackward` returns the last value in the linked list that satisfies the condition specified by
|
|
200
200
|
* the callback function. If no value satisfies the condition, it returns `null`.
|
|
201
201
|
*/
|
|
202
|
-
findBackward(callback: (
|
|
202
|
+
findBackward(callback: (value: E) => boolean): E | null;
|
|
203
203
|
/**
|
|
204
204
|
* The `toArrayBackward` function converts a doubly linked list into an array in reverse order.
|
|
205
205
|
* @returns The `toArrayBackward()` function returns an array of type `E[]`.
|
|
@@ -211,11 +211,11 @@ export declare class DoublyLinkedList<E = any> {
|
|
|
211
211
|
reverse(): void;
|
|
212
212
|
/**
|
|
213
213
|
* The `forEach` function iterates over each element in a linked list and applies a callback function to each element.
|
|
214
|
-
* @param callback - The callback parameter is a function that takes two arguments:
|
|
214
|
+
* @param callback - The callback parameter is a function that takes two arguments: value and index. The value argument
|
|
215
215
|
* represents the value of the current node in the linked list, and the index argument represents the index of the
|
|
216
216
|
* current node in the linked list.
|
|
217
217
|
*/
|
|
218
|
-
forEach(callback: (
|
|
218
|
+
forEach(callback: (value: E, index: number) => void): void;
|
|
219
219
|
/**
|
|
220
220
|
* The `map` function takes a callback function and applies it to each element in the DoublyLinkedList, returning a new
|
|
221
221
|
* DoublyLinkedList with the transformed values.
|
|
@@ -224,7 +224,7 @@ export declare class DoublyLinkedList<E = any> {
|
|
|
224
224
|
* DoublyLinkedList).
|
|
225
225
|
* @returns The `map` function is returning a new instance of `DoublyLinkedList<U>` that contains the mapped values.
|
|
226
226
|
*/
|
|
227
|
-
map<U>(callback: (
|
|
227
|
+
map<U>(callback: (value: E) => U): DoublyLinkedList<U>;
|
|
228
228
|
/**
|
|
229
229
|
* The `filter` function iterates through a DoublyLinkedList and returns a new DoublyLinkedList containing only the
|
|
230
230
|
* elements that satisfy the given callback function.
|
|
@@ -232,18 +232,18 @@ export declare class DoublyLinkedList<E = any> {
|
|
|
232
232
|
* It is used to determine whether a value should be included in the filtered list or not.
|
|
233
233
|
* @returns The filtered list, which is an instance of the DoublyLinkedList class.
|
|
234
234
|
*/
|
|
235
|
-
filter(callback: (
|
|
235
|
+
filter(callback: (value: E) => boolean): DoublyLinkedList<E>;
|
|
236
236
|
/**
|
|
237
237
|
* The `reduce` function iterates over a linked list and applies a callback function to each element, accumulating a
|
|
238
238
|
* single value.
|
|
239
|
-
* @param callback - The `callback` parameter is a function that takes two arguments: `accumulator` and `
|
|
239
|
+
* @param callback - The `callback` parameter is a function that takes two arguments: `accumulator` and `value`. It is
|
|
240
240
|
* used to perform a specific operation on each element of the linked list.
|
|
241
241
|
* @param {U} initialValue - The `initialValue` parameter is the initial value of the accumulator. It is the starting
|
|
242
242
|
* point for the reduction operation.
|
|
243
243
|
* @returns The `reduce` method is returning the final value of the accumulator after iterating through all the
|
|
244
244
|
* elements in the linked list.
|
|
245
245
|
*/
|
|
246
|
-
reduce<U>(callback: (accumulator: U,
|
|
246
|
+
reduce<U>(callback: (accumulator: U, value: E) => U, initialValue: U): U;
|
|
247
247
|
/**
|
|
248
248
|
* The `insertAfter` function inserts a new node with a given value after an existing node in a doubly linked list.
|
|
249
249
|
* @param {E | DoublyLinkedListNode<E>} existingValueOrNode - The existing value or node in the doubly linked list
|