deleteAnyNode(value) {
// contact me !!!
// linkedIn account : https://www.linkedin.com/in/mohammad-alshraideh-67820b186/
if (!this.head) return null;
let current = this.head;
while (current.next) {
if (current.value == value) {
current.value = current.next.value;
current.next = current.next.next;
}
current = current.next;
}
return current;
}
//if you find the answer is useful ,
//upvote ⇑⇑ , so can the others benefit also . @mohammad alshraideh ( ͡~ ͜ʖ ͡°)
deleteAnyNode(value) {
// contact me !!!
// linkedIn account : https://www.linkedin.com/in/mohammad-alshraideh-67820b186/
if (!this.head) return null;
let current = this.head;
while (current.next) {
if (current.value == value) {
current.value = current.next.value;
current.next = current.next.next;
}
current = current.next;
}
return current;
}
//if you find the answer is useful ,
//upvote ⇑⇑ , so can the others benefit also . @mohammad alshraideh ( ͡~ ͜ʖ ͡°)
void deleteNode(struct node **head, int key)
{
//temp is used to freeing the memory
struct node *temp;
//key found on the head node.
//move to head node to the next and free the head.
if(*head->data == key)
{
temp = *head; //backup the head to free its memory
*head = (*head)->next;
free(temp);
}
}
/* terst */
int removeFrameNode(FrameNode** head, char* name)
{
FrameNode* tmp = *head, *prev = NULL;;
int foundNode = FALSE;
while (tmp)
{
if (!strcmp(tmp->frame->name, name))
{
foundNode = TRUE;
break;
}
prev = tmp;
tmp = tmp->next;
}
if (foundNode)
{
if (tmp == *head)
{
*head = tmp->next;
}
else
{
prev->next = tmp->next;
}
free(tmp);
return FOUND;
}
else
{
return NOT_FOUND;
}
}