Created
July 10, 2022 22:58
-
-
Save RakhmedovRS/4b67829babc66f0a3d1845d6017d48dd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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