graph-typed 1.46.1 → 1.46.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.
@@ -16,6 +16,20 @@ export declare class DequeIterator<E> {
16
16
  iterateDirection: IterateDirection;
17
17
  index: number;
18
18
  readonly deque: Deque<E>;
19
+ /**
20
+ * The constructor initializes the index, iterate direction, and prev/next functions for a
21
+ * DequeIterator object.
22
+ * @param {number} index - The index parameter represents the current index position of the iterator
23
+ * within the deque. It is a number that indicates the position of the element that the iterator is
24
+ * currently pointing to.
25
+ * @param deque - The `deque` parameter is an instance of the `Deque` class. It represents a
26
+ * double-ended queue data structure, which allows elements to be added or removed from both ends.
27
+ * @param iterateDirection - The `iterateDirection` parameter is an optional parameter that specifies
28
+ * the direction in which the iterator should iterate over the elements of the `deque`. It has a
29
+ * default value of `IterateDirection.DEFAULT`.
30
+ * @returns The constructor is not returning anything. It is used to initialize the properties of the
31
+ * object being created.
32
+ */
19
33
  constructor(index: number, deque: Deque<E>, iterateDirection?: IterateDirection);
20
34
  get current(): E;
21
35
  set current(newElement: E);
@@ -31,18 +45,27 @@ export declare class Deque<E> {
31
45
  protected _lastInBucket: number;
32
46
  protected _bucketCount: number;
33
47
  protected readonly _bucketSize: number;
48
+ /**
49
+ * The constructor initializes a data structure with a specified bucket size and populates it with
50
+ * elements from an iterable.
51
+ * @param elements - The `elements` parameter is an iterable object (such as an array or a Set) that
52
+ * contains the initial elements to be stored in the data structure. It can also be an object with a
53
+ * `length` property or a `size` property, which represents the number of elements in the iterable.
54
+ * @param bucketSize - The `bucketSize` parameter is the maximum number of elements that can be
55
+ * stored in each bucket. It determines the size of each bucket in the data structure.
56
+ */
34
57
  constructor(elements?: IterableWithSizeOrLength<E>, bucketSize?: number);
35
58
  protected _buckets: E[][];
36
59
  get buckets(): E[][];
37
60
  protected _size: number;
38
61
  get size(): number;
39
- get first(): E | undefined;
40
- get last(): E | undefined;
41
62
  /**
42
- * Time Complexity: Amortized O(1) - Generally constant time, but resizing when the deque is full leads to O(n).
43
- * Space Complexity: O(n) - In worst case, resizing doubles the array size.
63
+ * The function returns the first element in a collection if it exists, otherwise it returns
64
+ * undefined.
65
+ * @returns The first element of the collection, of type E, is being returned.
44
66
  */
45
- empty(): boolean;
67
+ get first(): E | undefined;
68
+ get last(): E | undefined;
46
69
  /**
47
70
  * Time Complexity: O(1) - Removes the last element.
48
71
  * Space Complexity: O(1) - Operates in-place.
@@ -91,36 +114,415 @@ export declare class Deque<E> {
91
114
  * from the beginning. If the array is empty, it will return `undefined`.
92
115
  */
93
116
  popFirst(): E | undefined;
117
+ /**
118
+ * The clear() function resets the state of the object by initializing all variables to their default
119
+ * values.
120
+ */
94
121
  clear(): void;
122
+ /**
123
+ * The `begin()` function returns a new iterator for a deque starting from the first element.
124
+ * @returns A new instance of the DequeIterator class is being returned.
125
+ */
95
126
  begin(): DequeIterator<E>;
127
+ /**
128
+ * The `end()` function returns a new `DequeIterator` object with the size and reference to the
129
+ * current deque.
130
+ * @returns A new instance of the DequeIterator class is being returned.
131
+ */
96
132
  end(): DequeIterator<E>;
133
+ /**
134
+ * The reverseBegin function returns a new DequeIterator object that starts at the last element of
135
+ * the deque and iterates in reverse direction.
136
+ * @returns A new instance of the DequeIterator class is being returned.
137
+ */
97
138
  reverseBegin(): DequeIterator<E>;
139
+ /**
140
+ * The reverseEnd() function returns a new DequeIterator object that iterates over the elements of a
141
+ * Deque in reverse order.
142
+ * @returns A new instance of the DequeIterator class is being returned.
143
+ */
98
144
  reverseEnd(): DequeIterator<E>;
145
+ /**
146
+ * Time Complexity - Amortized O(1) (possible reallocation)
147
+ * Space Complexity - O(n) (due to potential resizing).
148
+ */
149
+ /**
150
+ * Time Complexity - Amortized O(1) (possible reallocation),
151
+ * Space Complexity - O(n) (due to potential resizing).
152
+ *
153
+ * The push function adds an element to a data structure and reallocates memory if necessary.
154
+ * @param {E} element - The `element` parameter represents the value that you want to add to the data
155
+ * structure.
156
+ * @returns The size of the data structure after the element has been pushed.
157
+ */
99
158
  push(element: E): number;
159
+ /**
160
+ * Time Complexity: O(1)
161
+ * Space Complexity: O(1)
162
+ */
163
+ /**
164
+ * Time Complexity: O(1)
165
+ * Space Complexity: O(1)
166
+ *
167
+ * The `pop()` function removes and returns the last element from a data structure, updating the
168
+ * internal state variables accordingly.
169
+ * @returns The element that was removed from the data structure is being returned.
170
+ */
100
171
  pop(): E | undefined;
172
+ /**
173
+ * Time Complexity: Amortized O(1)
174
+ * Space Complexity: O(n)
175
+ */
176
+ /**
177
+ * Time Complexity: Amortized O(1)
178
+ * Space Complexity: O(n)
179
+ *
180
+ * The `unshift` function adds an element to the beginning of an array-like data structure and
181
+ * returns the new size of the structure.
182
+ * @param {E} element - The `element` parameter represents the element that you want to add to the
183
+ * beginning of the data structure.
184
+ * @returns The size of the data structure after the element has been added.
185
+ */
101
186
  unshift(element: E): number;
187
+ /**
188
+ * Time Complexity: O(1)
189
+ * Space Complexity: O(1)
190
+ */
191
+ /**
192
+ * Time Complexity: O(1)
193
+ * Space Complexity: O(1)
194
+ *
195
+ * The `shift()` function removes and returns the first element from a data structure, updating the
196
+ * internal state variables accordingly.
197
+ * @returns The element that is being removed from the beginning of the data structure is being
198
+ * returned.
199
+ */
102
200
  shift(): E | undefined;
201
+ /**
202
+ * Time Complexity: O(1)
203
+ * Space Complexity: O(1)
204
+ */
205
+ /**
206
+ * Time Complexity: O(1)
207
+ * Space Complexity: O(1)
208
+ *
209
+ * The `getAt` function retrieves an element at a specified position in an array-like data structure.
210
+ * @param {number} pos - The `pos` parameter represents the position of the element that you want to
211
+ * retrieve from the data structure. It is of type `number` and should be a valid index within the
212
+ * range of the data structure.
213
+ * @returns The element at the specified position in the data structure is being returned.
214
+ */
103
215
  getAt(pos: number): E;
216
+ /**
217
+ * Time Complexity: O(1)
218
+ * Space Complexity: O(1)
219
+ */
220
+ /**
221
+ * Time Complexity: O(1)
222
+ * Space Complexity: O(1)
223
+ *
224
+ * The `setAt` function sets an element at a specific position in an array-like data structure.
225
+ * @param {number} pos - The `pos` parameter represents the position at which the element needs to be
226
+ * set. It is of type `number`.
227
+ * @param {E} element - The `element` parameter is the value that you want to set at the specified
228
+ * position in the data structure.
229
+ */
104
230
  setAt(pos: number, element: E): void;
231
+ /**
232
+ * Time Complexity: O(n)
233
+ * Space Complexity: O(n)
234
+ */
235
+ /**
236
+ * Time Complexity: O(n)
237
+ * Space Complexity: O(n)
238
+ *
239
+ * The `insertAt` function inserts one or more elements at a specified position in an array-like data
240
+ * structure.
241
+ * @param {number} pos - The `pos` parameter represents the position at which the element(s) should
242
+ * be inserted. It is of type `number`.
243
+ * @param {E} element - The `element` parameter represents the element that you want to insert into
244
+ * the array at the specified position.
245
+ * @param [num=1] - The `num` parameter represents the number of times the `element` should be
246
+ * inserted at the specified position (`pos`). By default, it is set to 1, meaning that the `element`
247
+ * will be inserted once. However, you can provide a different value for `num` if you want
248
+ * @returns The size of the array after the insertion is being returned.
249
+ */
105
250
  insertAt(pos: number, element: E, num?: number): number;
251
+ /**
252
+ * Time Complexity: O(1)
253
+ * Space Complexity: O(1)
254
+ */
255
+ /**
256
+ * Time Complexity: O(1)
257
+ * Space Complexity: O(1)
258
+ *
259
+ * The `cut` function updates the state of the object based on the given position and returns the
260
+ * updated size.
261
+ * @param {number} pos - The `pos` parameter represents the position at which the string should be
262
+ * cut. It is a number that indicates the index of the character where the cut should be made.
263
+ * @returns The method is returning the updated size of the data structure.
264
+ */
106
265
  cut(pos: number): number;
266
+ /**
267
+ * Time Complexity: O(n)
268
+ * Space Complexity: O(1)
269
+ */
270
+ /**
271
+ * Time Complexity: O(n)
272
+ * Space Complexity: O(1)
273
+ *
274
+ * The `deleteAt` function removes an element at a specified position in an array-like data
275
+ * structure.
276
+ * @param {number} pos - The `pos` parameter in the `deleteAt` function represents the position at
277
+ * which an element needs to be deleted from the data structure. It is of type `number` and indicates
278
+ * the index of the element to be deleted.
279
+ * @returns The size of the data structure after the deletion operation is performed.
280
+ */
107
281
  deleteAt(pos: number): number;
282
+ /**
283
+ * Time Complexity: O(n)
284
+ * Space Complexity: O(1)
285
+ */
286
+ /**
287
+ * Time Complexity: O(n)
288
+ * Space Complexity: O(1)
289
+ *
290
+ * The `delete` function removes all occurrences of a specified element from an array-like data
291
+ * structure.
292
+ * @param {E} element - The `element` parameter represents the element that you want to delete from
293
+ * the data structure.
294
+ * @returns The size of the data structure after the element has been deleted.
295
+ */
108
296
  delete(element: E): number;
297
+ /**
298
+ * Time Complexity: O(n)
299
+ * Space Complexity: O(1)
300
+ */
301
+ /**
302
+ * Time Complexity: O(n)
303
+ * Space Complexity: O(1)
304
+ *
305
+ * The function deletes an element from a deque using an iterator and returns the next iterator.
306
+ * @param iter - The parameter `iter` is of type `DequeIterator<E>`. It represents an iterator object
307
+ * that is used to iterate over elements in a deque (double-ended queue).
308
+ * @returns the updated iterator after deleting an element from the deque.
309
+ */
109
310
  deleteByIterator(iter: DequeIterator<E>): DequeIterator<E>;
311
+ /**
312
+ * Time Complexity: O(n)
313
+ * Space Complexity: O(1)
314
+ */
315
+ /**
316
+ * Time Complexity: O(n)
317
+ * Space Complexity: O(1)
318
+ *
319
+ * The function `findIterator` searches for an element in a deque and returns an iterator pointing to
320
+ * the element if found, otherwise it returns an iterator pointing to the end of the deque.
321
+ * @param {E} element - The `element` parameter is the element that you want to find in the deque.
322
+ * @returns The method `findIterator(element: E)` returns a `DequeIterator<E>` object.
323
+ */
110
324
  findIterator(element: E): DequeIterator<E>;
325
+ /**
326
+ * Time Complexity: O(n)
327
+ * Space Complexity: O(1)
328
+ */
329
+ /**
330
+ * Time Complexity: O(n)
331
+ * Space Complexity: O(1)
332
+ *
333
+ * The reverse() function reverses the order of the buckets and the elements within each bucket in a
334
+ * data structure.
335
+ * @returns The reverse() method is returning the object itself (this) after performing the reverse
336
+ * operation on the buckets and updating the relevant properties.
337
+ */
111
338
  reverse(): this;
339
+ /**
340
+ * Time Complexity: O(n)
341
+ * Space Complexity: O(1)
342
+ */
343
+ /**
344
+ * Time Complexity: O(n)
345
+ * Space Complexity: O(1)
346
+ *
347
+ * The `unique()` function removes duplicate elements from an array-like data structure and returns
348
+ * the number of unique elements.
349
+ * @returns The size of the modified array is being returned.
350
+ */
112
351
  unique(): number;
352
+ /**
353
+ * Time Complexity: O(n log n)
354
+ * Space Complexity: O(n)
355
+ */
356
+ /**
357
+ * Time Complexity: O(n log n)
358
+ * Space Complexity: O(n)
359
+ *
360
+ * The `sort` function sorts the elements in a data structure using a provided comparator function.
361
+ * @param [comparator] - The `comparator` parameter is a function that takes in two elements `x` and
362
+ * `y` of type `E` and returns a number. The comparator function is used to determine the order of
363
+ * the elements in the sorted array.
364
+ * @returns The method is returning the sorted instance of the object on which the method is called.
365
+ */
113
366
  sort(comparator?: (x: E, y: E) => number): this;
367
+ /**
368
+ * Time Complexity: O(n)
369
+ * Space Complexity: O(n)
370
+ */
371
+ /**
372
+ * Time Complexity: O(n)
373
+ * Space Complexity: O(n)
374
+ *
375
+ * The `shrinkToFit` function reorganizes the elements in an array-like data structure to minimize
376
+ * memory usage.
377
+ * @returns Nothing is being returned. The function is using the `return` statement to exit early if
378
+ * `this.size` is 0, but it does not return any value.
379
+ */
114
380
  shrinkToFit(): void;
381
+ /**
382
+ * Time Complexity: O(n)
383
+ * Space Complexity: O(1)
384
+ */
385
+ /**
386
+ * Time Complexity: O(n)
387
+ * Space Complexity: O(1)
388
+ *
389
+ * The `forEach` function iterates over each element in a deque and applies a callback function to
390
+ * each element.
391
+ * @param callback - The callback parameter is a function that will be called for each element in the
392
+ * deque. It takes three parameters:
393
+ */
115
394
  forEach(callback: (element: E, index: number, deque: Deque<E>) => void): void;
395
+ /**
396
+ * Time Complexity: O(n)
397
+ * Space Complexity: O(1)
398
+ */
399
+ /**
400
+ * Time Complexity: O(n)
401
+ * Space Complexity: O(1)
402
+ *
403
+ * The `find` function iterates over the elements in a deque and returns the first element for which
404
+ * the callback function returns true, or undefined if no such element is found.
405
+ * @param callback - A function that takes three parameters: element, index, and deque. It should
406
+ * return a boolean value indicating whether the element satisfies a certain condition.
407
+ * @returns The method `find` returns the first element in the deque that satisfies the condition
408
+ * specified by the callback function. If no element satisfies the condition, it returns `undefined`.
409
+ */
116
410
  find(callback: (element: E, index: number, deque: Deque<E>) => boolean): E | undefined;
411
+ /**
412
+ * Time Complexity: O(n)
413
+ * Space Complexity: O(n)
414
+ */
415
+ /**
416
+ * Time Complexity: O(n)
417
+ * Space Complexity: O(n)
418
+ *
419
+ * The `toArray` function converts the elements of a data structure into an array.
420
+ * @returns The `toArray()` method is returning an array of elements of type `E`.
421
+ */
117
422
  toArray(): E[];
423
+ /**
424
+ * Time Complexity: O(n)
425
+ * Space Complexity: O(n)
426
+ */
427
+ /**
428
+ * Time Complexity: O(n)
429
+ * Space Complexity: O(n)
430
+ *
431
+ * The `map` function takes a callback function and applies it to each element in the deque,
432
+ * returning a new deque with the results.
433
+ * @param callback - The `callback` parameter is a function that takes three arguments:
434
+ * @returns The `map` method is returning a new `Deque` object with the transformed elements.
435
+ */
118
436
  map<T>(callback: (element: E, index: number, deque: Deque<E>) => T): Deque<T>;
437
+ /**
438
+ * Time Complexity: O(n)
439
+ * Space Complexity: O(n)
440
+ */
441
+ /**
442
+ * Time Complexity: O(n)
443
+ * Space Complexity: O(n)
444
+ *
445
+ * The `filter` function creates a new deque containing only the elements that satisfy the given
446
+ * predicate function.
447
+ * @param predicate - The `predicate` parameter is a function that takes three arguments: `element`,
448
+ * `index`, and `deque`.
449
+ * @returns The `filter` method is returning a new `Deque` object that contains only the elements
450
+ * that satisfy the given `predicate` function.
451
+ */
119
452
  filter(predicate: (element: E, index: number, deque: Deque<E>) => boolean): Deque<E>;
453
+ /**
454
+ * Time Complexity: O(n)
455
+ * Space Complexity: O(1)
456
+ */
457
+ /**
458
+ * Time Complexity: O(n)
459
+ * Space Complexity: O(1)
460
+ *
461
+ * The `reduce` function iterates over the elements of a deque and applies a callback function to
462
+ * each element, accumulating a single value.
463
+ * @param callback - The `callback` parameter is a function that takes four arguments:
464
+ * @param {T} initialValue - The `initialValue` parameter is the initial value of the accumulator. It
465
+ * is the value that will be passed as the first argument to the `callback` function when reducing
466
+ * the elements of the deque.
467
+ * @returns the final value of the accumulator after iterating over all elements in the deque and
468
+ * applying the callback function to each element.
469
+ */
120
470
  reduce<T>(callback: (accumulator: T, element: E, index: number, deque: Deque<E>) => T, initialValue: T): T;
471
+ /**
472
+ * Time Complexity: O(n)
473
+ * Space Complexity: O(1)
474
+ */
475
+ /**
476
+ * Time Complexity: O(n)
477
+ * Space Complexity: O(1)
478
+ *
479
+ * The function "indexOf" returns the index of the first occurrence of a given element in an array,
480
+ * or -1 if the element is not found.
481
+ * @param {E} element - The "element" parameter represents the element that you want to find the
482
+ * index of in the data structure.
483
+ * @returns The indexOf function returns the index of the first occurrence of the specified element
484
+ * in the data structure. If the element is not found, it returns -1.
485
+ */
121
486
  indexOf(element: E): number;
487
+ /**
488
+ * Time Complexity: O(n)
489
+ * Space Complexity: O(1)
490
+ */
491
+ /**
492
+ * Time Complexity: O(n)
493
+ * Space Complexity: O(1)
494
+ *
495
+ * The above function is an implementation of the iterator protocol in TypeScript, allowing the
496
+ * object to be iterated over using a for...of loop.
497
+ */
122
498
  [Symbol.iterator](): Generator<E, void, unknown>;
499
+ /**
500
+ * Time Complexity: O(n)
501
+ * Space Complexity: O(n)
502
+ */
503
+ /**
504
+ * Time Complexity: O(n)
505
+ * Space Complexity: O(n)
506
+ *
507
+ * The `_reallocate` function reallocates the buckets in an array, adding new buckets if needed.
508
+ * @param {number} [needBucketNum] - The `needBucketNum` parameter is an optional number that
509
+ * specifies the number of new buckets needed. If not provided, it will default to half of the
510
+ * current bucket count (`this._bucketCount >> 1`) or 1 if the current bucket count is less than 2.
511
+ */
123
512
  protected _reallocate(needBucketNum?: number): void;
513
+ /**
514
+ * Time Complexity: O(1)
515
+ * Space Complexity: O(1)
516
+ */
517
+ /**
518
+ * Time Complexity: O(1)
519
+ * Space Complexity: O(1)
520
+ *
521
+ * The function calculates the bucket index and index within the bucket based on the given position.
522
+ * @param {number} pos - The `pos` parameter represents the position within the data structure. It is
523
+ * a number that indicates the index or position of an element within the structure.
524
+ * @returns an object with two properties: "bucketIndex" and "indexInBucket".
525
+ */
124
526
  protected _getBucketAndPosition(pos: number): {
125
527
  bucketIndex: number;
126
528
  indexInBucket: number;