min-heap-typed 1.39.5 → 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 +17 -17
- package/dist/data-structures/graph/abstract-graph.js +24 -24
- package/dist/data-structures/graph/directed-graph.d.ts +12 -12
- package/dist/data-structures/graph/directed-graph.js +15 -15
- package/dist/data-structures/graph/map-graph.d.ts +9 -9
- package/dist/data-structures/graph/map-graph.js +13 -13
- package/dist/data-structures/graph/undirected-graph.d.ts +11 -11
- package/dist/data-structures/graph/undirected-graph.js +14 -14
- 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.js +1 -1
- package/dist/interfaces/binary-tree.d.ts +2 -2
- package/dist/interfaces/graph.d.ts +2 -2
- 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 +34 -34
- package/src/data-structures/graph/directed-graph.ts +16 -16
- package/src/data-structures/graph/map-graph.ts +13 -13
- package/src/data-structures/graph/undirected-graph.ts +15 -15
- 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 +1 -1
- package/src/interfaces/binary-tree.ts +2 -2
- package/src/interfaces/graph.ts +2 -2
|
@@ -6,10 +6,10 @@ export declare class UndirectedVertex<V = any> extends AbstractVertex<V> {
|
|
|
6
6
|
* The constructor function initializes a vertex with an optional value.
|
|
7
7
|
* @param {VertexKey} key - The `key` parameter is of type `VertexKey` and represents the identifier of the vertex. It is
|
|
8
8
|
* used to uniquely identify the vertex within a graph or network.
|
|
9
|
-
* @param {V} [
|
|
9
|
+
* @param {V} [value] - The "value" parameter is an optional parameter of type V. It is used to initialize the value of the
|
|
10
10
|
* vertex. If no value is provided, the vertex will be initialized with a default value.
|
|
11
11
|
*/
|
|
12
|
-
constructor(key: VertexKey,
|
|
12
|
+
constructor(key: VertexKey, value?: V);
|
|
13
13
|
}
|
|
14
14
|
export declare class UndirectedEdge<E = number> extends AbstractEdge<E> {
|
|
15
15
|
/**
|
|
@@ -19,10 +19,10 @@ export declare class UndirectedEdge<E = number> extends AbstractEdge<E> {
|
|
|
19
19
|
* @param {VertexKey} v2 - The parameter `v2` is a `VertexKey`, which represents the identifier of the second vertex in a
|
|
20
20
|
* graph edge.
|
|
21
21
|
* @param {number} [weight] - The weight parameter is an optional number that represents the weight of the edge.
|
|
22
|
-
* @param {E} [
|
|
22
|
+
* @param {E} [value] - The "value" parameter is an optional parameter of type E. It is used to store a value associated
|
|
23
23
|
* with the edge.
|
|
24
24
|
*/
|
|
25
|
-
constructor(v1: VertexKey, v2: VertexKey, weight?: number,
|
|
25
|
+
constructor(v1: VertexKey, v2: VertexKey, weight?: number, value?: E);
|
|
26
26
|
private _vertices;
|
|
27
27
|
get vertices(): [VertexKey, VertexKey];
|
|
28
28
|
set vertices(v: [VertexKey, VertexKey]);
|
|
@@ -38,32 +38,32 @@ export declare class UndirectedGraph<V = any, E = any, VO extends UndirectedVert
|
|
|
38
38
|
* The function creates a new vertex with an optional value and returns it.
|
|
39
39
|
* @param {VertexKey} key - The `key` parameter is the unique identifier for the vertex. It is used to distinguish one
|
|
40
40
|
* vertex from another in the graph.
|
|
41
|
-
* @param [
|
|
41
|
+
* @param [value] - The `value` parameter is an optional value that can be assigned to the vertex. If a value is provided,
|
|
42
42
|
* 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
|
|
43
43
|
* the vertex.
|
|
44
44
|
* @returns The method is returning a new instance of the `UndirectedVertex` class, casted as type `VO`.
|
|
45
45
|
*/
|
|
46
|
-
createVertex(key: VertexKey,
|
|
46
|
+
createVertex(key: VertexKey, value?: VO['value']): VO;
|
|
47
47
|
/**
|
|
48
48
|
* The function creates an undirected edge between two vertices with an optional weight and value.
|
|
49
49
|
* @param {VertexKey} v1 - The parameter `v1` represents the first vertex of the edge.
|
|
50
50
|
* @param {VertexKey} v2 - The parameter `v2` represents the second vertex of the edge.
|
|
51
51
|
* @param {number} [weight] - The `weight` parameter is an optional number that represents the weight of the edge. If
|
|
52
52
|
* no weight is provided, it defaults to 1.
|
|
53
|
-
* @param [
|
|
53
|
+
* @param [value] - The `value` parameter is an optional value that can be assigned to the edge. It can be of any type and
|
|
54
54
|
* is used to store additional information or data associated with the edge.
|
|
55
55
|
* @returns a new instance of the `UndirectedEdge` class, which is casted as type `EO`.
|
|
56
56
|
*/
|
|
57
|
-
createEdge(v1: VertexKey, v2: VertexKey, weight?: number,
|
|
57
|
+
createEdge(v1: VertexKey, v2: VertexKey, weight?: number, value?: EO['value']): EO;
|
|
58
58
|
/**
|
|
59
59
|
* The function `getEdge` returns the first edge that connects two vertices, or null if no such edge exists.
|
|
60
|
-
* @param {VO |
|
|
60
|
+
* @param {VO | VertexKey | null} v1 - The parameter `v1` represents a vertex or vertex ID. It can be of type `VO` (vertex
|
|
61
61
|
* object), `null`, or `VertexKey` (a string or number representing the ID of a vertex).
|
|
62
|
-
* @param {VO |
|
|
62
|
+
* @param {VO | VertexKey | null} v2 - The parameter `v2` represents a vertex or vertex ID. It can be of type `VO` (vertex
|
|
63
63
|
* object), `null`, or `VertexKey` (vertex ID).
|
|
64
64
|
* @returns an edge (EO) or null.
|
|
65
65
|
*/
|
|
66
|
-
getEdge(v1: VO |
|
|
66
|
+
getEdge(v1: VO | VertexKey | null, v2: VO | VertexKey | null): EO | null;
|
|
67
67
|
/**
|
|
68
68
|
* The function removes an edge between two vertices in a graph and returns the removed edge.
|
|
69
69
|
* @param {VO | VertexKey} v1 - The parameter `v1` represents either a vertex object (`VO`) or a vertex ID (`VertexKey`).
|
|
@@ -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 {E} [
|
|
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
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,18 +75,18 @@ 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
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 {VO |
|
|
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 {VO |
|
|
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
91
|
* @returns an edge (EO) or null.
|
|
92
92
|
*/
|
|
@@ -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
|