binary-tree-typed 2.5.0 → 2.5.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/dist/cjs/index.cjs +609 -0
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs-legacy/index.cjs +609 -0
- package/dist/cjs-legacy/index.cjs.map +1 -1
- package/dist/esm/index.mjs +609 -0
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm-legacy/index.mjs +609 -0
- package/dist/esm-legacy/index.mjs.map +1 -1
- package/dist/types/data-structures/base/index.d.ts +1 -0
- package/dist/types/data-structures/base/iterable-entry-base.d.ts +8 -8
- package/dist/types/data-structures/base/linear-base.d.ts +3 -3
- package/dist/types/data-structures/binary-tree/avl-tree.d.ts +252 -0
- package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +294 -0
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +527 -2
- package/dist/types/data-structures/binary-tree/bst.d.ts +505 -1
- package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +399 -0
- package/dist/types/data-structures/binary-tree/segment-tree.d.ts +126 -1
- package/dist/types/data-structures/binary-tree/tree-map.d.ts +2881 -382
- package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +2867 -347
- package/dist/types/data-structures/binary-tree/tree-multi-set.d.ts +2328 -312
- package/dist/types/data-structures/binary-tree/tree-set.d.ts +2671 -277
- package/dist/types/data-structures/graph/abstract-graph.d.ts +4 -4
- package/dist/types/data-structures/graph/directed-graph.d.ts +210 -0
- package/dist/types/data-structures/graph/undirected-graph.d.ts +189 -0
- package/dist/types/data-structures/hash/hash-map.d.ts +241 -10
- package/dist/types/data-structures/heap/heap.d.ts +294 -0
- package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +360 -3
- package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +318 -3
- package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +380 -2
- package/dist/types/data-structures/matrix/matrix.d.ts +168 -0
- package/dist/types/data-structures/queue/deque.d.ts +319 -4
- package/dist/types/data-structures/queue/queue.d.ts +252 -0
- package/dist/types/data-structures/stack/stack.d.ts +210 -0
- package/dist/types/data-structures/trie/trie.d.ts +256 -4
- package/dist/types/interfaces/graph.d.ts +1 -1
- package/dist/types/types/common.d.ts +2 -2
- package/dist/types/types/data-structures/heap/heap.d.ts +1 -0
- package/dist/types/types/data-structures/priority-queue/priority-queue.d.ts +1 -0
- package/dist/types/types/utils/validate-type.d.ts +4 -4
- package/dist/umd/binary-tree-typed.js +609 -0
- package/dist/umd/binary-tree-typed.js.map +1 -1
- package/dist/umd/binary-tree-typed.min.js +5 -5
- package/dist/umd/binary-tree-typed.min.js.map +1 -1
- package/package.json +2 -2
- package/src/data-structures/base/index.ts +1 -0
- package/src/data-structures/base/iterable-entry-base.ts +8 -8
- package/src/data-structures/base/linear-base.ts +3 -3
- package/src/data-structures/binary-tree/avl-tree.ts +252 -0
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +295 -1
- package/src/data-structures/binary-tree/binary-tree.ts +527 -2
- package/src/data-structures/binary-tree/bst.ts +505 -1
- package/src/data-structures/binary-tree/red-black-tree.ts +399 -0
- package/src/data-structures/binary-tree/segment-tree.ts +127 -2
- package/src/data-structures/binary-tree/tree-map.ts +2958 -459
- package/src/data-structures/binary-tree/tree-multi-map.ts +3069 -549
- package/src/data-structures/binary-tree/tree-multi-set.ts +2476 -460
- package/src/data-structures/binary-tree/tree-set.ts +2816 -422
- package/src/data-structures/graph/abstract-graph.ts +4 -4
- package/src/data-structures/graph/directed-graph.ts +210 -0
- package/src/data-structures/graph/undirected-graph.ts +189 -0
- package/src/data-structures/hash/hash-map.ts +246 -15
- package/src/data-structures/heap/heap.ts +294 -0
- package/src/data-structures/linked-list/doubly-linked-list.ts +360 -3
- package/src/data-structures/linked-list/singly-linked-list.ts +318 -3
- package/src/data-structures/linked-list/skip-linked-list.ts +380 -2
- package/src/data-structures/matrix/matrix.ts +169 -1
- package/src/data-structures/queue/deque.ts +320 -5
- package/src/data-structures/queue/queue.ts +252 -0
- package/src/data-structures/stack/stack.ts +210 -0
- package/src/data-structures/trie/trie.ts +257 -5
- package/src/interfaces/graph.ts +1 -1
- package/src/types/common.ts +2 -2
- package/src/types/data-structures/heap/heap.ts +1 -0
- package/src/types/data-structures/priority-queue/priority-queue.ts +1 -0
- package/src/types/utils/validate-type.ts +4 -4
|
@@ -145,6 +145,27 @@ export declare class HashMap<K = any, V = any, R = [K, V]> extends IterableEntry
|
|
|
145
145
|
|
|
146
146
|
|
|
147
147
|
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
|
|
148
169
|
* @example
|
|
149
170
|
* // Check if empty
|
|
150
171
|
* const map = new HashMap();
|
|
@@ -164,6 +185,27 @@ export declare class HashMap<K = any, V = any, R = [K, V]> extends IterableEntry
|
|
|
164
185
|
|
|
165
186
|
|
|
166
187
|
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
|
|
167
209
|
* @example
|
|
168
210
|
* // Remove all entries
|
|
169
211
|
* const map = new HashMap<string, number>([['a', 1], ['b', 2]]);
|
|
@@ -176,7 +218,7 @@ export declare class HashMap<K = any, V = any, R = [K, V]> extends IterableEntry
|
|
|
176
218
|
* @remarks Time O(1), Space O(1)
|
|
177
219
|
* @returns True if the value is a 2-tuple.
|
|
178
220
|
*/
|
|
179
|
-
isEntry(rawElement:
|
|
221
|
+
isEntry(rawElement: unknown): rawElement is [K, V];
|
|
180
222
|
/**
|
|
181
223
|
* Insert or replace a single entry.
|
|
182
224
|
* @remarks Time O(1), Space O(1)
|
|
@@ -203,6 +245,48 @@ export declare class HashMap<K = any, V = any, R = [K, V]> extends IterableEntry
|
|
|
203
245
|
|
|
204
246
|
|
|
205
247
|
|
|
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
|
+
|
|
206
290
|
|
|
207
291
|
|
|
208
292
|
* @example
|
|
@@ -239,6 +323,27 @@ export declare class HashMap<K = any, V = any, R = [K, V]> extends IterableEntry
|
|
|
239
323
|
|
|
240
324
|
|
|
241
325
|
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
|
|
336
|
+
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
|
|
344
|
+
|
|
345
|
+
|
|
346
|
+
|
|
242
347
|
* @example
|
|
243
348
|
* // Add multiple entries
|
|
244
349
|
* const map = new HashMap<string, number>();
|
|
@@ -262,6 +367,27 @@ export declare class HashMap<K = any, V = any, R = [K, V]> extends IterableEntry
|
|
|
262
367
|
|
|
263
368
|
|
|
264
369
|
|
|
370
|
+
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+
|
|
374
|
+
|
|
375
|
+
|
|
376
|
+
|
|
377
|
+
|
|
378
|
+
|
|
379
|
+
|
|
380
|
+
|
|
381
|
+
|
|
382
|
+
|
|
383
|
+
|
|
384
|
+
|
|
385
|
+
|
|
386
|
+
|
|
387
|
+
|
|
388
|
+
|
|
389
|
+
|
|
390
|
+
|
|
265
391
|
* @example
|
|
266
392
|
* // HashMap get and has operations
|
|
267
393
|
* const map = new HashMap<string, number>([
|
|
@@ -301,6 +427,27 @@ export declare class HashMap<K = any, V = any, R = [K, V]> extends IterableEntry
|
|
|
301
427
|
|
|
302
428
|
|
|
303
429
|
|
|
430
|
+
|
|
431
|
+
|
|
432
|
+
|
|
433
|
+
|
|
434
|
+
|
|
435
|
+
|
|
436
|
+
|
|
437
|
+
|
|
438
|
+
|
|
439
|
+
|
|
440
|
+
|
|
441
|
+
|
|
442
|
+
|
|
443
|
+
|
|
444
|
+
|
|
445
|
+
|
|
446
|
+
|
|
447
|
+
|
|
448
|
+
|
|
449
|
+
|
|
450
|
+
|
|
304
451
|
* @example
|
|
305
452
|
* // Check key existence
|
|
306
453
|
* const map = new HashMap<string, number>([['a', 1], ['b', 2]]);
|
|
@@ -325,6 +472,27 @@ export declare class HashMap<K = any, V = any, R = [K, V]> extends IterableEntry
|
|
|
325
472
|
|
|
326
473
|
|
|
327
474
|
|
|
475
|
+
|
|
476
|
+
|
|
477
|
+
|
|
478
|
+
|
|
479
|
+
|
|
480
|
+
|
|
481
|
+
|
|
482
|
+
|
|
483
|
+
|
|
484
|
+
|
|
485
|
+
|
|
486
|
+
|
|
487
|
+
|
|
488
|
+
|
|
489
|
+
|
|
490
|
+
|
|
491
|
+
|
|
492
|
+
|
|
493
|
+
|
|
494
|
+
|
|
495
|
+
|
|
328
496
|
* @example
|
|
329
497
|
* // Remove entries by key
|
|
330
498
|
* const map = new HashMap<string, number>([['x', 10], ['y', 20], ['z', 30]]);
|
|
@@ -354,6 +522,27 @@ export declare class HashMap<K = any, V = any, R = [K, V]> extends IterableEntry
|
|
|
354
522
|
|
|
355
523
|
|
|
356
524
|
|
|
525
|
+
|
|
526
|
+
|
|
527
|
+
|
|
528
|
+
|
|
529
|
+
|
|
530
|
+
|
|
531
|
+
|
|
532
|
+
|
|
533
|
+
|
|
534
|
+
|
|
535
|
+
|
|
536
|
+
|
|
537
|
+
|
|
538
|
+
|
|
539
|
+
|
|
540
|
+
|
|
541
|
+
|
|
542
|
+
|
|
543
|
+
|
|
544
|
+
|
|
545
|
+
|
|
357
546
|
* @example
|
|
358
547
|
* // Create independent copy
|
|
359
548
|
* const map = new HashMap<string, number>([['a', 1]]);
|
|
@@ -380,6 +569,27 @@ export declare class HashMap<K = any, V = any, R = [K, V]> extends IterableEntry
|
|
|
380
569
|
|
|
381
570
|
|
|
382
571
|
|
|
572
|
+
|
|
573
|
+
|
|
574
|
+
|
|
575
|
+
|
|
576
|
+
|
|
577
|
+
|
|
578
|
+
|
|
579
|
+
|
|
580
|
+
|
|
581
|
+
|
|
582
|
+
|
|
583
|
+
|
|
584
|
+
|
|
585
|
+
|
|
586
|
+
|
|
587
|
+
|
|
588
|
+
|
|
589
|
+
|
|
590
|
+
|
|
591
|
+
|
|
592
|
+
|
|
383
593
|
* @example
|
|
384
594
|
* // Transform all values
|
|
385
595
|
* const prices = new HashMap<string, number>([['apple', 1], ['banana', 2]]);
|
|
@@ -388,7 +598,7 @@ export declare class HashMap<K = any, V = any, R = [K, V]> extends IterableEntry
|
|
|
388
598
|
* console.log(doubled.get('apple')); // 2;
|
|
389
599
|
* console.log(doubled.get('banana')); // 4;
|
|
390
600
|
*/
|
|
391
|
-
map<VM>(callbackfn: EntryCallback<K, V, VM>, thisArg?:
|
|
601
|
+
map<VM>(callbackfn: EntryCallback<K, V, VM>, thisArg?: unknown): HashMap<K, VM>;
|
|
392
602
|
/**
|
|
393
603
|
* Filter entries into a new map.
|
|
394
604
|
* @remarks Time O(N), Space O(N)
|
|
@@ -406,6 +616,27 @@ export declare class HashMap<K = any, V = any, R = [K, V]> extends IterableEntry
|
|
|
406
616
|
|
|
407
617
|
|
|
408
618
|
|
|
619
|
+
|
|
620
|
+
|
|
621
|
+
|
|
622
|
+
|
|
623
|
+
|
|
624
|
+
|
|
625
|
+
|
|
626
|
+
|
|
627
|
+
|
|
628
|
+
|
|
629
|
+
|
|
630
|
+
|
|
631
|
+
|
|
632
|
+
|
|
633
|
+
|
|
634
|
+
|
|
635
|
+
|
|
636
|
+
|
|
637
|
+
|
|
638
|
+
|
|
639
|
+
|
|
409
640
|
* @example
|
|
410
641
|
* // HashMap iteration and filter operations
|
|
411
642
|
* const map = new HashMap<number, string>([
|
|
@@ -432,7 +663,7 @@ export declare class HashMap<K = any, V = any, R = [K, V]> extends IterableEntry
|
|
|
432
663
|
* console.log(values); // contains 3; // 'Bob', 'Eve'
|
|
433
664
|
* console.log(values); // contains 7;
|
|
434
665
|
*/
|
|
435
|
-
filter(predicate: EntryCallback<K, V, boolean>, thisArg?:
|
|
666
|
+
filter(predicate: EntryCallback<K, V, boolean>, thisArg?: unknown): any;
|
|
436
667
|
/**
|
|
437
668
|
* (Protected) Create a like-kind instance and seed it from an iterable.
|
|
438
669
|
* @remarks Time O(N), Space O(N)
|
|
@@ -443,10 +674,10 @@ export declare class HashMap<K = any, V = any, R = [K, V]> extends IterableEntry
|
|
|
443
674
|
* @param [options] - Options forwarded to the constructor.
|
|
444
675
|
* @returns A like-kind map instance.
|
|
445
676
|
*/
|
|
446
|
-
protected _createLike<TK = K, TV = V, TR = [TK, TV]>(entries?: Iterable<[TK, TV] | TR>, options?:
|
|
677
|
+
protected _createLike<TK = K, TV = V, TR = [TK, TV]>(entries?: Iterable<[TK, TV] | TR>, options?: Record<string, unknown>): this;
|
|
447
678
|
protected _rehashNoObj(): void;
|
|
448
679
|
protected _getIterator(): IterableIterator<[K, V]>;
|
|
449
|
-
protected _isObjKey(key:
|
|
680
|
+
protected _isObjKey(key: unknown): key is object | ((...args: unknown[]) => unknown);
|
|
450
681
|
protected _getNoObjKey(key: K): string;
|
|
451
682
|
}
|
|
452
683
|
/**
|
|
@@ -561,10 +792,10 @@ export declare class LinkedHashMap<K = any, V = any, R = [K, V]> extends Iterabl
|
|
|
561
792
|
*/
|
|
562
793
|
deleteAt(index: number): boolean;
|
|
563
794
|
isEmpty(): boolean;
|
|
564
|
-
isEntry(rawElement:
|
|
795
|
+
isEntry(rawElement: unknown): rawElement is [K, V];
|
|
565
796
|
clear(): void;
|
|
566
|
-
clone():
|
|
567
|
-
filter(predicate: EntryCallback<K, V, boolean>, thisArg?:
|
|
797
|
+
clone(): this;
|
|
798
|
+
filter(predicate: EntryCallback<K, V, boolean>, thisArg?: unknown): this;
|
|
568
799
|
/**
|
|
569
800
|
* Map each entry to a new [key, value] pair and preserve order.
|
|
570
801
|
* @remarks Time O(N), Space O(N)
|
|
@@ -574,8 +805,8 @@ export declare class LinkedHashMap<K = any, V = any, R = [K, V]> extends Iterabl
|
|
|
574
805
|
* @param [thisArg] - Value for `this` inside the callback.
|
|
575
806
|
* @returns A new map of the same class with transformed entries.
|
|
576
807
|
*/
|
|
577
|
-
map<MK, MV>(callback: EntryCallback<K, V, [MK, MV]>, thisArg?:
|
|
808
|
+
map<MK, MV>(callback: EntryCallback<K, V, [MK, MV]>, thisArg?: unknown): LinkedHashMap<MK, MV>;
|
|
578
809
|
protected _getIterator(): IterableIterator<[K, V]>;
|
|
579
810
|
protected _deleteNode(node: HashMapLinkedNode<K, V | undefined>): boolean;
|
|
580
|
-
protected _createLike<TK = K, TV = V, TR = [TK, TV]>(entries?: Iterable<[TK, TV] | TR>, options?:
|
|
811
|
+
protected _createLike<TK = K, TV = V, TR = [TK, TV]>(entries?: Iterable<[TK, TV] | TR>, options?: Record<string, unknown>): this;
|
|
581
812
|
}
|
|
@@ -176,6 +176,27 @@ export declare class Heap<E = any, R = any> extends IterableElementBase<E, R> {
|
|
|
176
176
|
|
|
177
177
|
|
|
178
178
|
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
|
|
179
200
|
* @example
|
|
180
201
|
* // Track heap capacity
|
|
181
202
|
* const heap = new Heap<number>();
|
|
@@ -230,6 +251,27 @@ export declare class Heap<E = any, R = any> extends IterableElementBase<E, R> {
|
|
|
230
251
|
|
|
231
252
|
|
|
232
253
|
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
|
|
233
275
|
* @example
|
|
234
276
|
* // basic Heap creation and add operation
|
|
235
277
|
* // Create a min heap (default)
|
|
@@ -260,6 +302,27 @@ export declare class Heap<E = any, R = any> extends IterableElementBase<E, R> {
|
|
|
260
302
|
|
|
261
303
|
|
|
262
304
|
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
|
|
263
326
|
* @example
|
|
264
327
|
* // Add multiple elements
|
|
265
328
|
* const heap = new Heap<number>([], { comparator: (a, b) => a - b });
|
|
@@ -283,6 +346,27 @@ export declare class Heap<E = any, R = any> extends IterableElementBase<E, R> {
|
|
|
283
346
|
|
|
284
347
|
|
|
285
348
|
|
|
349
|
+
|
|
350
|
+
|
|
351
|
+
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
|
|
355
|
+
|
|
356
|
+
|
|
357
|
+
|
|
358
|
+
|
|
359
|
+
|
|
360
|
+
|
|
361
|
+
|
|
362
|
+
|
|
363
|
+
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+
|
|
368
|
+
|
|
369
|
+
|
|
286
370
|
* @example
|
|
287
371
|
* // Heap with custom comparator (MaxHeap behavior)
|
|
288
372
|
* interface Task {
|
|
@@ -325,6 +409,27 @@ export declare class Heap<E = any, R = any> extends IterableElementBase<E, R> {
|
|
|
325
409
|
|
|
326
410
|
|
|
327
411
|
|
|
412
|
+
|
|
413
|
+
|
|
414
|
+
|
|
415
|
+
|
|
416
|
+
|
|
417
|
+
|
|
418
|
+
|
|
419
|
+
|
|
420
|
+
|
|
421
|
+
|
|
422
|
+
|
|
423
|
+
|
|
424
|
+
|
|
425
|
+
|
|
426
|
+
|
|
427
|
+
|
|
428
|
+
|
|
429
|
+
|
|
430
|
+
|
|
431
|
+
|
|
432
|
+
|
|
328
433
|
* @example
|
|
329
434
|
* // Heap for event processing with priority
|
|
330
435
|
* interface Event {
|
|
@@ -399,6 +504,27 @@ export declare class Heap<E = any, R = any> extends IterableElementBase<E, R> {
|
|
|
399
504
|
|
|
400
505
|
|
|
401
506
|
|
|
507
|
+
|
|
508
|
+
|
|
509
|
+
|
|
510
|
+
|
|
511
|
+
|
|
512
|
+
|
|
513
|
+
|
|
514
|
+
|
|
515
|
+
|
|
516
|
+
|
|
517
|
+
|
|
518
|
+
|
|
519
|
+
|
|
520
|
+
|
|
521
|
+
|
|
522
|
+
|
|
523
|
+
|
|
524
|
+
|
|
525
|
+
|
|
526
|
+
|
|
527
|
+
|
|
402
528
|
* @example
|
|
403
529
|
* // Check if heap is empty
|
|
404
530
|
* const heap = new Heap<number>([], { comparator: (a, b) => a - b });
|
|
@@ -420,6 +546,27 @@ export declare class Heap<E = any, R = any> extends IterableElementBase<E, R> {
|
|
|
420
546
|
|
|
421
547
|
|
|
422
548
|
|
|
549
|
+
|
|
550
|
+
|
|
551
|
+
|
|
552
|
+
|
|
553
|
+
|
|
554
|
+
|
|
555
|
+
|
|
556
|
+
|
|
557
|
+
|
|
558
|
+
|
|
559
|
+
|
|
560
|
+
|
|
561
|
+
|
|
562
|
+
|
|
563
|
+
|
|
564
|
+
|
|
565
|
+
|
|
566
|
+
|
|
567
|
+
|
|
568
|
+
|
|
569
|
+
|
|
423
570
|
* @example
|
|
424
571
|
* // Remove all elements
|
|
425
572
|
* const heap = new Heap<number>([1, 2, 3], { comparator: (a, b) => a - b });
|
|
@@ -441,6 +588,27 @@ export declare class Heap<E = any, R = any> extends IterableElementBase<E, R> {
|
|
|
441
588
|
* @returns True if found.
|
|
442
589
|
|
|
443
590
|
|
|
591
|
+
|
|
592
|
+
|
|
593
|
+
|
|
594
|
+
|
|
595
|
+
|
|
596
|
+
|
|
597
|
+
|
|
598
|
+
|
|
599
|
+
|
|
600
|
+
|
|
601
|
+
|
|
602
|
+
|
|
603
|
+
|
|
604
|
+
|
|
605
|
+
|
|
606
|
+
|
|
607
|
+
|
|
608
|
+
|
|
609
|
+
|
|
610
|
+
|
|
611
|
+
|
|
444
612
|
* @example
|
|
445
613
|
* // Check element existence
|
|
446
614
|
* const heap = new Heap<number>([3, 1, 2], { comparator: (a, b) => a - b });
|
|
@@ -461,6 +629,27 @@ export declare class Heap<E = any, R = any> extends IterableElementBase<E, R> {
|
|
|
461
629
|
|
|
462
630
|
|
|
463
631
|
|
|
632
|
+
|
|
633
|
+
|
|
634
|
+
|
|
635
|
+
|
|
636
|
+
|
|
637
|
+
|
|
638
|
+
|
|
639
|
+
|
|
640
|
+
|
|
641
|
+
|
|
642
|
+
|
|
643
|
+
|
|
644
|
+
|
|
645
|
+
|
|
646
|
+
|
|
647
|
+
|
|
648
|
+
|
|
649
|
+
|
|
650
|
+
|
|
651
|
+
|
|
652
|
+
|
|
464
653
|
* @example
|
|
465
654
|
* // Remove specific element
|
|
466
655
|
* const heap = new Heap<number>([3, 1, 4, 1, 5], { comparator: (a, b) => a - b });
|
|
@@ -489,6 +678,27 @@ export declare class Heap<E = any, R = any> extends IterableElementBase<E, R> {
|
|
|
489
678
|
* @returns Array of visited elements.
|
|
490
679
|
|
|
491
680
|
|
|
681
|
+
|
|
682
|
+
|
|
683
|
+
|
|
684
|
+
|
|
685
|
+
|
|
686
|
+
|
|
687
|
+
|
|
688
|
+
|
|
689
|
+
|
|
690
|
+
|
|
691
|
+
|
|
692
|
+
|
|
693
|
+
|
|
694
|
+
|
|
695
|
+
|
|
696
|
+
|
|
697
|
+
|
|
698
|
+
|
|
699
|
+
|
|
700
|
+
|
|
701
|
+
|
|
492
702
|
* @example
|
|
493
703
|
* // Depth-first traversal
|
|
494
704
|
* const heap = new Heap<number>([3, 1, 2], { comparator: (a, b) => a - b });
|
|
@@ -517,6 +727,27 @@ export declare class Heap<E = any, R = any> extends IterableElementBase<E, R> {
|
|
|
517
727
|
|
|
518
728
|
|
|
519
729
|
|
|
730
|
+
|
|
731
|
+
|
|
732
|
+
|
|
733
|
+
|
|
734
|
+
|
|
735
|
+
|
|
736
|
+
|
|
737
|
+
|
|
738
|
+
|
|
739
|
+
|
|
740
|
+
|
|
741
|
+
|
|
742
|
+
|
|
743
|
+
|
|
744
|
+
|
|
745
|
+
|
|
746
|
+
|
|
747
|
+
|
|
748
|
+
|
|
749
|
+
|
|
750
|
+
|
|
520
751
|
* @example
|
|
521
752
|
* // Sort elements using heap
|
|
522
753
|
* const heap = new Heap<number>([5, 1, 3, 2, 4]);
|
|
@@ -537,6 +768,27 @@ export declare class Heap<E = any, R = any> extends IterableElementBase<E, R> {
|
|
|
537
768
|
|
|
538
769
|
|
|
539
770
|
|
|
771
|
+
|
|
772
|
+
|
|
773
|
+
|
|
774
|
+
|
|
775
|
+
|
|
776
|
+
|
|
777
|
+
|
|
778
|
+
|
|
779
|
+
|
|
780
|
+
|
|
781
|
+
|
|
782
|
+
|
|
783
|
+
|
|
784
|
+
|
|
785
|
+
|
|
786
|
+
|
|
787
|
+
|
|
788
|
+
|
|
789
|
+
|
|
790
|
+
|
|
791
|
+
|
|
540
792
|
* @example
|
|
541
793
|
* // Create independent copy
|
|
542
794
|
* const heap = new Heap<number>([3, 1, 4], { comparator: (a, b) => a - b });
|
|
@@ -561,6 +813,27 @@ export declare class Heap<E = any, R = any> extends IterableElementBase<E, R> {
|
|
|
561
813
|
|
|
562
814
|
|
|
563
815
|
|
|
816
|
+
|
|
817
|
+
|
|
818
|
+
|
|
819
|
+
|
|
820
|
+
|
|
821
|
+
|
|
822
|
+
|
|
823
|
+
|
|
824
|
+
|
|
825
|
+
|
|
826
|
+
|
|
827
|
+
|
|
828
|
+
|
|
829
|
+
|
|
830
|
+
|
|
831
|
+
|
|
832
|
+
|
|
833
|
+
|
|
834
|
+
|
|
835
|
+
|
|
836
|
+
|
|
564
837
|
* @example
|
|
565
838
|
* // Filter elements
|
|
566
839
|
* const heap = new Heap<number>([1, 2, 3, 4, 5], { comparator: (a, b) => a - b });
|
|
@@ -585,6 +858,27 @@ export declare class Heap<E = any, R = any> extends IterableElementBase<E, R> {
|
|
|
585
858
|
|
|
586
859
|
|
|
587
860
|
|
|
861
|
+
|
|
862
|
+
|
|
863
|
+
|
|
864
|
+
|
|
865
|
+
|
|
866
|
+
|
|
867
|
+
|
|
868
|
+
|
|
869
|
+
|
|
870
|
+
|
|
871
|
+
|
|
872
|
+
|
|
873
|
+
|
|
874
|
+
|
|
875
|
+
|
|
876
|
+
|
|
877
|
+
|
|
878
|
+
|
|
879
|
+
|
|
880
|
+
|
|
881
|
+
|
|
588
882
|
* @example
|
|
589
883
|
* // Transform elements
|
|
590
884
|
* const heap = new Heap<number>([1, 2, 3], { comparator: (a, b) => a - b });
|