和单向链表的主要区别在于删除,其他都是差不多的,就是需要后一个节点把pre和当前节点关联上
//双向链表没有必要招自己的后一个节点了。直接找自己,然后删除就ok了
public void del(_Node hero) {
_Node temp = head.next;
while (temp != null) {
if (temp.no == hero.no) {
temp.pre.next = temp.next;
if (temp.next != null) {
temp.next.pre = temp.pre;//有可能空指针异常。
}
break;
}
temp = temp.next;
}
}
}
3005

被折叠的 条评论
为什么被折叠?



