mirror of
https://gitea.smigz.com/smiggiddy/odin-codeprojects.git
synced 2024-12-25 06:00:43 -05:00
Merge branch 'main' into csci
This commit is contained in:
commit
ddba85e74b
2 changed files with 11 additions and 10 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -129,3 +129,4 @@ dist
|
|||
.yarn/install-state.gz
|
||||
.pnp.*
|
||||
|
||||
.DS_STORE
|
||||
|
|
|
@ -5,16 +5,6 @@ class LinkedList {
|
|||
this.head = null;
|
||||
}
|
||||
|
||||
getHead() {
|
||||
return this.tail;
|
||||
}
|
||||
getTail() {
|
||||
return this.head;
|
||||
}
|
||||
|
||||
getSize() {
|
||||
return this.size;
|
||||
}
|
||||
|
||||
append(value) {
|
||||
let newNode = new Node(value);
|
||||
|
@ -27,6 +17,7 @@ class LinkedList {
|
|||
}
|
||||
if (this.tail == null) {
|
||||
this.tail = newNode;
|
||||
|
||||
}
|
||||
|
||||
this.size += 1;
|
||||
|
@ -34,6 +25,7 @@ class LinkedList {
|
|||
|
||||
prepend(value) {
|
||||
let newNode = new Node(value);
|
||||
|
||||
if (this.tail == null) {
|
||||
this.tail = newNode;
|
||||
if (this.head == null) {
|
||||
|
@ -43,6 +35,7 @@ class LinkedList {
|
|||
const temp = this.tail;
|
||||
temp.nextNode = newNode;
|
||||
this.tail = newNode;
|
||||
|
||||
}
|
||||
this.size += 1;
|
||||
}
|
||||
|
@ -66,6 +59,7 @@ class LinkedList {
|
|||
this.tail = null;
|
||||
} else {
|
||||
this.head = this.head.nextNode;
|
||||
|
||||
}
|
||||
this.size -= 1;
|
||||
}
|
||||
|
@ -82,6 +76,7 @@ class LinkedList {
|
|||
}
|
||||
|
||||
return searchNodes(this.head, value);
|
||||
|
||||
}
|
||||
|
||||
find(value) {
|
||||
|
@ -97,12 +92,14 @@ class LinkedList {
|
|||
}
|
||||
|
||||
return searchNodes(this.head, value, index);
|
||||
|
||||
}
|
||||
|
||||
insertAt(value, index) {
|
||||
let previousNode = null;
|
||||
let newNode = new Node(value);
|
||||
let currentNode = this.head;
|
||||
|
||||
let count = 0;
|
||||
|
||||
if (index === 0) {
|
||||
|
@ -132,6 +129,7 @@ class LinkedList {
|
|||
removeAt(index) {
|
||||
let previousNode = null;
|
||||
let currentNode = this.head;
|
||||
|
||||
let count = 0;
|
||||
|
||||
if (index === 0) {
|
||||
|
@ -160,6 +158,7 @@ class LinkedList {
|
|||
let nodes = [];
|
||||
let current = this.head;
|
||||
|
||||
|
||||
while (current != null) {
|
||||
nodes.push(current.value);
|
||||
current = current.nextNode;
|
||||
|
@ -212,4 +211,5 @@ list.removeAt(0);
|
|||
list.toString();
|
||||
console.log("Removing element Deez Nuts");
|
||||
list.removeAt(3);
|
||||
|
||||
list.toString();
|
||||
|
|
Loading…
Reference in a new issue