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/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
|
/**
|
|
@@ -1376,7 +1376,7 @@ var DoublyLinkedList = class extends LinearLinkedBase {
|
|
|
1376
1376
|
static {
|
|
1377
1377
|
__name(this, "DoublyLinkedList");
|
|
1378
1378
|
}
|
|
1379
|
-
_equals = Object.is;
|
|
1379
|
+
_equals = /* @__PURE__ */ __name((a, b) => Object.is(a, b), "_equals");
|
|
1380
1380
|
/**
|
|
1381
1381
|
* Create a DoublyLinkedList and optionally bulk-insert elements.
|
|
1382
1382
|
* @remarks Time O(N), Space O(N)
|
|
@@ -1571,8 +1571,8 @@ var DoublyLinkedList = class extends LinearLinkedBase {
|
|
|
1571
1571
|
at(index) {
|
|
1572
1572
|
if (index < 0 || index >= this._length) return void 0;
|
|
1573
1573
|
let current = this.head;
|
|
1574
|
-
for (let i = 0; i < index; i++) current = current.next;
|
|
1575
|
-
return current
|
|
1574
|
+
for (let i = 0; i < index && current; i++) current = current.next;
|
|
1575
|
+
return current?.value;
|
|
1576
1576
|
}
|
|
1577
1577
|
/**
|
|
1578
1578
|
* Get the node reference at a given index.
|
|
@@ -1583,7 +1583,7 @@ var DoublyLinkedList = class extends LinearLinkedBase {
|
|
|
1583
1583
|
getNodeAt(index) {
|
|
1584
1584
|
if (index < 0 || index >= this._length) return void 0;
|
|
1585
1585
|
let current = this.head;
|
|
1586
|
-
for (let i = 0; i < index; i++) current = current.next;
|
|
1586
|
+
for (let i = 0; i < index && current; i++) current = current.next;
|
|
1587
1587
|
return current;
|
|
1588
1588
|
}
|
|
1589
1589
|
/**
|