min-heap-typed 1.50.0 → 1.50.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 (67) hide show
  1. package/dist/data-structures/base/iterable-base.d.ts +114 -9
  2. package/dist/data-structures/base/iterable-base.js +143 -7
  3. package/dist/data-structures/binary-tree/avl-tree.d.ts +43 -46
  4. package/dist/data-structures/binary-tree/avl-tree.js +68 -71
  5. package/dist/data-structures/binary-tree/binary-tree.d.ts +244 -199
  6. package/dist/data-structures/binary-tree/binary-tree.js +484 -376
  7. package/dist/data-structures/binary-tree/bst.d.ts +54 -74
  8. package/dist/data-structures/binary-tree/bst.js +30 -71
  9. package/dist/data-structures/binary-tree/rb-tree.d.ts +78 -60
  10. package/dist/data-structures/binary-tree/rb-tree.js +84 -89
  11. package/dist/data-structures/binary-tree/tree-multimap.d.ts +37 -56
  12. package/dist/data-structures/binary-tree/tree-multimap.js +64 -85
  13. package/dist/data-structures/graph/abstract-graph.d.ts +1 -0
  14. package/dist/data-structures/graph/abstract-graph.js +3 -0
  15. package/dist/data-structures/graph/directed-graph.d.ts +14 -0
  16. package/dist/data-structures/graph/directed-graph.js +26 -0
  17. package/dist/data-structures/graph/map-graph.d.ts +8 -0
  18. package/dist/data-structures/graph/map-graph.js +14 -0
  19. package/dist/data-structures/graph/undirected-graph.d.ts +16 -0
  20. package/dist/data-structures/graph/undirected-graph.js +25 -0
  21. package/dist/data-structures/hash/hash-map.d.ts +121 -15
  22. package/dist/data-structures/hash/hash-map.js +160 -25
  23. package/dist/data-structures/heap/heap.d.ts +66 -6
  24. package/dist/data-structures/heap/heap.js +66 -6
  25. package/dist/data-structures/linked-list/doubly-linked-list.d.ts +67 -50
  26. package/dist/data-structures/linked-list/doubly-linked-list.js +70 -64
  27. package/dist/data-structures/linked-list/singly-linked-list.d.ts +128 -103
  28. package/dist/data-structures/linked-list/singly-linked-list.js +130 -112
  29. package/dist/data-structures/linked-list/skip-linked-list.d.ts +63 -36
  30. package/dist/data-structures/linked-list/skip-linked-list.js +63 -36
  31. package/dist/data-structures/matrix/matrix.d.ts +35 -4
  32. package/dist/data-structures/matrix/matrix.js +50 -11
  33. package/dist/data-structures/queue/deque.d.ts +49 -19
  34. package/dist/data-structures/queue/deque.js +101 -47
  35. package/dist/data-structures/queue/queue.d.ts +39 -5
  36. package/dist/data-structures/queue/queue.js +47 -5
  37. package/dist/data-structures/stack/stack.d.ts +16 -0
  38. package/dist/data-structures/stack/stack.js +22 -0
  39. package/dist/data-structures/trie/trie.d.ts +38 -1
  40. package/dist/data-structures/trie/trie.js +41 -0
  41. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +1 -1
  42. package/dist/types/data-structures/hash/hash-map.d.ts +4 -3
  43. package/dist/types/utils/utils.d.ts +1 -0
  44. package/package.json +2 -2
  45. package/src/data-structures/base/iterable-base.ts +172 -19
  46. package/src/data-structures/binary-tree/avl-tree.ts +97 -97
  47. package/src/data-structures/binary-tree/binary-tree.ts +674 -671
  48. package/src/data-structures/binary-tree/bst.ts +89 -131
  49. package/src/data-structures/binary-tree/rb-tree.ts +127 -155
  50. package/src/data-structures/binary-tree/tree-multimap.ts +96 -112
  51. package/src/data-structures/graph/abstract-graph.ts +4 -0
  52. package/src/data-structures/graph/directed-graph.ts +30 -0
  53. package/src/data-structures/graph/map-graph.ts +15 -0
  54. package/src/data-structures/graph/undirected-graph.ts +28 -0
  55. package/src/data-structures/hash/hash-map.ts +175 -34
  56. package/src/data-structures/heap/heap.ts +66 -6
  57. package/src/data-structures/linked-list/doubly-linked-list.ts +72 -66
  58. package/src/data-structures/linked-list/singly-linked-list.ts +132 -114
  59. package/src/data-structures/linked-list/skip-linked-list.ts +63 -37
  60. package/src/data-structures/matrix/matrix.ts +52 -12
  61. package/src/data-structures/queue/deque.ts +108 -49
  62. package/src/data-structures/queue/queue.ts +51 -5
  63. package/src/data-structures/stack/stack.ts +24 -0
  64. package/src/data-structures/trie/trie.ts +45 -1
  65. package/src/types/data-structures/binary-tree/binary-tree.ts +1 -1
  66. package/src/types/data-structures/hash/hash-map.ts +4 -3
  67. package/src/types/utils/utils.ts +2 -0
