graph-typed 1.39.5 → 1.40.0

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.
Files changed (96) hide show
  1. package/dist/data-structures/binary-tree/avl-tree.d.ts +6 -6
  2. package/dist/data-structures/binary-tree/avl-tree.js +13 -14
  3. package/dist/data-structures/binary-tree/binary-indexed-tree.d.ts +0 -3
  4. package/dist/data-structures/binary-tree/binary-indexed-tree.js +2 -11
  5. package/dist/data-structures/binary-tree/binary-tree.d.ts +12 -27
  6. package/dist/data-structures/binary-tree/binary-tree.js +25 -46
  7. package/dist/data-structures/binary-tree/bst.d.ts +7 -7
  8. package/dist/data-structures/binary-tree/bst.js +16 -16
  9. package/dist/data-structures/binary-tree/rb-tree.d.ts +3 -5
  10. package/dist/data-structures/binary-tree/rb-tree.js +5 -11
  11. package/dist/data-structures/binary-tree/segment-tree.d.ts +14 -30
  12. package/dist/data-structures/binary-tree/segment-tree.js +20 -68
  13. package/dist/data-structures/binary-tree/tree-multiset.d.ts +7 -7
  14. package/dist/data-structures/binary-tree/tree-multiset.js +24 -24
  15. package/dist/data-structures/graph/abstract-graph.d.ts +16 -35
  16. package/dist/data-structures/graph/abstract-graph.js +18 -57
  17. package/dist/data-structures/graph/directed-graph.d.ts +16 -22
  18. package/dist/data-structures/graph/directed-graph.js +17 -35
  19. package/dist/data-structures/graph/map-graph.d.ts +13 -19
  20. package/dist/data-structures/graph/map-graph.js +15 -33
  21. package/dist/data-structures/graph/undirected-graph.d.ts +12 -19
  22. package/dist/data-structures/graph/undirected-graph.js +15 -28
  23. package/dist/data-structures/hash/coordinate-map.d.ts +0 -1
  24. package/dist/data-structures/hash/coordinate-map.js +0 -3
  25. package/dist/data-structures/hash/coordinate-set.d.ts +0 -1
  26. package/dist/data-structures/hash/coordinate-set.js +0 -3
  27. package/dist/data-structures/hash/hash-map.d.ts +8 -14
  28. package/dist/data-structures/hash/hash-map.js +4 -22
  29. package/dist/data-structures/hash/hash-table.d.ts +10 -13
  30. package/dist/data-structures/hash/hash-table.js +8 -17
  31. package/dist/data-structures/heap/heap.d.ts +12 -6
  32. package/dist/data-structures/heap/heap.js +40 -22
  33. package/dist/data-structures/linked-list/doubly-linked-list.d.ts +34 -42
  34. package/dist/data-structures/linked-list/doubly-linked-list.js +67 -91
  35. package/dist/data-structures/linked-list/singly-linked-list.d.ts +26 -32
  36. package/dist/data-structures/linked-list/singly-linked-list.js +64 -82
  37. package/dist/data-structures/linked-list/skip-linked-list.d.ts +29 -10
  38. package/dist/data-structures/linked-list/skip-linked-list.js +62 -17
  39. package/dist/data-structures/matrix/matrix.d.ts +1 -1
  40. package/dist/data-structures/matrix/matrix2d.d.ts +1 -1
  41. package/dist/data-structures/matrix/navigator.d.ts +4 -4
  42. package/dist/data-structures/queue/deque.d.ts +8 -12
  43. package/dist/data-structures/queue/deque.js +31 -43
  44. package/dist/data-structures/queue/queue.d.ts +20 -5
  45. package/dist/data-structures/queue/queue.js +35 -18
  46. package/dist/data-structures/stack/stack.d.ts +2 -1
  47. package/dist/data-structures/stack/stack.js +10 -7
  48. package/dist/data-structures/tree/tree.d.ts +3 -9
  49. package/dist/data-structures/tree/tree.js +3 -21
  50. package/dist/data-structures/trie/trie.d.ts +6 -12
  51. package/dist/data-structures/trie/trie.js +6 -24
  52. package/dist/interfaces/binary-tree.d.ts +3 -3
  53. package/dist/interfaces/graph.d.ts +2 -2
  54. package/dist/types/data-structures/binary-tree/bst.d.ts +1 -1
  55. package/package.json +2 -2
  56. package/src/data-structures/binary-tree/avl-tree.ts +15 -17
  57. package/src/data-structures/binary-tree/binary-indexed-tree.ts +3 -15
  58. package/src/data-structures/binary-tree/binary-tree.ts +35 -60
  59. package/src/data-structures/binary-tree/bst.ts +21 -22
  60. package/src/data-structures/binary-tree/rb-tree.ts +19 -27
  61. package/src/data-structures/binary-tree/segment-tree.ts +25 -92
  62. package/src/data-structures/binary-tree/tree-multiset.ts +26 -27
  63. package/src/data-structures/graph/abstract-graph.ts +42 -88
  64. package/src/data-structures/graph/directed-graph.ts +29 -55
  65. package/src/data-structures/graph/map-graph.ts +20 -45
  66. package/src/data-structures/graph/undirected-graph.ts +24 -41
  67. package/src/data-structures/hash/coordinate-map.ts +0 -4
  68. package/src/data-structures/hash/coordinate-set.ts +0 -4
  69. package/src/data-structures/hash/hash-map.ts +13 -37
  70. package/src/data-structures/hash/hash-table.ts +15 -27
  71. package/src/data-structures/hash/tree-map.ts +2 -1
  72. package/src/data-structures/hash/tree-set.ts +2 -1
  73. package/src/data-structures/heap/heap.ts +58 -30
  74. package/src/data-structures/heap/max-heap.ts +1 -1
  75. package/src/data-structures/heap/min-heap.ts +1 -1
  76. package/src/data-structures/linked-list/doubly-linked-list.ts +81 -115
  77. package/src/data-structures/linked-list/singly-linked-list.ts +76 -101
  78. package/src/data-structures/linked-list/skip-linked-list.ts +73 -25
  79. package/src/data-structures/matrix/matrix.ts +2 -2
  80. package/src/data-structures/matrix/matrix2d.ts +1 -1
  81. package/src/data-structures/matrix/navigator.ts +4 -4
  82. package/src/data-structures/matrix/vector2d.ts +2 -1
  83. package/src/data-structures/priority-queue/max-priority-queue.ts +1 -1
  84. package/src/data-structures/priority-queue/min-priority-queue.ts +1 -1
  85. package/src/data-structures/priority-queue/priority-queue.ts +1 -1
  86. package/src/data-structures/queue/deque.ts +38 -53
  87. package/src/data-structures/queue/queue.ts +38 -20
  88. package/src/data-structures/stack/stack.ts +13 -9
  89. package/src/data-structures/tree/tree.ts +7 -33
  90. package/src/data-structures/trie/trie.ts +14 -40
  91. package/src/interfaces/binary-tree.ts +3 -3
  92. package/src/interfaces/graph.ts +2 -2
  93. package/src/types/data-structures/binary-tree/bst.ts +1 -1
  94. package/src/types/data-structures/matrix/navigator.ts +1 -1
  95. package/src/types/utils/utils.ts +1 -1
  96. package/src/types/utils/validate-type.ts +2 -2
