min-heap-typed 1.50.2 → 1.50.3

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 (75) hide show
  1. package/dist/data-structures/base/iterable-base.d.ts +6 -0
  2. package/dist/data-structures/binary-tree/avl-tree.d.ts +29 -1
  3. package/dist/data-structures/binary-tree/avl-tree.js +33 -1
  4. package/dist/data-structures/binary-tree/binary-indexed-tree.d.ts +22 -0
  5. package/dist/data-structures/binary-tree/binary-indexed-tree.js +22 -0
  6. package/dist/data-structures/binary-tree/binary-tree.d.ts +1 -1
  7. package/dist/data-structures/binary-tree/binary-tree.js +1 -1
  8. package/dist/data-structures/binary-tree/bst.d.ts +46 -13
  9. package/dist/data-structures/binary-tree/bst.js +46 -13
  10. package/dist/data-structures/binary-tree/rb-tree.d.ts +54 -2
  11. package/dist/data-structures/binary-tree/rb-tree.js +73 -15
  12. package/dist/data-structures/binary-tree/segment-tree.d.ts +99 -6
  13. package/dist/data-structures/binary-tree/segment-tree.js +127 -10
  14. package/dist/data-structures/binary-tree/tree-multimap.d.ts +35 -2
  15. package/dist/data-structures/binary-tree/tree-multimap.js +38 -0
  16. package/dist/data-structures/graph/abstract-graph.d.ts +0 -78
  17. package/dist/data-structures/graph/abstract-graph.js +0 -189
  18. package/dist/data-structures/graph/directed-graph.d.ts +59 -0
  19. package/dist/data-structures/graph/directed-graph.js +105 -0
  20. package/dist/data-structures/graph/undirected-graph.d.ts +60 -7
  21. package/dist/data-structures/graph/undirected-graph.js +126 -18
  22. package/dist/data-structures/hash/hash-map.d.ts +143 -23
  23. package/dist/data-structures/hash/hash-map.js +196 -62
  24. package/dist/data-structures/heap/heap.d.ts +29 -19
  25. package/dist/data-structures/heap/heap.js +29 -20
  26. package/dist/data-structures/linked-list/doubly-linked-list.d.ts +71 -25
  27. package/dist/data-structures/linked-list/doubly-linked-list.js +83 -25
  28. package/dist/data-structures/linked-list/singly-linked-list.d.ts +26 -3
  29. package/dist/data-structures/linked-list/singly-linked-list.js +34 -3
  30. package/dist/data-structures/linked-list/skip-linked-list.d.ts +2 -2
  31. package/dist/data-structures/linked-list/skip-linked-list.js +2 -2
  32. package/dist/data-structures/matrix/matrix.d.ts +1 -1
  33. package/dist/data-structures/matrix/matrix.js +1 -1
  34. package/dist/data-structures/priority-queue/max-priority-queue.d.ts +10 -0
  35. package/dist/data-structures/priority-queue/max-priority-queue.js +10 -0
  36. package/dist/data-structures/priority-queue/min-priority-queue.d.ts +11 -0
  37. package/dist/data-structures/priority-queue/min-priority-queue.js +11 -0
  38. package/dist/data-structures/priority-queue/priority-queue.d.ts +8 -0
  39. package/dist/data-structures/priority-queue/priority-queue.js +8 -0
  40. package/dist/data-structures/queue/deque.d.ts +95 -21
  41. package/dist/data-structures/queue/deque.js +100 -16
  42. package/dist/data-structures/queue/queue.d.ts +65 -45
  43. package/dist/data-structures/queue/queue.js +65 -45
  44. package/dist/data-structures/stack/stack.d.ts +36 -22
  45. package/dist/data-structures/stack/stack.js +36 -22
  46. package/dist/data-structures/tree/tree.d.ts +57 -3
  47. package/dist/data-structures/tree/tree.js +77 -11
  48. package/dist/data-structures/trie/trie.d.ts +100 -36
  49. package/dist/data-structures/trie/trie.js +115 -36
  50. package/package.json +2 -2
  51. package/src/data-structures/base/iterable-base.ts +12 -0
  52. package/src/data-structures/binary-tree/avl-tree.ts +37 -3
  53. package/src/data-structures/binary-tree/binary-indexed-tree.ts +22 -0
  54. package/src/data-structures/binary-tree/binary-tree.ts +1 -1
  55. package/src/data-structures/binary-tree/bst.ts +46 -13
  56. package/src/data-structures/binary-tree/rb-tree.ts +79 -18
  57. package/src/data-structures/binary-tree/segment-tree.ts +145 -11
  58. package/src/data-structures/binary-tree/tree-multimap.ts +42 -3
  59. package/src/data-structures/graph/abstract-graph.ts +0 -211
  60. package/src/data-structures/graph/directed-graph.ts +122 -0
  61. package/src/data-structures/graph/undirected-graph.ts +143 -19
  62. package/src/data-structures/hash/hash-map.ts +228 -76
  63. package/src/data-structures/heap/heap.ts +31 -20
  64. package/src/data-structures/linked-list/doubly-linked-list.ts +96 -29
  65. package/src/data-structures/linked-list/singly-linked-list.ts +42 -6
  66. package/src/data-structures/linked-list/skip-linked-list.ts +2 -2
  67. package/src/data-structures/matrix/matrix.ts +1 -1
  68. package/src/data-structures/priority-queue/max-priority-queue.ts +10 -0
  69. package/src/data-structures/priority-queue/min-priority-queue.ts +11 -0
  70. package/src/data-structures/priority-queue/priority-queue.ts +8 -0
  71. package/src/data-structures/queue/deque.ts +118 -22
  72. package/src/data-structures/queue/queue.ts +68 -45
  73. package/src/data-structures/stack/stack.ts +39 -23
  74. package/src/data-structures/tree/tree.ts +89 -15
  75. package/src/data-structures/trie/trie.ts +131 -40
