data-structure-typed 2.6.0 → 2.6.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.
- package/.github/workflows/ci.yml +7 -2
- package/.github/workflows/release-package.yml +9 -2
- package/CHANGELOG.md +9 -1
- package/dist/cjs/binary-tree.cjs +2927 -23688
- package/dist/cjs/graph.cjs +845 -2634
- package/dist/cjs/hash.cjs +185 -616
- package/dist/cjs/heap.cjs +266 -818
- package/dist/cjs/index.cjs +5116 -31358
- package/dist/cjs/linked-list.cjs +644 -2615
- package/dist/cjs/matrix.cjs +220 -535
- package/dist/cjs/priority-queue.cjs +266 -818
- package/dist/cjs/queue.cjs +637 -2343
- package/dist/cjs/stack.cjs +124 -530
- package/dist/cjs/trie.cjs +145 -592
- package/dist/cjs-legacy/binary-tree.cjs +4352 -25113
- package/dist/cjs-legacy/graph.cjs +847 -2636
- package/dist/cjs-legacy/hash.cjs +181 -612
- package/dist/cjs-legacy/heap.cjs +266 -818
- package/dist/cjs-legacy/index.cjs +6657 -32899
- package/dist/cjs-legacy/linked-list.cjs +640 -2611
- package/dist/cjs-legacy/matrix.cjs +220 -535
- package/dist/cjs-legacy/priority-queue.cjs +266 -818
- package/dist/cjs-legacy/queue.cjs +634 -2340
- package/dist/cjs-legacy/stack.cjs +124 -530
- package/dist/cjs-legacy/trie.cjs +145 -592
- package/dist/esm/binary-tree.mjs +2927 -23688
- package/dist/esm/graph.mjs +845 -2634
- package/dist/esm/hash.mjs +185 -616
- package/dist/esm/heap.mjs +266 -818
- package/dist/esm/index.mjs +5116 -31358
- package/dist/esm/linked-list.mjs +644 -2615
- package/dist/esm/matrix.mjs +220 -535
- package/dist/esm/priority-queue.mjs +266 -818
- package/dist/esm/queue.mjs +637 -2343
- package/dist/esm/stack.mjs +124 -530
- package/dist/esm/trie.mjs +145 -592
- package/dist/esm-legacy/binary-tree.mjs +4352 -25113
- package/dist/esm-legacy/graph.mjs +847 -2636
- package/dist/esm-legacy/hash.mjs +181 -612
- package/dist/esm-legacy/heap.mjs +266 -818
- package/dist/esm-legacy/index.mjs +6657 -32899
- package/dist/esm-legacy/linked-list.mjs +640 -2611
- package/dist/esm-legacy/matrix.mjs +220 -535
- package/dist/esm-legacy/priority-queue.mjs +266 -818
- package/dist/esm-legacy/queue.mjs +634 -2340
- package/dist/esm-legacy/stack.mjs +124 -530
- package/dist/esm-legacy/trie.mjs +145 -592
- package/dist/types/data-structures/binary-tree/avl-tree.d.ts +29 -500
- package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +38 -563
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +230 -1212
- package/dist/types/data-structures/binary-tree/bst.d.ts +124 -1063
- package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +99 -854
- package/dist/types/data-structures/binary-tree/segment-tree.d.ts +62 -314
- package/dist/types/data-structures/binary-tree/tree-map.d.ts +366 -5057
- package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +277 -4885
- package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +253 -3929
- package/dist/types/data-structures/binary-tree/tree-set.d.ts +261 -4782
- package/dist/types/data-structures/graph/abstract-graph.d.ts +44 -44
- package/dist/types/data-structures/graph/directed-graph.d.ts +130 -527
- package/dist/types/data-structures/graph/undirected-graph.d.ts +125 -482
- package/dist/types/data-structures/hash/hash-map.d.ts +132 -562
- package/dist/types/data-structures/heap/heap.d.ts +194 -746
- package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +120 -809
- package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +121 -733
- package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +193 -863
- package/dist/types/data-structures/matrix/matrix.d.ts +159 -474
- package/dist/types/data-structures/priority-queue/max-priority-queue.d.ts +1 -6
- package/dist/types/data-structures/priority-queue/min-priority-queue.d.ts +6 -11
- package/dist/types/data-structures/priority-queue/priority-queue.d.ts +1 -1
- package/dist/types/data-structures/queue/deque.d.ts +196 -804
- package/dist/types/data-structures/queue/queue.d.ts +99 -585
- package/dist/types/data-structures/stack/stack.d.ts +75 -481
- package/dist/types/data-structures/trie/trie.d.ts +98 -584
- package/dist/umd/data-structure-typed.js +6580 -32822
- package/dist/umd/data-structure-typed.min.js +3 -3
- package/docs-site-docusaurus/docs/api/classes/AVLTree.md +162 -215
- package/docs-site-docusaurus/docs/api/classes/AVLTreeNode.md +9 -9
- package/docs-site-docusaurus/docs/api/classes/AbstractGraph.md +47 -47
- package/docs-site-docusaurus/docs/api/classes/BST.md +155 -208
- package/docs-site-docusaurus/docs/api/classes/BSTNode.md +7 -7
- package/docs-site-docusaurus/docs/api/classes/BinaryIndexedTree.md +13 -29
- package/docs-site-docusaurus/docs/api/classes/BinaryTree.md +104 -158
- package/docs-site-docusaurus/docs/api/classes/BinaryTreeNode.md +13 -13
- package/docs-site-docusaurus/docs/api/classes/Deque.md +253 -101
- package/docs-site-docusaurus/docs/api/classes/DirectedGraph.md +60 -80
- package/docs-site-docusaurus/docs/api/classes/DoublyLinkedList.md +244 -114
- package/docs-site-docusaurus/docs/api/classes/DoublyLinkedListNode.md +6 -6
- package/docs-site-docusaurus/docs/api/classes/FibonacciHeap.md +9 -9
- package/docs-site-docusaurus/docs/api/classes/FibonacciHeapNode.md +1 -1
- package/docs-site-docusaurus/docs/api/classes/HashMap.md +52 -48
- package/docs-site-docusaurus/docs/api/classes/Heap.md +119 -64
- package/docs-site-docusaurus/docs/api/classes/IterableElementBase.md +84 -14
- package/docs-site-docusaurus/docs/api/classes/LinearBase.md +138 -34
- package/docs-site-docusaurus/docs/api/classes/LinearLinkedBase.md +149 -41
- package/docs-site-docusaurus/docs/api/classes/LinkedHashMap.md +23 -23
- package/docs-site-docusaurus/docs/api/classes/LinkedListQueue.md +172 -92
- package/docs-site-docusaurus/docs/api/classes/MapGraph.md +60 -80
- package/docs-site-docusaurus/docs/api/classes/Matrix.md +57 -52
- package/docs-site-docusaurus/docs/api/classes/MaxHeap.md +117 -62
- package/docs-site-docusaurus/docs/api/classes/MaxPriorityQueue.md +120 -70
- package/docs-site-docusaurus/docs/api/classes/MinHeap.md +117 -62
- package/docs-site-docusaurus/docs/api/classes/MinPriorityQueue.md +125 -75
- package/docs-site-docusaurus/docs/api/classes/PriorityQueue.md +119 -64
- package/docs-site-docusaurus/docs/api/classes/Queue.md +158 -74
- package/docs-site-docusaurus/docs/api/classes/RedBlackTree.md +171 -225
- package/docs-site-docusaurus/docs/api/classes/SegmentTree.md +10 -22
- package/docs-site-docusaurus/docs/api/classes/SinglyLinkedList.md +172 -94
- package/docs-site-docusaurus/docs/api/classes/SinglyLinkedListNode.md +4 -4
- package/docs-site-docusaurus/docs/api/classes/SkipList.md +98 -75
- package/docs-site-docusaurus/docs/api/classes/Stack.md +112 -50
- package/docs-site-docusaurus/docs/api/classes/TreeMap.md +104 -129
- package/docs-site-docusaurus/docs/api/classes/TreeMultiMap.md +90 -121
- package/docs-site-docusaurus/docs/api/classes/TreeSet.md +298 -107
- package/docs-site-docusaurus/docs/api/classes/Trie.md +116 -58
- package/docs-site-docusaurus/docs/api/classes/TrieNode.md +8 -8
- package/docs-site-docusaurus/docs/api/classes/UndirectedGraph.md +59 -77
- package/package.json +45 -46
- package/src/common/error.ts +15 -32
- package/src/common/index.ts +0 -3
- package/src/data-structures/base/iterable-element-base.ts +0 -3
- package/src/data-structures/base/linear-base.ts +2 -36
- package/src/data-structures/binary-tree/avl-tree.ts +31 -529
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +47 -572
- package/src/data-structures/binary-tree/binary-tree.ts +326 -1311
- package/src/data-structures/binary-tree/bst.ts +158 -1082
- package/src/data-structures/binary-tree/red-black-tree.ts +451 -1290
- package/src/data-structures/binary-tree/segment-tree.ts +73 -351
- package/src/data-structures/binary-tree/tree-map.ts +462 -5124
- package/src/data-structures/binary-tree/tree-multi-map.ts +302 -4914
- package/src/data-structures/binary-tree/tree-multi-set.ts +299 -3983
- package/src/data-structures/binary-tree/tree-set.ts +338 -4836
- package/src/data-structures/graph/abstract-graph.ts +98 -167
- package/src/data-structures/graph/directed-graph.ts +137 -562
- package/src/data-structures/graph/map-graph.ts +0 -3
- package/src/data-structures/graph/undirected-graph.ts +132 -511
- package/src/data-structures/hash/hash-map.ts +154 -582
- package/src/data-structures/heap/heap.ts +200 -795
- package/src/data-structures/linked-list/doubly-linked-list.ts +121 -865
- package/src/data-structures/linked-list/singly-linked-list.ts +122 -794
- package/src/data-structures/linked-list/skip-linked-list.ts +211 -918
- package/src/data-structures/matrix/matrix.ts +179 -518
- package/src/data-structures/matrix/navigator.ts +0 -1
- package/src/data-structures/priority-queue/max-priority-queue.ts +1 -6
- package/src/data-structures/priority-queue/min-priority-queue.ts +6 -11
- package/src/data-structures/priority-queue/priority-queue.ts +1 -2
- package/src/data-structures/queue/deque.ts +214 -882
- package/src/data-structures/queue/queue.ts +102 -625
- package/src/data-structures/stack/stack.ts +76 -505
- package/src/data-structures/trie/trie.ts +98 -628
- package/src/types/common.ts +0 -10
- package/src/types/data-structures/binary-tree/bst.ts +0 -7
- package/src/types/data-structures/binary-tree/red-black-tree.ts +0 -1
- package/src/types/data-structures/graph/abstract-graph.ts +0 -2
- package/src/types/data-structures/hash/hash-map.ts +0 -3
- package/src/types/data-structures/hash/index.ts +0 -1
- package/src/types/data-structures/matrix/navigator.ts +0 -2
- package/src/types/utils/utils.ts +0 -7
- package/src/types/utils/validate-type.ts +0 -7
- package/src/utils/number.ts +0 -2
- package/src/utils/utils.ts +0 -5
|
@@ -72,19 +72,27 @@ import { IterableEntryBase } from '../base';
|
|
|
72
72
|
* console.log(activeCount); // 2;
|
|
73
73
|
* @example
|
|
74
74
|
* // Aggregate values
|
|
75
|
-
* const counts = new HashMap<string, number>([
|
|
75
|
+
* const counts = new HashMap<string, number>([
|
|
76
|
+
* ['a', 5],
|
|
77
|
+
* ['b', 3],
|
|
78
|
+
* ['c', 8]
|
|
79
|
+
* ]);
|
|
76
80
|
*
|
|
77
81
|
* const total = counts.reduce((sum, v) => sum + (v ?? 0), 0);
|
|
78
82
|
* console.log(total); // 16;
|
|
79
83
|
* @example
|
|
80
84
|
* // Iterate over entries
|
|
81
|
-
* const map = new HashMap<string, number>([
|
|
85
|
+
* const map = new HashMap<string, number>([
|
|
86
|
+
* ['x', 1],
|
|
87
|
+
* ['y', 2]
|
|
88
|
+
* ]);
|
|
82
89
|
* const keys: string[] = [];
|
|
83
90
|
*
|
|
84
91
|
* map.forEach((v, k) => keys.push(k));
|
|
85
92
|
* console.log(keys.sort()); // ['x', 'y'];
|
|
86
93
|
*/
|
|
87
94
|
export declare class HashMap<K = any, V = any, R = [K, V]> extends IterableEntryBase<K, V> {
|
|
95
|
+
protected readonly _toEntryFn?: (rawElement: R) => [K, V];
|
|
88
96
|
/**
|
|
89
97
|
* Create a HashMap and optionally bulk-insert entries.
|
|
90
98
|
* @remarks Time O(N), Space O(N)
|
|
@@ -111,7 +119,6 @@ export declare class HashMap<K = any, V = any, R = [K, V]> extends IterableEntry
|
|
|
111
119
|
* @returns Map of object→value.
|
|
112
120
|
*/
|
|
113
121
|
get objMap(): Map<object, V>;
|
|
114
|
-
protected readonly _toEntryFn?: (rawElement: R) => [K, V];
|
|
115
122
|
/**
|
|
116
123
|
* Get the raw→entry converter function if present.
|
|
117
124
|
* @remarks Time O(1), Space O(1)
|
|
@@ -136,101 +143,24 @@ export declare class HashMap<K = any, V = any, R = [K, V]> extends IterableEntry
|
|
|
136
143
|
* Check whether the map is empty.
|
|
137
144
|
* @remarks Time O(1), Space O(1)
|
|
138
145
|
* @returns True if size is 0.
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
* @example
|
|
180
|
-
* // Check if empty
|
|
181
|
-
* const map = new HashMap();
|
|
182
|
-
* console.log(map.isEmpty()); // true;
|
|
146
|
+
* @example
|
|
147
|
+
* // Check if empty
|
|
148
|
+
* const map = new HashMap();
|
|
149
|
+
* console.log(map.isEmpty()); // true;
|
|
183
150
|
*/
|
|
184
151
|
isEmpty(): boolean;
|
|
185
152
|
/**
|
|
186
153
|
* Remove all entries and reset counters.
|
|
187
154
|
* @remarks Time O(N), Space O(1)
|
|
188
155
|
* @returns void
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
* @example
|
|
230
|
-
* // Remove all entries
|
|
231
|
-
* const map = new HashMap<string, number>([['a', 1], ['b', 2]]);
|
|
232
|
-
* map.clear();
|
|
233
|
-
* console.log(map.isEmpty()); // true;
|
|
156
|
+
* @example
|
|
157
|
+
* // Remove all entries
|
|
158
|
+
* const map = new HashMap<string, number>([
|
|
159
|
+
* ['a', 1],
|
|
160
|
+
* ['b', 2]
|
|
161
|
+
* ]);
|
|
162
|
+
* map.clear();
|
|
163
|
+
* console.log(map.isEmpty()); // true;
|
|
234
164
|
*/
|
|
235
165
|
clear(): void;
|
|
236
166
|
/**
|
|
@@ -245,108 +175,24 @@ export declare class HashMap<K = any, V = any, R = [K, V]> extends IterableEntry
|
|
|
245
175
|
* @param key - Key.
|
|
246
176
|
* @param value - Value.
|
|
247
177
|
* @returns True when the operation succeeds.
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
* @example
|
|
333
|
-
* // basic HashMap creation and set operation
|
|
334
|
-
* // Create a simple HashMap with key-value pairs
|
|
335
|
-
* const map = new HashMap<number, string>([
|
|
336
|
-
* [1, 'one'],
|
|
337
|
-
* [2, 'two'],
|
|
338
|
-
* [3, 'three']
|
|
339
|
-
* ]);
|
|
340
|
-
*
|
|
341
|
-
* // Verify size
|
|
342
|
-
* console.log(map.size); // 3;
|
|
343
|
-
*
|
|
344
|
-
* // Set a new key-value pair
|
|
345
|
-
* map.set(4, 'four');
|
|
346
|
-
* console.log(map.size); // 4;
|
|
347
|
-
*
|
|
348
|
-
* // Verify entries
|
|
349
|
-
* console.log([...map.entries()]); // length: 4;
|
|
178
|
+
* @example
|
|
179
|
+
* // basic HashMap creation and set operation
|
|
180
|
+
* // Create a simple HashMap with key-value pairs
|
|
181
|
+
* const map = new HashMap<number, string>([
|
|
182
|
+
* [1, 'one'],
|
|
183
|
+
* [2, 'two'],
|
|
184
|
+
* [3, 'three']
|
|
185
|
+
* ]);
|
|
186
|
+
*
|
|
187
|
+
* // Verify size
|
|
188
|
+
* console.log(map.size); // 3;
|
|
189
|
+
*
|
|
190
|
+
* // Set a new key-value pair
|
|
191
|
+
* map.set(4, 'four');
|
|
192
|
+
* console.log(map.size); // 4;
|
|
193
|
+
*
|
|
194
|
+
* // Verify entries
|
|
195
|
+
* console.log([...map.entries()]); // length: 4;
|
|
350
196
|
*/
|
|
351
197
|
set(key: K, value: V): this;
|
|
352
198
|
/**
|
|
@@ -354,51 +200,15 @@ export declare class HashMap<K = any, V = any, R = [K, V]> extends IterableEntry
|
|
|
354
200
|
* @remarks Time O(N), Space O(N)
|
|
355
201
|
* @param entryOrRawElements - Iterable of entries or raw elements to insert.
|
|
356
202
|
* @returns Array of per-entry results.
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
* @example
|
|
398
|
-
* // Add multiple entries
|
|
399
|
-
* const map = new HashMap<string, number>();
|
|
400
|
-
* map.setMany([['a', 1], ['b', 2], ['c', 3]]);
|
|
401
|
-
* console.log(map.size); // 3;
|
|
203
|
+
* @example
|
|
204
|
+
* // Add multiple entries
|
|
205
|
+
* const map = new HashMap<string, number>();
|
|
206
|
+
* map.setMany([
|
|
207
|
+
* ['a', 1],
|
|
208
|
+
* ['b', 2],
|
|
209
|
+
* ['c', 3]
|
|
210
|
+
* ]);
|
|
211
|
+
* console.log(map.size); // 3;
|
|
402
212
|
*/
|
|
403
213
|
setMany(entryOrRawElements: Iterable<R | [K, V]>): boolean[];
|
|
404
214
|
/**
|
|
@@ -406,69 +216,27 @@ export declare class HashMap<K = any, V = any, R = [K, V]> extends IterableEntry
|
|
|
406
216
|
* @remarks Time O(1), Space O(1)
|
|
407
217
|
* @param key - Key to look up.
|
|
408
218
|
* @returns Value or undefined.
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
* @example
|
|
452
|
-
* // HashMap get and has operations
|
|
453
|
-
* const map = new HashMap<string, number>([
|
|
454
|
-
* ['apple', 1],
|
|
455
|
-
* ['banana', 2],
|
|
456
|
-
* ['cherry', 3]
|
|
457
|
-
* ]);
|
|
458
|
-
*
|
|
459
|
-
* // Check if key exists
|
|
460
|
-
* console.log(map.has('apple')); // true;
|
|
461
|
-
* console.log(map.has('date')); // false;
|
|
462
|
-
*
|
|
463
|
-
* // Get value by key
|
|
464
|
-
* console.log(map.get('banana')); // 2;
|
|
465
|
-
* console.log(map.get('grape')); // undefined;
|
|
466
|
-
*
|
|
467
|
-
* // Get all keys and values
|
|
468
|
-
* const keys = [...map.keys()];
|
|
469
|
-
* const values = [...map.values()];
|
|
470
|
-
* console.log(keys); // contains 'apple';
|
|
471
|
-
* console.log(values); // contains 3;
|
|
219
|
+
* @example
|
|
220
|
+
* // HashMap get and has operations
|
|
221
|
+
* const map = new HashMap<string, number>([
|
|
222
|
+
* ['apple', 1],
|
|
223
|
+
* ['banana', 2],
|
|
224
|
+
* ['cherry', 3]
|
|
225
|
+
* ]);
|
|
226
|
+
*
|
|
227
|
+
* // Check if key exists
|
|
228
|
+
* console.log(map.has('apple')); // true;
|
|
229
|
+
* console.log(map.has('date')); // false;
|
|
230
|
+
*
|
|
231
|
+
* // Get value by key
|
|
232
|
+
* console.log(map.get('banana')); // 2;
|
|
233
|
+
* console.log(map.get('grape')); // undefined;
|
|
234
|
+
*
|
|
235
|
+
* // Get all keys and values
|
|
236
|
+
* const keys = [...map.keys()];
|
|
237
|
+
* const values = [...map.values()];
|
|
238
|
+
* console.log(keys); // contains 'apple';
|
|
239
|
+
* console.log(values); // contains 3;
|
|
472
240
|
*/
|
|
473
241
|
get(key: K): V | undefined;
|
|
474
242
|
/**
|
|
@@ -476,54 +244,15 @@ export declare class HashMap<K = any, V = any, R = [K, V]> extends IterableEntry
|
|
|
476
244
|
* @remarks Time O(1), Space O(1)
|
|
477
245
|
* @param key - Key to test.
|
|
478
246
|
* @returns True if present.
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
* @example
|
|
522
|
-
* // Check key existence
|
|
523
|
-
* const map = new HashMap<string, number>([['a', 1], ['b', 2]]);
|
|
524
|
-
*
|
|
525
|
-
* console.log(map.has('a')); // true;
|
|
526
|
-
* console.log(map.has('z')); // false;
|
|
247
|
+
* @example
|
|
248
|
+
* // Check key existence
|
|
249
|
+
* const map = new HashMap<string, number>([
|
|
250
|
+
* ['a', 1],
|
|
251
|
+
* ['b', 2]
|
|
252
|
+
* ]);
|
|
253
|
+
*
|
|
254
|
+
* console.log(map.has('a')); // true;
|
|
255
|
+
* console.log(map.has('z')); // false;
|
|
527
256
|
*/
|
|
528
257
|
has(key: K): boolean;
|
|
529
258
|
/**
|
|
@@ -531,55 +260,17 @@ export declare class HashMap<K = any, V = any, R = [K, V]> extends IterableEntry
|
|
|
531
260
|
* @remarks Time O(1), Space O(1)
|
|
532
261
|
* @param key - Key to delete.
|
|
533
262
|
* @returns True if the key was found and removed.
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
* @example
|
|
577
|
-
* // Remove entries by key
|
|
578
|
-
* const map = new HashMap<string, number>([['x', 10], ['y', 20], ['z', 30]]);
|
|
579
|
-
*
|
|
580
|
-
* console.log(map.delete('y')); // true;
|
|
581
|
-
* console.log(map.has('y')); // false;
|
|
582
|
-
* console.log(map.size); // 2;
|
|
263
|
+
* @example
|
|
264
|
+
* // Remove entries by key
|
|
265
|
+
* const map = new HashMap<string, number>([
|
|
266
|
+
* ['x', 10],
|
|
267
|
+
* ['y', 20],
|
|
268
|
+
* ['z', 30]
|
|
269
|
+
* ]);
|
|
270
|
+
*
|
|
271
|
+
* console.log(map.delete('y')); // true;
|
|
272
|
+
* console.log(map.has('y')); // false;
|
|
273
|
+
* console.log(map.size); // 2;
|
|
583
274
|
*/
|
|
584
275
|
delete(key: K): boolean;
|
|
585
276
|
/**
|
|
@@ -593,52 +284,12 @@ export declare class HashMap<K = any, V = any, R = [K, V]> extends IterableEntry
|
|
|
593
284
|
* Deep clone this map, preserving hashing behavior.
|
|
594
285
|
* @remarks Time O(N), Space O(N)
|
|
595
286
|
* @returns A new map with the same content.
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
* @example
|
|
637
|
-
* // Create independent copy
|
|
638
|
-
* const map = new HashMap<string, number>([['a', 1]]);
|
|
639
|
-
* const copy = map.clone();
|
|
640
|
-
* copy.set('a', 99);
|
|
641
|
-
* console.log(map.get('a')); // 1;
|
|
287
|
+
* @example
|
|
288
|
+
* // Create independent copy
|
|
289
|
+
* const map = new HashMap<string, number>([['a', 1]]);
|
|
290
|
+
* const copy = map.clone();
|
|
291
|
+
* copy.set('a', 99);
|
|
292
|
+
* console.log(map.get('a')); // 1;
|
|
642
293
|
*/
|
|
643
294
|
clone(): this;
|
|
644
295
|
/**
|
|
@@ -648,55 +299,16 @@ export declare class HashMap<K = any, V = any, R = [K, V]> extends IterableEntry
|
|
|
648
299
|
* @param callbackfn - Mapping function (key, value, index, map) → newValue.
|
|
649
300
|
* @param [thisArg] - Value for `this` inside the callback.
|
|
650
301
|
* @returns A new map with transformed values.
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
* @example
|
|
694
|
-
* // Transform all values
|
|
695
|
-
* const prices = new HashMap<string, number>([['apple', 1], ['banana', 2]]);
|
|
696
|
-
*
|
|
697
|
-
* const doubled = prices.map(v => (v ?? 0) * 2);
|
|
698
|
-
* console.log(doubled.get('apple')); // 2;
|
|
699
|
-
* console.log(doubled.get('banana')); // 4;
|
|
302
|
+
* @example
|
|
303
|
+
* // Transform all values
|
|
304
|
+
* const prices = new HashMap<string, number>([
|
|
305
|
+
* ['apple', 1],
|
|
306
|
+
* ['banana', 2]
|
|
307
|
+
* ]);
|
|
308
|
+
*
|
|
309
|
+
* const doubled = prices.map(v => (v ?? 0) * 2);
|
|
310
|
+
* console.log(doubled.get('apple')); // 2;
|
|
311
|
+
* console.log(doubled.get('banana')); // 4;
|
|
700
312
|
*/
|
|
701
313
|
map<VM>(callbackfn: EntryCallback<K, V, VM>, thisArg?: unknown): HashMap<K, VM>;
|
|
702
314
|
/**
|
|
@@ -705,73 +317,31 @@ export declare class HashMap<K = any, V = any, R = [K, V]> extends IterableEntry
|
|
|
705
317
|
* @param predicate - Predicate (key, value, index, map) → boolean.
|
|
706
318
|
* @param [thisArg] - Value for `this` inside the predicate.
|
|
707
319
|
* @returns A new map containing entries that satisfied the predicate.
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
* @example
|
|
751
|
-
* // HashMap iteration and filter operations
|
|
752
|
-
* const map = new HashMap<number, string>([
|
|
753
|
-
* [1, 'Alice'],
|
|
754
|
-
* [2, 'Bob'],
|
|
755
|
-
* [3, 'Charlie'],
|
|
756
|
-
* [4, 'Diana'],
|
|
757
|
-
* [5, 'Eve']
|
|
758
|
-
* ]);
|
|
759
|
-
*
|
|
760
|
-
* // Iterate through entries
|
|
761
|
-
* const entries: [number, string][] = [];
|
|
762
|
-
* for (const [key, value] of map) {
|
|
763
|
-
* entries.push([key, value]);
|
|
764
|
-
* }
|
|
765
|
-
* console.log(entries); // length: 5;
|
|
766
|
-
*
|
|
767
|
-
* // Filter operation (for iteration with collection methods)
|
|
768
|
-
* const filtered = [...map].filter(([key]) => key > 2);
|
|
769
|
-
* console.log(filtered.length); // 3;
|
|
770
|
-
*
|
|
771
|
-
* // Map operation
|
|
772
|
-
* const values = [...map.values()].map(v => v.length);
|
|
773
|
-
* console.log(values); // contains 3; // 'Bob', 'Eve'
|
|
774
|
-
* console.log(values); // contains 7;
|
|
320
|
+
* @example
|
|
321
|
+
* // HashMap iteration and filter operations
|
|
322
|
+
* const map = new HashMap<number, string>([
|
|
323
|
+
* [1, 'Alice'],
|
|
324
|
+
* [2, 'Bob'],
|
|
325
|
+
* [3, 'Charlie'],
|
|
326
|
+
* [4, 'Diana'],
|
|
327
|
+
* [5, 'Eve']
|
|
328
|
+
* ]);
|
|
329
|
+
*
|
|
330
|
+
* // Iterate through entries
|
|
331
|
+
* const entries: [number, string][] = [];
|
|
332
|
+
* for (const [key, value] of map) {
|
|
333
|
+
* entries.push([key, value]);
|
|
334
|
+
* }
|
|
335
|
+
* console.log(entries); // length: 5;
|
|
336
|
+
*
|
|
337
|
+
* // Filter operation (for iteration with collection methods)
|
|
338
|
+
* const filtered = [...map].filter(([key]) => key > 2);
|
|
339
|
+
* console.log(filtered.length); // 3;
|
|
340
|
+
*
|
|
341
|
+
* // Map operation
|
|
342
|
+
* const values = [...map.values()].map(v => v.length);
|
|
343
|
+
* console.log(values); // contains 3; // 'Bob', 'Eve'
|
|
344
|
+
* console.log(values); // contains 7;
|
|
775
345
|
*/
|
|
776
346
|
filter(predicate: EntryCallback<K, V, boolean>, thisArg?: unknown): this;
|
|
777
347
|
/**
|
|
@@ -840,7 +410,6 @@ export declare class LinkedHashMap<K = any, V = any, R = [K, V]> extends Iterabl
|
|
|
840
410
|
* @returns Tail node or sentinel.
|
|
841
411
|
*/
|
|
842
412
|
get tail(): HashMapLinkedNode<K, V | undefined>;
|
|
843
|
-
protected readonly _toEntryFn?: (rawElement: R) => [K, V];
|
|
844
413
|
get toEntryFn(): ((rawElement: R) => [K, V]) | undefined;
|
|
845
414
|
protected _size: number;
|
|
846
415
|
get size(): number;
|
|
@@ -917,6 +486,7 @@ export declare class LinkedHashMap<K = any, V = any, R = [K, V]> extends Iterabl
|
|
|
917
486
|
* @returns A new map of the same class with transformed entries.
|
|
918
487
|
*/
|
|
919
488
|
map<MK, MV>(callback: EntryCallback<K, V, [MK, MV]>, thisArg?: unknown): LinkedHashMap<MK, MV>;
|
|
489
|
+
protected readonly _toEntryFn?: (rawElement: R) => [K, V];
|
|
920
490
|
protected _getIterator(): IterableIterator<[K, V]>;
|
|
921
491
|
protected _deleteNode(node: HashMapLinkedNode<K, V | undefined>): boolean;
|
|
922
492
|
protected _createLike<TK = K, TV = V, TR = [TK, TV]>(entries?: Iterable<[TK, TV] | TR>, options?: Record<string, unknown>): this;
|