queue-typed 2.4.2 → 2.4.4
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 +7 -7
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs-legacy/index.cjs +8 -7
- package/dist/cjs-legacy/index.cjs.map +1 -1
- package/dist/esm/index.mjs +7 -7
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm-legacy/index.mjs +8 -7
- package/dist/esm-legacy/index.mjs.map +1 -1
- package/dist/types/data-structures/base/iterable-element-base.d.ts +1 -1
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +5 -5
- package/dist/types/data-structures/binary-tree/bst.d.ts +1 -1
- package/dist/types/data-structures/binary-tree/tree-map.d.ts +10 -0
- package/dist/types/data-structures/binary-tree/tree-set.d.ts +10 -0
- package/dist/types/data-structures/graph/directed-graph.d.ts +2 -2
- package/dist/types/data-structures/graph/undirected-graph.d.ts +2 -2
- package/dist/types/data-structures/hash/hash-map.d.ts +2 -2
- package/dist/types/data-structures/heap/heap.d.ts +3 -7
- package/dist/types/types/data-structures/binary-tree/avl-tree.d.ts +1 -1
- package/dist/types/types/data-structures/binary-tree/red-black-tree.d.ts +1 -1
- package/dist/types/types/data-structures/linked-list/doubly-linked-list.d.ts +1 -1
- package/dist/types/types/data-structures/linked-list/singly-linked-list.d.ts +1 -1
- package/dist/types/types/data-structures/priority-queue/priority-queue.d.ts +1 -1
- package/dist/types/types/data-structures/stack/stack.d.ts +1 -1
- package/dist/umd/queue-typed.js +8 -7
- package/dist/umd/queue-typed.js.map +1 -1
- package/dist/umd/queue-typed.min.js +1 -1
- package/dist/umd/queue-typed.min.js.map +1 -1
- package/package.json +2 -2
- package/src/data-structures/base/iterable-element-base.ts +2 -2
- package/src/data-structures/binary-tree/binary-tree.ts +8 -7
- package/src/data-structures/binary-tree/bst.ts +1 -1
- package/src/data-structures/binary-tree/tree-map.ts +16 -0
- package/src/data-structures/binary-tree/tree-multi-set.ts +5 -5
- package/src/data-structures/binary-tree/tree-set.ts +16 -0
- package/src/data-structures/graph/abstract-graph.ts +18 -18
- package/src/data-structures/graph/directed-graph.ts +4 -4
- package/src/data-structures/graph/map-graph.ts +1 -1
- package/src/data-structures/graph/undirected-graph.ts +4 -4
- package/src/data-structures/hash/hash-map.ts +6 -4
- package/src/data-structures/heap/heap.ts +17 -14
- package/src/data-structures/linked-list/doubly-linked-list.ts +4 -4
- package/src/data-structures/linked-list/singly-linked-list.ts +15 -9
- package/src/data-structures/queue/deque.ts +1 -1
- package/src/data-structures/stack/stack.ts +1 -1
- package/src/data-structures/trie/trie.ts +10 -5
- package/src/types/data-structures/binary-tree/avl-tree.ts +1 -1
- package/src/types/data-structures/binary-tree/red-black-tree.ts +1 -1
- package/src/types/data-structures/linked-list/doubly-linked-list.ts +1 -1
- package/src/types/data-structures/linked-list/singly-linked-list.ts +1 -1
- package/src/types/data-structures/priority-queue/priority-queue.ts +1 -1
- package/src/types/data-structures/stack/stack.ts +1 -1
|
@@ -654,7 +654,7 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
654
654
|
*/
|
|
655
655
|
constructor(elements = [], options) {
|
|
656
656
|
super(options);
|
|
657
|
-
__publicField(this, "_equals", Object.is);
|
|
657
|
+
__publicField(this, "_equals", /* @__PURE__ */ __name((a, b) => Object.is(a, b), "_equals"));
|
|
658
658
|
__publicField(this, "_head");
|
|
659
659
|
__publicField(this, "_tail");
|
|
660
660
|
__publicField(this, "_length", 0);
|
|
@@ -742,6 +742,7 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
742
742
|
* @returns Removed element or undefined.
|
|
743
743
|
*/
|
|
744
744
|
pop() {
|
|
745
|
+
var _a;
|
|
745
746
|
if (!this.head) return void 0;
|
|
746
747
|
if (this.head === this.tail) {
|
|
747
748
|
const value2 = this.head.value;
|
|
@@ -751,8 +752,8 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
751
752
|
return value2;
|
|
752
753
|
}
|
|
753
754
|
let current = this.head;
|
|
754
|
-
while (current.next !== this.tail) current = current.next;
|
|
755
|
-
const value = this.tail.value;
|
|
755
|
+
while (current.next && current.next !== this.tail) current = current.next;
|
|
756
|
+
const value = (_a = this.tail) == null ? void 0 : _a.value;
|
|
756
757
|
current.next = void 0;
|
|
757
758
|
this._tail = current;
|
|
758
759
|
this._length--;
|
|
@@ -840,8 +841,8 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
840
841
|
at(index) {
|
|
841
842
|
if (index < 0 || index >= this._length) return void 0;
|
|
842
843
|
let current = this.head;
|
|
843
|
-
for (let i = 0; i < index; i++) current = current.next;
|
|
844
|
-
return current.value;
|
|
844
|
+
for (let i = 0; i < index && current; i++) current = current.next;
|
|
845
|
+
return current == null ? void 0 : current.value;
|
|
845
846
|
}
|
|
846
847
|
/**
|
|
847
848
|
* Type guard: check whether the input is a SinglyLinkedListNode.
|
|
@@ -861,7 +862,7 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
861
862
|
getNodeAt(index) {
|
|
862
863
|
if (index < 0 || index >= this._length) return void 0;
|
|
863
864
|
let current = this.head;
|
|
864
|
-
for (let i = 0; i < index; i++) current = current.next;
|
|
865
|
+
for (let i = 0; i < index && current; i++) current = current.next;
|
|
865
866
|
return current;
|
|
866
867
|
}
|
|
867
868
|
/**
|
|
@@ -1714,7 +1715,7 @@ var _Deque = class _Deque extends LinearBase {
|
|
|
1714
1715
|
*/
|
|
1715
1716
|
constructor(elements = [], options) {
|
|
1716
1717
|
super(options);
|
|
1717
|
-
__publicField(this, "_equals", Object.is);
|
|
1718
|
+
__publicField(this, "_equals", /* @__PURE__ */ __name((a, b) => Object.is(a, b), "_equals"));
|
|
1718
1719
|
__publicField(this, "_bucketSize", 1 << 12);
|
|
1719
1720
|
__publicField(this, "_bucketFirst", 0);
|
|
1720
1721
|
__publicField(this, "_firstInBucket", 0);
|