queue-typed 2.4.3 → 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/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-multi-set.ts +5 -5
- 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
package/dist/cjs/index.cjs
CHANGED
|
@@ -653,7 +653,7 @@ var SinglyLinkedList = class extends LinearLinkedBase {
|
|
|
653
653
|
static {
|
|
654
654
|
__name(this, "SinglyLinkedList");
|
|
655
655
|
}
|
|
656
|
-
_equals = Object.is;
|
|
656
|
+
_equals = /* @__PURE__ */ __name((a, b) => Object.is(a, b), "_equals");
|
|
657
657
|
/**
|
|
658
658
|
* Create a SinglyLinkedList and optionally bulk-insert elements.
|
|
659
659
|
* @remarks Time O(N), Space O(N)
|
|
@@ -757,8 +757,8 @@ var SinglyLinkedList = class extends LinearLinkedBase {
|
|
|
757
757
|
return value2;
|
|
758
758
|
}
|
|
759
759
|
let current = this.head;
|
|
760
|
-
while (current.next !== this.tail) current = current.next;
|
|
761
|
-
const value = this.tail
|
|
760
|
+
while (current.next && current.next !== this.tail) current = current.next;
|
|
761
|
+
const value = this.tail?.value;
|
|
762
762
|
current.next = void 0;
|
|
763
763
|
this._tail = current;
|
|
764
764
|
this._length--;
|
|
@@ -846,8 +846,8 @@ var SinglyLinkedList = class extends LinearLinkedBase {
|
|
|
846
846
|
at(index) {
|
|
847
847
|
if (index < 0 || index >= this._length) return void 0;
|
|
848
848
|
let current = this.head;
|
|
849
|
-
for (let i = 0; i < index; i++) current = current.next;
|
|
850
|
-
return current
|
|
849
|
+
for (let i = 0; i < index && current; i++) current = current.next;
|
|
850
|
+
return current?.value;
|
|
851
851
|
}
|
|
852
852
|
/**
|
|
853
853
|
* Type guard: check whether the input is a SinglyLinkedListNode.
|
|
@@ -867,7 +867,7 @@ var SinglyLinkedList = class extends LinearLinkedBase {
|
|
|
867
867
|
getNodeAt(index) {
|
|
868
868
|
if (index < 0 || index >= this._length) return void 0;
|
|
869
869
|
let current = this.head;
|
|
870
|
-
for (let i = 0; i < index; i++) current = current.next;
|
|
870
|
+
for (let i = 0; i < index && current; i++) current = current.next;
|
|
871
871
|
return current;
|
|
872
872
|
}
|
|
873
873
|
/**
|
|
@@ -1712,7 +1712,7 @@ var Deque = class extends LinearBase {
|
|
|
1712
1712
|
static {
|
|
1713
1713
|
__name(this, "Deque");
|
|
1714
1714
|
}
|
|
1715
|
-
_equals = Object.is;
|
|
1715
|
+
_equals = /* @__PURE__ */ __name((a, b) => Object.is(a, b), "_equals");
|
|
1716
1716
|
/**
|
|
1717
1717
|
* Create a Deque and optionally bulk-insert elements.
|
|
1718
1718
|
* @remarks Time O(N), Space O(N)
|