linked-list-typed 1.50.4 → 1.50.5

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.
@@ -4,6 +4,7 @@ export declare abstract class IterableEntryBase<K = any, V = any> {
4
4
  * Time Complexity: O(n)
5
5
  * Space Complexity: O(1)
6
6
  */
7
+ abstract get size(): number;
7
8
  /**
8
9
  * Time Complexity: O(n)
9
10
  * Space Complexity: O(1)
@@ -91,6 +92,10 @@ export declare abstract class IterableEntryBase<K = any, V = any> {
91
92
  * Time Complexity: O(n)
92
93
  * Space Complexity: O(1)
93
94
  */
95
+ /**
96
+ * Time Complexity: O(n)
97
+ * Space Complexity: O(1)
98
+ */
94
99
  /**
95
100
  * Time Complexity: O(n)
96
101
  * Space Complexity: O(1)
@@ -171,10 +176,6 @@ export declare abstract class IterableEntryBase<K = any, V = any> {
171
176
  * collection, otherwise it returns `undefined`.
172
177
  */
173
178
  get(key: K): V | undefined;
174
- /**
175
- * Time Complexity: O(n)
176
- * Space Complexity: O(1)
177
- */
178
179
  /**
179
180
  * Time Complexity: O(n)
180
181
  * Space Complexity: O(1)
@@ -205,6 +206,7 @@ export declare abstract class IterableEntryBase<K = any, V = any> {
205
206
  protected abstract _getIterator(...args: any[]): IterableIterator<[K, V]>;
206
207
  }
207
208
  export declare abstract class IterableElementBase<E = any, C = any> {
209
+ abstract get size(): number;
208
210
  /**
209
211
  * Time Complexity: O(n)
210
212
  * Space Complexity: O(1)
@@ -253,6 +255,10 @@ export declare abstract class IterableElementBase<E = any, C = any> {
253
255
  * Time Complexity: O(n)
254
256
  * Space Complexity: O(1)
255
257
  */
258
+ /**
259
+ * Time Complexity: O(n)
260
+ * Space Complexity: O(1)
261
+ */
256
262
  /**
257
263
  * Time Complexity: O(n)
258
264
  * Space Complexity: O(1)
@@ -307,10 +313,6 @@ export declare abstract class IterableElementBase<E = any, C = any> {
307
313
  * callback function. If no element satisfies the callback function, `undefined` is returned.
308
314
  */
309
315
  find(callbackfn: ElementCallback<E, boolean>, thisArg?: any): E | undefined;
310
- /**
311
- * Time Complexity: O(n)
312
- * Space Complexity: O(1)
313
- */
314
316
  /**
315
317
  * Time Complexity: O(n)
316
318
  * Space Complexity: O(1)
@@ -2,10 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.IterableElementBase = exports.IterableEntryBase = void 0;
4
4
  class IterableEntryBase {
5
- /**
6
- * Time Complexity: O(n)
7
- * Space Complexity: O(1)
8
- */
9
5
  /**
10
6
  * Time Complexity: O(n)
11
7
  * Space Complexity: O(1)
@@ -123,6 +119,10 @@ class IterableEntryBase {
123
119
  * Time Complexity: O(n)
124
120
  * Space Complexity: O(1)
125
121
  */
122
+ /**
123
+ * Time Complexity: O(n)
124
+ * Space Complexity: O(1)
125
+ */
126
126
  /**
127
127
  * Time Complexity: O(n)
128
128
  * Space Complexity: O(1)
@@ -237,10 +237,6 @@ class IterableEntryBase {
237
237
  }
238
238
  return;
239
239
  }
240
- /**
241
- * Time Complexity: O(n)
242
- * Space Complexity: O(1)
243
- */
244
240
  /**
245
241
  * Time Complexity: O(n)
246
242
  * Space Complexity: O(1)
@@ -338,6 +334,10 @@ class IterableElementBase {
338
334
  * Time Complexity: O(n)
339
335
  * Space Complexity: O(1)
340
336
  */
337
+ /**
338
+ * Time Complexity: O(n)
339
+ * Space Complexity: O(1)
340
+ */
341
341
  /**
342
342
  * Time Complexity: O(n)
343
343
  * Space Complexity: O(1)
@@ -412,10 +412,6 @@ class IterableElementBase {
412
412
  }
413
413
  return;
414
414
  }
415
- /**
416
- * Time Complexity: O(n)
417
- * Space Complexity: O(1)
418
- */
419
415
  /**
420
416
  * Time Complexity: O(n)
421
417
  * Space Complexity: O(1)
@@ -41,6 +41,7 @@ export declare abstract class AbstractGraph<V = any, E = any, VO extends Abstrac
41
41
  protected _vertexMap: Map<VertexKey, VO>;
42
42
  get vertexMap(): Map<VertexKey, VO>;
43
43
  set vertexMap(v: Map<VertexKey, VO>);
44
+ get size(): number;
44
45
  /**
45
46
  * In TypeScript, a subclass inherits the interface implementation of its parent class, without needing to implement the same interface again in the subclass. This behavior differs from Java's approach. In Java, if a parent class implements an interface, the subclass needs to explicitly implement the same interface, even if the parent class has already implemented it.
46
47
  * This means that using abstract methods in the parent class cannot constrain the grandchild classes. Defining methods within an interface also cannot constrain the descendant classes. When inheriting from this class, developers need to be aware that this method needs to be overridden.
@@ -50,6 +50,9 @@ class AbstractGraph extends base_1.IterableEntryBase {
50
50
  set vertexMap(v) {
51
51
  this._vertexMap = v;
52
52
  }
53
+ get size() {
54
+ return this._vertexMap.size;
55
+ }
53
56
  /**
54
57
  * Time Complexity: O(1) - Constant time for Map lookup.
55
58
  * Space Complexity: O(1) - Constant space, as it creates only a few variables.
@@ -131,24 +131,19 @@ export declare class DoublyLinkedList<E = any> extends IterableElementBase<E> {
131
131
  * Space Complexity: O(1)
132
132
  */
133
133
  /**
134
- * Time Complexity: O(1)
135
- * Space Complexity: O(1)
136
- *
137
- * The push function adds a new node with the given value to the end of the doubly linked list.
138
- * @param {E} value - The value to be added to the linked list.
134
+ * The push function adds a new element to the end of a doubly linked list.
135
+ * @param {E} element - The "element" parameter represents the value that you want to add to the
136
+ * doubly linked list.
137
+ * @returns The `push` method is returning a boolean value, `true`.
139
138
  */
140
- push(value: E): boolean;
139
+ push(element: E): boolean;
141
140
  /**
142
141
  * Time Complexity: O(1)
143
142
  * Space Complexity: O(1)
144
143
  */
145
144
  /**
146
- * Time Complexity: O(1)
147
- * Space Complexity: O(1)
148
- *
149
- * The `pop()` function removes and returns the value of the last node in a doubly linked list.
150
- * @returns The method is returning the value of the removed node (removedNode.value) if the list is not empty. If the
151
- * list is empty, it returns undefined.
145
+ * The `pop()` function removes and returns the value of the last element in a linked list.
146
+ * @returns The method is returning the value of the removed node.
152
147
  */
153
148
  pop(): E | undefined;
154
149
  /**
@@ -156,12 +151,8 @@ export declare class DoublyLinkedList<E = any> extends IterableElementBase<E> {
156
151
  * Space Complexity: O(1)
157
152
  */
158
153
  /**
159
- * Time Complexity: O(1)
160
- * Space Complexity: O(1)
161
- *
162
- * The `shift()` function removes and returns the value of the first node in a doubly linked list.
163
- * @returns The method `shift()` returns the value of the node that is removed from the beginning of the doubly linked
164
- * list.
154
+ * The `shift()` function removes and returns the value of the first element in a doubly linked list.
155
+ * @returns The value of the removed node.
165
156
  */
166
157
  shift(): E | undefined;
167
158
  /**
@@ -169,14 +160,12 @@ export declare class DoublyLinkedList<E = any> extends IterableElementBase<E> {
169
160
  * Space Complexity: O(1)
170
161
  */
171
162
  /**
172
- * Time Complexity: O(1)
173
- * Space Complexity: O(1)
174
- *
175
- * The unshift function adds a new node with the given value to the beginning of a doubly linked list.
176
- * @param {E} value - The `value` parameter represents the value of the new node that will be added to the beginning of the
177
- * doubly linked list.
163
+ * The unshift function adds a new element to the beginning of a doubly linked list.
164
+ * @param {E} element - The "element" parameter represents the value of the element that you want to
165
+ * add to the beginning of the doubly linked list.
166
+ * @returns The `unshift` method is returning a boolean value, `true`.
178
167
  */
179
- unshift(value: E): boolean;
168
+ unshift(element: E): boolean;
180
169
  /**
181
170
  * Time Complexity: O(n)
182
171
  * Space Complexity: O(1)
@@ -449,57 +438,6 @@ export declare class DoublyLinkedList<E = any> extends IterableElementBase<E> {
449
438
  * object.
450
439
  */
451
440
  map<T>(callback: ElementCallback<E, T>, thisArg?: any): DoublyLinkedList<T>;
452
- /**
453
- * Time Complexity: O(1)
454
- * Space Complexity: O(1)
455
- */
456
- /**
457
- * Time Complexity: O(1)
458
- * Space Complexity: O(1)
459
- *
460
- * The addLast function adds a new node with the given value to the end of the doubly linked list.
461
- * @param {E} value - The value to be added to the linked list.
462
- */
463
- addLast(value: E): boolean;
464
- /**
465
- * Time Complexity: O(1)
466
- * Space Complexity: O(1)
467
- */
468
- /**
469
- * Time Complexity: O(1)
470
- * Space Complexity: O(1)
471
- *
472
- * The `pollLast()` function removes and returns the value of the last node in a doubly linked list.
473
- * @returns The method is returning the value of the removed node (removedNode.value) if the list is not empty. If the
474
- * list is empty, it returns undefined.
475
- */
476
- pollLast(): E | undefined;
477
- /**
478
- * Time Complexity: O(1)
479
- * Space Complexity: O(1)
480
- */
481
- /**
482
- * Time Complexity: O(1)
483
- * Space Complexity: O(1)
484
- *
485
- * The `pollFirst()` function removes and returns the value of the first node in a doubly linked list.
486
- * @returns The method `shift()` returns the value of the node that is removed from the beginning of the doubly linked
487
- * list.
488
- */
489
- pollFirst(): E | undefined;
490
- /**
491
- * Time Complexity: O(1)
492
- * Space Complexity: O(1)
493
- */
494
- /**
495
- * Time Complexity: O(1)
496
- * Space Complexity: O(1)
497
- *
498
- * The addFirst function adds a new node with the given value to the beginning of a doubly linked list.
499
- * @param {E} value - The `value` parameter represents the value of the new node that will be added to the beginning of the
500
- * doubly linked list.
501
- */
502
- addFirst(value: E): void;
503
441
  /**
504
442
  * The function returns an iterator that iterates over the values of a linked list.
505
443
  */
@@ -161,14 +161,13 @@ class DoublyLinkedList extends base_1.IterableElementBase {
161
161
  * Space Complexity: O(1)
162
162
  */
163
163
  /**
164
- * Time Complexity: O(1)
165
- * Space Complexity: O(1)
166
- *
167
- * The push function adds a new node with the given value to the end of the doubly linked list.
168
- * @param {E} value - The value to be added to the linked list.
164
+ * The push function adds a new element to the end of a doubly linked list.
165
+ * @param {E} element - The "element" parameter represents the value that you want to add to the
166
+ * doubly linked list.
167
+ * @returns The `push` method is returning a boolean value, `true`.
169
168
  */
170
- push(value) {
171
- const newNode = new DoublyLinkedListNode(value);
169
+ push(element) {
170
+ const newNode = new DoublyLinkedListNode(element);
172
171
  if (!this.head) {
173
172
  this._head = newNode;
174
173
  this._tail = newNode;
@@ -186,12 +185,8 @@ class DoublyLinkedList extends base_1.IterableElementBase {
186
185
  * Space Complexity: O(1)
187
186
  */
188
187
  /**
189
- * Time Complexity: O(1)
190
- * Space Complexity: O(1)
191
- *
192
- * The `pop()` function removes and returns the value of the last node in a doubly linked list.
193
- * @returns The method is returning the value of the removed node (removedNode.value) if the list is not empty. If the
194
- * list is empty, it returns undefined.
188
+ * The `pop()` function removes and returns the value of the last element in a linked list.
189
+ * @returns The method is returning the value of the removed node.
195
190
  */
196
191
  pop() {
197
192
  if (!this.tail)
@@ -213,12 +208,8 @@ class DoublyLinkedList extends base_1.IterableElementBase {
213
208
  * Space Complexity: O(1)
214
209
  */
215
210
  /**
216
- * Time Complexity: O(1)
217
- * Space Complexity: O(1)
218
- *
219
- * The `shift()` function removes and returns the value of the first node in a doubly linked list.
220
- * @returns The method `shift()` returns the value of the node that is removed from the beginning of the doubly linked
221
- * list.
211
+ * The `shift()` function removes and returns the value of the first element in a doubly linked list.
212
+ * @returns The value of the removed node.
222
213
  */
223
214
  shift() {
224
215
  if (!this.head)
@@ -240,15 +231,13 @@ class DoublyLinkedList extends base_1.IterableElementBase {
240
231
  * Space Complexity: O(1)
241
232
  */
242
233
  /**
243
- * Time Complexity: O(1)
244
- * Space Complexity: O(1)
245
- *
246
- * The unshift function adds a new node with the given value to the beginning of a doubly linked list.
247
- * @param {E} value - The `value` parameter represents the value of the new node that will be added to the beginning of the
248
- * doubly linked list.
234
+ * The unshift function adds a new element to the beginning of a doubly linked list.
235
+ * @param {E} element - The "element" parameter represents the value of the element that you want to
236
+ * add to the beginning of the doubly linked list.
237
+ * @returns The `unshift` method is returning a boolean value, `true`.
249
238
  */
250
- unshift(value) {
251
- const newNode = new DoublyLinkedListNode(value);
239
+ unshift(element) {
240
+ const newNode = new DoublyLinkedListNode(element);
252
241
  if (!this.head) {
253
242
  this._head = newNode;
254
243
  this._tail = newNode;
@@ -738,65 +727,6 @@ class DoublyLinkedList extends base_1.IterableElementBase {
738
727
  }
739
728
  return mappedList;
740
729
  }
741
- /**
742
- * Time Complexity: O(1)
743
- * Space Complexity: O(1)
744
- */
745
- /**
746
- * Time Complexity: O(1)
747
- * Space Complexity: O(1)
748
- *
749
- * The addLast function adds a new node with the given value to the end of the doubly linked list.
750
- * @param {E} value - The value to be added to the linked list.
751
- */
752
- addLast(value) {
753
- return this.push(value);
754
- }
755
- /**
756
- * Time Complexity: O(1)
757
- * Space Complexity: O(1)
758
- */
759
- /**
760
- * Time Complexity: O(1)
761
- * Space Complexity: O(1)
762
- *
763
- * The `pollLast()` function removes and returns the value of the last node in a doubly linked list.
764
- * @returns The method is returning the value of the removed node (removedNode.value) if the list is not empty. If the
765
- * list is empty, it returns undefined.
766
- */
767
- pollLast() {
768
- return this.pop();
769
- }
770
- /**
771
- * Time Complexity: O(1)
772
- * Space Complexity: O(1)
773
- */
774
- /**
775
- * Time Complexity: O(1)
776
- * Space Complexity: O(1)
777
- *
778
- * The `pollFirst()` function removes and returns the value of the first node in a doubly linked list.
779
- * @returns The method `shift()` returns the value of the node that is removed from the beginning of the doubly linked
780
- * list.
781
- */
782
- pollFirst() {
783
- return this.shift();
784
- }
785
- /**
786
- * Time Complexity: O(1)
787
- * Space Complexity: O(1)
788
- */
789
- /**
790
- * Time Complexity: O(1)
791
- * Space Complexity: O(1)
792
- *
793
- * The addFirst function adds a new node with the given value to the beginning of a doubly linked list.
794
- * @param {E} value - The `value` parameter represents the value of the new node that will be added to the beginning of the
795
- * doubly linked list.
796
- */
797
- addFirst(value) {
798
- this.unshift(value);
799
- }
800
730
  /**
801
731
  * The function returns an iterator that iterates over the values of a linked list.
802
732
  */
@@ -60,6 +60,18 @@ export declare class SinglyLinkedList<E = any> extends IterableElementBase<E> {
60
60
  * @returns The method is returning either a SinglyLinkedListNode object or undefined.
61
61
  */
62
62
  get tail(): SinglyLinkedListNode<E> | undefined;
63
+ /**
64
+ * The above function returns the value of the first element in a linked list, or undefined if the
65
+ * list is empty.
66
+ * @returns The value of the first node in the linked list, or undefined if the linked list is empty.
67
+ */
68
+ get first(): E | undefined;
69
+ /**
70
+ * The function returns the value of the last element in a linked list, or undefined if the list is
71
+ * empty.
72
+ * @returns The value of the last node in the linked list, or undefined if the linked list is empty.
73
+ */
74
+ get last(): E | undefined;
63
75
  protected _size: number;
64
76
  /**
65
77
  * The function returns the size of an object.
@@ -82,21 +94,6 @@ export declare class SinglyLinkedList<E = any> extends IterableElementBase<E> {
82
94
  * @returns The `fromArray` function returns a `SinglyLinkedList` object.
83
95
  */
84
96
  static fromArray<E>(data: E[]): SinglyLinkedList<E>;
85
- /**
86
- * Time Complexity: O(1)
87
- * Space Complexity: O(1)
88
- * Constant time, as it involves basic pointer adjustments.
89
- * Constant space, as it only creates a new node.
90
- */
91
- /**
92
- * Time Complexity: O(1)
93
- * Space Complexity: O(1)
94
- *
95
- * The `push` function adds a new node with the given value to the end of a singly linked list.
96
- * @param {E} value - The "value" parameter represents the value that you want to add to the linked list. It can be of
97
- * any type (E) as specified in the generic type declaration of the class or function.
98
- */
99
- push(value: E): boolean;
100
97
  /**
101
98
  * Time Complexity: O(1)
102
99
  * Space Complexity: O(1)
@@ -105,11 +102,12 @@ export declare class SinglyLinkedList<E = any> extends IterableElementBase<E> {
105
102
  * Time Complexity: O(1)
106
103
  * Space Complexity: O(1)
107
104
  *
108
- * The `push` function adds a new node with the given value to the end of a singly linked list.
109
- * @param {E} value - The "value" parameter represents the value that you want to add to the linked list. It can be of
110
- * any type (E) as specified in the generic type declaration of the class or function.
105
+ * The push function adds a new element to the end of a singly linked list.
106
+ * @param {E} element - The "element" parameter represents the value of the element that you want to
107
+ * add to the linked list.
108
+ * @returns The `push` method is returning a boolean value, `true`.
111
109
  */
112
- addLast(value: E): boolean;
110
+ push(element: E): boolean;
113
111
  /**
114
112
  * Time Complexity: O(n)
115
113
  * Space Complexity: O(1)
@@ -119,26 +117,11 @@ export declare class SinglyLinkedList<E = any> extends IterableElementBase<E> {
119
117
  * Time Complexity: O(n)
120
118
  * Space Complexity: O(1)
121
119
  *
122
- * The `pop()` function removes and returns the value of the last element in a linked list, updating the head and tail
123
- * pointers accordingly.
124
- * @returns The method `pop()` returns the value of the node that is being removed from the end of the linked list. If
125
- * the linked list is empty, it returns `undefined`.
120
+ * The `pop` function removes and returns the value of the last element in a linked list.
121
+ * @returns The method is returning the value of the element that is being popped from the end of the
122
+ * list.
126
123
  */
127
124
  pop(): E | undefined;
128
- /**
129
- * Time Complexity: O(n)
130
- * Space Complexity: O(1)
131
- */
132
- /**
133
- * Time Complexity: O(n)
134
- * Space Complexity: O(1)
135
- *
136
- * The `pollLast()` function removes and returns the value of the last element in a linked list, updating the head and tail
137
- * pointers accordingly.
138
- * @returns The method `pop()` returns the value of the node that is being removed from the end of the linked list. If
139
- * the linked list is empty, it returns `undefined`.
140
- */
141
- pollLast(): E | undefined;
142
125
  /**
143
126
  * Time Complexity: O(1)
144
127
  * Space Complexity: O(1)
@@ -147,8 +130,8 @@ export declare class SinglyLinkedList<E = any> extends IterableElementBase<E> {
147
130
  * Time Complexity: O(1)
148
131
  * Space Complexity: O(1)
149
132
  *
150
- * The `shift()` function removes and returns the value of the first node in a linked list.
151
- * @returns The value of the node that is being removed from the beginning of the linked list.
133
+ * The `shift()` function removes and returns the value of the first element in a linked list.
134
+ * @returns The value of the removed node.
152
135
  */
153
136
  shift(): E | undefined;
154
137
  /**
@@ -159,40 +142,15 @@ export declare class SinglyLinkedList<E = any> extends IterableElementBase<E> {
159
142
  * Time Complexity: O(1)
160
143
  * Space Complexity: O(1)
161
144
  *
162
- * The `pollFirst()` function removes and returns the value of the first node in a linked list.
163
- * @returns The value of the node that is being removed from the beginning of the linked list.
164
- */
165
- pollFirst(): E | undefined;
166
- /**
167
- * Time Complexity: O(1)
168
- * Space Complexity: O(1)
169
- */
170
- /**
171
- * Time Complexity: O(1)
172
- * Space Complexity: O(1)
173
- *
174
- * The unshift function adds a new node with the given value to the beginning of a singly linked list.
175
- * @param {E} value - The parameter "value" represents the value of the new node that will be added to the beginning of the
176
- * linked list.
177
- */
178
- unshift(value: E): boolean;
179
- /**
180
- * Time Complexity: O(1)
181
- * Space Complexity: O(1)
182
- */
183
- /**
184
- * Time Complexity: O(1)
185
- * Space Complexity: O(1)
186
- *
187
- * The addFirst function adds a new node with the given value to the beginning of a singly linked list.
188
- * @param {E} value - The parameter "value" represents the value of the new node that will be added to the beginning of the
189
- * linked list.
145
+ * The unshift function adds a new element to the beginning of a singly linked list.
146
+ * @param {E} element - The "element" parameter represents the value of the element that you want to
147
+ * add to the beginning of the singly linked list.
148
+ * @returns The `unshift` method is returning a boolean value, `true`.
190
149
  */
191
- addFirst(value: E): boolean;
150
+ unshift(element: E): boolean;
192
151
  /**
193
152
  * Time Complexity: O(n)
194
153
  * Space Complexity: O(1)
195
- * Linear time, where n is the index, as it may need to traverse the list to find the desired node.
196
154
  */
197
155
  /**
198
156
  * Time Complexity: O(n)