heap-typed 1.49.1 → 1.49.2

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 (31) hide show
  1. package/dist/data-structures/base/iterable-base.d.ts +11 -0
  2. package/dist/data-structures/base/iterable-base.js +21 -0
  3. package/dist/data-structures/hash/hash-map.d.ts +9 -9
  4. package/dist/data-structures/hash/hash-map.js +16 -15
  5. package/dist/data-structures/heap/heap.d.ts +6 -35
  6. package/dist/data-structures/heap/heap.js +10 -42
  7. package/dist/data-structures/linked-list/doubly-linked-list.d.ts +87 -93
  8. package/dist/data-structures/linked-list/doubly-linked-list.js +126 -129
  9. package/dist/data-structures/linked-list/singly-linked-list.d.ts +16 -21
  10. package/dist/data-structures/linked-list/singly-linked-list.js +42 -42
  11. package/dist/data-structures/linked-list/skip-linked-list.d.ts +2 -2
  12. package/dist/data-structures/linked-list/skip-linked-list.js +2 -2
  13. package/dist/data-structures/queue/deque.d.ts +70 -75
  14. package/dist/data-structures/queue/deque.js +100 -110
  15. package/dist/data-structures/queue/queue.d.ts +13 -14
  16. package/dist/data-structures/queue/queue.js +15 -18
  17. package/dist/data-structures/stack/stack.d.ts +2 -3
  18. package/dist/data-structures/stack/stack.js +2 -5
  19. package/dist/data-structures/trie/trie.d.ts +1 -2
  20. package/dist/data-structures/trie/trie.js +2 -5
  21. package/package.json +1 -1
  22. package/src/data-structures/base/iterable-base.ts +24 -0
  23. package/src/data-structures/hash/hash-map.ts +27 -28
  24. package/src/data-structures/heap/heap.ts +19 -57
  25. package/src/data-structures/linked-list/doubly-linked-list.ts +138 -142
  26. package/src/data-structures/linked-list/singly-linked-list.ts +49 -49
  27. package/src/data-structures/linked-list/skip-linked-list.ts +2 -2
  28. package/src/data-structures/queue/deque.ts +122 -135
  29. package/src/data-structures/queue/queue.ts +19 -23
  30. package/src/data-structures/stack/stack.ts +4 -8
  31. package/src/data-structures/trie/trie.ts +5 -9
@@ -23,13 +23,13 @@ exports.DoublyLinkedListNode = DoublyLinkedListNode;
23
23
  */