@@ -10,6 +10,14 @@ class SkipListNode {
10
10
  }
11
11
  exports.SkipListNode = SkipListNode;
12
12
  class SkipList {
13
+ /**
14
+ * The constructor function initializes a SkipLinkedList object with optional options and elements.
15
+ * @param elements - The `elements` parameter is an iterable containing key-value pairs `[K, V]`. It
16
+ * is used to initialize the SkipLinkedList with the given key-value pairs. If no elements are
17
+ * provided, the SkipLinkedList will be empty.
18
+ * @param {SkipLinkedListOptions} [options] - The `options` parameter is an optional object that can
19
+ * contain two properties:
20
+ */
13
21
  constructor(elements = [], options) {
14
22
  this._head = new SkipListNode(undefined, undefined, this.maxLevel);
15
23
  this._level = 0;
@@ -27,25 +35,41 @@ class SkipList {
27
35
  this.add(key, value);
28
36
  }
29
37
  }
38
+ /**
39
+ * The function returns the head node of a SkipList.
40
+ * @returns The method is returning a SkipListNode object with generic key type K and value type V.
41
+ */
30
42
  get head() {
31
43
  return this._head;
32
44
  }
45
+ /**
46
+ * The function returns the value of the private variable _level.
47
+ * @returns The level property of the object.
48
+ */
33
49
  get level() {
34
50
  return this._level;
35
51
  }
52
+ /**
53
+ * The function returns the maximum level.
54
+ * @returns The value of the variable `_maxLevel` is being returned.
55
+ */
36
56
  get maxLevel() {
37
57
  return this._maxLevel;
38
58
  }
59
+ /**
60
+ * The function returns the probability value.
61
+ * @returns The probability value stored in the private variable `_probability` is being returned.
62
+ */
39
63
  get probability() {
40
64
  return this._probability;
41
65
  }
42
66
  /**
43
- * Time Complexity: O(log n) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
44
- * Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
67
+ * Time Complexity: O(log n)
68
+ * Space Complexity: O(1)
45
69
  */
46
70
  /**
47
- * Time Complexity: O(1) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
48
- * Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
71
+ * Time Complexity: O(1)
72
+ * Space Complexity: O(1)
49
73
  *
50
74
  * Get the value of the first element (the smallest element) in the Skip List.
51
75
  * @returns The value of the first element, or undefined if the Skip List is empty.
@@ -55,12 +79,12 @@ class SkipList {
55
79
  return firstNode ? firstNode.value : undefined;
56
80
  }
57
81
  /**
58
- * Time Complexity: O(log n) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
59
- * Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
82
+ * Time Complexity: O(log n)
83
+ * Space Complexity: O(1)
60
84
  */
61
85
  /**
62
- * Time Complexity: O(log n) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
63
- * Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
86
+ * Time Complexity: O(log n)
87
+ * Space Complexity: O(1)
64
88
  *
65
89
  * Get the value of the last element (the largest element) in the Skip List.
66
90
  * @returns The value of the last element, or undefined if the Skip List is empty.
@@ -75,12 +99,12 @@ class SkipList {
75
99
  return current.value;
76
100
  }
77
101
  /**
78
- * Time Complexity: O(log n) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
79
- * Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
102
+ * Time Complexity: O(log n)
103
+ * Space Complexity: O(1)
80
104
  */
81
105
  /**
82
- * Time Complexity: O(log n) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
83
- * Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
106
+ * Time Complexity: O(log n)
107
+ * Space Complexity: O(1)
84
108
  *
85
109
  * The add function adds a new node with a given key and value to a Skip List data structure.
86
110
  * @param {K} key - The key parameter represents the key of the node that needs to be added to the skip list.
@@ -106,12 +130,12 @@ class SkipList {
106
130
  }
107
131
  }
108
132
  /**
109
- * Time Complexity: O(log n) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
110
- * Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
133
+ * Time Complexity: O(log n)
134
+ * Space Complexity: O(1)
111
135
  */
112
136
  /**
113
- * Time Complexity: O(log n) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
114
- * Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
137
+ * Time Complexity: O(log n)
138
+ * Space Complexity: O(1)
115
139
  *
116
140
  * The function `get` retrieves the value associated with a given key from a skip list data structure.
117
141
  * @param {K} key - The `key` parameter is the key of the element that we want to retrieve from the data structure.
@@ -132,23 +156,25 @@ class SkipList {
132
156
  return undefined;
133
157
  }
134
158
  /**
135
- * Time Complexity: O(1) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
136
- * Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
159
+ * Time Complexity: O(log n)
160
+ * Space Complexity: O(1)
137
161
  */
138
162
  /**
139
- * Time Complexity: O(log n) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
140
- * Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
163
+ * The function checks if a key exists in a data structure.
164
+ * @param {K} key - The parameter "key" is of type K, which represents the type of the key being
165
+ * checked.
166
+ * @returns a boolean value.
141
167
  */
142
168
  has(key) {
143
169
  return this.get(key) !== undefined;
144
170
  }
145
171
  /**
146
- * Time Complexity: O(log n) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
147
- * Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
172
+ * Time Complexity: O(log n)
173
+ * Space Complexity: O(1)
148
174
  */
149
175
  /**
150
- * Time Complexity: O(log n) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
151
- * Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
176
+ * Time Complexity: O(log n)
177
+ * Space Complexity: O(1)
152
178
  *
153
179
  * The `delete` function removes a node with a specific key from a Skip List data structure.
154
180
  * @param {K} key - The key parameter represents the key of the node that needs to be removed from the skip list.
@@ -180,12 +206,12 @@ class SkipList {
180
206
  return false;
181
207
  }
182
208
  /**
183
- * Time Complexity: O(log n) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
184
- * Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
209
+ * Time Complexity: O(log n)
210
+ * Space Complexity: O(1)
185
211
  */
186
212
  /**
187
- * Time Complexity: O(log n) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
188
- * Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
213
+ * Time Complexity: O(log n)
214
+ * Space Complexity: O(1)
189
215
  *
190
216
  * Get the value of the first element in the Skip List that is greater than the given key.
191
217
  * @param key - the given key.
@@ -202,12 +228,12 @@ class SkipList {
202
228
  return nextNode ? nextNode.value : undefined;
203
229
  }
204
230
  /**
205
- * Time Complexity: O(log n) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
206
- * Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
231
+ * Time Complexity: O(log n)
232
+ * Space Complexity: O(1)
207
233
  */
208
234
  /**
209
- * Time Complexity: O(log n) - where n is the number of elements in the SkipList, as it traverses the levels of the SkipList.
210
- * Space Complexity: O(1) - constant space, as it uses a fixed amount of space regardless of the size of the SkipList.
235
+ * Time Complexity: O(log n)
236
+ * Space Complexity: O(1)
211
237
  *
212
238
  * Get the value of the last element in the Skip List that is less than the given key.
213
239
  * @param key - the given key.
@@ -227,12 +253,13 @@ class SkipList {
227
253
  return lastLess ? lastLess.value : undefined;
228
254
  }
229
255
  /**
230
- * Time Complexity: O(maxLevel) - where maxLevel is the maximum level of the SkipList, as it may iterate up to maxLevel times in the worst case.
231
- * Space Complexity: O(1) - constant space.
256
+ * Time Complexity: O(maxLevel)
257
+ * Space Complexity: O(1)
258
+ * where maxLevel is the maximum level of the SkipList, as it may iterate up to maxLevel times in the worst case.
232
259
  */
233
260
  /**
234
- * Time Complexity: O(maxLevel) - where maxLevel is the maximum level of the SkipList, as it may iterate up to maxLevel times in the worst case.
235
- * Space Complexity: O(1) - constant space.
261
+ * Time Complexity: O(maxLevel)
262
+ * Space Complexity: O(1)
236
263
  *
237
264
  * The function "_randomLevel" generates a random level based on a given probability and maximum level.
238
265
  * @returns the level, which is a number.
@@ -16,13 +16,37 @@ export declare class Matrix {
16
16
  */
17
17
  constructor(data: number[][], options?: MatrixOptions);
18
18
  protected _rows: number;
19
+ /**
20
+ * The function returns the number of rows.
21
+ * @returns The number of rows.
22
+ */
19
23
  get rows(): number;
20
24
  protected _cols: number;
25
+ /**
26
+ * The function returns the value of the private variable _cols.
27
+ * @returns The number of columns.
28
+ */
21
29
  get cols(): number;
22
30
  protected _data: number[][];
31
+ /**
32
+ * The function returns a two-dimensional array of numbers.
33
+ * @returns The data property, which is a two-dimensional array of numbers.
34
+ */
23
35
  get data(): number[][];
36
+ /**
37
+ * The above function returns the value of the _addFn property.
38
+ * @returns The value of the property `_addFn` is being returned.
39
+ */
24
40
  get addFn(): (a: number | undefined, b: number) => number | undefined;
41
+ /**
42
+ * The function returns the value of the _subtractFn property.
43
+ * @returns The `_subtractFn` property is being returned.
44
+ */
25
45
  get subtractFn(): (a: number, b: number) => number;
46
+ /**
47
+ * The function returns the value of the _multiplyFn property.
48
+ * @returns The `_multiplyFn` property is being returned.
49
+ */
26
50
  get multiplyFn(): (a: number, b: number) => number;
27
51
  /**
28
52
  * The `get` function returns the value at the specified row and column index if it is a valid index.
@@ -93,9 +117,6 @@ export declare class Matrix {
93
117
  * @returns a new Matrix object.
94
118
  */
95
119
  dot(matrix: Matrix): Matrix | undefined;
96
- protected _addFn(a: number | undefined, b: number): number | undefined;
97
- protected _subtractFn(a: number, b: number): number;
98
- protected _multiplyFn(a: number, b: number): number;
99
120
  /**
100
121
  * The function checks if a given row and column index is valid within a specified range.
101
122
  * @param {number} row - The `row` parameter represents the row index of a two-dimensional array or
@@ -104,7 +125,17 @@ export declare class Matrix {
104
125
  * or grid. It is used to check if the given column index is valid within the bounds of the grid.
105
126
  * @returns A boolean value is being returned.
106
127
  */
107
- protected isValidIndex(row: number, col: number): boolean;
128
+ isValidIndex(row: number, col: number): boolean;
129
+ /**
130
+ * The `clone` function returns a new instance of the Matrix class with the same data and properties
131
+ * as the original instance.
132
+ * @returns The `clone()` method is returning a new instance of the `Matrix` class with the same data
133
+ * and properties as the current instance.
134
+ */
135
+ clone(): Matrix;
136
+ protected _addFn(a: number | undefined, b: number): number | undefined;
137
+ protected _subtractFn(a: number, b: number): number;
138
+ protected _multiplyFn(a: number, b: number): number;
108
139
  /**
109
140
  * The function `_swapRows` swaps the positions of two rows in an array.
110
141
  * @param {number} row1 - The `row1` parameter is the index of the first row that you want to swap.
@@ -44,21 +44,45 @@ class Matrix {
44
44
  }
45
45
  }
46
46
  }
47
+ /**
48
+ * The function returns the number of rows.
49
+ * @returns The number of rows.
50
+ */
47
51
  get rows() {
48
52
  return this._rows;
49
53
  }
54
+ /**
55
+ * The function returns the value of the private variable _cols.
56
+ * @returns The number of columns.
57
+ */
50
58
  get cols() {
51
59
  return this._cols;
52
60
  }
61
+ /**
62
+ * The function returns a two-dimensional array of numbers.
63
+ * @returns The data property, which is a two-dimensional array of numbers.
64
+ */
53
65
  get data() {
54
66
  return this._data;
55
67
  }
68
+ /**
69
+ * The above function returns the value of the _addFn property.
70
+ * @returns The value of the property `_addFn` is being returned.
71
+ */
56
72
  get addFn() {
57
73
  return this._addFn;
58
74
  }
75
+ /**
76
+ * The function returns the value of the _subtractFn property.
77
+ * @returns The `_subtractFn` property is being returned.
78
+ */
59
79
  get subtractFn() {
60
80
  return this._subtractFn;
61
81
  }
82
+ /**
83
+ * The function returns the value of the _multiplyFn property.
84
+ * @returns The `_multiplyFn` property is being returned.
85
+ */
62
86
  get multiplyFn() {
63
87
  return this._multiplyFn;
64
88
  }
@@ -332,17 +356,6 @@ class Matrix {
332
356
  multiplyFn: this.multiplyFn
333
357
  });
