双向链表结点结构
typedef struct DualNode
{
Elemtype data;
struct DualNode *prior;
struct DualNode *next;
}DualNode, *DuLinkList;
双向循环链表
双向链表的插入操作
//顺序很重要不能搞反
s->next = p;
s->prior = p->prior;
p->prior->next = s;
p->prior = s;
关键在于交换的过程中不能乱序,比如第四步先被执行了,那么p->prior就会提前变成s,使得插入操作出错。
双向链表的删除操作
p->prior->next = p->next;
p->next->prior = p->prior;
free(p);