@@ -9,8 +9,39 @@ class SinglyLinkedListNode {
9
9
  * will be stored in the node of a linked list.
10
10
  */
11
11
  constructor(value) {
12
- this.value = value;
13
- this.next = undefined;
12
+ this._value = value;
13
+ this._next = undefined;
14
+ }
15
+ /**
16
+ * The function returns the value of a protected variable.
17
+ * @returns The value of the variable `_value` is being returned.
18
+ */
19
+ get value() {
20
+ return this._value;
21
+ }
22
+ /**
23
+ * The above function sets the value of a variable.
24
+ * @param {E} value - The parameter "value" is of type E, which means it can be any type.
25
+ */
26
+ set value(value) {
27
+ this._value = value;
28
+ }
29
+ /**
30
+ * The `next` function returns the next node in a singly linked list.
31
+ * @returns The `next` property is being returned. It can be either a `SinglyLinkedListNode<E>`
32
+ * object or `undefined`.
33
+ */
34
+ get next() {
35
+ return this._next;
36
+ }
37
+ /**
38
+ * The "next" property of a SinglyLinkedListNode is set to the provided value.
39
+ * @param {SinglyLinkedListNode<E> | undefined} value - The `value` parameter is of type
40
+ * `SinglyLinkedListNode<E> | undefined`. This means that it can accept either a
41
+ * `SinglyLinkedListNode` object or `undefined` as its value.
42
+ */
43
+ set next(value) {
44
+ this._next = value;
14
45
  }
15
46
  }
16
47
  exports.SinglyLinkedListNode = SinglyLinkedListNode;
@@ -656,7 +687,7 @@ class SinglyLinkedList extends base_1.IterableElementBase {
656
687
  return filteredList;
657
688
  }
658
689
  /**
659
- * Time Complexity: O(n), where n is the number of elements in the linked list.
690
+ * Time Complexity: O(n)
660
691
  * Space Complexity: O(n)
661
692
  */
662
693
  /**
@@ -30,7 +30,7 @@ export declare class SkipList<K, V> {
30
30
  get head(): SkipListNode<K, V>;
31
31
  protected _level: number;
32
32
  /**
33
- * The function returns the value of the private variable _level.
33
+ * The function returns the value of the protected variable _level.
34
34
  * @returns The level property of the object.
35
35
  */
