Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save RakhmedovRS/4b67829babc66f0a3d1845d6017d48dd to your computer and use it in GitHub Desktop.
Save RakhmedovRS/4b67829babc66f0a3d1845d6017d48dd to your computer and use it in GitHub Desktop.
/**
* Delete the index-th node in the linked list, if the index is valid.
*/
public void deleteAtIndex(int index)
{
if (index < 0 || index >= size)
{
return;
}
Link current = head;
while (index-- >= 0)
{
current = current.next;
}
current.prev.next = current.next;
current.next.prev = current.prev;
size--;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment