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
package/dist/esm/index.mjs
CHANGED
|
@@ -651,7 +651,7 @@ var SinglyLinkedList = class extends LinearLinkedBase {
|
|
|
651
651
|
static {
|
|
652
652
|
__name(this, "SinglyLinkedList");
|
|
653
653
|
}
|
|
654
|
-
_equals = Object.is;
|
|
654
|
+
_equals = /* @__PURE__ */ __name((a, b) => Object.is(a, b), "_equals");
|
|
655
655
|
/**
|
|
656
656
|
* Create a SinglyLinkedList and optionally bulk-insert elements.
|
|
657
657
|
* @remarks Time O(N), Space O(N)
|
|
@@ -755,8 +755,8 @@ var SinglyLinkedList = class extends LinearLinkedBase {
|
|
|
755
755
|
return value2;
|
|
756
756
|
}
|
|
757
757
|
let current = this.head;
|
|
758
|
-
while (current.next !== this.tail) current = current.next;
|
|
759
|
-
const value = this.tail
|
|
758
|
+
while (current.next && current.next !== this.tail) current = current.next;
|
|
759
|
+
const value = this.tail?.value;
|
|
760
760
|
current.next = void 0;
|
|
761
761
|
this._tail = current;
|
|
762
762
|
this._length--;
|
|
@@ -844,8 +844,8 @@ var SinglyLinkedList = class extends LinearLinkedBase {
|
|
|
844
844
|
at(index) {
|
|
845
845
|
if (index < 0 || index >= this._length) return void 0;
|
|
846
846
|
let current = this.head;
|
|
847
|
-
for (let i = 0; i < index; i++) current = current.next;
|
|
848
|
-
return current
|
|
847
|
+
for (let i = 0; i < index && current; i++) current = current.next;
|
|
848
|
+
return current?.value;
|
|
849
849
|
}
|
|
850
850
|
/**
|
|
851
851
|
* Type guard: check whether the input is a SinglyLinkedListNode.
|
|
@@ -865,7 +865,7 @@ var SinglyLinkedList = class extends LinearLinkedBase {
|
|
|
865
865
|
getNodeAt(index) {
|
|
866
866
|
if (index < 0 || index >= this._length) return void 0;
|
|
867
867
|
let current = this.head;
|
|
868
|
-
for (let i = 0; i < index; i++) current = current.next;
|
|
868
|
+
for (let i = 0; i < index && current; i++) current = current.next;
|
|
869
869
|
return current;
|
|
870
870
|
}
|
|
871
871
|
/**
|
|
@@ -1710,7 +1710,7 @@ var Deque = class extends LinearBase {
|
|
|
1710
1710
|
static {
|
|
1711
1711
|
__name(this, "Deque");
|
|
1712
1712
|
}
|
|
1713
|
-
_equals = Object.is;
|
|
1713
|
+
_equals = /* @__PURE__ */ __name((a, b) => Object.is(a, b), "_equals");
|
|
1714
1714
|
/**
|
|
1715
1715
|
* Create a Deque and optionally bulk-insert elements.
|
|
1716
1716
|
* @remarks Time O(N), Space O(N)
|