赞
踩
已知P结点是某双向链表的中间结点:
1.在P结点后插入S结点
S->next = P->next;
P->next->prior = S;
S->prior = P;
P->next = S;
2.在P结点前插入S结点
S->prior = P->prior;
P->prior->next = S;
S->next = P;
P->prior = S;
3.删除P结点的直接后继节点
Q = P->next;
P->next = P->next->next;
P->next->prior = P;
free(Q);
4.删除P结点的直接前驱结点
Q = P->prior;
P->prior->next = P;
P->prior = P->prior->prior;
free(Q);
5.删除P结点
P->prior->next = P->next;
P->next->prior = P->prior;
free(P);
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。