24
24
  class DoublyLinkedList extends base_1.IterableElementBase {
25
25
  /**
26
- * The constructor initializes the linked list with an empty head, tail, and length.
26
+ * The constructor initializes the linked list with an empty head, tail, and size.
27
27
  */
28
28
  constructor(elements) {
29
29
  super();
30
30
  this._head = undefined;
31
31
  this._tail = undefined;
32
- this._length = 0;
32
+ this._size = 0;
33
33
  if (elements) {
34
34
  for (const el of elements) {
35
35
  this.push(el);
@@ -42,18 +42,15 @@ class DoublyLinkedList extends base_1.IterableElementBase {
42
42
  get tail() {
43
43
  return this._tail;
44
44
  }
45
- get length() {
46
- return this._length;
47
- }
48
45
  get size() {
49
- return this.length;
46
+ return this._size;
50
47
  }
51
48
  /**
52
- * Time Complexity: O(n), where n is the length of the input array.
49
+ * Time Complexity: O(n), where n is the size of the input array.
53
50
  * Space Complexity: O(n)
54
51
  */
55
52
  /**
56
- * Time Complexity: O(n), where n is the length of the input array.
53
+ * Time Complexity: O(n), where n is the size of the input array.
57
54
  * Space Complexity: O(n)
58
55
  *
59
56
  * The `fromArray` function creates a new instance of a DoublyLinkedList and populates it with the elements from the
@@ -90,21 +87,8 @@ class DoublyLinkedList extends base_1.IterableElementBase {
90
87
  this.tail.next = newNode;
91
88
  this._tail = newNode;
92
89
  }
93
- this._length++;
94
- }
95
- /**
96
- * Time Complexity: O(1)
97
- * Space Complexity: O(1)
98
- */
99
- /**
100
- * Time Complexity: O(1)
101
- * Space Complexity: O(1)
102
- *
103
- * The addLast function adds a new node with the given value to the end of the doubly linked list.
104
- * @param {E} value - The value to be added to the linked list.
105
- */
106
- addLast(value) {
107
- this.push(value);
90
+ this._size++;
91
+ return true;
108
92
  }
109
93
  /**
110
94
  * Time Complexity: O(1)
@@ -130,24 +114,9 @@ class DoublyLinkedList extends base_1.IterableElementBase {
130
114
  this._tail = removedNode.prev;
131
115
  this.tail.next = undefined;
132
116
  }
133
- this._length--;
117
+ this._size--;
134
118
  return removedNode.value;
135
119
  }
136
- /**
137
- * Time Complexity: O(1)
138
- * Space Complexity: O(1)
139
- */
140
- /**
141
- * Time Complexity: O(1)
142
- * Space Complexity: O(1)
143
- *
144
- * The `pollLast()` function removes and returns the value of the last node in a doubly linked list.
145
- * @returns The method is returning the value of the removed node (removedNode.value) if the list is not empty. If the
146
- * list is empty, it returns undefined.
147
- */
148
- pollLast() {
149
- return this.pop();
150
- }
151
120
  /**
152
121
  * Time Complexity: O(1)
153
122
  * Space Complexity: O(1)
@@ -172,24 +141,9 @@ class DoublyLinkedList extends base_1.IterableElementBase {
172
141
  this._head = removedNode.next;
173
142
  this.head.prev = undefined;
174
143
  }
175
- this._length--;
144
+ this._size--;
176
145
  return removedNode.value;
177
146
  }
178
- /**
179
- * Time Complexity: O(1)
180
- * Space Complexity: O(1)
181
- */
182
- /**
183
- * Time Complexity: O(1)
184
- * Space Complexity: O(1)
185
- *
186
- * The `pollFirst()` function removes and returns the value of the first node in a doubly linked list.
187
- * @returns The method `shift()` returns the value of the node that is removed from the beginning of the doubly linked
188
- * list.
189
- */
190
- pollFirst() {
191
- return this.shift();
192
- }
193
147
  /**
194
148
  * Time Complexity: O(1)
195
149
  * Space Complexity: O(1)
@@ -213,52 +167,8 @@ class DoublyLinkedList extends base_1.IterableElementBase {
213
167
  this.head.prev = newNode;
214
168
  this._head = newNode;
215
169
  }
216
- this._length++;
217
- }
218
- /**
219
- * Time Complexity: O(1)
220
- * Space Complexity: O(1)
221
- */
222
- /**
223
- * Time Complexity: O(1)
224
- * Space Complexity: O(1)
225
- *
226
- * The addFirst function adds a new node with the given value to the beginning of a doubly linked list.
227
- * @param {E} value - The `value` parameter represents the value of the new node that will be added to the beginning of the
228
- * doubly linked list.
229
- */
230
- addFirst(value) {
231
- this.unshift(value);
232
- }
233
- /**
234
- * Time Complexity: O(n), where n is the number of elements in the linked list.
235
- * Space Complexity: O(1)
236
- */
237
- /**
238
- * Time Complexity: O(n), where n is the number of elements in the linked list.
239
- * Space Complexity: O(1)
240
- *
241
- * The `getFirst` function returns the first node in a doubly linked list, or undefined if the list is empty.
242
- * @returns The method `getFirst()` returns the first node of the doubly linked list, or `undefined` if the list is empty.
243
- */
244
- getFirst() {
245
- var _a;
246
- return (_a = this.head) === null || _a === void 0 ? void 0 : _a.value;
247
- }
248
- /**
249
- * Time Complexity: O(n), where n is the number of elements in the linked list.
250
- * Space Complexity: O(1)
251
- */
252
- /**
253
- * Time Complexity: O(n), where n is the number of elements in the linked list.
254
- * Space Complexity: O(1)
255
- *
256
- * The `getLast` function returns the last node in a doubly linked list, or undefined if the list is empty.
257
- * @returns The method `getLast()` returns the last node of the doubly linked list, or `undefined` if the list is empty.
258
- */
259
- getLast() {
260
- var _a;
261
- return (_a = this.tail) === null || _a === void 0 ? void 0 : _a.value;
170
+ this._size++;
171
+ return true;
262
172
  }
263
173
  /**
264
174
  * Time Complexity: O(n), where n is the number of elements in the linked list.
@@ -275,7 +185,7 @@ class DoublyLinkedList extends base_1.IterableElementBase {
275
185
  * or the linked list is empty, it will return undefined.
276
186
  */
277
187
  getAt(index) {
278
- if (index < 0 || index >= this.length)
188
+ if (index < 0 || index >= this.size)
279
189
  return undefined;
280
190
  let current = this.head;
281
191
  for (let i = 0; i < index; i++) {
@@ -299,7 +209,7 @@ class DoublyLinkedList extends base_1.IterableElementBase {
299
209
  * valid range of the linked list, otherwise it returns `undefined`.
300
210
  */
301
211
  getNodeAt(index) {
302
- if (index < 0 || index >= this.length)
212
+ if (index < 0 || index >= this.size)
303
213
  return undefined;
304
214
  let current = this.head;
305
215
  for (let i = 0; i < index; i++) {
@@ -347,14 +257,14 @@ class DoublyLinkedList extends base_1.IterableElementBase {
347
257
  * @returns The `insert` method returns a boolean value. It returns `true` if the insertion is successful, and `false`
348
258
  * if the index is out of bounds.
349
259
  */
350
- insertAt(index, value) {
351
- if (index < 0 || index > this.length)
260
+ addAt(index, value) {
261
+ if (index < 0 || index > this.size)
352
262
  return false;
353
263
  if (index === 0) {
354
264
  this.unshift(value);
355
265
  return true;
356
266
  }
357
- if (index === this.length) {
267
+ if (index === this.size) {
358
268
  this.push(value);
359
269
  return true;
360
270
  }
@@ -365,7 +275,7 @@ class DoublyLinkedList extends base_1.IterableElementBase {
365
275
  newNode.next = nextNode;
366
276
  prevNode.next = newNode;
367
277
  nextNode.prev = newNode;
368
- this._length++;
278
+ this._size++;
369
279
  return true;
370
280
  }
371
281
  /**
@@ -376,7 +286,7 @@ class DoublyLinkedList extends base_1.IterableElementBase {
376
286
  * Time Complexity: O(n), where n is the number of elements in the linked list.
377
287
  * Space Complexity: O(1)
378
288
  *
379
- * The `insertBefore` function inserts a new value before an existing value or node in a doubly linked list.
289
+ * The `addBefore` function inserts a new value before an existing value or node in a doubly linked list.
380
290
  * @param {E | DoublyLinkedListNode<E>} existingValueOrNode - The existing value or node in the doubly linked list
381
291
  * before which the new value will be inserted. It can be either the value of the existing node or the existing node
382
292
  * itself.
@@ -385,7 +295,7 @@ class DoublyLinkedList extends base_1.IterableElementBase {
385
295
  * @returns The method returns a boolean value. It returns `true` if the insertion is successful, and `false` if the
386
296
  * insertion fails.
387
297
  */
388
- insertBefore(existingValueOrNode, newValue) {
298
+ addBefore(existingValueOrNode, newValue) {
389
299
  let existingNode;
390
300
  if (existingValueOrNode instanceof DoublyLinkedListNode) {
391
301
  existingNode = existingValueOrNode;
@@ -404,7 +314,7 @@ class DoublyLinkedList extends base_1.IterableElementBase {
404
314
  if (existingNode === this.head) {
405
315
  this._head = newNode;
406
316
  }
407
- this._length++;
317
+ this._size++;
408
318
  return true;
409
319
  }
410
320
  return false;
@@ -417,7 +327,7 @@ class DoublyLinkedList extends base_1.IterableElementBase {
417
327
  * Time Complexity: O(n), where n is the number of elements in the linked list.
418
328
  * Space Complexity: O(1)
419
329
  *
420
- * The `insertAfter` function inserts a new node with a given value after an existing node in a doubly linked list.
330
+ * The `addAfter` function inserts a new node with a given value after an existing node in a doubly linked list.
421
331
  * @param {E | DoublyLinkedListNode<E>} existingValueOrNode - The existing value or node in the doubly linked list
422
332
  * after which the new value will be inserted. It can be either the value of the existing node or the existing node
423
333
  * itself.
@@ -425,7 +335,7 @@ class DoublyLinkedList extends base_1.IterableElementBase {
425
335
  * @returns The method returns a boolean value. It returns true if the insertion is successful, and false if the
426
336
  * existing value or node is not found in the doubly linked list.
427
337
  */
428
- insertAfter(existingValueOrNode, newValue) {
338
+ addAfter(existingValueOrNode, newValue) {
429
339
  let existingNode;
430
340
  if (existingValueOrNode instanceof DoublyLinkedListNode) {
431
341
  existingNode = existingValueOrNode;
@@ -444,7 +354,7 @@ class DoublyLinkedList extends base_1.IterableElementBase {
444
354
  if (existingNode === this.tail) {
445
355
  this._tail = newNode;
446
356
  }
447
- this._length++;
357
+ this._size++;
448
358
  return true;
449
359
  }
450
360
  return false;
@@ -464,19 +374,23 @@ class DoublyLinkedList extends base_1.IterableElementBase {
464
374
  * bounds.
465
375
  */
466
376
  deleteAt(index) {
467
- if (index < 0 || index >= this.length)
468
- return undefined;
469
- if (index === 0)
470
- return this.shift();
471
- if (index === this.length - 1)
472
- return this.pop();
377
+ if (index < 0 || index >= this.size)
378
+ return false;
379
+ if (index === 0) {
380
+ this.shift();
381
+ return true;
382
+ }
383
+ if (index === this.size - 1) {
384
+ this.pop();
385
+ return true;
386
+ }
473
387
  const removedNode = this.getNodeAt(index);
474
388
  const prevNode = removedNode.prev;
475
389
  const nextNode = removedNode.next;
476
390
  prevNode.next = nextNode;
477
391
  nextNode.prev = prevNode;
478
- this._length--;
479
- return removedNode.value;
392
+ this._size--;
393
+ return true;
480
394
  }
481
395
  /**
482
396
  * Time Complexity: O(n), where n is the number of elements in the linked list.
@@ -512,26 +426,26 @@ class DoublyLinkedList extends base_1.IterableElementBase {
512
426
  const nextNode = node.next;
513
427
  prevNode.next = nextNode;
514
428
  nextNode.prev = prevNode;
515
- this._length--;
429
+ this._size--;
516
430
  }
517
431
  return true;
518
432
  }
519
433
  return false;
520
434
  }
521
435
  /**
522
- * The function checks if a variable has a length greater than zero and returns a boolean value.
436
+ * The function checks if a variable has a size greater than zero and returns a boolean value.
523
437
  * @returns A boolean value is being returned.
524
438
  */
525
439
  isEmpty() {
526
- return this.length === 0;
440
+ return this.size === 0;
527
441
  }
528
442
  /**
529
- * The `clear` function resets the linked list by setting the head, tail, and length to undefined and 0 respectively.
443
+ * The `clear` function resets the linked list by setting the head, tail, and size to undefined and 0 respectively.
530
444
  */
531
445
  clear() {
532
446
  this._head = undefined;
533
447
  this._tail = undefined;
534
- this._length = 0;
448
+ this._size = 0;
535
449
  }
536
450
  /**
537
451
  * Time Complexity: O(n), where n is the number of elements in the linked list.
@@ -626,6 +540,7 @@ class DoublyLinkedList extends base_1.IterableElementBase {
626
540
  [current.prev, current.next] = [current.next, current.prev];
627
541
  current = next;
628
542
  }
543
+ return this;
629
544
  }
630
545
  /**
631
546
  * Time Complexity: O(n), where n is the number of elements in the linked list.
@@ -729,12 +644,94 @@ class DoublyLinkedList extends base_1.IterableElementBase {
729
644
  }
730
645
  return mappedList;
731
646
  }
647
+ /**
648
+ * Time Complexity: O(1)
649
+ * Space Complexity: O(1)
650
+ */
651
+ /**
652
+ * Time Complexity: O(1)
653
+ * Space Complexity: O(1)
654
+ *
655
+ * The addLast function adds a new node with the given value to the end of the doubly linked list.
656
+ * @param {E} value - The value to be added to the linked list.
657
+ */
658
+ addLast(value) {
659
+ return this.push(value);
660
+ }
661
+ /**
662
+ * Time Complexity: O(1)
663
+ * Space Complexity: O(1)
664
+ */
665
+ /**
666
+ * Time Complexity: O(1)
667
+ * Space Complexity: O(1)
668
+ *
669
+ * The `pollLast()` function removes and returns the value of the last node in a doubly linked list.
670
+ * @returns The method is returning the value of the removed node (removedNode.value) if the list is not empty. If the
671
+ * list is empty, it returns undefined.
672
+ */
673
+ pollLast() {
674
+ return this.pop();
675
+ }
676
+ /**
677
+ * Time Complexity: O(1)
678
+ * Space Complexity: O(1)
679
+ */
680
+ /**
681
+ * Time Complexity: O(1)
682
+ * Space Complexity: O(1)
683
+ *
684
+ * The `pollFirst()` function removes and returns the value of the first node in a doubly linked list.
685
+ * @returns The method `shift()` returns the value of the node that is removed from the beginning of the doubly linked
686
+ * list.
687
+ */
688
+ pollFirst() {
689
+ return this.shift();
690
+ }
691
+ /**
692
+ * Time Complexity: O(1)
693
+ * Space Complexity: O(1)
694
+ */
695
+ /**
696
+ * Time Complexity: O(1)
697
+ * Space Complexity: O(1)
698
+ *
699
+ * The addFirst function adds a new node with the given value to the beginning of a doubly linked list.
700
+ * @param {E} value - The `value` parameter represents the value of the new node that will be added to the beginning of the
701
+ * doubly linked list.
702
+ */
703
+ addFirst(value) {
704
+ this.unshift(value);
705
+ }
732
706
  /**
733
707
  * Time Complexity: O(n), where n is the number of elements in the linked list.
734
- * Space Complexity: O(n)
708
+ * Space Complexity: O(1)
735
709
  */
736
- print() {
737
- console.log([...this]);
710
+ /**
711
+ * Time Complexity: O(n), where n is the number of elements in the linked list.
712
+ * Space Complexity: O(1)
713
+ *
714
+ * The `get first` function returns the first node in a doubly linked list, or undefined if the list is empty.
715
+ * @returns The method `get first()` returns the first node of the doubly linked list, or `undefined` if the list is empty.
716
+ */
717
+ get first() {
718
+ var _a;
719
+ return (_a = this.head) === null || _a === void 0 ? void 0 : _a.value;
720
+ }
721
+ /**
722
+ * Time Complexity: O(n), where n is the number of elements in the linked list.
723
+ * Space Complexity: O(1)
724
+ */
725
+ /**
726
+ * Time Complexity: O(n), where n is the number of elements in the linked list.
727
+ * Space Complexity: O(1)
728
+ *
729
+ * The `get last` function returns the last node in a doubly linked list, or undefined if the list is empty.
730
+ * @returns The method `get last()` returns the last node of the doubly linked list, or `undefined` if the list is empty.
731
+ */
732
+ get last() {
733
+ var _a;
734
+ return (_a = this.tail) === null || _a === void 0 ? void 0 : _a.value;
738
735
  }
739
736
  /**
740
737
  * The function returns an iterator that iterates over the values of a linked list.
@@ -26,8 +26,8 @@ export declare class SinglyLinkedList<E = any> extends IterableElementBase<E> {
26
26
  get head(): SinglyLinkedListNode<E> | undefined;
27
27
  protected _tail: SinglyLinkedListNode<E> | undefined;
28
28
  get tail(): SinglyLinkedListNode<E> | undefined;
29
- protected _length: number;
30
- get length(): number;
29
+ protected _size: number;
30
+ get size(): number;
31
31
  /**
32
32
  * Time Complexity: O(n) - Linear time, where n is the length of the input array, as it performs a loop to push each element into the linked list.
33
33
  * Space Complexity: O(n) - Linear space, as it creates a new node for each element in the array.
@@ -54,7 +54,7 @@ export declare class SinglyLinkedList<E = any> extends IterableElementBase<E> {
54
54
  * @param {E} value - The "value" parameter represents the value that you want to add to the linked list. It can be of
55
55
  * any type (E) as specified in the generic type declaration of the class or function.
56
56
  */
57
- push(value: E): void;
57
+ push(value: E): boolean;
58
58
  /**
59
59
  * Time Complexity: O(1) - Constant time, as it involves basic pointer adjustments.
60
60
  * Space Complexity: O(1) - Constant space, as it only creates a new node.
@@ -67,7 +67,7 @@ export declare class SinglyLinkedList<E = any> extends IterableElementBase<E> {
67
67
  * @param {E} value - The "value" parameter represents the value that you want to add to the linked list. It can be of
68
68
  * any type (E) as specified in the generic type declaration of the class or function.
69
69
  */
70
- addLast(value: E): void;
70
+ addLast(value: E): boolean;
71
71
  /**
72
72
  * Time Complexity: O(n) - Linear time in the worst case, as it may need to traverse the list to find the last element.
73
73
  * Space Complexity: O(1) - Constant space.
@@ -132,7 +132,7 @@ export declare class SinglyLinkedList<E = any> extends IterableElementBase<E> {
132
132
  * @param {E} value - The parameter "value" represents the value of the new node that will be added to the beginning of the
133
133
  * linked list.
134
134
  */
135
- unshift(value: E): void;
135
+ unshift(value: E): boolean;
136
136
  /**
137
137
  * Time Complexity: O(1) - Constant time, as it involves adjusting pointers at the head.
138
138
  * Space Complexity: O(1) - Constant space.
@@ -145,7 +145,7 @@ export declare class SinglyLinkedList<E = any> extends IterableElementBase<E> {
145
145
  * @param {E} value - The parameter "value" represents the value of the new node that will be added to the beginning of the
146
146
  * linked list.
147
147
  */
148
- addFirst(value: E): void;
148
+ addFirst(value: E): boolean;
149
149
  /**
150
150
  * Time Complexity: O(n) - Linear time, where n is the index, as it may need to traverse the list to find the desired node.
151
151
  * Space Complexity: O(1) - Constant space.
@@ -190,7 +190,7 @@ export declare class SinglyLinkedList<E = any> extends IterableElementBase<E> {
190
190
  * @returns The method `deleteAt` returns the value of the node that was deleted, or `undefined` if the index is out of
191
191
  * bounds.
192
192
  */
193
- deleteAt(index: number): E | undefined;
193
+ deleteAt(index: number): boolean;
194
194
  /**
195
195
  * Time Complexity: O(n) - Linear time, where n is the index, as it may need to traverse the list to find the desired node.
196
196
  * Space Complexity: O(1) - Constant space.
@@ -205,7 +205,7 @@ export declare class SinglyLinkedList<E = any> extends IterableElementBase<E> {
205
205
  * @returns The `delete` method returns a boolean value. It returns `true` if the value or node is found and
206
206
  * successfully deleted from the linked list, and `false` if the value or node is not found in the linked list.
207
207
  */
208
- delete(valueOrNode: E | SinglyLinkedListNode<E> | undefined | undefined): boolean;
208
+ delete(valueOrNode: E | SinglyLinkedListNode<E> | undefined): boolean;
209
209
  /**
210
210
  * Time Complexity: O(n) - Linear time, where n is the index, as it may need to traverse the list to find the desired node.
211
211
  * Space Complexity: O(1) - Constant space.
@@ -214,7 +214,7 @@ export declare class SinglyLinkedList<E = any> extends IterableElementBase<E> {
214
214
  * Time Complexity: O(n) - Linear time, where n is the index, as it may need to traverse the list to find the desired node.
215
215
  * Space Complexity: O(1) - Constant space.
216
216
  *
217
- * The `insertAt` function inserts a value at a specified index in a singly linked list.
217
+ * The `addAt` function inserts a value at a specified index in a singly linked list.
218
218
  * @param {number} index - The index parameter represents the position at which the new value should be inserted in the
219
219
  * linked list. It is of type number.
220
220
  * @param {E} value - The `value` parameter represents the value that you want to insert into the linked list at the
@@ -222,7 +222,7 @@ export declare class SinglyLinkedList<E = any> extends IterableElementBase<E> {
222
222
  * @returns The `insert` method returns a boolean value. It returns `true` if the insertion is successful, and `false`
223
223
  * if the index is out of bounds.
224
224
  */
225
- insertAt(index: number, value: E): boolean;
225
+ addAt(index: number, value: E): boolean;
226
226
  /**
227
227
  * The function checks if the length of a data structure is equal to zero and returns a boolean value indicating
228
228
  * whether it is empty or not.
@@ -256,7 +256,7 @@ export declare class SinglyLinkedList<E = any> extends IterableElementBase<E> {
256
256
  * The `reverse` function reverses the order of the nodes in a singly linked list.
257
257
  * @returns The reverse() method does not return anything. It has a return type of void.
258
258
  */
259
- reverse(): void;
259
+ reverse(): this;
260
260
  /**
261
261
  * Time Complexity: O(n) - Linear time, where n is the length of the list, as it needs to reverse the pointers of each node.
262
262
  * Space Complexity: O(1) - Constant space.
@@ -309,14 +309,14 @@ export declare class SinglyLinkedList<E = any> extends IterableElementBase<E> {
309
309
  * Time Complexity: O(n) - Linear time, where n is the length of the list, as it needs to reverse the pointers of each node.
310
310
  * Space Complexity: O(1) - Constant space.
311
311
  *
312
- * The `insertBefore` function inserts a new value before an existing value in a singly linked list.
312
+ * The `addBefore` function inserts a new value before an existing value in a singly linked list.
313
313
  * @param {E | SinglyLinkedListNode<E>} existingValueOrNode - The existing value or node that you want to insert the
314
314
  * new value before. It can be either the value itself or a node containing the value in the linked list.
315
315
  * @param {E} newValue - The `newValue` parameter represents the value that you want to insert into the linked list.
316
- * @returns The method `insertBefore` returns a boolean value. It returns `true` if the new value was successfully
316
+ * @returns The method `addBefore` returns a boolean value. It returns `true` if the new value was successfully
317
317
  * inserted before the existing value, and `false` otherwise.
318
318
  */
319
- insertBefore(existingValueOrNode: E | SinglyLinkedListNode<E>, newValue: E): boolean;
319
+ addBefore(existingValueOrNode: E | SinglyLinkedListNode<E>, newValue: E): boolean;
320
320
  /**
321
321
  * Time Complexity: O(n) - Linear time, where n is the length of the list, as it needs to reverse the pointers of each node.
322
322
  * Space Complexity: O(1) - Constant space.
@@ -325,14 +325,14 @@ export declare class SinglyLinkedList<E = any> extends IterableElementBase<E> {
325
325
  * Time Complexity: O(n) - Linear time, where n is the length of the list, as it needs to reverse the pointers of each node.
326
326
  * Space Complexity: O(1) - Constant space.
327
327
  *
328
- * The `insertAfter` function inserts a new node with a given value after an existing node in a singly linked list.
328
+ * The `addAfter` function inserts a new node with a given value after an existing node in a singly linked list.
329
329
  * @param {E | SinglyLinkedListNode<E>} existingValueOrNode - The existing value or node in the linked list after which
330
330
  * the new value will be inserted. It can be either the value of the existing node or the existing node itself.
331
331
  * @param {E} newValue - The value that you want to insert into the linked list after the existing value or node.
332
332
  * @returns The method returns a boolean value. It returns true if the new value was successfully inserted after the
333
333
  * existing value or node, and false if the existing value or node was not found in the linked list.
334
334
  */
335
- insertAfter(existingValueOrNode: E | SinglyLinkedListNode<E>, newValue: E): boolean;
335
+ addAfter(existingValueOrNode: E | SinglyLinkedListNode<E>, newValue: E): boolean;
336
336
  /**
337
337
  * Time Complexity: O(n) - Linear time, where n is the length of the list, as it needs to reverse the pointers of each node.
338
338
  * Space Complexity: O(1) - Constant space.
@@ -387,10 +387,5 @@ export declare class SinglyLinkedList<E = any> extends IterableElementBase<E> {
387
387
  * of applying the provided `callback` function to each element in the original list.
388
388
  */
389
389
  map<T>(callback: ElementCallback<E, T>, thisArg?: any): SinglyLinkedList<T>;
390
- /**
391
- * Time Complexity: O(n), where n is the number of elements in the linked list.
392
- * Space Complexity: O(n)
393
- */
394
- print(): void;
395
390
  protected _getIterator(): IterableIterator<E>;
396
391
  }