双向循环链表的增删查操作
typedef structDNode
{
ElemType data;
struct DNode *prior, *next;
}DNode, * DoubleList;
插入操作:
intDlinkIns(DoubleList L, int i, ElemType e)
{
DNode *s, *p;
s=(DNode*) malloc(sizeof(DNode));
if(s)
{
s->data = e;
s->prior =p->prior; p->prior->next = s;
s->next= p;p->prior=s;
return TRUE;
}
else
returnFALSE;
}
删除操作:
intDlinkDel(DoubleList L, int i, ElemType *e)
{
DNode *p;
*e = p->data;
p->prior->next= p->next;
p->next->prior=p->prior;
free(p);
return TRUE;
}