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
|
@@ -656,7 +656,7 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
656
656
|
*/
|
|
657
657
|
constructor(elements = [], options) {
|
|
658
658
|
super(options);
|
|
659
|
-
__publicField(this, "_equals", Object.is);
|
|
659
|
+
__publicField(this, "_equals", /* @__PURE__ */ __name((a, b) => Object.is(a, b), "_equals"));
|
|
660
660
|
__publicField(this, "_head");
|
|
661
661
|
__publicField(this, "_tail");
|
|
662
662
|
__publicField(this, "_length", 0);
|
|
@@ -744,6 +744,7 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
744
744
|
* @returns Removed element or undefined.
|
|
745
745
|
*/
|
|
746
746
|
pop() {
|
|
747
|
+
var _a;
|
|
747
748
|
if (!this.head) return void 0;
|
|
748
749
|
if (this.head === this.tail) {
|
|
749
750
|
const value2 = this.head.value;
|
|
@@ -753,8 +754,8 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
753
754
|
return value2;
|
|
754
755
|
}
|
|
755
756
|
let current = this.head;
|
|
756
|
-
while (current.next !== this.tail) current = current.next;
|
|
757
|
-
const value = this.tail.value;
|
|
757
|
+
while (current.next && current.next !== this.tail) current = current.next;
|
|
758
|
+
const value = (_a = this.tail) == null ? void 0 : _a.value;
|
|
758
759
|
current.next = void 0;
|
|
759
760
|
this._tail = current;
|
|
760
761
|
this._length--;
|
|
@@ -842,8 +843,8 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
842
843
|
at(index) {
|
|
843
844
|
if (index < 0 || index >= this._length) return void 0;
|
|
844
845
|
let current = this.head;
|
|
845
|
-
for (let i = 0; i < index; i++) current = current.next;
|
|
846
|
-
return current.value;
|
|
846
|
+
for (let i = 0; i < index && current; i++) current = current.next;
|
|
847
|
+
return current == null ? void 0 : current.value;
|
|
847
848
|
}
|
|
848
849
|
/**
|
|
849
850
|
* Type guard: check whether the input is a SinglyLinkedListNode.
|
|
@@ -863,7 +864,7 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
863
864
|
getNodeAt(index) {
|
|
864
865
|
if (index < 0 || index >= this._length) return void 0;
|
|
865
866
|
let current = this.head;
|
|
866
|
-
for (let i = 0; i < index; i++) current = current.next;
|
|
867
|
+
for (let i = 0; i < index && current; i++) current = current.next;
|
|
867
868
|
return current;
|
|
868
869
|
}
|
|
869
870
|
/**
|
|
@@ -1379,7 +1380,7 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
1379
1380
|
*/
|
|
1380
1381
|
constructor(elements = [], options) {
|
|
1381
1382
|
super(options);
|
|
1382
|
-
__publicField(this, "_equals", Object.is);
|
|
1383
|
+
__publicField(this, "_equals", /* @__PURE__ */ __name((a, b) => Object.is(a, b), "_equals"));
|
|
1383
1384
|
__publicField(this, "_head");
|
|
1384
1385
|
__publicField(this, "_tail");
|
|
1385
1386
|
__publicField(this, "_length", 0);
|
|
@@ -1567,8 +1568,8 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
1567
1568
|
at(index) {
|
|
1568
1569
|
if (index < 0 || index >= this._length) return void 0;
|
|
1569
1570
|
let current = this.head;
|
|
1570
|
-
for (let i = 0; i < index; i++) current = current.next;
|
|
1571
|
-
return current.value;
|
|
1571
|
+
for (let i = 0; i < index && current; i++) current = current.next;
|
|
1572
|
+
return current == null ? void 0 : current.value;
|
|
1572
1573
|
}
|
|
1573
1574
|
/**
|
|
1574
1575
|
* Get the node reference at a given index.
|
|
@@ -1579,7 +1580,7 @@ var _DoublyLinkedList = class _DoublyLinkedList extends LinearLinkedBase {
|
|
|
1579
1580
|
getNodeAt(index) {
|
|
1580
1581
|
if (index < 0 || index >= this._length) return void 0;
|
|
1581
1582
|
let current = this.head;
|
|
1582
|
-
for (let i = 0; i < index; i++) current = current.next;
|
|
1583
|
+
for (let i = 0; i < index && current; i++) current = current.next;
|
|
1583
1584
|
return current;
|
|
1584
1585
|
}
|
|
1585
1586
|
/**
|