min-heap-typed 1.52.3 → 1.52.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-element-base.d.ts +1 -37
- package/dist/data-structures/base/iterable-element-base.js +1 -37
- package/dist/data-structures/base/iterable-entry-base.d.ts +2 -54
- package/dist/data-structures/base/iterable-entry-base.js +1 -49
- package/dist/data-structures/binary-tree/avl-tree-multi-map.d.ts +0 -32
- package/dist/data-structures/binary-tree/avl-tree-multi-map.js +9 -41
- package/dist/data-structures/binary-tree/avl-tree.d.ts +0 -46
- package/dist/data-structures/binary-tree/avl-tree.js +0 -46
- package/dist/data-structures/binary-tree/binary-tree.d.ts +82 -147
- package/dist/data-structures/binary-tree/binary-tree.js +299 -331
- package/dist/data-structures/binary-tree/bst.d.ts +1 -40
- package/dist/data-structures/binary-tree/bst.js +12 -44
- package/dist/data-structures/binary-tree/rb-tree.d.ts +0 -48
- package/dist/data-structures/binary-tree/rb-tree.js +2 -50
- package/dist/data-structures/binary-tree/tree-multi-map.d.ts +0 -32
- package/dist/data-structures/binary-tree/tree-multi-map.js +9 -41
- package/dist/data-structures/graph/abstract-graph.d.ts +0 -75
- package/dist/data-structures/graph/abstract-graph.js +0 -75
- package/dist/data-structures/graph/directed-graph.d.ts +0 -98
- package/dist/data-structures/graph/directed-graph.js +0 -98
- package/dist/data-structures/graph/undirected-graph.d.ts +0 -50
- package/dist/data-structures/graph/undirected-graph.js +0 -50
- package/dist/data-structures/hash/hash-map.d.ts +5 -92
- package/dist/data-structures/hash/hash-map.js +29 -115
- package/dist/data-structures/heap/heap.d.ts +0 -32
- package/dist/data-structures/heap/heap.js +0 -32
- package/dist/data-structures/linked-list/doubly-linked-list.d.ts +5 -88
- package/dist/data-structures/linked-list/doubly-linked-list.js +5 -88
- package/dist/data-structures/linked-list/singly-linked-list.d.ts +1 -83
- package/dist/data-structures/linked-list/singly-linked-list.js +2 -84
- package/dist/data-structures/linked-list/skip-linked-list.d.ts +1 -35
- package/dist/data-structures/linked-list/skip-linked-list.js +1 -35
- package/dist/data-structures/queue/deque.d.ts +1 -98
- package/dist/data-structures/queue/deque.js +3 -99
- package/dist/data-structures/queue/queue.d.ts +5 -58
- package/dist/data-structures/queue/queue.js +4 -57
- package/dist/data-structures/stack/stack.d.ts +1 -34
- package/dist/data-structures/stack/stack.js +1 -34
- package/dist/data-structures/tree/tree.js +2 -1
- package/dist/data-structures/trie/trie.d.ts +0 -64
- package/dist/data-structures/trie/trie.js +0 -64
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +8 -0
- package/dist/types/data-structures/binary-tree/binary-tree.js +6 -0
- package/dist/types/utils/utils.d.ts +13 -12
- package/dist/utils/number.d.ts +13 -0
- package/dist/utils/number.js +13 -0
- package/dist/utils/utils.d.ts +125 -3
- package/dist/utils/utils.js +177 -21
- package/package.json +2 -2
- package/src/data-structures/base/iterable-element-base.ts +2 -42
- package/src/data-structures/base/iterable-entry-base.ts +3 -62
- package/src/data-structures/binary-tree/avl-tree-multi-map.ts +8 -48
- package/src/data-structures/binary-tree/avl-tree.ts +0 -57
- package/src/data-structures/binary-tree/binary-tree.ts +329 -358
- package/src/data-structures/binary-tree/bst.ts +11 -54
- package/src/data-structures/binary-tree/rb-tree.ts +2 -62
- package/src/data-structures/binary-tree/tree-multi-map.ts +8 -48
- package/src/data-structures/graph/abstract-graph.ts +0 -92
- package/src/data-structures/graph/directed-graph.ts +0 -122
- package/src/data-structures/graph/undirected-graph.ts +0 -62
- package/src/data-structures/hash/hash-map.ts +31 -139
- package/src/data-structures/heap/heap.ts +0 -40
- package/src/data-structures/linked-list/doubly-linked-list.ts +5 -112
- package/src/data-structures/linked-list/singly-linked-list.ts +2 -104
- package/src/data-structures/linked-list/skip-linked-list.ts +1 -44
- package/src/data-structures/queue/deque.ts +2 -125
- package/src/data-structures/queue/queue.ts +5 -72
- package/src/data-structures/stack/stack.ts +1 -43
- package/src/data-structures/tree/tree.ts +1 -1
- package/src/data-structures/trie/trie.ts +0 -80
- package/src/types/data-structures/binary-tree/binary-tree.ts +8 -1
- package/src/types/utils/utils.ts +17 -15
- package/src/utils/number.ts +13 -0
- package/src/utils/utils.ts +174 -18
|
@@ -34,12 +34,8 @@ export class HashMap<K = any, V = any, R = [K, V]> extends IterableEntryBase<K,
|
|
|
34
34
|
super();
|
|
35
35
|
if (options) {
|
|
36
36
|
const { hashFn, toEntryFn } = options;
|
|
37
|
-
if (hashFn)
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
if (toEntryFn) {
|
|
41
|
-
this._toEntryFn = toEntryFn;
|
|
42
|
-
}
|
|
37
|
+
if (hashFn) this._hashFn = hashFn;
|
|
38
|
+
if (toEntryFn) this._toEntryFn = toEntryFn;
|
|
43
39
|
}
|
|
44
40
|
if (entryOrRawElements) {
|
|
45
41
|
this.setMany(entryOrRawElements);
|
|
@@ -167,8 +163,8 @@ export class HashMap<K = any, V = any, R = [K, V]> extends IterableEntryBase<K,
|
|
|
167
163
|
if (this.isEntry(rawEle)) {
|
|
168
164
|
key = rawEle[0];
|
|
169
165
|
value = rawEle[1];
|
|
170
|
-
} else if (this.
|
|
171
|
-
const item = this.
|
|
166
|
+
} else if (this._toEntryFn) {
|
|
167
|
+
const item = this._toEntryFn(rawEle);
|
|
172
168
|
key = item[0];
|
|
173
169
|
value = item[1];
|
|
174
170
|
}
|
|
@@ -238,9 +234,7 @@ export class HashMap<K = any, V = any, R = [K, V]> extends IterableEntryBase<K,
|
|
|
238
234
|
/**
|
|
239
235
|
* Time Complexity: O(n)
|
|
240
236
|
* Space Complexity: O(n)
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
/**
|
|
237
|
+
*
|
|
244
238
|
* The clone function creates a new HashMap with the same key-value pairs as
|
|
245
239
|
* this one. The clone function is useful for creating a copy of an existing
|
|
246
240
|
* HashMap, and then modifying that copy without affecting the original.
|
|
@@ -248,14 +242,9 @@ export class HashMap<K = any, V = any, R = [K, V]> extends IterableEntryBase<K,
|
|
|
248
242
|
* @return A new hashmap with the same values as this one
|
|
249
243
|
*/
|
|
250
244
|
clone(): HashMap<K, V, R> {
|
|
251
|
-
return new HashMap<K, V, R>(this, { hashFn: this.
|
|
245
|
+
return new HashMap<K, V, R>(this, { hashFn: this._hashFn, toEntryFn: this._toEntryFn });
|
|
252
246
|
}
|
|
253
247
|
|
|
254
|
-
/**
|
|
255
|
-
* Time Complexity: O(n)
|
|
256
|
-
* Space Complexity: O(n)
|
|
257
|
-
*/
|
|
258
|
-
|
|
259
248
|
/**
|
|
260
249
|
* Time Complexity: O(n)
|
|
261
250
|
* Space Complexity: O(n)
|
|
@@ -306,18 +295,6 @@ export class HashMap<K = any, V = any, R = [K, V]> extends IterableEntryBase<K,
|
|
|
306
295
|
return filteredMap;
|
|
307
296
|
}
|
|
308
297
|
|
|
309
|
-
/**
|
|
310
|
-
* The put function sets a value in a data structure using a specified key.
|
|
311
|
-
* @param {K} key - The key parameter is of type K, which represents the type of the key being passed
|
|
312
|
-
* to the function.
|
|
313
|
-
* @param {V} value - The value parameter represents the value that you want to associate with the
|
|
314
|
-
* specified key in the data structure.
|
|
315
|
-
* @returns The method is returning a boolean value.
|
|
316
|
-
*/
|
|
317
|
-
put(key: K, value: V): boolean {
|
|
318
|
-
return this.set(key, value);
|
|
319
|
-
}
|
|
320
|
-
|
|
321
298
|
/**
|
|
322
299
|
* The function returns an iterator that yields key-value pairs from both an object store and an
|
|
323
300
|
* object map.
|
|
@@ -353,7 +330,7 @@ export class HashMap<K = any, V = any, R = [K, V]> extends IterableEntryBase<K,
|
|
|
353
330
|
|
|
354
331
|
let strKey: string;
|
|
355
332
|
if (keyType !== 'string' && keyType !== 'number' && keyType !== 'symbol') {
|
|
356
|
-
strKey = this.
|
|
333
|
+
strKey = this._hashFn(key);
|
|
357
334
|
} else {
|
|
358
335
|
if (keyType === 'number') {
|
|
359
336
|
// TODO numeric key should has its own hash
|
|
@@ -383,7 +360,7 @@ export class LinkedHashMap<K = any, V = any, R = [K, V]> extends IterableEntryBa
|
|
|
383
360
|
* @param [options] - The `options` parameter is an optional object that can contain the following
|
|
384
361
|
* properties:
|
|
385
362
|
*/
|
|
386
|
-
constructor(entryOrRawElements: Iterable<R> = [], options?: LinkedHashMapOptions<K, V, R>) {
|
|
363
|
+
constructor(entryOrRawElements: Iterable<R | [K, V]> = [], options?: LinkedHashMapOptions<K, V, R>) {
|
|
387
364
|
super();
|
|
388
365
|
this._sentinel = <HashMapLinkedNode<K, V>>{};
|
|
389
366
|
this._sentinel.prev = this._sentinel.next = this._head = this._tail = this._sentinel;
|
|
@@ -399,10 +376,7 @@ export class LinkedHashMap<K = any, V = any, R = [K, V]> extends IterableEntryBa
|
|
|
399
376
|
}
|
|
400
377
|
|
|
401
378
|
if (entryOrRawElements) {
|
|
402
|
-
|
|
403
|
-
const [key, value] = this.toEntryFn(el);
|
|
404
|
-
this.set(key, value);
|
|
405
|
-
}
|
|
379
|
+
this.setMany(entryOrRawElements);
|
|
406
380
|
}
|
|
407
381
|
}
|
|
408
382
|
|
|
@@ -469,7 +443,7 @@ export class LinkedHashMap<K = any, V = any, R = [K, V]> extends IterableEntryBa
|
|
|
469
443
|
return this._tail;
|
|
470
444
|
}
|
|
471
445
|
|
|
472
|
-
protected _toEntryFn
|
|
446
|
+
protected _toEntryFn?: (rawElement: R) => [K, V] = (rawElement: R) => {
|
|
473
447
|
if (this.isEntry(rawElement)) {
|
|
474
448
|
// TODO, For performance optimization, it may be necessary to only inspect the first element traversed.
|
|
475
449
|
return rawElement;
|
|
@@ -498,11 +472,6 @@ export class LinkedHashMap<K = any, V = any, R = [K, V]> extends IterableEntryBa
|
|
|
498
472
|
return this._size;
|
|
499
473
|
}
|
|
500
474
|
|
|
501
|
-
/**
|
|
502
|
-
* Time Complexity: O(1)
|
|
503
|
-
* Space Complexity: O(1)
|
|
504
|
-
*/
|
|
505
|
-
|
|
506
475
|
/**
|
|
507
476
|
* Time Complexity: O(1)
|
|
508
477
|
* Space Complexity: O(1)
|
|
@@ -516,11 +485,6 @@ export class LinkedHashMap<K = any, V = any, R = [K, V]> extends IterableEntryBa
|
|
|
516
485
|
return <[K, V]>[this.head.key, this.head.value];
|
|
517
486
|
}
|
|
518
487
|
|
|
519
|
-
/**
|
|
520
|
-
* Time Complexity: O(1)
|
|
521
|
-
* Space Complexity: O(1)
|
|
522
|
-
*/
|
|
523
|
-
|
|
524
488
|
/**
|
|
525
489
|
* Time Complexity: O(1)
|
|
526
490
|
* Space Complexity: O(1)
|
|
@@ -557,11 +521,6 @@ export class LinkedHashMap<K = any, V = any, R = [K, V]> extends IterableEntryBa
|
|
|
557
521
|
}
|
|
558
522
|
}
|
|
559
523
|
|
|
560
|
-
/**
|
|
561
|
-
* Time Complexity: O(1)
|
|
562
|
-
* Space Complexity: O(1)
|
|
563
|
-
*/
|
|
564
|
-
|
|
565
524
|
/**
|
|
566
525
|
* Time Complexity: O(1)
|
|
567
526
|
* Space Complexity: O(1)
|
|
@@ -579,7 +538,7 @@ export class LinkedHashMap<K = any, V = any, R = [K, V]> extends IterableEntryBa
|
|
|
579
538
|
const isNewKey = !this.has(key); // Check if the key is new
|
|
580
539
|
|
|
581
540
|
if (isWeakKey(key)) {
|
|
582
|
-
const hash = this.
|
|
541
|
+
const hash = this._objHashFn(key);
|
|
583
542
|
node = this.objMap.get(hash);
|
|
584
543
|
|
|
585
544
|
if (!node && isNewKey) {
|
|
@@ -591,7 +550,7 @@ export class LinkedHashMap<K = any, V = any, R = [K, V]> extends IterableEntryBa
|
|
|
591
550
|
node.value = value;
|
|
592
551
|
}
|
|
593
552
|
} else {
|
|
594
|
-
const hash = this.
|
|
553
|
+
const hash = this._hashFn(key);
|
|
595
554
|
node = this.noObjMap[hash];
|
|
596
555
|
|
|
597
556
|
if (!node && isNewKey) {
|
|
@@ -627,11 +586,20 @@ export class LinkedHashMap<K = any, V = any, R = [K, V]> extends IterableEntryBa
|
|
|
627
586
|
* R.
|
|
628
587
|
* @returns The `setMany` function returns an array of booleans.
|
|
629
588
|
*/
|
|
630
|
-
setMany(entryOrRawElements: Iterable<R>): boolean[] {
|
|
589
|
+
setMany(entryOrRawElements: Iterable<R | [K, V]>): boolean[] {
|
|
631
590
|
const results: boolean[] = [];
|
|
632
591
|
for (const rawEle of entryOrRawElements) {
|
|
633
|
-
|
|
634
|
-
|
|
592
|
+
let key: K | undefined, value: V | undefined;
|
|
593
|
+
if (this.isEntry(rawEle)) {
|
|
594
|
+
key = rawEle[0];
|
|
595
|
+
value = rawEle[1];
|
|
596
|
+
} else if (this._toEntryFn) {
|
|
597
|
+
const item = this._toEntryFn(rawEle);
|
|
598
|
+
key = item[0];
|
|
599
|
+
value = item[1];
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
if (key !== undefined && value !== undefined) results.push(this.set(key, value));
|
|
635
603
|
}
|
|
636
604
|
return results;
|
|
637
605
|
}
|
|
@@ -644,19 +612,14 @@ export class LinkedHashMap<K = any, V = any, R = [K, V]> extends IterableEntryBa
|
|
|
644
612
|
*/
|
|
645
613
|
override has(key: K): boolean {
|
|
646
614
|
if (isWeakKey(key)) {
|
|
647
|
-
const hash = this.
|
|
615
|
+
const hash = this._objHashFn(key);
|
|
648
616
|
return this.objMap.has(hash);
|
|
649
617
|
} else {
|
|
650
|
-
const hash = this.
|
|
618
|
+
const hash = this._hashFn(key);
|
|
651
619
|
return hash in this.noObjMap;
|
|
652
620
|
}
|
|
653
621
|
}
|
|
654
622
|
|
|
655
|
-
/**
|
|
656
|
-
* Time Complexity: O(1)
|
|
657
|
-
* Space Complexity: O(1)
|
|
658
|
-
*/
|
|
659
|
-
|
|
660
623
|
/**
|
|
661
624
|
* Time Complexity: O(1)
|
|
662
625
|
* Space Complexity: O(1)
|
|
@@ -672,21 +635,16 @@ export class LinkedHashMap<K = any, V = any, R = [K, V]> extends IterableEntryBa
|
|
|
672
635
|
*/
|
|
673
636
|
override get(key: K): V | undefined {
|
|
674
637
|
if (isWeakKey(key)) {
|
|
675
|
-
const hash = this.
|
|
638
|
+
const hash = this._objHashFn(key);
|
|
676
639
|
const node = this.objMap.get(hash);
|
|
677
640
|
return node ? node.value : undefined;
|
|
678
641
|
} else {
|
|
679
|
-
const hash = this.
|
|
642
|
+
const hash = this._hashFn(key);
|
|
680
643
|
const node = this.noObjMap[hash];
|
|
681
644
|
return node ? node.value : undefined;
|
|
682
645
|
}
|
|
683
646
|
}
|
|
684
647
|
|
|
685
|
-
/**
|
|
686
|
-
* Time Complexity: O(n)
|
|
687
|
-
* Space Complexity: O(1)
|
|
688
|
-
*/
|
|
689
|
-
|
|
690
648
|
/**
|
|
691
649
|
* Time Complexity: O(n)
|
|
692
650
|
* Space Complexity: O(1)
|
|
@@ -707,11 +665,6 @@ export class LinkedHashMap<K = any, V = any, R = [K, V]> extends IterableEntryBa
|
|
|
707
665
|
return node.value;
|
|
708
666
|
}
|
|
709
667
|
|
|
710
|
-
/**
|
|
711
|
-
* Time Complexity: O(1)
|
|
712
|
-
* Space Complexity: O(1)
|
|
713
|
-
*/
|
|
714
|
-
|
|
715
668
|
/**
|
|
716
669
|
* Time Complexity: O(1)
|
|
717
670
|
* Space Complexity: O(1)
|
|
@@ -726,7 +679,7 @@ export class LinkedHashMap<K = any, V = any, R = [K, V]> extends IterableEntryBa
|
|
|
726
679
|
let node;
|
|
727
680
|
|
|
728
681
|
if (isWeakKey(key)) {
|
|
729
|
-
const hash = this.
|
|
682
|
+
const hash = this._objHashFn(key);
|
|
730
683
|
// Get nodes from WeakMap
|
|
731
684
|
node = this.objMap.get(hash);
|
|
732
685
|
|
|
@@ -737,7 +690,7 @@ export class LinkedHashMap<K = any, V = any, R = [K, V]> extends IterableEntryBa
|
|
|
737
690
|
// Remove nodes from WeakMap
|
|
738
691
|
this.objMap.delete(hash);
|
|
739
692
|
} else {
|
|
740
|
-
const hash = this.
|
|
693
|
+
const hash = this._hashFn(key);
|
|
741
694
|
// Get nodes from noObjMap
|
|
742
695
|
node = this.noObjMap[hash];
|
|
743
696
|
|
|
@@ -754,11 +707,6 @@ export class LinkedHashMap<K = any, V = any, R = [K, V]> extends IterableEntryBa
|
|
|
754
707
|
return true;
|
|
755
708
|
}
|
|
756
709
|
|
|
757
|
-
/**
|
|
758
|
-
* Time Complexity: O(n)
|
|
759
|
-
* Space Complexity: O(1)
|
|
760
|
-
*/
|
|
761
|
-
|
|
762
710
|
/**
|
|
763
711
|
* Time Complexity: O(n)
|
|
764
712
|
* Space Complexity: O(1)
|
|
@@ -777,11 +725,6 @@ export class LinkedHashMap<K = any, V = any, R = [K, V]> extends IterableEntryBa
|
|
|
777
725
|
return this._deleteNode(node);
|
|
778
726
|
}
|
|
779
727
|
|
|
780
|
-
/**
|
|
781
|
-
* Time Complexity: O(1)
|
|
782
|
-
* Space Complexity: O(1)
|
|
783
|
-
*/
|
|
784
|
-
|
|
785
728
|
/**
|
|
786
729
|
* Time Complexity: O(1)
|
|
787
730
|
* Space Complexity: O(1)
|
|
@@ -804,11 +747,6 @@ export class LinkedHashMap<K = any, V = any, R = [K, V]> extends IterableEntryBa
|
|
|
804
747
|
return Array.isArray(rawElement) && rawElement.length === 2;
|
|
805
748
|
}
|
|
806
749
|
|
|
807
|
-
/**
|
|
808
|
-
* Time Complexity: O(1)
|
|
809
|
-
* Space Complexity: O(1)
|
|
810
|
-
*/
|
|
811
|
-
|
|
812
750
|
/**
|
|
813
751
|
* Time Complexity: O(1)
|
|
814
752
|
* Space Complexity: O(1)
|
|
@@ -821,11 +759,6 @@ export class LinkedHashMap<K = any, V = any, R = [K, V]> extends IterableEntryBa
|
|
|
821
759
|
this._head = this._tail = this._sentinel.prev = this._sentinel.next = this._sentinel;
|
|
822
760
|
}
|
|
823
761
|
|
|
824
|
-
/**
|
|
825
|
-
* Time Complexity: O(n)
|
|
826
|
-
* Space Complexity: O(n)
|
|
827
|
-
*/
|
|
828
|
-
|
|
829
762
|
/**
|
|
830
763
|
* Time Complexity: O(n)
|
|
831
764
|
* Space Complexity: O(n)
|
|
@@ -836,7 +769,7 @@ export class LinkedHashMap<K = any, V = any, R = [K, V]> extends IterableEntryBa
|
|
|
836
769
|
* of the original `LinkedHashMap` object.
|
|
837
770
|
*/
|
|
838
771
|
clone(): LinkedHashMap<K, V> {
|
|
839
|
-
const cloned = new LinkedHashMap<K, V>([], { hashFn: this.
|
|
772
|
+
const cloned = new LinkedHashMap<K, V>([], { hashFn: this._hashFn, objHashFn: this._objHashFn });
|
|
840
773
|
for (const entry of this) {
|
|
841
774
|
const [key, value] = entry;
|
|
842
775
|
cloned.set(key, value);
|
|
@@ -844,11 +777,6 @@ export class LinkedHashMap<K = any, V = any, R = [K, V]> extends IterableEntryBa
|
|
|
844
777
|
return cloned;
|
|
845
778
|
}
|
|
846
779
|
|
|
847
|
-
/**
|
|
848
|
-
* Time Complexity: O(n)
|
|
849
|
-
* Space Complexity: O(n)
|
|
850
|
-
*/
|
|
851
|
-
|
|
852
780
|
/**
|
|
853
781
|
* Time Complexity: O(n)
|
|
854
782
|
* Space Complexity: O(n)
|
|
@@ -876,11 +804,6 @@ export class LinkedHashMap<K = any, V = any, R = [K, V]> extends IterableEntryBa
|
|
|
876
804
|
return filteredMap;
|
|
877
805
|
}
|
|
878
806
|
|
|
879
|
-
/**
|
|
880
|
-
* Time Complexity: O(n)
|
|
881
|
-
* Space Complexity: O(n)
|
|
882
|
-
*/
|
|
883
|
-
|
|
884
807
|
/**
|
|
885
808
|
* Time Complexity: O(n)
|
|
886
809
|
* Space Complexity: O(n)
|
|
@@ -909,32 +832,6 @@ export class LinkedHashMap<K = any, V = any, R = [K, V]> extends IterableEntryBa
|
|
|
909
832
|
return mappedMap;
|
|
910
833
|
}
|
|
911
834
|
|
|
912
|
-
/**
|
|
913
|
-
* Time Complexity: O(1)
|
|
914
|
-
* Space Complexity: O(1)
|
|
915
|
-
*/
|
|
916
|
-
|
|
917
|
-
/**
|
|
918
|
-
* Time Complexity: O(1)
|
|
919
|
-
* Space Complexity: O(1)
|
|
920
|
-
*
|
|
921
|
-
* The put function sets a value in a data structure using a specified key.
|
|
922
|
-
* @param {K} key - The key parameter is of type K, which represents the type of the key being passed
|
|
923
|
-
* to the function.
|
|
924
|
-
* @param {V} value - The value parameter represents the value that you want to associate with the
|
|
925
|
-
* specified key in the data structure.
|
|
926
|
-
* @returns The method is returning a boolean value.
|
|
927
|
-
*/
|
|
928
|
-
put(key: K, value: V): boolean {
|
|
929
|
-
return this.set(key, value);
|
|
930
|
-
}
|
|
931
|
-
|
|
932
|
-
/**
|
|
933
|
-
* Time Complexity: O(n)
|
|
934
|
-
* Space Complexity: O(1)
|
|
935
|
-
* where n is the number of entries in the LinkedHashMap.
|
|
936
|
-
*/
|
|
937
|
-
|
|
938
835
|
/**
|
|
939
836
|
* Time Complexity: O(n)
|
|
940
837
|
* Space Complexity: O(1)
|
|
@@ -950,11 +847,6 @@ export class LinkedHashMap<K = any, V = any, R = [K, V]> extends IterableEntryBa
|
|
|
950
847
|
}
|
|
951
848
|
}
|
|
952
849
|
|
|
953
|
-
/**
|
|
954
|
-
* Time Complexity: O(1)
|
|
955
|
-
* Space Complexity: O(1)
|
|
956
|
-
*/
|
|
957
|
-
|
|
958
850
|
/**
|
|
959
851
|
* Time Complexity: O(1)
|
|
960
852
|
* Space Complexity: O(1)
|
|
@@ -560,11 +560,6 @@ export class FibonacciHeap<E> {
|
|
|
560
560
|
return this.min ? this.min.element : undefined;
|
|
561
561
|
}
|
|
562
562
|
|
|
563
|
-
/**
|
|
564
|
-
* Time Complexity: O(n), where n is the number of elements in the linked list.
|
|
565
|
-
* Space Complexity: O(1)
|
|
566
|
-
*/
|
|
567
|
-
|
|
568
563
|
/**
|
|
569
564
|
* Time Complexity: O(n), where n is the number of elements in the linked list.
|
|
570
565
|
* Space Complexity: O(1)
|
|
@@ -612,11 +607,6 @@ export class FibonacciHeap<E> {
|
|
|
612
607
|
}
|
|
613
608
|
}
|
|
614
609
|
|
|
615
|
-
/**
|
|
616
|
-
* Time Complexity: O(log n)
|
|
617
|
-
* Space Complexity: O(1)
|
|
618
|
-
*/
|
|
619
|
-
|
|
620
610
|
/**
|
|
621
611
|
* Time Complexity: O(log n)
|
|
622
612
|
* Space Complexity: O(1)
|
|
@@ -628,11 +618,6 @@ export class FibonacciHeap<E> {
|
|
|
628
618
|
return this.pop();
|
|
629
619
|
}
|
|
630
620
|
|
|
631
|
-
/**
|
|
632
|
-
* Time Complexity: O(log n)
|
|
633
|
-
* Space Complexity: O(1)
|
|
634
|
-
*/
|
|
635
|
-
|
|
636
621
|
/**
|
|
637
622
|
* Time Complexity: O(log n)
|
|
638
623
|
* Space Complexity: O(1)
|
|
@@ -667,11 +652,6 @@ export class FibonacciHeap<E> {
|
|
|
667
652
|
return z.element;
|
|
668
653
|
}
|
|
669
654
|
|
|
670
|
-
/**
|
|
671
|
-
* Time Complexity: O(1)
|
|
672
|
-
* Space Complexity: O(1)
|
|
673
|
-
*/
|
|
674
|
-
|
|
675
655
|
/**
|
|
676
656
|
* Time Complexity: O(1)
|
|
677
657
|
* Space Complexity: O(1)
|
|
@@ -732,11 +712,6 @@ export class FibonacciHeap<E> {
|
|
|
732
712
|
return 0;
|
|
733
713
|
}
|
|
734
714
|
|
|
735
|
-
/**
|
|
736
|
-
* Time Complexity: O(1)
|
|
737
|
-
* Space Complexity: O(1)
|
|
738
|
-
*/
|
|
739
|
-
|
|
740
715
|
/**
|
|
741
716
|
* Time Complexity: O(1)
|
|
742
717
|
* Space Complexity: O(1)
|
|
@@ -755,11 +730,6 @@ export class FibonacciHeap<E> {
|
|
|
755
730
|
}
|
|
756
731
|
}
|
|
757
732
|
|
|
758
|
-
/**
|
|
759
|
-
* Time Complexity: O(1)
|
|
760
|
-
* Space Complexity: O(1)
|
|
761
|
-
*/
|
|
762
|
-
|
|
763
733
|
/**
|
|
764
734
|
* Time Complexity: O(1)
|
|
765
735
|
* Space Complexity: O(1)
|
|
@@ -774,11 +744,6 @@ export class FibonacciHeap<E> {
|
|
|
774
744
|
if (node.right) node.right.left = node.left;
|
|
775
745
|
}
|
|
776
746
|
|
|
777
|
-
/**
|
|
778
|
-
* Time Complexity: O(1)
|
|
779
|
-
* Space Complexity: O(1)
|
|
780
|
-
*/
|
|
781
|
-
|
|
782
747
|
/**
|
|
783
748
|
* Time Complexity: O(1)
|
|
784
749
|
* Space Complexity: O(1)
|
|
@@ -797,11 +762,6 @@ export class FibonacciHeap<E> {
|
|
|
797
762
|
y.parent = x;
|
|
798
763
|
}
|
|
799
764
|
|
|
800
|
-
/**
|
|
801
|
-
* Time Complexity: O(n log n)
|
|
802
|
-
* Space Complexity: O(n)
|
|
803
|
-
*/
|
|
804
|
-
|
|
805
765
|
/**
|
|
806
766
|
* Time Complexity: O(n log n)
|
|
807
767
|
* Space Complexity: O(n)
|