min-heap-typed 1.50.3 → 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.
- package/dist/data-structures/base/iterable-base.d.ts +10 -8
- package/dist/data-structures/base/iterable-base.js +8 -12
- package/dist/data-structures/binary-tree/{tree-multimap.d.ts → avl-tree-multi-map.d.ts} +11 -11
- package/dist/data-structures/binary-tree/{tree-multimap.js → avl-tree-multi-map.js} +14 -14
- package/dist/data-structures/binary-tree/bst.js +5 -7
- package/dist/data-structures/binary-tree/index.d.ts +2 -1
- package/dist/data-structures/binary-tree/index.js +2 -1
- package/dist/data-structures/binary-tree/rb-tree.js +17 -9
- package/dist/data-structures/binary-tree/tree-multi-map.d.ts +200 -0
- package/dist/data-structures/binary-tree/tree-multi-map.js +399 -0
- package/dist/data-structures/graph/abstract-graph.d.ts +1 -0
- package/dist/data-structures/graph/abstract-graph.js +3 -0
- package/dist/data-structures/linked-list/doubly-linked-list.d.ts +14 -76
- package/dist/data-structures/linked-list/doubly-linked-list.js +16 -86
- package/dist/data-structures/linked-list/singly-linked-list.d.ts +27 -69
- package/dist/data-structures/linked-list/singly-linked-list.js +35 -79
- package/dist/data-structures/queue/deque.d.ts +0 -53
- package/dist/data-structures/queue/deque.js +0 -61
- package/dist/data-structures/queue/queue.d.ts +0 -70
- package/dist/data-structures/queue/queue.js +0 -87
- package/dist/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +5 -0
- package/dist/types/data-structures/binary-tree/index.d.ts +2 -1
- package/dist/types/data-structures/binary-tree/index.js +2 -1
- package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +5 -0
- package/dist/types/data-structures/binary-tree/tree-multi-map.js +2 -0
- package/package.json +2 -2
- package/src/data-structures/base/iterable-base.ts +14 -10
- package/src/data-structures/binary-tree/{tree-multimap.ts → avl-tree-multi-map.ts} +20 -20
- package/src/data-structures/binary-tree/bst.ts +5 -6
- package/src/data-structures/binary-tree/index.ts +2 -1
- package/src/data-structures/binary-tree/rb-tree.ts +20 -10
- package/src/data-structures/binary-tree/tree-multi-map.ts +463 -0
- package/src/data-structures/graph/abstract-graph.ts +4 -0
- package/src/data-structures/heap/heap.ts +1 -1
- package/src/data-structures/linked-list/doubly-linked-list.ts +16 -94
- package/src/data-structures/linked-list/singly-linked-list.ts +35 -87
- package/src/data-structures/queue/deque.ts +0 -67
- package/src/data-structures/queue/queue.ts +0 -98
- package/src/types/data-structures/binary-tree/avl-tree-multi-map.ts +8 -0
- package/src/types/data-structures/binary-tree/index.ts +2 -1
- package/src/types/data-structures/binary-tree/tree-multi-map.ts +8 -0
- package/dist/types/data-structures/binary-tree/tree-multimap.d.ts +0 -5
- package/src/types/data-structures/binary-tree/tree-multimap.ts +0 -8
- /package/dist/types/data-structures/binary-tree/{tree-multimap.js → avl-tree-multi-map.js} +0 -0
|
@@ -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
|
|
109
|
-
* @param {E}
|
|
110
|
-
*
|
|
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
|
-
|
|
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
|
|
123
|
-
*
|
|
124
|
-
*
|
|
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
|
|
151
|
-
* @returns The value of the
|
|
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
|
|
163
|
-
* @
|
|
164
|
-
|
|
165
|
-
|
|
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
|
-
|
|
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)
|
|
@@ -74,6 +74,24 @@ class SinglyLinkedList extends base_1.IterableElementBase {
|
|
|
74
74
|
get tail() {
|
|
75
75
|
return this._tail;
|
|
76
76
|
}
|
|
77
|
+
/**
|
|
78
|
+
* The above function returns the value of the first element in a linked list, or undefined if the
|
|
79
|
+
* list is empty.
|
|
80
|
+
* @returns The value of the first node in the linked list, or undefined if the linked list is empty.
|
|
81
|
+
*/
|
|
82
|
+
get first() {
|
|
83
|
+
var _a;
|
|
84
|
+
return (_a = this.head) === null || _a === void 0 ? void 0 : _a.value;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* The function returns the value of the last element in a linked list, or undefined if the list is
|
|
88
|
+
* empty.
|
|
89
|
+
* @returns The value of the last node in the linked list, or undefined if the linked list is empty.
|
|
90
|
+
*/
|
|
91
|
+
get last() {
|
|
92
|
+
var _a;
|
|
93
|
+
return (_a = this.tail) === null || _a === void 0 ? void 0 : _a.value;
|
|
94
|
+
}
|
|
77
95
|
/**
|
|
78
96
|
* The function returns the size of an object.
|
|
79
97
|
* @returns The size of the object, which is a number.
|
|
@@ -106,19 +124,18 @@ class SinglyLinkedList extends base_1.IterableElementBase {
|
|
|
106
124
|
/**
|
|
107
125
|
* Time Complexity: O(1)
|
|
108
126
|
* Space Complexity: O(1)
|
|
109
|
-
* Constant time, as it involves basic pointer adjustments.
|
|
110
|
-
* Constant space, as it only creates a new node.
|
|
111
127
|
*/
|
|
112
128
|
/**
|
|
113
129
|
* Time Complexity: O(1)
|
|
114
130
|
* Space Complexity: O(1)
|
|
115
131
|
*
|
|
116
|
-
* The
|
|
117
|
-
* @param {E}
|
|
118
|
-
*
|
|
132
|
+
* The push function adds a new element to the end of a singly linked list.
|
|
133
|
+
* @param {E} element - The "element" parameter represents the value of the element that you want to
|
|
134
|
+
* add to the linked list.
|
|
135
|
+
* @returns The `push` method is returning a boolean value, `true`.
|
|
119
136
|
*/
|
|
120
|
-
push(
|
|
121
|
-
const newNode = new SinglyLinkedListNode(
|
|
137
|
+
push(element) {
|
|
138
|
+
const newNode = new SinglyLinkedListNode(element);
|
|
122
139
|
if (!this.head) {
|
|
123
140
|
this._head = newNode;
|
|
124
141
|
this._tail = newNode;
|
|
@@ -130,21 +147,6 @@ class SinglyLinkedList extends base_1.IterableElementBase {
|
|
|
130
147
|
this._size++;
|
|
131
148
|
return true;
|
|
132
149
|
}
|
|
133
|
-
/**
|
|
134
|
-
* Time Complexity: O(1)
|
|
135
|
-
* Space Complexity: O(1)
|
|
136
|
-
*/
|
|
137
|
-
/**
|
|
138
|
-
* Time Complexity: O(1)
|
|
139
|
-
* Space Complexity: O(1)
|
|
140
|
-
*
|
|
141
|
-
* The `push` function adds a new node with the given value to the end of a singly linked list.
|
|
142
|
-
* @param {E} value - The "value" parameter represents the value that you want to add to the linked list. It can be of
|
|
143
|
-
* any type (E) as specified in the generic type declaration of the class or function.
|
|
144
|
-
*/
|
|
145
|
-
addLast(value) {
|
|
146
|
-
return this.push(value);
|
|
147
|
-
}
|
|
148
150
|
/**
|
|
149
151
|
* Time Complexity: O(n)
|
|
150
152
|
* Space Complexity: O(1)
|
|
@@ -154,10 +156,9 @@ class SinglyLinkedList extends base_1.IterableElementBase {
|
|
|
154
156
|
* Time Complexity: O(n)
|
|
155
157
|
* Space Complexity: O(1)
|
|
156
158
|
*
|
|
157
|
-
* The `pop
|
|
158
|
-
*
|
|
159
|
-
*
|
|
160
|
-
* the linked list is empty, it returns `undefined`.
|
|
159
|
+
* The `pop` function removes and returns the value of the last element in a linked list.
|
|
160
|
+
* @returns The method is returning the value of the element that is being popped from the end of the
|
|
161
|
+
* list.
|
|
161
162
|
*/
|
|
162
163
|
pop() {
|
|
163
164
|
if (!this.head)
|
|
@@ -179,22 +180,6 @@ class SinglyLinkedList extends base_1.IterableElementBase {
|
|
|
179
180
|
this._size--;
|
|
180
181
|
return value;
|
|
181
182
|
}
|
|
182
|
-
/**
|
|
183
|
-
* Time Complexity: O(n)
|
|
184
|
-
* Space Complexity: O(1)
|
|
185
|
-
*/
|
|
186
|
-
/**
|
|
187
|
-
* Time Complexity: O(n)
|
|
188
|
-
* Space Complexity: O(1)
|
|
189
|
-
*
|
|
190
|
-
* The `pollLast()` function removes and returns the value of the last element in a linked list, updating the head and tail
|
|
191
|
-
* pointers accordingly.
|
|
192
|
-
* @returns The method `pop()` returns the value of the node that is being removed from the end of the linked list. If
|
|
193
|
-
* the linked list is empty, it returns `undefined`.
|
|
194
|
-
*/
|
|
195
|
-
pollLast() {
|
|
196
|
-
return this.pop();
|
|
197
|
-
}
|
|
198
183
|
/**
|
|
199
184
|
* Time Complexity: O(1)
|
|
200
185
|
* Space Complexity: O(1)
|
|
@@ -203,8 +188,8 @@ class SinglyLinkedList extends base_1.IterableElementBase {
|
|
|
203
188
|
* Time Complexity: O(1)
|
|
204
189
|
* Space Complexity: O(1)
|
|
205
190
|
*
|
|
206
|
-
* The `shift()` function removes and returns the value of the first
|
|
207
|
-
* @returns The value of the
|
|
191
|
+
* The `shift()` function removes and returns the value of the first element in a linked list.
|
|
192
|
+
* @returns The value of the removed node.
|
|
208
193
|
*/
|
|
209
194
|
shift() {
|
|
210
195
|
if (!this.head)
|
|
@@ -222,26 +207,13 @@ class SinglyLinkedList extends base_1.IterableElementBase {
|
|
|
222
207
|
* Time Complexity: O(1)
|
|
223
208
|
* Space Complexity: O(1)
|
|
224
209
|
*
|
|
225
|
-
* The
|
|
226
|
-
* @
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
return this.shift();
|
|
230
|
-
}
|
|
231
|
-
/**
|
|
232
|
-
* Time Complexity: O(1)
|
|
233
|
-
* Space Complexity: O(1)
|
|
234
|
-
*/
|
|
235
|
-
/**
|
|
236
|
-
* Time Complexity: O(1)
|
|
237
|
-
* Space Complexity: O(1)
|
|
238
|
-
*
|
|
239
|
-
* The unshift function adds a new node with the given value to the beginning of a singly linked list.
|
|
240
|
-
* @param {E} value - The parameter "value" represents the value of the new node that will be added to the beginning of the
|
|
241
|
-
* linked list.
|
|
210
|
+
* The unshift function adds a new element to the beginning of a singly linked list.
|
|
211
|
+
* @param {E} element - The "element" parameter represents the value of the element that you want to
|
|
212
|
+
* add to the beginning of the singly linked list.
|
|
213
|
+
* @returns The `unshift` method is returning a boolean value, `true`.
|
|
242
214
|
*/
|
|
243
|
-
unshift(
|
|
244
|
-
const newNode = new SinglyLinkedListNode(
|
|
215
|
+
unshift(element) {
|
|
216
|
+
const newNode = new SinglyLinkedListNode(element);
|
|
245
217
|
if (!this.head) {
|
|
246
218
|
this._head = newNode;
|
|
247
219
|
this._tail = newNode;
|
|
@@ -253,25 +225,9 @@ class SinglyLinkedList extends base_1.IterableElementBase {
|
|
|
253
225
|
this._size++;
|
|
254
226
|
return true;
|
|
255
227
|
}
|
|
256
|
-
/**
|
|
257
|
-
* Time Complexity: O(1)
|
|
258
|
-
* Space Complexity: O(1)
|
|
259
|
-
*/
|
|
260
|
-
/**
|
|
261
|
-
* Time Complexity: O(1)
|
|
262
|
-
* Space Complexity: O(1)
|
|
263
|
-
*
|
|
264
|
-
* The addFirst function adds a new node with the given value to the beginning of a singly linked list.
|
|
265
|
-
* @param {E} value - The parameter "value" represents the value of the new node that will be added to the beginning of the
|
|
266
|
-
* linked list.
|
|
267
|
-
*/
|
|
268
|
-
addFirst(value) {
|
|
269
|
-
return this.unshift(value);
|
|
270
|
-
}
|
|
271
228
|
/**
|
|
272
229
|
* Time Complexity: O(n)
|
|
273
230
|
* Space Complexity: O(1)
|
|
274
|
-
* Linear time, where n is the index, as it may need to traverse the list to find the desired node.
|
|
275
231
|
*/
|
|
276
232
|
/**
|
|
277
233
|
* Time Complexity: O(n)
|
|
@@ -432,59 +432,6 @@ export declare class Deque<E> extends IterableElementBase<E> {
|
|
|
432
432
|
* @returns a new Deque object with the mapped values.
|
|
433
433
|
*/
|
|
434
434
|
map<T>(callback: ElementCallback<E, T>, thisArg?: any): Deque<T>;
|
|
435
|
-
/**
|
|
436
|
-
* Time Complexity: Amortized O(1) - Similar to push, resizing leads to O(n).
|
|
437
|
-
* Space Complexity: O(n) - Due to potential resizing.
|
|
438
|
-
*/
|
|
439
|
-
/**
|
|
440
|
-
* Time Complexity: Amortized O(1) - Similar to push, resizing leads to O(n).
|
|
441
|
-
* Space Complexity: O(n) - Due to potential resizing.
|
|
442
|
-
*
|
|
443
|
-
* The addLast function adds an element to the end of an array.
|
|
444
|
-
* @param {E} element - The element parameter represents the element that you want to add to the end of the
|
|
445
|
-
* data structure.
|
|
446
|
-
*/
|
|
447
|
-
addLast(element: E): boolean;
|
|
448
|
-
/**
|
|
449
|
-
* Time Complexity: O(1)
|
|
450
|
-
* Space Complexity: O(1)
|
|
451
|
-
*/
|
|
452
|
-
/**
|
|
453
|
-
* Time Complexity: O(1)
|
|
454
|
-
* Space Complexity: O(1)
|
|
455
|
-
*
|
|
456
|
-
* The function "pollLast" removes and returns the last element of an array.
|
|
457
|
-
* @returns The last element of the array is being returned.
|
|
458
|
-
*/
|
|
459
|
-
pollLast(): E | undefined;
|
|
460
|
-
/**
|
|
461
|
-
* Time Complexity: O(1)
|
|
462
|
-
* Space Complexity: O(1)
|
|
463
|
-
* /
|
|
464
|
-
|
|
465
|
-
/**
|
|
466
|
-
* Time Complexity: O(1)
|
|
467
|
-
* Space Complexity: O(1)
|
|
468
|
-
*
|
|
469
|
-
* The "addFirst" function adds an element to the beginning of an array.
|
|
470
|
-
* @param {E} element - The parameter "element" represents the element that you want to add to the
|
|
471
|
-
* beginning of the data structure.
|
|
472
|
-
*/
|
|
473
|
-
addFirst(element: E): boolean;
|
|
474
|
-
/**
|
|
475
|
-
* Time Complexity: O(1)
|
|
476
|
-
* Space Complexity: O(1)
|
|
477
|
-
* /
|
|
478
|
-
|
|
479
|
-
/**
|
|
480
|
-
* Time Complexity: O(1)
|
|
481
|
-
* Space Complexity: O(1)
|
|
482
|
-
*
|
|
483
|
-
* The function "pollFirst" removes and returns the first element of an array.
|
|
484
|
-
* @returns The method `pollFirst()` is returning the first element of the array after removing it
|
|
485
|
-
* from the beginning. If the array is empty, it will return `undefined`.
|
|
486
|
-
*/
|
|
487
|
-
pollFirst(): E | undefined;
|
|
488
435
|
/**
|
|
489
436
|
* Time Complexity: O(n)
|
|
490
437
|
* Space Complexity: O(1)
|
|
@@ -767,67 +767,6 @@ class Deque extends base_1.IterableElementBase {
|
|
|
767
767
|
}
|
|
768
768
|
return newDeque;
|
|
769
769
|
}
|
|
770
|
-
/**
|
|
771
|
-
* Time Complexity: Amortized O(1) - Similar to push, resizing leads to O(n).
|
|
772
|
-
* Space Complexity: O(n) - Due to potential resizing.
|
|
773
|
-
*/
|
|
774
|
-
/**
|
|
775
|
-
* Time Complexity: Amortized O(1) - Similar to push, resizing leads to O(n).
|
|
776
|
-
* Space Complexity: O(n) - Due to potential resizing.
|
|
777
|
-
*
|
|
778
|
-
* The addLast function adds an element to the end of an array.
|
|
779
|
-
* @param {E} element - The element parameter represents the element that you want to add to the end of the
|
|
780
|
-
* data structure.
|
|
781
|
-
*/
|
|
782
|
-
addLast(element) {
|
|
783
|
-
return this.push(element);
|
|
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 function "pollLast" removes and returns the last element of an array.
|
|
794
|
-
* @returns The last element of the array is being returned.
|
|
795
|
-
*/
|
|
796
|
-
pollLast() {
|
|
797
|
-
return this.pop();
|
|
798
|
-
}
|
|
799
|
-
/**
|
|
800
|
-
* Time Complexity: O(1)
|
|
801
|
-
* Space Complexity: O(1)
|
|
802
|
-
* /
|
|
803
|
-
|
|
804
|
-
/**
|
|
805
|
-
* Time Complexity: O(1)
|
|
806
|
-
* Space Complexity: O(1)
|
|
807
|
-
*
|
|
808
|
-
* The "addFirst" function adds an element to the beginning of an array.
|
|
809
|
-
* @param {E} element - The parameter "element" represents the element that you want to add to the
|
|
810
|
-
* beginning of the data structure.
|
|
811
|
-
*/
|
|
812
|
-
addFirst(element) {
|
|
813
|
-
return this.unshift(element);
|
|
814
|
-
}
|
|
815
|
-
/**
|
|
816
|
-
* Time Complexity: O(1)
|
|
817
|
-
* Space Complexity: O(1)
|
|
818
|
-
* /
|
|
819
|
-
|
|
820
|
-
/**
|
|
821
|
-
* Time Complexity: O(1)
|
|
822
|
-
* Space Complexity: O(1)
|
|
823
|
-
*
|
|
824
|
-
* The function "pollFirst" removes and returns the first element of an array.
|
|
825
|
-
* @returns The method `pollFirst()` is returning the first element of the array after removing it
|
|
826
|
-
* from the beginning. If the array is empty, it will return `undefined`.
|
|
827
|
-
*/
|
|
828
|
-
pollFirst() {
|
|
829
|
-
return this.shift();
|
|
830
|
-
}
|
|
831
770
|
/**
|
|
832
771
|
* Time Complexity: O(n)
|
|
833
772
|
* Space Complexity: O(1)
|
|
@@ -120,56 +120,6 @@ export declare class Queue<E = any> extends IterableElementBase<E> {
|
|
|
120
120
|
* @return A boolean value
|
|
121
121
|
*/
|
|
122
122
|
deleteAt(index: number): boolean;
|
|
123
|
-
/**
|
|
124
|
-
* Time Complexity: O(1)
|
|
125
|
-
* Space Complexity: O(1)
|
|
126
|
-
*/
|
|
127
|
-
/**
|
|
128
|
-
* Time Complexity: O(1)
|
|
129
|
-
* Space Complexity: O(1)
|
|
130
|
-
*
|
|
131
|
-
* The `peek` function returns the first element of the array `_elements` if it exists, otherwise it returns `undefined`.
|
|
132
|
-
* @returns The `peek()` method returns the first element of the data structure, represented by the `_elements` array at
|
|
133
|
-
* the `_offset` index. If the data structure is empty (size is 0), it returns `undefined`.
|
|
134
|
-
*/
|
|
135
|
-
peek(): E | undefined;
|
|
136
|
-
/**
|
|
137
|
-
* Time Complexity: O(1)
|
|
138
|
-
* Space Complexity: O(1)
|
|
139
|
-
*/
|
|
140
|
-
/**
|
|
141
|
-
* Time Complexity: O(1)
|
|
142
|
-
* Space Complexity: O(1)
|
|
143
|
-
*
|
|
144
|
-
* The `peekLast` function returns the last element in an array-like data structure, or undefined if the structure is empty.
|
|
145
|
-
* @returns The method `peekLast()` returns the last element of the `_elements` array if the array is not empty. If the
|
|
146
|
-
* array is empty, it returns `undefined`.
|
|
147
|
-
*/
|
|
148
|
-
peekLast(): E | undefined;
|
|
149
|
-
/**
|
|
150
|
-
* Time Complexity: O(1)
|
|
151
|
-
* Space Complexity: O(1)
|
|
152
|
-
*/
|
|
153
|
-
/**
|
|
154
|
-
* Time Complexity: O(1)
|
|
155
|
-
* Space Complexity: O(1)
|
|
156
|
-
*
|
|
157
|
-
* The enqueue function adds a value to the end of a queue.
|
|
158
|
-
* @param {E} value - The value parameter represents the value that you want to add to the queue.
|
|
159
|
-
*/
|
|
160
|
-
enqueue(value: E): boolean;
|
|
161
|
-
/**
|
|
162
|
-
* Time Complexity: O(1)
|
|
163
|
-
* Space Complexity: O(1)
|
|
164
|
-
*/
|
|
165
|
-
/**
|
|
166
|
-
* Time Complexity: O(1)
|
|
167
|
-
* Space Complexity: O(1)
|
|
168
|
-
*
|
|
169
|
-
* The `dequeue` function removes and returns the first element from a queue, or returns undefined if the queue is empty.
|
|
170
|
-
* @returns The method is returning a value of type E or undefined.
|
|
171
|
-
*/
|
|
172
|
-
dequeue(): E | undefined;
|
|
173
123
|
/**
|
|
174
124
|
* Time Complexity: O(1)
|
|
175
125
|
* Space Complexity: O(1)
|
|
@@ -288,26 +238,6 @@ export declare class Queue<E = any> extends IterableElementBase<E> {
|
|
|
288
238
|
* 4. Frequent Enqueuing and Dequeuing Operations: If your application involves frequent enqueuing and dequeuing operations and is less concerned with random access, then LinkedListQueue is a good choice.
|
|
289
239
|
*/
|
|
290
240
|
export declare class LinkedListQueue<E = any> extends SinglyLinkedList<E> {
|
|
291
|
-
/**
|
|
292
|
-
* The `get first` function returns the value of the head node in a linked list, or `undefined` if the list is empty.
|
|
293
|
-
* @returns The `get first()` method is returning the value of the `head` node if it exists, otherwise it returns `undefined`.
|
|
294
|
-
*/
|
|
295
|
-
get first(): E | undefined;
|
|
296
|
-
/**
|
|
297
|
-
* The enqueue function adds a value to the end of an array.
|
|
298
|
-
* @param {E} value - The value parameter represents the value that you want to add to the queue.
|
|
299
|
-
*/
|
|
300
|
-
enqueue(value: E): boolean;
|
|
301
|
-
/**
|
|
302
|
-
* The `dequeue` function removes and returns the first element from a queue, or returns undefined if the queue is empty.
|
|
303
|
-
* @returns The method is returning the element at the front of the queue, or undefined if the queue is empty.
|
|
304
|
-
*/
|
|
305
|
-
dequeue(): E | undefined;
|
|
306
|
-
/**
|
|
307
|
-
* The `peek` function returns the value of the head node in a linked list, or `undefined` if the list is empty.
|
|
308
|
-
* @returns The `peek()` method is returning the value of the `head` node if it exists, otherwise it returns `undefined`.
|
|
309
|
-
*/
|
|
310
|
-
peek(): E | undefined;
|
|
311
241
|
/**
|
|
312
242
|
* Time Complexity: O(n)
|
|
313
243
|
* Space Complexity: O(n)
|
|
@@ -156,64 +156,6 @@ class Queue extends base_1.IterableElementBase {
|
|
|
156
156
|
const spliced = this.elements.splice(index, 1);
|
|
157
157
|
return spliced.length === 1;
|
|
158
158
|
}
|
|
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 `peek` function returns the first element of the array `_elements` if it exists, otherwise it returns `undefined`.
|
|
168
|
-
* @returns The `peek()` method returns the first element of the data structure, represented by the `_elements` array at
|
|
169
|
-
* the `_offset` index. If the data structure is empty (size is 0), it returns `undefined`.
|
|
170
|
-
*/
|
|
171
|
-
peek() {
|
|
172
|
-
return this.first;
|
|
173
|
-
}
|
|
174
|
-
/**
|
|
175
|
-
* Time Complexity: O(1)
|
|
176
|
-
* Space Complexity: O(1)
|
|
177
|
-
*/
|
|
178
|
-
/**
|
|
179
|
-
* Time Complexity: O(1)
|
|
180
|
-
* Space Complexity: O(1)
|
|
181
|
-
*
|
|
182
|
-
* The `peekLast` function returns the last element in an array-like data structure, or undefined if the structure is empty.
|
|
183
|
-
* @returns The method `peekLast()` returns the last element of the `_elements` array if the array is not empty. If the
|
|
184
|
-
* array is empty, it returns `undefined`.
|
|
185
|
-
*/
|
|
186
|
-
peekLast() {
|
|
187
|
-
return this.last;
|
|
188
|
-
}
|
|
189
|
-
/**
|
|
190
|
-
* Time Complexity: O(1)
|
|
191
|
-
* Space Complexity: O(1)
|
|
192
|
-
*/
|
|
193
|
-
/**
|
|
194
|
-
* Time Complexity: O(1)
|
|
195
|
-
* Space Complexity: O(1)
|
|
196
|
-
*
|
|
197
|
-
* The enqueue function adds a value to the end of a queue.
|
|
198
|
-
* @param {E} value - The value parameter represents the value that you want to add to the queue.
|
|
199
|
-
*/
|
|
200
|
-
enqueue(value) {
|
|
201
|
-
return this.push(value);
|
|
202
|
-
}
|
|
203
|
-
/**
|
|
204
|
-
* Time Complexity: O(1)
|
|
205
|
-
* Space Complexity: O(1)
|
|
206
|
-
*/
|
|
207
|
-
/**
|
|
208
|
-
* Time Complexity: O(1)
|
|
209
|
-
* Space Complexity: O(1)
|
|
210
|
-
*
|
|
211
|
-
* The `dequeue` function removes and returns the first element from a queue, or returns undefined if the queue is empty.
|
|
212
|
-
* @returns The method is returning a value of type E or undefined.
|
|
213
|
-
*/
|
|
214
|
-
dequeue() {
|
|
215
|
-
return this.shift();
|
|
216
|
-
}
|
|
217
159
|
/**
|
|
218
160
|
* Time Complexity: O(1)
|
|
219
161
|
* Space Complexity: O(1)
|
|
@@ -366,35 +308,6 @@ exports.Queue = Queue;
|
|
|
366
308
|
* 4. Frequent Enqueuing and Dequeuing Operations: If your application involves frequent enqueuing and dequeuing operations and is less concerned with random access, then LinkedListQueue is a good choice.
|
|
367
309
|
*/
|
|
368
310
|
class LinkedListQueue extends linked_list_1.SinglyLinkedList {
|
|
369
|
-
/**
|
|
370
|
-
* The `get first` function returns the value of the head node in a linked list, or `undefined` if the list is empty.
|
|
371
|
-
* @returns The `get first()` method is returning the value of the `head` node if it exists, otherwise it returns `undefined`.
|
|
372
|
-
*/
|
|
373
|
-
get first() {
|
|
374
|
-
var _a;
|
|
375
|
-
return (_a = this.head) === null || _a === void 0 ? void 0 : _a.value;
|
|
376
|
-
}
|
|
377
|
-
/**
|
|
378
|
-
* The enqueue function adds a value to the end of an array.
|
|
379
|
-
* @param {E} value - The value parameter represents the value that you want to add to the queue.
|
|
380
|
-
*/
|
|
381
|
-
enqueue(value) {
|
|
382
|
-
return this.push(value);
|
|
383
|
-
}
|
|
384
|
-
/**
|
|
385
|
-
* The `dequeue` function removes and returns the first element from a queue, or returns undefined if the queue is empty.
|
|
386
|
-
* @returns The method is returning the element at the front of the queue, or undefined if the queue is empty.
|
|
387
|
-
*/
|
|
388
|
-
dequeue() {
|
|
389
|
-
return this.shift();
|
|
390
|
-
}
|
|
391
|
-
/**
|
|
392
|
-
* The `peek` function returns the value of the head node in a linked list, or `undefined` if the list is empty.
|
|
393
|
-
* @returns The `peek()` method is returning the value of the `head` node if it exists, otherwise it returns `undefined`.
|
|
394
|
-
*/
|
|
395
|
-
peek() {
|
|
396
|
-
return this.first;
|
|
397
|
-
}
|
|
398
311
|
/**
|
|
399
312
|
* Time Complexity: O(n)
|
|
400
313
|
* Space Complexity: O(n)
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { AVLTreeMultiMap, AVLTreeMultiMapNode } from '../../../data-structures';
|
|
2
|
+
import type { AVLTreeOptions } from './avl-tree';
|
|
3
|
+
export type AVLTreeMultiMapNodeNested<K, V> = AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, AVLTreeMultiMapNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
|
|
4
|
+
export type AVLTreeMultiMapNested<K, V, N extends AVLTreeMultiMapNode<K, V, N>> = AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, AVLTreeMultiMap<K, V, N, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
|
|
5
|
+
export type AVLTreeMultiMapOptions<K> = AVLTreeOptions<K> & {};
|
|
@@ -18,5 +18,6 @@ __exportStar(require("./binary-tree"), exports);
|
|
|
18
18
|
__exportStar(require("./bst"), exports);
|
|
19
19
|
__exportStar(require("./avl-tree"), exports);
|
|
20
20
|
__exportStar(require("./segment-tree"), exports);
|
|
21
|
-
__exportStar(require("./tree-
|
|
21
|
+
__exportStar(require("./avl-tree-multi-map"), exports);
|
|
22
22
|
__exportStar(require("./rb-tree"), exports);
|
|
23
|
+
__exportStar(require("./tree-multi-map"), exports);
|