334
358
  }
335
- _addFn(a, b) {
336
- if (a === undefined)
337
- return b;
338
- return a + b;
339
- }
340
- _subtractFn(a, b) {
341
- return a - b;
342
- }
343
- _multiplyFn(a, b) {
344
- return a * b;
345
- }
346
359
  /**
347
360
  * The function checks if a given row and column index is valid within a specified range.
348
361
  * @param {number} row - The `row` parameter represents the row index of a two-dimensional array or
@@ -354,6 +367,32 @@ class Matrix {
354
367
  isValidIndex(row, col) {
355
368
  return row >= 0 && row < this.rows && col >= 0 && col < this.cols;
356
369
  }
370
+ /**
371
+ * The `clone` function returns a new instance of the Matrix class with the same data and properties
372
+ * as the original instance.
373
+ * @returns The `clone()` method is returning a new instance of the `Matrix` class with the same data
374
+ * and properties as the current instance.
375
+ */
376
+ clone() {
377
+ return new Matrix(this.data, {
378
+ rows: this.rows,
379
+ cols: this.cols,
380
+ addFn: this.addFn,
381
+ subtractFn: this.subtractFn,
382
+ multiplyFn: this.multiplyFn
383
+ });
384
+ }
385
+ _addFn(a, b) {
386
+ if (a === undefined)
387
+ return b;
388
+ return a + b;
389
+ }
390
+ _subtractFn(a, b) {
391
+ return a - b;
392
+ }
393
+ _multiplyFn(a, b) {
394
+ return a * b;
395
+ }
357
396
  /**
358
397
  * The function `_swapRows` swaps the positions of two rows in an array.
359
398
  * @param {number} row1 - The `row1` parameter is the index of the first row that you want to swap.
@@ -21,10 +21,36 @@ export declare class Deque<E> extends IterableElementBase<E> {
21
21
  protected _lastInBucket: number;
22
22
  protected _bucketCount: number;
23
23
  protected readonly _bucketSize: number;
24
+ /**
25
+ * The constructor initializes a Deque object with an optional iterable of elements and options.
26
+ * @param elements - An iterable object (such as an array or a Set) that contains the initial
27
+ * elements to be added to the deque. It can also be an object with a `length` or `size` property
28
+ * that represents the number of elements in the iterable object. If no elements are provided, an
29
+ * empty deque
30
+ * @param {DequeOptions} [options] - The `options` parameter is an optional object that can contain
31
+ * configuration options for the deque. In this code, it is used to set the `bucketSize` option,
32
+ * which determines the size of each bucket in the deque. If the `bucketSize` option is not provided
33
+ * or is not a number
34
+ */
24
35
  constructor(elements?: IterableWithSizeOrLength<E>, options?: DequeOptions);
