linked-list-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 +10 -10
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs-legacy/index.cjs +11 -10
- package/dist/cjs-legacy/index.cjs.map +1 -1
- package/dist/esm/index.mjs +10 -10
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm-legacy/index.mjs +11 -10
- 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/linked-list-typed.js +11 -10
- package/dist/umd/linked-list-typed.js.map +1 -1
- package/dist/umd/linked-list-typed.min.js +1 -1
- package/dist/umd/linked-list-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
|
/**
|
|
@@ -1374,7 +1374,7 @@ var DoublyLinkedList = class extends LinearLinkedBase {
|
|
|
1374
1374
|
static {
|
|
1375
1375
|
__name(this, "DoublyLinkedList");
|
|
1376
1376
|
}
|
|
1377
|
-
_equals = Object.is;
|
|
1377
|
+
_equals = /* @__PURE__ */ __name((a, b) => Object.is(a, b), "_equals");
|
|
1378
1378
|
/**
|
|
1379
1379
|
* Create a DoublyLinkedList and optionally bulk-insert elements.
|
|
1380
1380
|
* @remarks Time O(N), Space O(N)
|
|
@@ -1569,8 +1569,8 @@ var DoublyLinkedList = class extends LinearLinkedBase {
|
|
|
1569
1569
|
at(index) {
|
|
1570
1570
|
if (index < 0 || index >= this._length) return void 0;
|
|
1571
1571
|
let current = this.head;
|
|
1572
|
-
for (let i = 0; i < index; i++) current = current.next;
|
|
1573
|
-
return current
|
|
1572
|
+
for (let i = 0; i < index && current; i++) current = current.next;
|
|
1573
|
+
return current?.value;
|
|
1574
1574
|
}
|
|
1575
1575
|
/**
|
|
1576
1576
|
* Get the node reference at a given index.
|
|
@@ -1581,7 +1581,7 @@ var DoublyLinkedList = class extends LinearLinkedBase {
|
|
|
1581
1581
|
getNodeAt(index) {
|
|
1582
1582
|
if (index < 0 || index >= this._length) return void 0;
|
|
1583
1583
|
let current = this.head;
|
|
1584
|
-
for (let i = 0; i < index; i++) current = current.next;
|
|
1584
|
+
for (let i = 0; i < index && current; i++) current = current.next;
|
|
1585
1585
|
return current;
|
|
1586
1586
|
}
|
|
1587
1587
|
/**
|