data-structure-typed 1.45.3 → 1.46.1
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/CHANGELOG.md +1 -1
- package/README.md +91 -40
- package/benchmark/report.html +17 -17
- package/benchmark/report.json +160 -142
- package/dist/cjs/data-structures/hash/hash-map.d.ts +6 -5
- package/dist/cjs/data-structures/hash/hash-map.js +9 -6
- package/dist/cjs/data-structures/hash/hash-map.js.map +1 -1
- package/dist/cjs/data-structures/heap/heap.d.ts +59 -47
- package/dist/cjs/data-structures/heap/heap.js +133 -123
- package/dist/cjs/data-structures/heap/heap.js.map +1 -1
- package/dist/cjs/data-structures/queue/deque.d.ts +131 -164
- package/dist/cjs/data-structures/queue/deque.js +543 -211
- package/dist/cjs/data-structures/queue/deque.js.map +1 -1
- package/dist/cjs/types/data-structures/hash/hash-map.d.ts +0 -9
- package/dist/cjs/types/helpers.d.ts +11 -0
- package/dist/cjs/utils/utils.d.ts +1 -0
- package/dist/cjs/utils/utils.js +3 -1
- package/dist/cjs/utils/utils.js.map +1 -1
- package/dist/mjs/data-structures/hash/hash-map.d.ts +6 -5
- package/dist/mjs/data-structures/hash/hash-map.js +9 -6
- package/dist/mjs/data-structures/heap/heap.d.ts +59 -47
- package/dist/mjs/data-structures/heap/heap.js +133 -123
- package/dist/mjs/data-structures/queue/deque.d.ts +131 -164
- package/dist/mjs/data-structures/queue/deque.js +544 -201
- package/dist/mjs/types/data-structures/hash/hash-map.d.ts +0 -9
- package/dist/mjs/types/helpers.d.ts +11 -0
- package/dist/mjs/utils/utils.d.ts +1 -0
- package/dist/mjs/utils/utils.js +1 -0
- package/dist/umd/data-structure-typed.js +684 -328
- package/dist/umd/data-structure-typed.min.js +1 -1
- package/dist/umd/data-structure-typed.min.js.map +1 -1
- package/package.json +1 -1
- package/src/data-structures/hash/hash-map.ts +11 -7
- package/src/data-structures/heap/heap.ts +132 -128
- package/src/data-structures/queue/deque.ts +605 -226
- package/src/types/data-structures/hash/hash-map.ts +0 -11
- package/src/types/helpers.ts +15 -0
- package/src/utils/utils.ts +2 -0
- package/test/performance/data-structures/linked-list/doubly-linked-list.test.ts +21 -0
- package/test/performance/data-structures/priority-queue/priority-queue.test.ts +7 -7
- package/test/performance/data-structures/queue/deque.test.ts +24 -13
- package/test/unit/data-structures/hash/hash-map.test.ts +4 -4
- package/test/unit/data-structures/heap/heap.test.ts +2 -1
- package/test/unit/data-structures/priority-queue/max-priority-queue.test.ts +3 -3
- package/test/unit/data-structures/priority-queue/priority-queue.test.ts +3 -3
- package/test/unit/data-structures/queue/deque.test.ts +252 -240
- /package/test/performance/data-structures/{comparation.test.ts → comparison.test.ts} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hash-map.js","sourceRoot":"","sources":["../../../../src/data-structures/hash/hash-map.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,uCAAuE;AAGvE;;;;GAIG;AACH,MAAa,eAAe;IAM1B;;;;;;;;;;;;;;OAcG;IACH,YACE,IAA6B,EAC7B,QAAiC,EACjC,OAAsB,EACtB,mDAA6D;QAE7D,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QAEzC,IAAI,IAAI,CAAC,gBAAgB,qCAA6B,EAAE;YACtD,IAAI,CAAC,IAAI,GAAG;gBACV,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,SAAS,EAAE;oBACtC,IAAA,uBAAe,GAAE,CAAC;iBACnB;gBACD,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;gBAC7B,OAAO,IAAI,CAAC;YACd,CAAC,CAAC;YACF,IAAI,CAAC,IAAI,GAAG;gBACV,IAAI,IAAI,CAAC,KAAK,KAAK,IAAI,CAAC,SAAS,EAAE;oBACjC,IA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gBAC7B,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC;YACtB,CAAC;YACD,GAAG,EAAE,CAAC,CAAC,EAAE,IAAS,EAAE,QAAW,EAAE,EAAE;gBACjC,IAAI,IAAI,KAAK,GAAG,EAAE;oBAChB,MAAM,IAAI,SAAS,CAAC,2BAA2B,CAAC,CAAC;iBAClD;gBACD,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,QAAQ,CAAC;gBAC5B,OAAO,IAAI,CAAC;YACd,CAAC;SACF,CAAC,CAAC;IACL,CAAC;IAED;;;OAGG;IACH,YAAY;QACV,OAAO,IAAI,CAAC,KAAK,KAAK,IAAI,CAAC,SAAS,CAAC;IACvC,CAAC;IAED,IAAI;QACF,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI;QACF,OAAO,IAAI,CAAC;IACd,CAAC;CACF;
|
|
1
|
+
{"version":3,"file":"hash-map.js","sourceRoot":"","sources":["../../../../src/data-structures/hash/hash-map.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,uCAAuE;AAGvE;;;;GAIG;AACH,MAAa,eAAe;IAM1B;;;;;;;;;;;;;;OAcG;IACH,YACE,IAA6B,EAC7B,QAAiC,EACjC,OAAsB,EACtB,mDAA6D;QAE7D,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QAEzC,IAAI,IAAI,CAAC,gBAAgB,qCAA6B,EAAE;YACtD,IAAI,CAAC,IAAI,GAAG;gBACV,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,SAAS,EAAE;oBACtC,IAAA,uBAAe,GAAE,CAAC;iBACnB;gBACD,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;gBAC7B,OAAO,IAAI,CAAC;YACd,CAAC,CAAC;YACF,IAAI,CAAC,IAAI,G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AC9B,MAAc,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;YACrC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;SAClB;IACH,CAAC;IAED;;;;;;;;;OASG;IACO,WAAW,CAAC,IAA6B;QACjD,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC;QAC5B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,IAAI,KAAK,IAAI,CAAC,KAAK,EAAE;YACvB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;SACnB;QACD,IAAI,IAAI,KAAK,IAAI,CAAC,KAAK,EAAE;YACvB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;SACnB;QACD,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC;IAClB,CAAC;CACF;AA7WD,0BA6WC"}
|
|
@@ -8,10 +8,10 @@ import type { Comparator, DFSOrderPattern } from '../../types';
|
|
|
8
8
|
export declare class Heap<E = any> {
|
|
9
9
|
constructor(options: {
|
|
10
10
|
comparator: Comparator<E>;
|
|
11
|
-
|
|
11
|
+
elements?: E[];
|
|
12
12
|
});
|
|
13
|
-
protected
|
|
14
|
-
get
|
|
13
|
+
protected _elements: E[];
|
|
14
|
+
get elements(): E[];
|
|
15
15
|
protected _comparator: Comparator<E>;
|
|
16
16
|
get comparator(): Comparator<E>;
|
|
17
17
|
/**
|
|
@@ -24,20 +24,20 @@ export declare class Heap<E = any> {
|
|
|
24
24
|
*/
|
|
25
25
|
get leaf(): E | undefined;
|
|
26
26
|
/**
|
|
27
|
-
* Static method that creates a binary heap from an array of
|
|
27
|
+
* Static method that creates a binary heap from an array of elements and a comparison function.
|
|
28
28
|
* @returns A new Heap instance.
|
|
29
29
|
* @param options
|
|
30
30
|
*/
|
|
31
31
|
static heapify<E>(options: {
|
|
32
|
-
|
|
32
|
+
elements: E[];
|
|
33
33
|
comparator: Comparator<E>;
|
|
34
34
|
}): Heap<E>;
|
|
35
35
|
/**
|
|
36
|
-
* Time Complexity: O(log n), where n is the number of
|
|
36
|
+
* Time Complexity: O(log n), where n is the number of elements in the heap.
|
|
37
37
|
* Space Complexity: O(1)
|
|
38
38
|
*/
|
|
39
39
|
/**
|
|
40
|
-
* Time Complexity: O(log n), where n is the number of
|
|
40
|
+
* Time Complexity: O(log n), where n is the number of elements in the heap.
|
|
41
41
|
* Space Complexity: O(1)
|
|
42
42
|
*
|
|
43
43
|
* Insert an element into the heap and maintain the heap properties.
|
|
@@ -45,11 +45,11 @@ export declare class Heap<E = any> {
|
|
|
45
45
|
*/
|
|
46
46
|
add(element: E): Heap<E>;
|
|
47
47
|
/**
|
|
48
|
-
* Time Complexity: O(log n), where n is the number of
|
|
48
|
+
* Time Complexity: O(log n), where n is the number of elements in the heap.
|
|
49
49
|
* Space Complexity: O(1)
|
|
50
50
|
*/
|
|
51
51
|
/**
|
|
52
|
-
* Time Complexity: O(log n), where n is the number of
|
|
52
|
+
* Time Complexity: O(log n), where n is the number of elements in the heap.
|
|
53
53
|
* Space Complexity: O(1)
|
|
54
54
|
*
|
|
55
55
|
* Insert an element into the heap and maintain the heap properties.
|
|
@@ -57,11 +57,11 @@ export declare class Heap<E = any> {
|
|
|
57
57
|
*/
|
|
58
58
|
push(element: E): Heap<E>;
|
|
59
59
|
/**
|
|
60
|
-
* Time Complexity: O(log n), where n is the number of
|
|
60
|
+
* Time Complexity: O(log n), where n is the number of elements in the heap.
|
|
61
61
|
* Space Complexity: O(1)
|
|
62
62
|
*/
|
|
63
63
|
/**
|
|
64
|
-
* Time Complexity: O(log n), where n is the number of
|
|
64
|
+
* Time Complexity: O(log n), where n is the number of elements in the heap.
|
|
65
65
|
* Space Complexity: O(1)
|
|
66
66
|
*
|
|
67
67
|
* Remove and return the top element (smallest or largest element) from the heap.
|
|
@@ -69,11 +69,11 @@ export declare class Heap<E = any> {
|
|
|
69
69
|
*/
|
|
70
70
|
poll(): E | undefined;
|
|
71
71
|
/**
|
|
72
|
-
* Time Complexity: O(log n), where n is the number of
|
|
72
|
+
* Time Complexity: O(log n), where n is the number of elements in the heap.
|
|
73
73
|
* Space Complexity: O(1)
|
|
74
74
|
*/
|
|
75
75
|
/**
|
|
76
|
-
* Time Complexity: O(log n), where n is the number of
|
|
76
|
+
* Time Complexity: O(log n), where n is the number of elements in the heap.
|
|
77
77
|
* Space Complexity: O(1)
|
|
78
78
|
*
|
|
79
79
|
* Remove and return the top element (smallest or largest element) from the heap.
|
|
@@ -91,27 +91,27 @@ export declare class Heap<E = any> {
|
|
|
91
91
|
*/
|
|
92
92
|
isEmpty(): boolean;
|
|
93
93
|
/**
|
|
94
|
-
* Reset the
|
|
94
|
+
* Reset the elements of the heap. Make the elements empty.
|
|
95
95
|
*/
|
|
96
96
|
clear(): void;
|
|
97
97
|
/**
|
|
98
|
-
* Time Complexity: O(n), where n is the number of elements in the
|
|
98
|
+
* Time Complexity: O(n), where n is the number of elements in the elements array.
|
|
99
99
|
* Space Complexity: O(n)
|
|
100
100
|
*/
|
|
101
101
|
/**
|
|
102
|
-
* Time Complexity: O(n), where n is the number of elements in the
|
|
102
|
+
* Time Complexity: O(n), where n is the number of elements in the elements array.
|
|
103
103
|
* Space Complexity: O(n)
|
|
104
104
|
*
|
|
105
|
-
* Clear and add
|
|
106
|
-
* @param
|
|
105
|
+
* Clear and add elements of the heap
|
|
106
|
+
* @param elements
|
|
107
107
|
*/
|
|
108
|
-
refill(
|
|
108
|
+
refill(elements: E[]): void;
|
|
109
109
|
/**
|
|
110
|
-
* Time Complexity: O(n), where n is the number of
|
|
110
|
+
* Time Complexity: O(n), where n is the number of elements in the heap.
|
|
111
111
|
* Space Complexity: O(1)
|
|
112
112
|
*/
|
|
113
113
|
/**
|
|
114
|
-
* Time Complexity: O(n), where n is the number of
|
|
114
|
+
* Time Complexity: O(n), where n is the number of elements in the heap.
|
|
115
115
|
* Space Complexity: O(1)
|
|
116
116
|
*
|
|
117
117
|
* Use a comparison function to check whether a binary heap contains a specific element.
|
|
@@ -120,11 +120,27 @@ export declare class Heap<E = any> {
|
|
|
120
120
|
*/
|
|
121
121
|
has(element: E): boolean;
|
|
122
122
|
/**
|
|
123
|
-
* Time Complexity: O(n), where n is the number of
|
|
123
|
+
* Time Complexity: O(n). The worst-case O(n), where n is the number of elements in the heap. This is because, in the worst case, the element to be deleted is located at the end of the heap (not the root), and after deletion, we may need to reorganize the elements by performing a sinkDown operation.
|
|
124
|
+
* Space Complexity: O(1)
|
|
125
|
+
*/
|
|
126
|
+
/**
|
|
127
|
+
* Time Complexity: O(n). The worst-case O(n), where n is the number of elements in the heap. This is because, in the worst case, the element to be deleted is located at the end of the heap (not the root), and after deletion, we may need to reorganize the elements by performing a sinkDown operation.
|
|
128
|
+
* Space Complexity: O(1)
|
|
129
|
+
*
|
|
130
|
+
* The `delete` function removes an element from an array-like data structure, maintaining the order
|
|
131
|
+
* and structure of the remaining elements.
|
|
132
|
+
* @param {E} element - The `element` parameter represents the element that you want to delete from
|
|
133
|
+
* the array `this.elements`.
|
|
134
|
+
* @returns The `delete` function is returning a boolean value. It returns `true` if the element was
|
|
135
|
+
* successfully deleted from the array, and `false` if the element was not found in the array.
|
|
136
|
+
*/
|
|
137
|
+
delete(element: E): boolean;
|
|
138
|
+
/**
|
|
139
|
+
* Time Complexity: O(n), where n is the number of elements in the heap.
|
|
124
140
|
* Space Complexity: O(h), where h is the height of the heap.
|
|
125
141
|
*/
|
|
126
142
|
/**
|
|
127
|
-
* Time Complexity: O(n), where n is the number of
|
|
143
|
+
* Time Complexity: O(n), where n is the number of elements in the heap.
|
|
128
144
|
* Space Complexity: O(h), where h is the height of the heap.
|
|
129
145
|
*
|
|
130
146
|
* Depth-first search (DFS) method, different traversal orders can be selected。
|
|
@@ -144,11 +160,6 @@ export declare class Heap<E = any> {
|
|
|
144
160
|
* @returns An array containing the elements of the heap.
|
|
145
161
|
*/
|
|
146
162
|
toArray(): E[];
|
|
147
|
-
/**
|
|
148
|
-
* Time Complexity: O(1)
|
|
149
|
-
* Space Complexity: O(1)
|
|
150
|
-
*/
|
|
151
|
-
getNodes(): E[];
|
|
152
163
|
/**
|
|
153
164
|
* Time Complexity: O(n)
|
|
154
165
|
* Space Complexity: O(n)
|
|
@@ -178,13 +189,12 @@ export declare class Heap<E = any> {
|
|
|
178
189
|
* Space Complexity: O(1)
|
|
179
190
|
*/
|
|
180
191
|
/**
|
|
181
|
-
* Time Complexity: O(
|
|
192
|
+
* Time Complexity: O(n)
|
|
182
193
|
* Space Complexity: O(1)
|
|
183
194
|
*
|
|
184
|
-
*
|
|
185
|
-
* @param index - The index of the newly added element.
|
|
195
|
+
* Fix the entire heap to maintain heap properties.
|
|
186
196
|
*/
|
|
187
|
-
|
|
197
|
+
fix(): void;
|
|
188
198
|
/**
|
|
189
199
|
* Time Complexity: O(log n)
|
|
190
200
|
* Space Complexity: O(1)
|
|
@@ -193,21 +203,23 @@ export declare class Heap<E = any> {
|
|
|
193
203
|
* Time Complexity: O(log n)
|
|
194
204
|
* Space Complexity: O(1)
|
|
195
205
|
*
|
|
196
|
-
*
|
|
197
|
-
* @param index - The index
|
|
206
|
+
* Float operation to maintain heap properties after adding an element.
|
|
207
|
+
* @param index - The index of the newly added element.
|
|
198
208
|
*/
|
|
199
|
-
protected
|
|
209
|
+
protected _bubbleUp(index: number): void;
|
|
200
210
|
/**
|
|
201
211
|
* Time Complexity: O(n)
|
|
202
212
|
* Space Complexity: O(1)
|
|
203
213
|
*/
|
|
204
214
|
/**
|
|
205
|
-
* Time Complexity: O(n)
|
|
215
|
+
* Time Complexity: O(log n)
|
|
206
216
|
* Space Complexity: O(1)
|
|
207
217
|
*
|
|
208
|
-
*
|
|
218
|
+
* Sinking operation to maintain heap properties after removing the top element.
|
|
219
|
+
* @param index - The index from which to start sinking.
|
|
220
|
+
* @param halfLength
|
|
209
221
|
*/
|
|
210
|
-
protected
|
|
222
|
+
protected _sinkDown(index: number, halfLength: number): void;
|
|
211
223
|
}
|
|
212
224
|
export declare class FibonacciHeapNode<E> {
|
|
213
225
|
element: E;
|
|
@@ -274,17 +286,17 @@ export declare class FibonacciHeap<E> {
|
|
|
274
286
|
*/
|
|
275
287
|
peek(): E | undefined;
|
|
276
288
|
/**
|
|
277
|
-
* Time Complexity: O(n), where n is the number of
|
|
289
|
+
* Time Complexity: O(n), where n is the number of elements in the linked list.
|
|
278
290
|
* Space Complexity: O(1)
|
|
279
291
|
*/
|
|
280
292
|
/**
|
|
281
|
-
* Time Complexity: O(n), where n is the number of
|
|
293
|
+
* Time Complexity: O(n), where n is the number of elements in the linked list.
|
|
282
294
|
* Space Complexity: O(1)
|
|
283
295
|
*
|
|
284
296
|
* Get the size (number of elements) of the heap.
|
|
285
297
|
* @param {FibonacciHeapNode<E>} head - The head of the linked list.
|
|
286
298
|
* @protected
|
|
287
|
-
* @returns FibonacciHeapNode<E>[] - An array containing the
|
|
299
|
+
* @returns FibonacciHeapNode<E>[] - An array containing the elements of the linked list.
|
|
288
300
|
*/
|
|
289
301
|
consumeLinkedList(head?: FibonacciHeapNode<E>): FibonacciHeapNode<E>[];
|
|
290
302
|
/**
|
|
@@ -296,11 +308,11 @@ export declare class FibonacciHeap<E> {
|
|
|
296
308
|
*/
|
|
297
309
|
mergeWithChild(parent: FibonacciHeapNode<E>, node: FibonacciHeapNode<E>): void;
|
|
298
310
|
/**
|
|
299
|
-
* Time Complexity: O(log n), where n is the number of
|
|
311
|
+
* Time Complexity: O(log n), where n is the number of elements in the heap.
|
|
300
312
|
* Space Complexity: O(1)
|
|
301
313
|
*/
|
|
302
314
|
/**
|
|
303
|
-
* Time Complexity: O(log n), where n is the number of
|
|
315
|
+
* Time Complexity: O(log n), where n is the number of elements in the heap.
|
|
304
316
|
* Space Complexity: O(1)
|
|
305
317
|
*
|
|
306
318
|
* Remove and return the top element (smallest or largest element) from the heap.
|
|
@@ -308,11 +320,11 @@ export declare class FibonacciHeap<E> {
|
|
|
308
320
|
*/
|
|
309
321
|
poll(): E | undefined;
|
|
310
322
|
/**
|
|
311
|
-
* Time Complexity: O(log n), where n is the number of
|
|
323
|
+
* Time Complexity: O(log n), where n is the number of elements in the heap.
|
|
312
324
|
* Space Complexity: O(1)
|
|
313
325
|
*/
|
|
314
326
|
/**
|
|
315
|
-
* Time Complexity: O(log n), where n is the number of
|
|
327
|
+
* Time Complexity: O(log n), where n is the number of elements in the heap.
|
|
316
328
|
* Space Complexity: O(1)
|
|
317
329
|
*
|
|
318
330
|
* Remove and return the top element (smallest or largest element) from the heap.
|
|
@@ -384,11 +396,11 @@ export declare class FibonacciHeap<E> {
|
|
|
384
396
|
*/
|
|
385
397
|
protected link(y: FibonacciHeapNode<E>, x: FibonacciHeapNode<E>): void;
|
|
386
398
|
/**
|
|
387
|
-
* Time Complexity: O(n log n), where n is the number of
|
|
399
|
+
* Time Complexity: O(n log n), where n is the number of elements in the heap.
|
|
388
400
|
* Space Complexity: O(n)
|
|
389
401
|
*/
|
|
390
402
|
/**
|
|
391
|
-
* Time Complexity: O(n log n), where n is the number of
|
|
403
|
+
* Time Complexity: O(n log n), where n is the number of elements in the heap.
|
|
392
404
|
* Space Complexity: O(n)
|
|
393
405
|
*
|
|
394
406
|
* Remove and return the top element (smallest or largest element) from the heap.
|