Skip to content

Commit

Permalink
增加可重复删除指定value的代码
Browse files Browse the repository at this point in the history
  • Loading branch information
chinalwb committed Oct 6, 2018
1 parent 20e6597 commit 1d24c84
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions java/06_linkedlist/SinglyLinkedList.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,22 @@ public void deleteByValue(int value) {
} else {
q.next = q.next.next;
}

// 可重复删除指定value的代码
/*
if (head != null && head.data == value) {
head = head.next;
}
Node pNode = head;
while (pNode != null) {
if (pNode.next.data == data) {
pNode.next = pNode.next.next;
continue;
}
pNode = pNode.next;
}
*/
}

public void printAll() {
Expand Down

0 comments on commit 1d24c84

Please sign in to comment.