data-structure-typed 1.46.2 → 1.46.3
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 +16 -16
- package/benchmark/report.html +1 -46
- package/benchmark/report.json +16 -385
- package/dist/cjs/data-structures/hash/hash-map.d.ts +10 -91
- package/dist/cjs/data-structures/hash/hash-map.js +22 -178
- package/dist/cjs/data-structures/hash/hash-map.js.map +1 -1
- package/dist/cjs/data-structures/queue/deque.d.ts +6 -74
- package/dist/cjs/data-structures/queue/deque.js +20 -142
- package/dist/cjs/data-structures/queue/deque.js.map +1 -1
- package/dist/mjs/data-structures/hash/hash-map.d.ts +10 -91
- package/dist/mjs/data-structures/hash/hash-map.js +22 -181
- package/dist/mjs/data-structures/queue/deque.d.ts +6 -74
- package/dist/mjs/data-structures/queue/deque.js +16 -140
- package/dist/umd/data-structure-typed.js +73 -349
- package/dist/umd/data-structure-typed.min.js +1 -1
- package/dist/umd/data-structure-typed.min.js.map +1 -1
- package/package.json +4 -3
- package/src/data-structures/hash/hash-map.ts +25 -196
- package/src/data-structures/queue/deque.ts +22 -161
- package/test/performance/data-structures/hash/hash-map.test.ts +11 -11
- package/test/performance/reportor.ts +6 -3
- package/test/unit/data-structures/hash/hash-map.test.ts +4 -5
- package/test/unit/data-structures/queue/deque.test.ts +28 -0
|
@@ -103,7 +103,6 @@ var dataStructureTyped = (() => {
|
|
|
103
103
|
CoordinateMap: () => CoordinateMap,
|
|
104
104
|
CoordinateSet: () => CoordinateSet,
|
|
105
105
|
Deque: () => Deque,
|
|
106
|
-
DequeIterator: () => DequeIterator,
|
|
107
106
|
DirectedEdge: () => DirectedEdge,
|
|
108
107
|
DirectedGraph: () => DirectedGraph,
|
|
109
108
|
DirectedVertex: () => DirectedVertex,
|
|
@@ -113,7 +112,6 @@ var dataStructureTyped = (() => {
|
|
|
113
112
|
FibonacciHeap: () => FibonacciHeap,
|
|
114
113
|
FibonacciHeapNode: () => FibonacciHeapNode,
|
|
115
114
|
HashMap: () => HashMap,
|
|
116
|
-
HashMapIterator: () => HashMapIterator,
|
|
117
115
|
HashTable: () => HashTable,
|
|
118
116
|
HashTableNode: () => HashTableNode,
|
|
119
117
|
Heap: () => Heap,
|
|
@@ -568,146 +566,7 @@ var dataStructureTyped = (() => {
|
|
|
568
566
|
};
|
|
569
567
|
var calcMinUnitsRequired = (totalQuantity, unitSize) => Math.floor((totalQuantity + unitSize - 1) / unitSize);
|
|
570
568
|
|
|
571
|
-
// src/types/data-structures/binary-tree/binary-tree.ts
|
|
572
|
-
var IterationType = /* @__PURE__ */ ((IterationType3) => {
|
|
573
|
-
IterationType3["ITERATIVE"] = "ITERATIVE";
|
|
574
|
-
IterationType3["RECURSIVE"] = "RECURSIVE";
|
|
575
|
-
return IterationType3;
|
|
576
|
-
})(IterationType || {});
|
|
577
|
-
var FamilyPosition = /* @__PURE__ */ ((FamilyPosition2) => {
|
|
578
|
-
FamilyPosition2["ROOT"] = "ROOT";
|
|
579
|
-
FamilyPosition2["LEFT"] = "LEFT";
|
|
580
|
-
FamilyPosition2["RIGHT"] = "RIGHT";
|
|
581
|
-
FamilyPosition2["ROOT_LEFT"] = "ROOT_LEFT";
|
|
582
|
-
FamilyPosition2["ROOT_RIGHT"] = "ROOT_RIGHT";
|
|
583
|
-
FamilyPosition2["ISOLATED"] = "ISOLATED";
|
|
584
|
-
FamilyPosition2["MAL_NODE"] = "MAL_NODE";
|
|
585
|
-
return FamilyPosition2;
|
|
586
|
-
})(FamilyPosition || {});
|
|
587
|
-
|
|
588
|
-
// src/types/data-structures/binary-tree/rb-tree.ts
|
|
589
|
-
var RBTNColor = /* @__PURE__ */ ((RBTNColor2) => {
|
|
590
|
-
RBTNColor2[RBTNColor2["RED"] = 1] = "RED";
|
|
591
|
-
RBTNColor2[RBTNColor2["BLACK"] = 0] = "BLACK";
|
|
592
|
-
return RBTNColor2;
|
|
593
|
-
})(RBTNColor || {});
|
|
594
|
-
|
|
595
|
-
// src/types/helpers.ts
|
|
596
|
-
var CP = /* @__PURE__ */ ((CP2) => {
|
|
597
|
-
CP2["lt"] = "lt";
|
|
598
|
-
CP2["eq"] = "eq";
|
|
599
|
-
CP2["gt"] = "gt";
|
|
600
|
-
return CP2;
|
|
601
|
-
})(CP || {});
|
|
602
|
-
var IterateDirection = /* @__PURE__ */ ((IterateDirection2) => {
|
|
603
|
-
IterateDirection2[IterateDirection2["DEFAULT"] = 0] = "DEFAULT";
|
|
604
|
-
IterateDirection2[IterateDirection2["REVERSE"] = 1] = "REVERSE";
|
|
605
|
-
return IterateDirection2;
|
|
606
|
-
})(IterateDirection || {});
|
|
607
|
-
|
|
608
569
|
// src/data-structures/hash/hash-map.ts
|
|
609
|
-
var HashMapIterator = class _HashMapIterator {
|
|
610
|
-
/**
|
|
611
|
-
* This is a constructor function for a linked list iterator in a HashMap data structure.
|
|
612
|
-
* @param node - The `node` parameter is a reference to a `HashMapLinkedNode` object. This object
|
|
613
|
-
* represents a node in a linked list used in a hash map data structure. It contains a key-value pair
|
|
614
|
-
* and references to the previous and next nodes in the linked list.
|
|
615
|
-
* @param sentinel - The `sentinel` parameter is a reference to a special node in a linked list. It
|
|
616
|
-
* is used to mark the beginning or end of the list and is typically used in data structures like
|
|
617
|
-
* hash maps or linked lists to simplify operations and boundary checks.
|
|
618
|
-
* @param hashMap - A HashMap object that stores key-value pairs.
|
|
619
|
-
* @param {IterateDirection} iterateDirection - The `iterateDirection` parameter is an optional
|
|
620
|
-
* parameter that specifies the direction in which the iterator should iterate over the elements of
|
|
621
|
-
* the HashMap. It can take one of the following values:
|
|
622
|
-
* @returns The constructor does not return anything. It is used to initialize the properties and
|
|
623
|
-
* methods of the object being created.
|
|
624
|
-
*/
|
|
625
|
-
constructor(node, sentinel, hashMap, iterateDirection = 0 /* DEFAULT */) {
|
|
626
|
-
__publicField(this, "hashMap");
|
|
627
|
-
__publicField(this, "iterateDirection");
|
|
628
|
-
__publicField(this, "_node");
|
|
629
|
-
__publicField(this, "_sentinel");
|
|
630
|
-
this._node = node;
|
|
631
|
-
this._sentinel = sentinel;
|
|
632
|
-
this.iterateDirection = iterateDirection;
|
|
633
|
-
if (this.iterateDirection === 0 /* DEFAULT */) {
|
|
634
|
-
this.prev = function() {
|
|
635
|
-
if (this._node.prev === this._sentinel) {
|
|
636
|
-
throwRangeError();
|
|
637
|
-
}
|
|
638
|
-
this._node = this._node.prev;
|
|
639
|
-
return this;
|
|
640
|
-
};
|
|
641
|
-
this.next = function() {
|
|
642
|
-
if (this._node === this._sentinel) {
|
|
643
|
-
throwRangeError();
|
|
644
|
-
}
|
|
645
|
-
this._node = this._node.next;
|
|
646
|
-
return this;
|
|
647
|
-
};
|
|
648
|
-
} else {
|
|
649
|
-
this.prev = function() {
|
|
650
|
-
if (this._node.next === this._sentinel) {
|
|
651
|
-
throwRangeError();
|
|
652
|
-
}
|
|
653
|
-
this._node = this._node.next;
|
|
654
|
-
return this;
|
|
655
|
-
};
|
|
656
|
-
this.next = function() {
|
|
657
|
-
if (this._node === this._sentinel) {
|
|
658
|
-
throwRangeError();
|
|
659
|
-
}
|
|
660
|
-
this._node = this._node.prev;
|
|
661
|
-
return this;
|
|
662
|
-
};
|
|
663
|
-
}
|
|
664
|
-
this.hashMap = hashMap;
|
|
665
|
-
}
|
|
666
|
-
/**
|
|
667
|
-
* The above function returns a Proxy object that allows access to the key and value of a node in a
|
|
668
|
-
* data structure.
|
|
669
|
-
* @returns The code is returning a Proxy object.
|
|
670
|
-
*/
|
|
671
|
-
get current() {
|
|
672
|
-
if (this._node === this._sentinel) {
|
|
673
|
-
throwRangeError();
|
|
674
|
-
}
|
|
675
|
-
return new Proxy([], {
|
|
676
|
-
get: (target, prop) => {
|
|
677
|
-
if (prop === "0")
|
|
678
|
-
return this._node.key;
|
|
679
|
-
else if (prop === "1")
|
|
680
|
-
return this._node.value;
|
|
681
|
-
target[0] = this._node.key;
|
|
682
|
-
target[1] = this._node.value;
|
|
683
|
-
return target[prop];
|
|
684
|
-
},
|
|
685
|
-
set: (_, prop, newValue) => {
|
|
686
|
-
if (prop !== "1") {
|
|
687
|
-
throw new TypeError(`prop should be string '1'`);
|
|
688
|
-
}
|
|
689
|
-
this._node.value = newValue;
|
|
690
|
-
return true;
|
|
691
|
-
}
|
|
692
|
-
});
|
|
693
|
-
}
|
|
694
|
-
/**
|
|
695
|
-
* The function checks if a node is accessible.
|
|
696
|
-
* @returns a boolean value indicating whether the `_node` is not equal to the `_sentinel`.
|
|
697
|
-
*/
|
|
698
|
-
isAccessible() {
|
|
699
|
-
return this._node !== this._sentinel;
|
|
700
|
-
}
|
|
701
|
-
prev() {
|
|
702
|
-
return this;
|
|
703
|
-
}
|
|
704
|
-
next() {
|
|
705
|
-
return this;
|
|
706
|
-
}
|
|
707
|
-
clone() {
|
|
708
|
-
return new _HashMapIterator(this._node, this._sentinel, this.hashMap, this.iterateDirection);
|
|
709
|
-
}
|
|
710
|
-
};
|
|
711
570
|
var HashMap = class {
|
|
712
571
|
/**
|
|
713
572
|
* The constructor initializes a HashMap object with an optional initial set of key-value pairs.
|
|
@@ -733,49 +592,6 @@ var dataStructureTyped = (() => {
|
|
|
733
592
|
get size() {
|
|
734
593
|
return this._size;
|
|
735
594
|
}
|
|
736
|
-
/**
|
|
737
|
-
* Time Complexity: O(1)
|
|
738
|
-
* Space Complexity: O(1)
|
|
739
|
-
*
|
|
740
|
-
* The function returns a new iterator object for a HashMap.
|
|
741
|
-
* @returns A new instance of the HashMapIterator class is being returned.
|
|
742
|
-
*/
|
|
743
|
-
get begin() {
|
|
744
|
-
return new HashMapIterator(this._head, this._sentinel, this);
|
|
745
|
-
}
|
|
746
|
-
/**
|
|
747
|
-
* Time Complexity: O(1)
|
|
748
|
-
* Space Complexity: O(1)
|
|
749
|
-
*
|
|
750
|
-
* The function returns a new HashMapIterator object with the _sentinel value as both the start and
|
|
751
|
-
* end values.
|
|
752
|
-
* @returns A new instance of the HashMapIterator class is being returned.
|
|
753
|
-
*/
|
|
754
|
-
get end() {
|
|
755
|
-
return new HashMapIterator(this._sentinel, this._sentinel, this);
|
|
756
|
-
}
|
|
757
|
-
/**
|
|
758
|
-
* Time Complexity: O(1)
|
|
759
|
-
* Space Complexity: O(1)
|
|
760
|
-
*
|
|
761
|
-
* The reverseBegin function returns a new HashMapIterator object that iterates over the elements of
|
|
762
|
-
* a HashMap in reverse order.
|
|
763
|
-
* @returns A new instance of the HashMapIterator class is being returned.
|
|
764
|
-
*/
|
|
765
|
-
get reverseBegin() {
|
|
766
|
-
return new HashMapIterator(this._tail, this._sentinel, this, 1 /* REVERSE */);
|
|
767
|
-
}
|
|
768
|
-
/**
|
|
769
|
-
* Time Complexity: O(1)
|
|
770
|
-
* Space Complexity: O(1)
|
|
771
|
-
*
|
|
772
|
-
* The reverseEnd function returns a new HashMapIterator object that iterates over the elements of a
|
|
773
|
-
* HashMap in reverse order.
|
|
774
|
-
* @returns A new instance of the HashMapIterator class is being returned.
|
|
775
|
-
*/
|
|
776
|
-
get reverseEnd() {
|
|
777
|
-
return new HashMapIterator(this._sentinel, this._sentinel, this, 1 /* REVERSE */);
|
|
778
|
-
}
|
|
779
595
|
/**
|
|
780
596
|
* Time Complexity: O(1)
|
|
781
597
|
* Space Complexity: O(1)
|
|
@@ -802,6 +618,27 @@ var dataStructureTyped = (() => {
|
|
|
802
618
|
return;
|
|
803
619
|
return [this._tail.key, this._tail.value];
|
|
804
620
|
}
|
|
621
|
+
/**
|
|
622
|
+
* The `begin()` function in TypeScript iterates over a linked list and yields key-value pairs.
|
|
623
|
+
*/
|
|
624
|
+
*begin() {
|
|
625
|
+
let node = this._head;
|
|
626
|
+
while (node !== this._sentinel) {
|
|
627
|
+
yield [node.key, node.value];
|
|
628
|
+
node = node.next;
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
/**
|
|
632
|
+
* The function `reverseBegin()` iterates over a linked list in reverse order, yielding each node's
|
|
633
|
+
* key and value.
|
|
634
|
+
*/
|
|
635
|
+
*reverseBegin() {
|
|
636
|
+
let node = this._tail;
|
|
637
|
+
while (node !== this._sentinel) {
|
|
638
|
+
yield [node.key, node.value];
|
|
639
|
+
node = node.prev;
|
|
640
|
+
}
|
|
641
|
+
}
|
|
805
642
|
/**
|
|
806
643
|
* Time Complexity: O(1)
|
|
807
644
|
* Space Complexity: O(1)
|
|
@@ -900,33 +737,6 @@ var dataStructureTyped = (() => {
|
|
|
900
737
|
}
|
|
901
738
|
return [node.key, node.value];
|
|
902
739
|
}
|
|
903
|
-
/**
|
|
904
|
-
* Time Complexity: O(1)
|
|
905
|
-
* Space Complexity: O(1)
|
|
906
|
-
*
|
|
907
|
-
* The function `getIterator` returns a new instance of `HashMapIterator` based on the provided key
|
|
908
|
-
* and whether it is an object key or not.
|
|
909
|
-
* @param {K} key - The `key` parameter is the key used to retrieve the iterator from the HashMap. It
|
|
910
|
-
* can be of any type, depending on how the HashMap is implemented.
|
|
911
|
-
* @param {boolean} [isObjectKey] - The `isObjectKey` parameter is an optional boolean parameter that
|
|
912
|
-
* indicates whether the `key` parameter is an object key. If `isObjectKey` is `true`, it means that
|
|
913
|
-
* the `key` parameter is an object and needs to be handled differently. If `isObjectKey` is `false`
|
|
914
|
-
* @returns a new instance of the `HashMapIterator` class.
|
|
915
|
-
*/
|
|
916
|
-
getIterator(key, isObjectKey) {
|
|
917
|
-
let node;
|
|
918
|
-
if (isObjectKey) {
|
|
919
|
-
const index = key[this.OBJ_KEY_INDEX];
|
|
920
|
-
if (index === void 0) {
|
|
921
|
-
node = this._sentinel;
|
|
922
|
-
} else {
|
|
923
|
-
node = this._nodes[index];
|
|
924
|
-
}
|
|
925
|
-
} else {
|
|
926
|
-
node = this._orgMap[key] || this._sentinel;
|
|
927
|
-
}
|
|
928
|
-
return new HashMapIterator(node, this._sentinel, this);
|
|
929
|
-
}
|
|
930
740
|
/**
|
|
931
741
|
* Time Complexity: O(1)
|
|
932
742
|
* Space Complexity: O(1)
|
|
@@ -3161,79 +2971,6 @@ var dataStructureTyped = (() => {
|
|
|
3161
2971
|
};
|
|
3162
2972
|
|
|
3163
2973
|
// src/data-structures/queue/deque.ts
|
|
3164
|
-
var DequeIterator = class _DequeIterator {
|
|
3165
|
-
/**
|
|
3166
|
-
* The constructor initializes the index, iterate direction, and prev/next functions for a
|
|
3167
|
-
* DequeIterator object.
|
|
3168
|
-
* @param {number} index - The index parameter represents the current index position of the iterator
|
|
3169
|
-
* within the deque. It is a number that indicates the position of the element that the iterator is
|
|
3170
|
-
* currently pointing to.
|
|
3171
|
-
* @param deque - The `deque` parameter is an instance of the `Deque` class. It represents a
|
|
3172
|
-
* double-ended queue data structure, which allows elements to be added or removed from both ends.
|
|
3173
|
-
* @param iterateDirection - The `iterateDirection` parameter is an optional parameter that specifies
|
|
3174
|
-
* the direction in which the iterator should iterate over the elements of the `deque`. It has a
|
|
3175
|
-
* default value of `IterateDirection.DEFAULT`.
|
|
3176
|
-
* @returns The constructor is not returning anything. It is used to initialize the properties of the
|
|
3177
|
-
* object being created.
|
|
3178
|
-
*/
|
|
3179
|
-
constructor(index, deque, iterateDirection = 0 /* DEFAULT */) {
|
|
3180
|
-
__publicField(this, "iterateDirection");
|
|
3181
|
-
__publicField(this, "index");
|
|
3182
|
-
__publicField(this, "deque");
|
|
3183
|
-
this.index = index;
|
|
3184
|
-
this.iterateDirection = iterateDirection;
|
|
3185
|
-
if (this.iterateDirection === 0 /* DEFAULT */) {
|
|
3186
|
-
this.prev = function() {
|
|
3187
|
-
if (this.index === 0) {
|
|
3188
|
-
throwRangeError();
|
|
3189
|
-
}
|
|
3190
|
-
this.index -= 1;
|
|
3191
|
-
return this;
|
|
3192
|
-
};
|
|
3193
|
-
this.next = function() {
|
|
3194
|
-
if (this.index === this.deque.size) {
|
|
3195
|
-
throwRangeError();
|
|
3196
|
-
}
|
|
3197
|
-
this.index += 1;
|
|
3198
|
-
return this;
|
|
3199
|
-
};
|
|
3200
|
-
} else {
|
|
3201
|
-
this.prev = function() {
|
|
3202
|
-
if (this.index === this.deque.size - 1) {
|
|
3203
|
-
throwRangeError();
|
|
3204
|
-
}
|
|
3205
|
-
this.index += 1;
|
|
3206
|
-
return this;
|
|
3207
|
-
};
|
|
3208
|
-
this.next = function() {
|
|
3209
|
-
if (this.index === -1) {
|
|
3210
|
-
throwRangeError();
|
|
3211
|
-
}
|
|
3212
|
-
this.index -= 1;
|
|
3213
|
-
return this;
|
|
3214
|
-
};
|
|
3215
|
-
}
|
|
3216
|
-
this.deque = deque;
|
|
3217
|
-
}
|
|
3218
|
-
get current() {
|
|
3219
|
-
return this.deque.getAt(this.index);
|
|
3220
|
-
}
|
|
3221
|
-
set current(newElement) {
|
|
3222
|
-
this.deque.setAt(this.index, newElement);
|
|
3223
|
-
}
|
|
3224
|
-
isAccessible() {
|
|
3225
|
-
return this.index !== this.deque.size;
|
|
3226
|
-
}
|
|
3227
|
-
prev() {
|
|
3228
|
-
return this;
|
|
3229
|
-
}
|
|
3230
|
-
next() {
|
|
3231
|
-
return this;
|
|
3232
|
-
}
|
|
3233
|
-
clone() {
|
|
3234
|
-
return new _DequeIterator(this.index, this.deque, this.iterateDirection);
|
|
3235
|
-
}
|
|
3236
|
-
};
|
|
3237
2974
|
var Deque = class _Deque {
|
|
3238
2975
|
/**
|
|
3239
2976
|
* The constructor initializes a data structure with a specified bucket size and populates it with
|
|
@@ -3367,35 +3104,25 @@ var dataStructureTyped = (() => {
|
|
|
3367
3104
|
this._firstInBucket = this._lastInBucket = this._bucketSize >> 1;
|
|
3368
3105
|
}
|
|
3369
3106
|
/**
|
|
3370
|
-
* The
|
|
3371
|
-
* @returns A new instance of the DequeIterator class is being returned.
|
|
3372
|
-
*/
|
|
3373
|
-
begin() {
|
|
3374
|
-
return new DequeIterator(0, this);
|
|
3375
|
-
}
|
|
3376
|
-
/**
|
|
3377
|
-
* The `end()` function returns a new `DequeIterator` object with the size and reference to the
|
|
3378
|
-
* current deque.
|
|
3379
|
-
* @returns A new instance of the DequeIterator class is being returned.
|
|
3380
|
-
*/
|
|
3381
|
-
end() {
|
|
3382
|
-
return new DequeIterator(this.size, this);
|
|
3383
|
-
}
|
|
3384
|
-
/**
|
|
3385
|
-
* The reverseBegin function returns a new DequeIterator object that starts at the last element of
|
|
3386
|
-
* the deque and iterates in reverse direction.
|
|
3387
|
-
* @returns A new instance of the DequeIterator class is being returned.
|
|
3107
|
+
* The below function is a generator that yields elements from a collection one by one.
|
|
3388
3108
|
*/
|
|
3389
|
-
|
|
3390
|
-
|
|
3109
|
+
*begin() {
|
|
3110
|
+
let index = 0;
|
|
3111
|
+
while (index < this.size) {
|
|
3112
|
+
yield this.getAt(index);
|
|
3113
|
+
index++;
|
|
3114
|
+
}
|
|
3391
3115
|
}
|
|
3392
3116
|
/**
|
|
3393
|
-
* The
|
|
3394
|
-
*
|
|
3395
|
-
* @returns A new instance of the DequeIterator class is being returned.
|
|
3117
|
+
* The function `reverseBegin()` is a generator that yields elements in reverse order starting from
|
|
3118
|
+
* the last element.
|
|
3396
3119
|
*/
|
|
3397
|
-
|
|
3398
|
-
|
|
3120
|
+
*reverseBegin() {
|
|
3121
|
+
let index = this.size - 1;
|
|
3122
|
+
while (index >= 0) {
|
|
3123
|
+
yield this.getAt(index);
|
|
3124
|
+
index--;
|
|
3125
|
+
}
|
|
3399
3126
|
}
|
|
3400
3127
|
/**
|
|
3401
3128
|
* Time Complexity - Amortized O(1) (possible reallocation)
|
|
@@ -3705,46 +3432,6 @@ var dataStructureTyped = (() => {
|
|
|
3705
3432
|
this.cut(index - 1);
|
|
3706
3433
|
return this.size;
|
|
3707
3434
|
}
|
|
3708
|
-
/**
|
|
3709
|
-
* Time Complexity: O(n)
|
|
3710
|
-
* Space Complexity: O(1)
|
|
3711
|
-
*/
|
|
3712
|
-
/**
|
|
3713
|
-
* Time Complexity: O(n)
|
|
3714
|
-
* Space Complexity: O(1)
|
|
3715
|
-
*
|
|
3716
|
-
* The function deletes an element from a deque using an iterator and returns the next iterator.
|
|
3717
|
-
* @param iter - The parameter `iter` is of type `DequeIterator<E>`. It represents an iterator object
|
|
3718
|
-
* that is used to iterate over elements in a deque (double-ended queue).
|
|
3719
|
-
* @returns the updated iterator after deleting an element from the deque.
|
|
3720
|
-
*/
|
|
3721
|
-
deleteByIterator(iter) {
|
|
3722
|
-
const index = iter.index;
|
|
3723
|
-
this.deleteAt(index);
|
|
3724
|
-
iter = iter.next();
|
|
3725
|
-
return iter;
|
|
3726
|
-
}
|
|
3727
|
-
/**
|
|
3728
|
-
* Time Complexity: O(n)
|
|
3729
|
-
* Space Complexity: O(1)
|
|
3730
|
-
*/
|
|
3731
|
-
/**
|
|
3732
|
-
* Time Complexity: O(n)
|
|
3733
|
-
* Space Complexity: O(1)
|
|
3734
|
-
*
|
|
3735
|
-
* The function `findIterator` searches for an element in a deque and returns an iterator pointing to
|
|
3736
|
-
* the element if found, otherwise it returns an iterator pointing to the end of the deque.
|
|
3737
|
-
* @param {E} element - The `element` parameter is the element that you want to find in the deque.
|
|
3738
|
-
* @returns The method `findIterator(element: E)` returns a `DequeIterator<E>` object.
|
|
3739
|
-
*/
|
|
3740
|
-
findIterator(element) {
|
|
3741
|
-
for (let i = 0; i < this.size; ++i) {
|
|
3742
|
-
if (this.getAt(i) === element) {
|
|
3743
|
-
return new DequeIterator(i, this);
|
|
3744
|
-
}
|
|
3745
|
-
}
|
|
3746
|
-
return this.end();
|
|
3747
|
-
}
|
|
3748
3435
|
/**
|
|
3749
3436
|
* Time Complexity: O(n)
|
|
3750
3437
|
* Space Complexity: O(1)
|
|
@@ -6909,6 +6596,43 @@ var dataStructureTyped = (() => {
|
|
|
6909
6596
|
}
|
|
6910
6597
|
};
|
|
6911
6598
|
|
|
6599
|
+
// src/types/data-structures/binary-tree/binary-tree.ts
|
|
6600
|
+
var IterationType = /* @__PURE__ */ ((IterationType3) => {
|
|
6601
|
+
IterationType3["ITERATIVE"] = "ITERATIVE";
|
|
6602
|
+
IterationType3["RECURSIVE"] = "RECURSIVE";
|
|
6603
|
+
return IterationType3;
|
|
6604
|
+
})(IterationType || {});
|
|
6605
|
+
var FamilyPosition = /* @__PURE__ */ ((FamilyPosition2) => {
|
|
6606
|
+
FamilyPosition2["ROOT"] = "ROOT";
|
|
6607
|
+
FamilyPosition2["LEFT"] = "LEFT";
|
|
6608
|
+
FamilyPosition2["RIGHT"] = "RIGHT";
|
|
6609
|
+
FamilyPosition2["ROOT_LEFT"] = "ROOT_LEFT";
|
|
6610
|
+
FamilyPosition2["ROOT_RIGHT"] = "ROOT_RIGHT";
|
|
6611
|
+
FamilyPosition2["ISOLATED"] = "ISOLATED";
|
|
6612
|
+
FamilyPosition2["MAL_NODE"] = "MAL_NODE";
|
|
6613
|
+
return FamilyPosition2;
|
|
6614
|
+
})(FamilyPosition || {});
|
|
6615
|
+
|
|
6616
|
+
// src/types/data-structures/binary-tree/rb-tree.ts
|
|
6617
|
+
var RBTNColor = /* @__PURE__ */ ((RBTNColor2) => {
|
|
6618
|
+
RBTNColor2[RBTNColor2["RED"] = 1] = "RED";
|
|
6619
|
+
RBTNColor2[RBTNColor2["BLACK"] = 0] = "BLACK";
|
|
6620
|
+
return RBTNColor2;
|
|
6621
|
+
})(RBTNColor || {});
|
|
6622
|
+
|
|
6623
|
+
// src/types/helpers.ts
|
|
6624
|
+
var CP = /* @__PURE__ */ ((CP2) => {
|
|
6625
|
+
CP2["lt"] = "lt";
|
|
6626
|
+
CP2["eq"] = "eq";
|
|
6627
|
+
CP2["gt"] = "gt";
|
|
6628
|
+
return CP2;
|
|
6629
|
+
})(CP || {});
|
|
6630
|
+
var IterateDirection = /* @__PURE__ */ ((IterateDirection2) => {
|
|
6631
|
+
IterateDirection2[IterateDirection2["DEFAULT"] = 0] = "DEFAULT";
|
|
6632
|
+
IterateDirection2[IterateDirection2["REVERSE"] = 1] = "REVERSE";
|
|
6633
|
+
return IterateDirection2;
|
|
6634
|
+
})(IterateDirection || {});
|
|
6635
|
+
|
|
6912
6636
|
// src/data-structures/binary-tree/binary-tree.ts
|
|
6913
6637
|
var BinaryTreeNode = class {
|
|
6914
6638
|
/**
|