@@ -6,34 +6,26 @@
6
6
  * @license MIT License
7
7
  */
8
8
  export declare class DoublyLinkedListNode<E = any> {
9
+ value: E;
10
+ next: DoublyLinkedListNode<E> | null;
11
+ prev: DoublyLinkedListNode<E> | null;
9
12
  /**
10
13
  * The constructor function initializes the value, next, and previous properties of an object.
11
- * @param {E} val - The "val" parameter is the value that will be stored in the node. It can be of any data type, as it
14
+ * @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
15
  * is defined as a generic type "E".
13
16
  */
14
- constructor(val: E);
15
- private _val;
16
- get val(): E;
17
- set val(value: E);
18
- private _next;
19
- get next(): DoublyLinkedListNode<E> | null;
20
- set next(value: DoublyLinkedListNode<E> | null);
21
- private _prev;
22
- get prev(): DoublyLinkedListNode<E> | null;
23
- set prev(value: DoublyLinkedListNode<E> | null);
17
+ constructor(value: E);
24
18
  }
25
19
  export declare class DoublyLinkedList<E = any> {
26
20
  /**
27
21
  * The constructor initializes the linked list with an empty head, tail, and length.
28
22
  */
29
23
  constructor();
30
- private _head;
24
+ protected _head: DoublyLinkedListNode<E> | null;
31
25
  get head(): DoublyLinkedListNode<E> | null;
32
- set head(value: DoublyLinkedListNode<E> | null);
33
- private _tail;
26
+ protected _tail: DoublyLinkedListNode<E> | null;
34
27
  get tail(): DoublyLinkedListNode<E> | null;
35
- set tail(value: DoublyLinkedListNode<E> | null);
36
- private _length;
28
+ protected _length: number;
37
29
  get length(): number;
38
30
  get size(): number;
39
31
  /**
@@ -45,23 +37,23 @@ export declare class DoublyLinkedList<E = any> {
45
37
  static fromArray<E>(data: E[]): DoublyLinkedList<E>;
46
38
  /**
47
39
  * The push function adds a new node with the given value to the end of the doubly linked list.
48
- * @param {E} val - The value to be added to the linked list.
40
+ * @param {E} value - The value to be added to the linked list.
49
41
  */
50
- push(val: E): void;
42
+ push(value: E): void;
51
43
  /**
52
44
  * The addLast function adds a new node with the given value to the end of the doubly linked list.
53
- * @param {E} val - The value to be added to the linked list.
45
+ * @param {E} value - The value to be added to the linked list.
54
46
  */
55
- addLast(val: E): void;
47
+ addLast(value: E): void;
56
48
  /**
57
49
  * 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.val) if the list is not empty. If the
50
+ * @returns The method is returning the value of the removed node (removedNode.value) if the list is not empty. If the
59
51
  * list is empty, it returns null.
60
52
  */
61
53
  pop(): E | undefined;
62
54
  /**
63
55
  * 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.val) if the list is not empty. If the
56
+ * @returns The method is returning the value of the removed node (removedNode.value) if the list is not empty. If the
65
57
  * list is empty, it returns null.
66
58
  */
67
59
  popLast(): E | undefined;
@@ -79,16 +71,16 @@ export declare class DoublyLinkedList<E = any> {
79
71
  popFirst(): E | undefined;
80
72
  /**
81
73
  * The unshift function adds a new node with the given value to the beginning of a doubly linked list.
82
- * @param {E} val - The `val` parameter represents the value of the new node that will be added to the beginning of the
74
+ * @param {E} value - The `value` parameter represents the value of the new node that will be added to the beginning of the
83
75
  * doubly linked list.
84
76
  */
85
- unshift(val: E): void;
77
+ unshift(value: E): void;
86
78
  /**
87
79
  * The addFirst function adds a new node with the given value to the beginning of a doubly linked list.
88
- * @param {E} val - The `val` parameter represents the value of the new node that will be added to the beginning of the
80
+ * @param {E} value - The `value` parameter represents the value of the new node that will be added to the beginning of the
89
81
  * doubly linked list.
90
82
  */
91
- addFirst(val: E): void;
83
+ addFirst(value: E): void;
92
84
  /**
93
85
  * The `getFirst` function returns the first node in a doubly linked list, or null if the list is empty.
94
86
  * @returns The method `getFirst()` returns the first node of the doubly linked list, or `null` if the list is empty.
@@ -119,21 +111,21 @@ export declare class DoublyLinkedList<E = any> {
119
111
  /**
120
112
  * The function `findNodeByValue` searches for a node with a specific value in a doubly linked list and returns the
121
113
  * node if found, otherwise it returns null.
122
- * @param {E} val - The `val` 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 `val`
114
+ * @param {E} value - The `value` parameter is the value that we want to search for in the doubly linked list.
115
+ * @returns The function `findNodeByValue` returns a `DoublyLinkedListNode<E>` if a node with the specified value `value`
124
116
  * is found in the linked list. If no such node is found, it returns `null`.
125
117
  */
126
- getNode(val: E | null): DoublyLinkedListNode<E> | null;
118
+ getNode(value: E | null): DoublyLinkedListNode<E> | null;
127
119
  /**
128
120
  * The `insert` function inserts a value at a specified index in a doubly linked list.
129
121
  * @param {number} index - The index parameter represents the position at which the new value should be inserted in the
130
122
  * DoublyLinkedList. It is of type number.
131
- * @param {E} val - The `val` parameter represents the value that you want to insert into the Doubly Linked List at the
123
+ * @param {E} value - The `value` parameter represents the value that you want to insert into the Doubly Linked List at the
132
124
  * specified index.
133
125
  * @returns The `insert` method returns a boolean value. It returns `true` if the insertion is successful, and `false`
134
126
  * if the index is out of bounds.
135
127
  */
136
- insertAt(index: number, val: E): boolean;
128
+ insertAt(index: number, value: E): boolean;
137
129
  /**
138
130
  * The `insertBefore` function inserts a new value before an existing value or node in a doubly linked list.
139
131
  * @param {E | DoublyLinkedListNode<E>} existingValueOrNode - The existing value or node in the doubly linked list
@@ -182,15 +174,15 @@ export declare class DoublyLinkedList<E = any> {
182
174
  * @returns The method `find` returns the first element in the linked list that satisfies the condition specified by
183
175
  * the callback function. If no element satisfies the condition, it returns `null`.
184
176
  */
185
- find(callback: (val: E) => boolean): E | null;
177
+ find(callback: (value: E) => boolean): E | null;
186
178
  /**
187
179
  * The function returns the index of the first occurrence of a given value in a linked list.
188
- * @param {E} val - The parameter `val` is of type `E`, which means it can be any data type. It represents the value
180
+ * @param {E} value - The parameter `value` is of type `E`, which means it can be any data type. It represents the value
189
181
  * 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 `val` in the linked
182
+ * @returns The method `indexOf` returns the index of the first occurrence of the specified value `value` in the linked
191
183
  * list. If the value is not found, it returns -1.
192
184
  */
193
- indexOf(val: E): number;
185
+ indexOf(value: E): number;
194
186
  /**
195
187
  * The `findBackward` function iterates through a linked list from the last node to the first node and returns the last
196
188
  * value that satisfies the given callback function, or null if no value satisfies the callback.
@@ -199,7 +191,7 @@ export declare class DoublyLinkedList<E = any> {
199
191
  * @returns The method `findBackward` returns the last value in the linked list that satisfies the condition specified by
200
192
  * the callback function. If no value satisfies the condition, it returns `null`.
201
193
  */
202
- findBackward(callback: (val: E) => boolean): E | null;
194
+ findBackward(callback: (value: E) => boolean): E | null;
203
195
  /**
204
196
  * The `toArrayBackward` function converts a doubly linked list into an array in reverse order.
205
197
  * @returns The `toArrayBackward()` function returns an array of type `E[]`.
@@ -211,11 +203,11 @@ export declare class DoublyLinkedList<E = any> {
211
203
  reverse(): void;
212
204
  /**
213
205
  * 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: val and index. The val argument
206
+ * @param callback - The callback parameter is a function that takes two arguments: value and index. The value argument
215
207
  * represents the value of the current node in the linked list, and the index argument represents the index of the
216
208
  * current node in the linked list.
217
209
  */
218
- forEach(callback: (val: E, index: number) => void): void;
210
+ forEach(callback: (value: E, index: number) => void): void;
219
211
  /**
220
212
  * The `map` function takes a callback function and applies it to each element in the DoublyLinkedList, returning a new
221
213
  * DoublyLinkedList with the transformed values.
@@ -224,7 +216,7 @@ export declare class DoublyLinkedList<E = any> {
224
216
  * DoublyLinkedList).
225
217
  * @returns The `map` function is returning a new instance of `DoublyLinkedList<U>` that contains the mapped values.
226
218
  */
227
- map<U>(callback: (val: E) => U): DoublyLinkedList<U>;
219
+ map<U>(callback: (value: E) => U): DoublyLinkedList<U>;
228
220
  /**
229
221
  * The `filter` function iterates through a DoublyLinkedList and returns a new DoublyLinkedList containing only the
230
222
  * elements that satisfy the given callback function.
@@ -232,18 +224,18 @@ export declare class DoublyLinkedList<E = any> {
232
224
  * It is used to determine whether a value should be included in the filtered list or not.
233
225
  * @returns The filtered list, which is an instance of the DoublyLinkedList class.
234
226
  */
235
- filter(callback: (val: E) => boolean): DoublyLinkedList<E>;
227
+ filter(callback: (value: E) => boolean): DoublyLinkedList<E>;
236
228
  /**
237
229
  * The `reduce` function iterates over a linked list and applies a callback function to each element, accumulating a
238
230
  * single value.
239
- * @param callback - The `callback` parameter is a function that takes two arguments: `accumulator` and `val`. It is
231
+ * @param callback - The `callback` parameter is a function that takes two arguments: `accumulator` and `value`. It is
240
232
  * used to perform a specific operation on each element of the linked list.
241
233
  * @param {U} initialValue - The `initialValue` parameter is the initial value of the accumulator. It is the starting
242
234
  * point for the reduction operation.
243
235
  * @returns The `reduce` method is returning the final value of the accumulator after iterating through all the
244
236
  * elements in the linked list.
245
237
  */
246
- reduce<U>(callback: (accumulator: U, val: E) => U, initialValue: U): U;
238
+ reduce<U>(callback: (accumulator: U, value: E) => U, initialValue: U): U;
247
239
  /**
248
240
  * The `insertAfter` function inserts a new node with a given value after an existing node in a doubly linked list.
249
241
  * @param {E | DoublyLinkedListNode<E>} existingValueOrNode - The existing value or node in the doubly linked list
@@ -11,31 +11,13 @@ exports.DoublyLinkedList = exports.DoublyLinkedListNode = void 0;
11
11
  class DoublyLinkedListNode {
12
12
  /**
13
13
  * The constructor function initializes the value, next, and previous properties of an object.
14
- * @param {E} val - The "val" parameter is the value that will be stored in the node. It can be of any data type, as it
14
+ * @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
15
15
  * is defined as a generic type "E".
16
16
  */
17
- constructor(val) {
18
- this._val = val;
19
- this._next = null;
20
- this._prev = null;
21
- }
22
- get val() {
23
- return this._val;
24
- }
25
- set val(value) {
26
- this._val = value;
27
- }
28
- get next() {
29
- return this._next;
30
- }
31
- set next(value) {
32
- this._next = value;
33
- }
34
- get prev() {
35
- return this._prev;
36
- }
37
- set prev(value) {
38
- this._prev = value;
17
+ constructor(value) {
18
+ this.value = value;
19
+ this.next = null;
20
+ this.prev = null;
39
21
  }
40
22
  }
41
23
  exports.DoublyLinkedListNode = DoublyLinkedListNode;
@@ -51,15 +33,9 @@ class DoublyLinkedList {
51
33
  get head() {
52
34
  return this._head;
53
35
  }
54
- set head(value) {
55
- this._head = value;
56
- }
57
36
  get tail() {
58
37
  return this._tail;
59
38
  }
60
- set tail(value) {
61
- this._tail = value;
62
- }
63
39
  get length() {
64
40
  return this._length;
65
41
  }
@@ -81,31 +57,31 @@ class DoublyLinkedList {
81
57
  }
82
58
  /**
83
59
  * The push function adds a new node with the given value to the end of the doubly linked list.
84
- * @param {E} val - The value to be added to the linked list.
60
+ * @param {E} value - The value to be added to the linked list.
85
61
  */
86
- push(val) {
87
- const newNode = new DoublyLinkedListNode(val);
62
+ push(value) {
63
+ const newNode = new DoublyLinkedListNode(value);
88
64
  if (!this.head) {
89
- this.head = newNode;
90
- this.tail = newNode;
65
+ this._head = newNode;
66
+ this._tail = newNode;
91
67
  }
92
68
  else {
93
69
  newNode.prev = this.tail;
94
70
  this.tail.next = newNode;
95
- this.tail = newNode;
71
+ this._tail = newNode;
96
72
  }
97
73
  this._length++;
98
74
  }
99
75
  /**
100
76
  * The addLast function adds a new node with the given value to the end of the doubly linked list.
101
- * @param {E} val - The value to be added to the linked list.
77
+ * @param {E} value - The value to be added to the linked list.
102
78
  */
103
- addLast(val) {
104
- this.push(val);
79
+ addLast(value) {
80
+ this.push(value);
105
81
  }
106
82
  /**
107
83
  * The `pop()` function removes and returns the value of the last node in a doubly linked list.
108
- * @returns The method is returning the value of the removed node (removedNode.val) if the list is not empty. If the
84
+ * @returns The method is returning the value of the removed node (removedNode.value) if the list is not empty. If the
109
85
  * list is empty, it returns null.
110
86
  */
111
87
  pop() {
@@ -113,19 +89,19 @@ class DoublyLinkedList {
113
89
  return undefined;
114
90
  const removedNode = this.tail;
115
91
  if (this.head === this.tail) {
116
- this.head = null;
117
- this.tail = null;
92
+ this._head = null;
93
+ this._tail = null;
118
94
  }
119
95
  else {
120
- this.tail = removedNode.prev;
96
+ this._tail = removedNode.prev;
121
97
  this.tail.next = null;
122
98
  }
123
99
  this._length--;
124
- return removedNode.val;
100
+ return removedNode.value;
125
101
  }
126
102
  /**
127
103
  * The `popLast()` function removes and returns the value of the last node in a doubly linked list.
128
- * @returns The method is returning the value of the removed node (removedNode.val) if the list is not empty. If the
104
+ * @returns The method is returning the value of the removed node (removedNode.value) if the list is not empty. If the
129
105
  * list is empty, it returns null.
130
106
  */
131
107
  popLast() {
@@ -141,15 +117,15 @@ class DoublyLinkedList {
141
117
  return undefined;
142
118
  const removedNode = this.head;
143
119
  if (this.head === this.tail) {
144
- this.head = null;
145
- this.tail = null;
120
+ this._head = null;
121
+ this._tail = null;
146
122
  }
147
123
  else {
148
- this.head = removedNode.next;
124
+ this._head = removedNode.next;
149
125
  this.head.prev = null;
150
126
  }
151
127
  this._length--;
152
- return removedNode.val;
128
+ return removedNode.value;
153
129
  }
154
130
  /**
155
131
  * The `popFirst()` function removes and returns the value of the first node in a doubly linked list.
@@ -161,29 +137,29 @@ class DoublyLinkedList {
161
137
  }
162
138
  /**
163
139
  * The unshift function adds a new node with the given value to the beginning of a doubly linked list.
164
- * @param {E} val - The `val` parameter represents the value of the new node that will be added to the beginning of the
140
+ * @param {E} value - The `value` parameter represents the value of the new node that will be added to the beginning of the
165
141
  * doubly linked list.
166
142
  */
167
- unshift(val) {
168
- const newNode = new DoublyLinkedListNode(val);
143
+ unshift(value) {
144
+ const newNode = new DoublyLinkedListNode(value);
169
145
  if (!this.head) {
170
- this.head = newNode;
171
- this.tail = newNode;
146
+ this._head = newNode;
147
+ this._tail = newNode;
172
148
  }
173
149
  else {
174
150
  newNode.next = this.head;
175
151
  this.head.prev = newNode;
176
- this.head = newNode;
152
+ this._head = newNode;
177
153
  }
178
154
  this._length++;
179
155
  }
180
156
  /**
181
157
  * The addFirst function adds a new node with the given value to the beginning of a doubly linked list.
182
- * @param {E} val - The `val` parameter represents the value of the new node that will be added to the beginning of the
158
+ * @param {E} value - The `value` parameter represents the value of the new node that will be added to the beginning of the
183
159
  * doubly linked list.
184
160
  */
185
- addFirst(val) {
186
- this.unshift(val);
161
+ addFirst(value) {
162
+ this.unshift(value);
187
163
  }
188
164
  /**
189
165
  * The `getFirst` function returns the first node in a doubly linked list, or null if the list is empty.
@@ -191,7 +167,7 @@ class DoublyLinkedList {
191
167
  */
192
168
  getFirst() {
193
169
  var _a;
194
- return (_a = this.head) === null || _a === void 0 ? void 0 : _a.val;
170
+ return (_a = this.head) === null || _a === void 0 ? void 0 : _a.value;
195
171
  }
196
172
  /**
197
173
  * The `getLast` function returns the last node in a doubly linked list, or null if the list is empty.
@@ -199,7 +175,7 @@ class DoublyLinkedList {
199
175
  */
200
176
  getLast() {
201
177
  var _a;
202
- return (_a = this.tail) === null || _a === void 0 ? void 0 : _a.val;
178
+ return (_a = this.tail) === null || _a === void 0 ? void 0 : _a.value;
203
179
  }
204
180
  /**
205
181
  * The `getAt` function returns the value at a specified index in a linked list, or null if the index is out of bounds.
@@ -215,7 +191,7 @@ class DoublyLinkedList {
215
191
  for (let i = 0; i < index; i++) {
216
192
  current = current.next;
217
193
  }
218
- return current.val;
194
+ return current.value;
219
195
  }
220
196
  /**
221
197
  * The function `getNodeAt` returns the node at a given index in a doubly linked list, or null if the index is out of
@@ -237,14 +213,14 @@ class DoublyLinkedList {
237
213
  /**
238
214
  * The function `findNodeByValue` searches for a node with a specific value in a doubly linked list and returns the
239
215
  * node if found, otherwise it returns null.
240
- * @param {E} val - The `val` parameter is the value that we want to search for in the doubly linked list.
241
- * @returns The function `findNodeByValue` returns a `DoublyLinkedListNode<E>` if a node with the specified value `val`
216
+ * @param {E} value - The `value` parameter is the value that we want to search for in the doubly linked list.
217
+ * @returns The function `findNodeByValue` returns a `DoublyLinkedListNode<E>` if a node with the specified value `value`
242
218
  * is found in the linked list. If no such node is found, it returns `null`.
243
219
  */
244
- getNode(val) {
220
+ getNode(value) {
245
221
  let current = this.head;
246
222
  while (current) {
247
- if (current.val === val) {
223
+ if (current.value === value) {
248
224
  return current;
249
225
  }
250
226
  current = current.next;
@@ -255,23 +231,23 @@ class DoublyLinkedList {
255
231
  * The `insert` function inserts a value at a specified index in a doubly linked list.
256
232
  * @param {number} index - The index parameter represents the position at which the new value should be inserted in the
257
233
  * DoublyLinkedList. It is of type number.
258
- * @param {E} val - The `val` parameter represents the value that you want to insert into the Doubly Linked List at the
234
+ * @param {E} value - The `value` parameter represents the value that you want to insert into the Doubly Linked List at the
259
235
  * specified index.
260
236
  * @returns The `insert` method returns a boolean value. It returns `true` if the insertion is successful, and `false`
261
237
  * if the index is out of bounds.
262
238
  */
263
- insertAt(index, val) {
239
+ insertAt(index, value) {
264
240
  if (index < 0 || index > this.length)
265
241
  return false;
266
242
  if (index === 0) {
267
- this.unshift(val);
243
+ this.unshift(value);
268
244
  return true;
269
245
  }
270
246
  if (index === this.length) {
271
- this.push(val);
247
+ this.push(value);
272
248
  return true;
273
249
  }
274
- const newNode = new DoublyLinkedListNode(val);
250
+ const newNode = new DoublyLinkedListNode(value);
275
251
  const prevNode = this.getNodeAt(index - 1);
276
252
  const nextNode = prevNode.next;
277
253
  newNode.prev = prevNode;
@@ -308,7 +284,7 @@ class DoublyLinkedList {
308
284
  newNode.next = existingNode;
309
285
  existingNode.prev = newNode;
310
286
  if (existingNode === this.head) {
311
- this.head = newNode;
287
+ this._head = newNode;
312
288
  }
313
289
  this._length++;
314
290
  return true;
@@ -335,7 +311,7 @@ class DoublyLinkedList {
335
311
  prevNode.next = nextNode;
336
312
  nextNode.prev = prevNode;
337
313
  this._length--;
338
- return removedNode.val;
314
+ return removedNode.value;
339
315
  }
340
316
  /**
341
317
  * The `delete` function removes a node from a doubly linked list based on either the node itself or its value.
@@ -378,7 +354,7 @@ class DoublyLinkedList {
378
354
  const array = [];
379
355
  let current = this.head;
380
356
  while (current) {
381
- array.push(current.val);
357
+ array.push(current.value);
382
358
  current = current.next;
383
359
  }
384
360
  return array;
@@ -408,8 +384,8 @@ class DoublyLinkedList {
408
384
  find(callback) {
409
385
  let current = this.head;
410
386
  while (current) {
411
- if (callback(current.val)) {
412
- return current.val;
387
+ if (callback(current.value)) {
388
+ return current.value;
413
389
  }
414
390
  current = current.next;
415
391
  }
@@ -417,16 +393,16 @@ class DoublyLinkedList {
417
393
  }
418
394
  /**
419
395
  * The function returns the index of the first occurrence of a given value in a linked list.
420
- * @param {E} val - The parameter `val` is of type `E`, which means it can be any data type. It represents the value
396
+ * @param {E} value - The parameter `value` is of type `E`, which means it can be any data type. It represents the value
421
397
  * that we are searching for in the linked list.
422
- * @returns The method `indexOf` returns the index of the first occurrence of the specified value `val` in the linked
398
+ * @returns The method `indexOf` returns the index of the first occurrence of the specified value `value` in the linked
423
399
  * list. If the value is not found, it returns -1.
424
400
  */
425
- indexOf(val) {
401
+ indexOf(value) {
426
402
  let index = 0;
427
403
  let current = this.head;
428
404
  while (current) {
429
- if (current.val === val) {
405
+ if (current.value === value) {
430
406
  return index;
431
407
  }
432
408
  index++;
@@ -445,8 +421,8 @@ class DoublyLinkedList {
445
421
  findBackward(callback) {
446
422
  let current = this.tail;
447
423
  while (current) {
448
- if (callback(current.val)) {
449
- return current.val;
424
+ if (callback(current.value)) {
425
+ return current.value;
450
426
  }
451
427
  current = current.prev;
452
428
  }
@@ -460,7 +436,7 @@ class DoublyLinkedList {
460
436
  const array = [];
461
437
  let current = this.tail;
462
438
  while (current) {
463
- array.push(current.val);
439
+ array.push(current.value);
464
440
  current = current.prev;
465
441
  }
466
442
  return array;
@@ -470,7 +446,7 @@ class DoublyLinkedList {
470
446
  */
471
447
  reverse() {
472
448
  let current = this.head;
473
- [this.head, this.tail] = [this.tail, this.head];
449
+ [this._head, this._tail] = [this.tail, this.head];
474
450
  while (current) {
475
451
  const next = current.next;
476
452
  [current.prev, current.next] = [current.next, current.prev];
@@ -479,7 +455,7 @@ class DoublyLinkedList {
479
455
  }
480
456
  /**
481
457
  * The `forEach` function iterates over each element in a linked list and applies a callback function to each element.
482
- * @param callback - The callback parameter is a function that takes two arguments: val and index. The val argument
458
+ * @param callback - The callback parameter is a function that takes two arguments: value and index. The value argument
483
459
  * represents the value of the current node in the linked list, and the index argument represents the index of the
484
460
  * current node in the linked list.
485
461
  */
@@ -487,7 +463,7 @@ class DoublyLinkedList {
487
463
  let current = this.head;
488
464
  let index = 0;
489
465
  while (current) {
490
- callback(current.val, index);
466
+ callback(current.value, index);
491
467
  current = current.next;
492
468
  index++;
493
469
  }
@@ -504,7 +480,7 @@ class DoublyLinkedList {
504
480
  const mappedList = new DoublyLinkedList();
505
481
  let current = this.head;
506
482
  while (current) {
507
- mappedList.push(callback(current.val));
483
+ mappedList.push(callback(current.value));
508
484
  current = current.next;
509
485
  }
510
486
  return mappedList;
@@ -520,8 +496,8 @@ class DoublyLinkedList {
520
496
  const filteredList = new DoublyLinkedList();
521
497
  let current = this.head;
522
498
  while (current) {
523
- if (callback(current.val)) {
524
- filteredList.push(current.val);
499
+ if (callback(current.value)) {
500
+ filteredList.push(current.value);
525
501
  }
526
502
  current = current.next;
527
503
  }
@@ -530,7 +506,7 @@ class DoublyLinkedList {
530
506
  /**
531
507
  * The `reduce` function iterates over a linked list and applies a callback function to each element, accumulating a
532
508
  * single value.
533
- * @param callback - The `callback` parameter is a function that takes two arguments: `accumulator` and `val`. It is
509
+ * @param callback - The `callback` parameter is a function that takes two arguments: `accumulator` and `value`. It is
534
510
  * used to perform a specific operation on each element of the linked list.
535
511
  * @param {U} initialValue - The `initialValue` parameter is the initial value of the accumulator. It is the starting
536
512
  * point for the reduction operation.
@@ -541,7 +517,7 @@ class DoublyLinkedList {
541
517
  let accumulator = initialValue;
542
518
  let current = this.head;
543
519
  while (current) {
544
- accumulator = callback(accumulator, current.val);
520
+ accumulator = callback(accumulator, current.value);
545
521
  current = current.next;
546
522
  }
547
523
  return accumulator;
@@ -572,7 +548,7 @@ class DoublyLinkedList {
572
548
  newNode.prev = existingNode;
573
549
  existingNode.next = newNode;
574
550
  if (existingNode === this.tail) {
575
- this.tail = newNode;
551
+ this._tail = newNode;
576
552
  }
577
553
  this._length++;
578
554
  return true;
@@ -585,7 +561,7 @@ class DoublyLinkedList {
585
561
  *[Symbol.iterator]() {
586
562
  let current = this.head;
587
563
  while (current) {
588
- yield current.val;
564
+ yield current.value;
589
565
  current = current.next;
590
566
  }
591
567
  }