36
36
  get level(): number;
@@ -43,7 +43,7 @@ export declare class SkipList<K, V> {
43
43
  protected _probability: number;
44
44
  /**
45
45
  * The function returns the probability value.
46
- * @returns The probability value stored in the private variable `_probability` is being returned.
46
+ * @returns The probability value stored in the protected variable `_probability` is being returned.
47
47
  */
48
48
  get probability(): number;
49
49
  /**
@@ -43,7 +43,7 @@ class SkipList {
43
43
  return this._head;
44
44
  }
45
45
  /**
46
- * The function returns the value of the private variable _level.
46
+ * The function returns the value of the protected variable _level.
47
47
  * @returns The level property of the object.
48
48
  */
49
49
  get level() {
@@ -58,7 +58,7 @@ class SkipList {
58
58
  }
59
59
  /**
60
60
  * The function returns the probability value.
61
- * @returns The probability value stored in the private variable `_probability` is being returned.
61
+ * @returns The probability value stored in the protected variable `_probability` is being returned.
62
62
  */
63
63
  get probability() {
64
64
  return this._probability;
@@ -23,7 +23,7 @@ export declare class Matrix {
23
23
  get rows(): number;
24
24
  protected _cols: number;
25
25
  /**
26
- * The function returns the value of the private variable _cols.
26
+ * The function returns the value of the protected variable _cols.
27
27
  * @returns The number of columns.
28
28
  */
29
29
  get cols(): number;
@@ -52,7 +52,7 @@ class Matrix {
52
52
  return this._rows;
53
53
  }
54
54
  /**
55
- * The function returns the value of the private variable _cols.
55
+ * The function returns the value of the protected variable _cols.
56
56
  * @returns The number of columns.
57
57
  */
58
58
  get cols() {
@@ -8,5 +8,15 @@
8
8
  import type { PriorityQueueOptions } from '../../types';
9
9
  import { PriorityQueue } from './priority-queue';
10
10
  export declare class MaxPriorityQueue<E = any> extends PriorityQueue<E> {
11
+ /**
12
+ * The constructor initializes a PriorityQueue with optional elements and options, including a
13
+ * comparator function.
14
+ * @param elements - The `elements` parameter is an iterable object that contains the initial
15
+ * elements to be added to the priority queue. It is optional and defaults to an empty array if not
16
+ * provided.
17
+ * @param options - The `options` parameter is an object that contains additional configuration
18
+ * options for the priority queue. In this case, it has a property called `comparator` which is a
19
+ * function used to compare elements in the priority queue.
20
+ */
11
21
  constructor(elements?: Iterable<E>, options?: PriorityQueueOptions<E>);
12
22
  }
@@ -3,6 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MaxPriorityQueue = void 0;
4
4
  const priority_queue_1 = require("./priority-queue");
5
5
  class MaxPriorityQueue extends priority_queue_1.PriorityQueue {
6
+ /**
7
+ * The constructor initializes a PriorityQueue with optional elements and options, including a
8
+ * comparator function.
9
+ * @param elements - The `elements` parameter is an iterable object that contains the initial
10
+ * elements to be added to the priority queue. It is optional and defaults to an empty array if not
11
+ * provided.
12
+ * @param options - The `options` parameter is an object that contains additional configuration
13
+ * options for the priority queue. In this case, it has a property called `comparator` which is a
14
+ * function used to compare elements in the priority queue.
15
+ */
6
16
  constructor(elements = [], options = {
7
17
  comparator: (a, b) => {
8
18
  if (!(typeof a === 'number' && typeof b === 'number')) {
@@ -8,5 +8,16 @@
8
8
  import type { PriorityQueueOptions } from '../../types';
9
9
  import { PriorityQueue } from './priority-queue';
10
10
  export declare class MinPriorityQueue<E = any> extends PriorityQueue<E> {
11
+ /**
12
+ * The constructor initializes a PriorityQueue with optional elements and options, including a
13
+ * comparator function.
14
+ * @param elements - The `elements` parameter is an iterable object that contains the initial
15
+ * elements to be added to the priority queue. It is optional and defaults to an empty array if not
16
+ * provided.
17
+ * @param options - The `options` parameter is an object that contains additional configuration
18
+ * options for the priority queue. In this case, it has a property called `comparator` which is a
19
+ * function used to compare elements in the priority queue. The `comparator` function takes two
20
+ * parameters `a` and `b`,
21
+ */
11
22
  constructor(elements?: Iterable<E>, options?: PriorityQueueOptions<E>);
12
23
  }
@@ -3,6 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MinPriorityQueue = void 0;
4
4
  const priority_queue_1 = require("./priority-queue");
5
5
  class MinPriorityQueue extends priority_queue_1.PriorityQueue {
6
+ /**
7
+ * The constructor initializes a PriorityQueue with optional elements and options, including a
8
+ * comparator function.
9
+ * @param elements - The `elements` parameter is an iterable object that contains the initial
10
+ * elements to be added to the priority queue. It is optional and defaults to an empty array if not
11
+ * provided.
12
+ * @param options - The `options` parameter is an object that contains additional configuration
13
+ * options for the priority queue. In this case, it has a property called `comparator` which is a
14
+ * function used to compare elements in the priority queue. The `comparator` function takes two
15
+ * parameters `a` and `b`,
16
+ */
6
17
  constructor(elements = [], options = {
7
18
  comparator: (a, b) => {
8
19
  if (!(typeof a === 'number' && typeof b === 'number')) {
@@ -16,5 +16,13 @@ import { Heap } from '../heap';
16
16
  * 6. Kth Largest Element in a Data Stream: Used to maintain a min-heap of size K for quickly finding the Kth largest element in stream data
17
17
  */
18
18
  export declare class PriorityQueue<E = any> extends Heap<E> {
19
+ /**
20
+ * The constructor initializes a priority queue with optional elements and options.
21
+ * @param elements - The `elements` parameter is an iterable object that contains the initial
22
+ * elements to be added to the priority queue. It is an optional parameter and if not provided, the
23
+ * priority queue will be initialized as empty.
24
+ * @param [options] - The `options` parameter is an optional object that can be used to customize the
25
+ * behavior of the priority queue. It can contain the following properties:
26
+ */
19
27
  constructor(elements?: Iterable<E>, options?: PriorityQueueOptions<E>);
20
28
  }
@@ -11,6 +11,14 @@ const heap_1 = require("../heap");
11
11
  * 6. Kth Largest Element in a Data Stream: Used to maintain a min-heap of size K for quickly finding the Kth largest element in stream data
12
12
  */
13
13
  class PriorityQueue extends heap_1.Heap {
14
+ /**
15
+ * The constructor initializes a priority queue with optional elements and options.
16
+ * @param elements - The `elements` parameter is an iterable object that contains the initial
17
+ * elements to be added to the priority queue. It is an optional parameter and if not provided, the
18
+ * priority queue will be initialized as empty.
19
+ * @param [options] - The `options` parameter is an optional object that can be used to customize the
20
+ * behavior of the priority queue. It can contain the following properties:
21
+ */
14
22
  constructor(elements = [], options) {
15
23
  super(elements, options);
16
24
  }
@@ -15,12 +15,6 @@ import { IterableElementBase } from '../base';
15
15
  * 5. Performance jitter: Deque may experience performance jitter, but DoublyLinkedList will not
16
16
  */
17
17
  export declare class Deque<E> extends IterableElementBase<E> {
18
- protected _bucketFirst: number;
19
- protected _firstInBucket: number;
20
- protected _bucketLast: number;
21
- protected _lastInBucket: number;
22
- protected _bucketCount: number;
23
- protected readonly _bucketSize: number;
24
18
  /**
25
19
  * The constructor initializes a Deque object with an optional iterable of elements and options.
26
20
  * @param elements - An iterable object (such as an array or a Set) that contains the initial
@@ -33,16 +27,48 @@ export declare class Deque<E> extends IterableElementBase<E> {
33
27
  * or is not a number
34
28
  */
35
29
  constructor(elements?: IterableWithSizeOrLength<E>, options?: DequeOptions);
30
+ protected _bucketSize: number;
36
31
  /**
37
32
  * The bucketSize function returns the size of the bucket.
38
33
  *
39
34
  * @return The size of the bucket
40
35
  */
41
36
  get bucketSize(): number;
37
+ protected _bucketFirst: number;
38
+ /**
39
+ * The function returns the value of the protected variable `_bucketFirst`.
40
+ * @returns The value of the `_bucketFirst` property.
41
+ */
42
+ get bucketFirst(): number;
43
+ protected _firstInBucket: number;
44
+ /**
45
+ * The function returns the value of the protected variable _firstInBucket.
46
+ * @returns The method is returning the value of the variable `_firstInBucket`, which is of type
47
+ * `number`.
48
+ */
49
+ get firstInBucket(): number;
50
+ protected _bucketLast: number;
51
+ /**
52
+ * The function returns the value of the protected variable `_bucketLast`.
53
+ * @returns The value of the `_bucketLast` property, which is a number.
54
+ */
55
+ get bucketLast(): number;
56
+ protected _lastInBucket: number;
57
+ /**
58
+ * The function returns the value of the protected variable _lastInBucket.
59
+ * @returns The method is returning the value of the variable `_lastInBucket`, which is of type
60
+ * `number`.
61
+ */
62
+ get lastInBucket(): number;
63
+ protected _bucketCount: number;
64
+ /**
65
+ * The function returns the number of buckets.
66
+ * @returns The number of buckets.
67
+ */
68
+ get bucketCount(): number;
42
69
  protected _buckets: E[][];
43
70
  /**
44
71
  * The buckets function returns the buckets property of the object.
45
- *
46
72
  * @return The buckets property
47
73
  */
48
74
  get buckets(): E[][];
@@ -120,11 +146,25 @@ export declare class Deque<E> extends IterableElementBase<E> {
120
146
  */
121
147
  shift(): E | undefined;
122
148
  /**
123
- * Time Complexity: O(1) - Removes the last element.
124
- * Space Complexity: O(1) - Operates in-place.
149
+ * Time Complexity: O(1)
150
+ * Space Complexity: O(1)
151
+ */
152
+ /**
153
+ * Time Complexity: O(1)
154
+ * Space Complexity: O(1)
155
+ *
156
+ * The function checks if the size of an object is equal to zero and returns a boolean value.
157
+ * @returns A boolean value indicating whether the size of the object is 0 or not.
125
158
  */
126
159
  isEmpty(): boolean;
127
160
  /**
161
+ * Time Complexity: O(1)
162
+ * Space Complexity: O(1)
163
+ */
164
+ /**
165
+ * Time Complexity: O(1)
166
+ * Space Complexity: O(1)
167
+ *
128
168
  * The clear() function resets the state of the object by initializing all variables to their default
129
169
  * values.
130
170
  */
@@ -204,14 +244,33 @@ export declare class Deque<E> extends IterableElementBase<E> {
204
244
  * @returns The method is returning the updated size of the data structure.
205
245
  */
206
246
  cut(pos: number, isCutSelf?: boolean): Deque<E>;
247
+ /**
248
+ * Time Complexity: O(1)
249
+ * Space Complexity: O(1) or O(n)
250
+ */
251
+ /**
252
+ * Time Complexity: O(1)
253
+ * Space Complexity: O(1) or O(n)
254
+ *
255
+ * The `cutRest` function cuts the elements from a specified position in a deque and returns a new
256
+ * deque with the cut elements.
257
+ * @param {number} pos - The `pos` parameter represents the position from which to cut the Deque. It
258
+ * is a number that indicates the index of the element in the Deque where the cut should start.
259
+ * @param [isCutSelf=false] - isCutSelf is a boolean parameter that determines whether the original
260
+ * Deque should be modified or a new Deque should be created. If isCutSelf is true, the original
261
+ * Deque will be modified by cutting off elements starting from the specified position. If isCutSelf
262
+ * is false, a new De
263
+ * @returns The function `cutRest` returns either the modified original deque (`this`) or a new deque
264
+ * (`newDeque`) depending on the value of the `isCutSelf` parameter.
265
+ */
207
266
  cutRest(pos: number, isCutSelf?: boolean): Deque<E>;
208
267
  /**
209
268
  * Time Complexity: O(n)
210
- * Space Complexity: O(1)
269
+ * Space Complexity: O(1) or O(n)
211
270
  */
212
271
  /**
213
272
  * Time Complexity: O(n)
214
- * Space Complexity: O(1)
273
+ * Space Complexity: O(1) or O(n)
215
274
  *
216
275
  * The `deleteAt` function removes an element at a specified position in an array-like data
217
276
  * structure.
@@ -378,8 +437,8 @@ export declare class Deque<E> extends IterableElementBase<E> {
378
437
  * Space Complexity: O(n) - Due to potential resizing.
379
438
  */
380
439
  /**
381
- * Time Complexity: O(1)
382
- * Space Complexity: O(n) - In worst case, resizing doubles the array size.
440
+ * Time Complexity: Amortized O(1) - Similar to push, resizing leads to O(n).
441
+ * Space Complexity: O(n) - Due to potential resizing.
383
442
  *
384
443
  * The addLast function adds an element to the end of an array.
385
444
  * @param {E} element - The element parameter represents the element that you want to add to the end of the
@@ -387,20 +446,25 @@ export declare class Deque<E> extends IterableElementBase<E> {
387
446
  */
388
447
  addLast(element: E): boolean;
389
448
  /**
390
- * Time Complexity: O(1) - Removes the first element.
391
- * Space Complexity: O(1) - In-place operation.
449
+ * Time Complexity: O(1)
450
+ * Space Complexity: O(1)
392
451
  */
393
452
  /**
394
- * Time Complexity: O(1) - Removes the last element.
395
- * Space Complexity: O(1) - Operates in-place.
453
+ * Time Complexity: O(1)
454
+ * Space Complexity: O(1)
396
455
  *
397
456
  * The function "pollLast" removes and returns the last element of an array.
398
457
  * @returns The last element of the array is being returned.
399
458
  */
400
459
  pollLast(): E | undefined;
401
460
  /**
402
- * Time Complexity: O(1).
403
- * Space Complexity: O(n) - Due to potential resizing.
461
+ * Time Complexity: O(1)
462
+ * Space Complexity: O(1)
463
+ * /
464
+
465
+ /**
466
+ * Time Complexity: O(1)
467
+ * Space Complexity: O(1)
404
468
  *
405
469
  * The "addFirst" function adds an element to the beginning of an array.
406
470
  * @param {E} element - The parameter "element" represents the element that you want to add to the
@@ -408,8 +472,13 @@ export declare class Deque<E> extends IterableElementBase<E> {
408
472
  */
409
473
  addFirst(element: E): boolean;
410
474
  /**
411
- * Time Complexity: O(1) - Removes the first element.
412
- * Space Complexity: O(1) - In-place operation.
475
+ * Time Complexity: O(1)
476
+ * Space Complexity: O(1)
477
+ * /
478
+
479
+ /**
480
+ * Time Complexity: O(1)
481
+ * Space Complexity: O(1)
413
482
  *
414
483
  * The function "pollFirst" removes and returns the first element of an array.
415
484
  * @returns The method `pollFirst()` is returning the first element of the array after removing it
@@ -417,6 +486,11 @@ export declare class Deque<E> extends IterableElementBase<E> {
417
486
  */
418
487
  pollFirst(): E | undefined;
419
488
  /**
489
+ * Time Complexity: O(n)
490
+ * Space Complexity: O(1)
491
+ * /
492
+
493
+ /**
420
494
  * Time Complexity: O(n)
421
495
  * Space Complexity: O(1)
422
496
  *
@@ -24,12 +24,12 @@ class Deque extends base_1.IterableElementBase {
24
24
  */
25
25
  constructor(elements = [], options) {
26
26
  super();
27
+ this._bucketSize = 1 << 12;
27
28
  this._bucketFirst = 0;
28
29
  this._firstInBucket = 0;
29
30
  this._bucketLast = 0;
30
31
  this._lastInBucket = 0;
31
32
  this._bucketCount = 0;
32
- this._bucketSize = 1 << 12;
33
33
  this._buckets = [];
34
34
  this._size = 0;
35
35
  if (options) {
@@ -69,9 +69,45 @@ class Deque extends base_1.IterableElementBase {
69
69
  get bucketSize() {
70
70
  return this._bucketSize;
71
71
  }
72
+ /**
73
+ * The function returns the value of the protected variable `_bucketFirst`.
74
+ * @returns The value of the `_bucketFirst` property.
75
+ */
76
+ get bucketFirst() {
77
+ return this._bucketFirst;
78
+ }
79
+ /**
80
+ * The function returns the value of the protected variable _firstInBucket.
81
+ * @returns The method is returning the value of the variable `_firstInBucket`, which is of type
82
+ * `number`.
83
+ */
84
+ get firstInBucket() {
85
+ return this._firstInBucket;
86
+ }
87
+ /**
88
+ * The function returns the value of the protected variable `_bucketLast`.
89
+ * @returns The value of the `_bucketLast` property, which is a number.
90
+ */
91
+ get bucketLast() {
92
+ return this._bucketLast;
93
+ }
94
+ /**
95
+ * The function returns the value of the protected variable _lastInBucket.
96
+ * @returns The method is returning the value of the variable `_lastInBucket`, which is of type
97
+ * `number`.
98
+ */
99
+ get lastInBucket() {
100
+ return this._lastInBucket;
101
+ }
102
+ /**
103
+ * The function returns the number of buckets.
104
+ * @returns The number of buckets.
105
+ */
106
+ get bucketCount() {
107
+ return this._bucketCount;
108
+ }
72
109
  /**
73
110
  * The buckets function returns the buckets property of the object.
74
- *
75
111
  * @return The buckets property
76
112
  */
77
113
  get buckets() {
@@ -236,13 +272,27 @@ class Deque extends base_1.IterableElementBase {
236
272
  return element;
237
273
  }
238
274
  /**
239
- * Time Complexity: O(1) - Removes the last element.
240
- * Space Complexity: O(1) - Operates in-place.
275
+ * Time Complexity: O(1)
276
+ * Space Complexity: O(1)
277
+ */
278
+ /**
279
+ * Time Complexity: O(1)
280
+ * Space Complexity: O(1)
281
+ *
282
+ * The function checks if the size of an object is equal to zero and returns a boolean value.
283
+ * @returns A boolean value indicating whether the size of the object is 0 or not.
241
284
  */
242
285
  isEmpty() {
243
286
  return this.size === 0;
244
287
  }
245
288
  /**
289
+ * Time Complexity: O(1)
290
+ * Space Complexity: O(1)
291
+ */
292
+ /**
293
+ * Time Complexity: O(1)
294
+ * Space Complexity: O(1)
295
+ *
246
296
  * The clear() function resets the state of the object by initializing all variables to their default
247
297
  * values.
248
298
  */
@@ -390,6 +440,25 @@ class Deque extends base_1.IterableElementBase {
390
440
  return newDeque;
391
441
  }
392
442
  }
443
+ /**
444
+ * Time Complexity: O(1)
445
+ * Space Complexity: O(1) or O(n)
446
+ */
447
+ /**
448
+ * Time Complexity: O(1)
449
+ * Space Complexity: O(1) or O(n)
450
+ *
451
+ * The `cutRest` function cuts the elements from a specified position in a deque and returns a new
452
+ * deque with the cut elements.
453
+ * @param {number} pos - The `pos` parameter represents the position from which to cut the Deque. It
454
+ * is a number that indicates the index of the element in the Deque where the cut should start.
455
+ * @param [isCutSelf=false] - isCutSelf is a boolean parameter that determines whether the original
456
+ * Deque should be modified or a new Deque should be created. If isCutSelf is true, the original
457
+ * Deque will be modified by cutting off elements starting from the specified position. If isCutSelf
458
+ * is false, a new De
459
+ * @returns The function `cutRest` returns either the modified original deque (`this`) or a new deque
460
+ * (`newDeque`) depending on the value of the `isCutSelf` parameter.
461
+ */
393
462
  cutRest(pos, isCutSelf = false) {
394
463
  if (isCutSelf) {
395
464
  if (pos < 0) {
@@ -412,11 +481,11 @@ class Deque extends base_1.IterableElementBase {
412
481
  }
413
482
  /**
414
483
  * Time Complexity: O(n)
415
- * Space Complexity: O(1)
484
+ * Space Complexity: O(1) or O(n)
416
485
  */
417
486
  /**
418
487
  * Time Complexity: O(n)
419
- * Space Complexity: O(1)
488
+ * Space Complexity: O(1) or O(n)
420
489
  *
421
490
  * The `deleteAt` function removes an element at a specified position in an array-like data
422
491
  * structure.
@@ -703,8 +772,8 @@ class Deque extends base_1.IterableElementBase {
703
772
  * Space Complexity: O(n) - Due to potential resizing.
704
773
  */
705
774
  /**
706
- * Time Complexity: O(1)
707
- * Space Complexity: O(n) - In worst case, resizing doubles the array size.
775
+ * Time Complexity: Amortized O(1) - Similar to push, resizing leads to O(n).
776
+ * Space Complexity: O(n) - Due to potential resizing.
708
777
  *
709
778
  * The addLast function adds an element to the end of an array.
710
779
  * @param {E} element - The element parameter represents the element that you want to add to the end of the
@@ -714,12 +783,12 @@ class Deque extends base_1.IterableElementBase {
714
783
  return this.push(element);
715
784
  }
716
785
  /**
717
- * Time Complexity: O(1) - Removes the first element.
718
- * Space Complexity: O(1) - In-place operation.
786
+ * Time Complexity: O(1)
787
+ * Space Complexity: O(1)
719
788
  */
720
789
  /**
721
- * Time Complexity: O(1) - Removes the last element.
722
- * Space Complexity: O(1) - Operates in-place.
790
+ * Time Complexity: O(1)
791
+ * Space Complexity: O(1)
723
792
  *
724
793
  * The function "pollLast" removes and returns the last element of an array.
725
794
  * @returns The last element of the array is being returned.
@@ -728,8 +797,13 @@ class Deque extends base_1.IterableElementBase {
728
797
  return this.pop();
729
798
  }
730
799
  /**
731
- * Time Complexity: O(1).
732
- * Space Complexity: O(n) - Due to potential resizing.
800
+ * Time Complexity: O(1)
801
+ * Space Complexity: O(1)
802
+ * /
803
+
804
+ /**
805
+ * Time Complexity: O(1)
806
+ * Space Complexity: O(1)
733
807
  *
734
808
  * The "addFirst" function adds an element to the beginning of an array.
735
809
  * @param {E} element - The parameter "element" represents the element that you want to add to the
@@ -739,8 +813,13 @@ class Deque extends base_1.IterableElementBase {
739
813
  return this.unshift(element);
740
814
  }
741
815
  /**
742
- * Time Complexity: O(1) - Removes the first element.
743
- * Space Complexity: O(1) - In-place operation.
816
+ * Time Complexity: O(1)
817
+ * Space Complexity: O(1)
818
+ * /
819
+
820
+ /**
821
+ * Time Complexity: O(1)
822
+ * Space Complexity: O(1)
744
823
  *
745
824
  * The function "pollFirst" removes and returns the first element of an array.
746
825
  * @returns The method `pollFirst()` is returning the first element of the array after removing it
@@ -750,6 +829,11 @@ class Deque extends base_1.IterableElementBase {
750
829
  return this.shift();
751
830
  }
752
831
  /**
832
+ * Time Complexity: O(n)
833
+ * Space Complexity: O(1)
834
+ * /
835
+
836
+ /**
753
837
  * Time Complexity: O(n)
754
838
  * Space Complexity: O(1)
755
839
  *