在双向链表中删除指定元素。
1
void del(List head, List node){
2
List pre=new List();
3
pre.next = head;
4
List cur = head;
5
while(cur && cur!=node){
6
cur=cur.next;
7
pre=pre.next;
8
}
9
if(!cur) return;
10
List post = cur.next;
11
pre.next=cur.next;
12
post.last=cur.last;
13
return;
14
}
void del(List head, List node){2
List pre=new List();3
pre.next = head;4
List cur = head;5
while(cur && cur!=node){6
cur=cur.next;7
pre=pre.next;8
}9
if(!cur) return;10
List post = cur.next;11
pre.next=cur.next;12
post.last=cur.last;13
return;14
}



浙公网安备 33010602011771号