Skip to content

Commit 9b78621

Browse files
committed
Revert "Fix for Issue TheAlgorithms#773. Deleting an element that doesn't exist causes NPE"
This reverts commit 7eb0785.
1 parent 7eb0785 commit 9b78621

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

DataStructures/Lists/DoublyLinkedList.java

+2-7
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,8 @@ public Link deleteTail() {
116116
public void delete(int x) {
117117
Link current = head;
118118

119-
while (current.value != x) {// Find the position to delete
120-
if (current != tail) {
121-
current = current.next;
122-
} else {// If we reach the tail and the element is still not found
123-
throw new RuntimeException("The element to be deleted does not exist!");
124-
}
125-
}
119+
while (current.value != x) // Find the position to delete
120+
current = current.next;
126121

127122
if (current == head)
128123
deleteHead();

0 commit comments

Comments
 (0)