// 核心代码
1. s->prior=p->prior;
2. p->prior->next=s;
3. s->next=p;
4. p->prior=s;
Status ListInsert_DuL(DuLinkList &L,int i,ElemType e){
if(!(p=GetElemP_DuL(L,i))) return ERROR;
s=new DuLNode;
s->data=e;
s->prior=p->prior;
p->prior->next=s;
s->next=p;
p->prior=s;
return OK;
}
2.双向链表的删除:
// 核心代码
1. p->prior->next=p->next;
2. p->next->prior=p->prior;
Status ListDelete_DuL(DuLinkList &L,int i,ElemType &e){
if(!(p=GetElemP_DuL(L,i)))
return ERROR;
e=p->data;
p->prior->next=p->next;
p->next->prior=p->prior;
delete p;
return OK;
}
4.循环链表的基本操作
理解单链表和双向链表的操作,循环链表的操作也类似。这里不在赘述。
四、比较顺序表和单链表
欢迎关注公众号:coder辰砂 (一个认认真真写东西的公众号)