36
+ /**
37
+ * The bucketSize function returns the size of the bucket.
38
+ *
39
+ * @return The size of the bucket
40
+ */
41
+ get bucketSize(): number;
25
42
  protected _buckets: E[][];
43
+ /**
44
+ * The buckets function returns the buckets property of the object.
45
+ *
46
+ * @return The buckets property
47
+ */
26
48
  get buckets(): E[][];
27
49
  protected _size: number;
50
+ /**
51
+ * The size function returns the number of items in the stack.
52
+ * @return The number of values in the set
53
+ */
28
54
  get size(): number;
29
55
  /**
30
56
  * The function returns the first element in a collection if it exists, otherwise it returns
@@ -32,6 +58,10 @@ export declare class Deque<E> extends IterableElementBase<E> {
32
58
  * @returns The first element of the collection, of type E, is being returned.
33
59
  */
34
60
  get first(): E | undefined;
61
+ /**
62
+ * The last function returns the last element in the queue.
63
+ * @return The last element in the array
64
+ */
35
65
  get last(): E | undefined;
36
66
  /**
37
67
  * Time Complexity - Amortized O(1) (possible reallocation)
@@ -116,13 +146,13 @@ export declare class Deque<E> extends IterableElementBase<E> {
116
146
  * Time Complexity: O(1)
117
147
  * Space Complexity: O(1)
118
148
  *
119
- * The `getAt` function retrieves an element at a specified position in an array-like data structure.
149
+ * The `at` function retrieves an element at a specified position in an array-like data structure.
120
150
  * @param {number} pos - The `pos` parameter represents the position of the element that you want to
121
151
  * retrieve from the data structure. It is of type `number` and should be a valid index within the
122
152
  * range of the data structure.
123
153
  * @returns The element at the specified position in the data structure is being returned.
124
154
  */
125
- getAt(pos: number): E;
155
+ at(pos: number): E;
126
156
  /**
127
157
  * Time Complexity: O(1)
128
158
  * Space Complexity: O(1)
@@ -170,9 +200,11 @@ export declare class Deque<E> extends IterableElementBase<E> {
170
200
  * updated size.
171
201
  * @param {number} pos - The `pos` parameter represents the position at which the string should be
172
202
  * cut. It is a number that indicates the index of the character where the cut should be made.
203
+ * @param {boolean} isCutSelf - If true, the original deque will not be cut, and return a new deque
173
204
  * @returns The method is returning the updated size of the data structure.
174
205
  */
175
- cut(pos: number): number;
206
+ cut(pos: number, isCutSelf?: boolean): Deque<E>;
207
+ cutRest(pos: number, isCutSelf?: boolean): Deque<E>;
176
208
  /**
177
209
  * Time Complexity: O(n)
178
210
  * Space Complexity: O(1)
@@ -260,22 +292,6 @@ export declare class Deque<E> extends IterableElementBase<E> {
260
292
  * `this.size` is 0, but it does not return any value.
261
293
  */
262
294
  shrinkToFit(): void;
263
- /**
264
- * Time Complexity: O(n)
265
- * Space Complexity: O(1)
266
- */
267
- /**
268
- * Time Complexity: O(n)
269
- * Space Complexity: O(1)
270
- *
271
- * The `find` function iterates over the elements in a deque and returns the first element for which
272
- * the callback function returns true, or undefined if no such element is found.
273
- * @param callback - A function that takes three parameters: element, index, and deque. It should
274
- * return a boolean value indicating whether the element satisfies a certain condition.
275
- * @returns The method `find` returns the first element in the deque that satisfies the condition
276
- * specified by the callback function. If no element satisfies the condition, it returns `undefined`.
277
- */
278
- find(callback: (element: E, index: number, deque: Deque<E>) => boolean): E | undefined;
279
295
  /**
280
296
  * Time Complexity: O(n)
281
297
  * Space Complexity: O(1)
@@ -304,6 +320,20 @@ export declare class Deque<E> extends IterableElementBase<E> {
304
320
  * @returns The `toArray()` method is returning an array of elements of type `E`.
305
321
  */
306
322
  toArray(): E[];
323
+ /**
324
+ * Time Complexity: O(n)
325
+ * Space Complexity: O(n)
326
+ */
327
+ /**
328
+ * Time Complexity: O(n)
329
+ * Space Complexity: O(n)
330
+ *
331
+ * The `clone()` function returns a new instance of the `Deque` class with the same elements and
332
+ * bucket size as the original instance.
333
+ * @returns The `clone()` method is returning a new instance of the `Deque` class with the same
334
+ * elements as the original deque (`this`) and the same bucket size.
335
+ */
336
+ clone(): Deque<E>;
307
337
  /**
308
338
  * Time Complexity: O(n)
309
339
  * Space Complexity: O(n)