bool InitDlinkList(DLinklist &L) {
L = (DNode*)malloc(sizeof(DNode));
if (L == NULL)
return false;
L->prior = NULL;
L->next = NULL;
return true;
}
bool Empty(DLinklist L) {
if (L->next = NULL)
return true;
else
return false;
}
bool InsertNextNode(DNode *p, DNode *s) {
if (p == NULL || s == NULL) {
return false;
}
s->next = p->next;
if (p->next != NULL)
p->next->prior = s->next;
s->prior = p;
p->next = s;
}
bool DeleteNextNode(DNode *p) {
if (p == NULL)
return false;
DNode *q = p->next;
if (q == NULL)
return false;
p->next = q->next;
if (q->next != NULL)
q->next->prior = p;
free(q);
return true;
}
void Outputnext(DLinklist L) {
DNode *p = L;
while (p != NULL) {
p->next;
cout << p->data << endl;
}
}
void OutputPrior(DLinklist L) {
DNode *p = L;
while (p->prior != NULL) {
p->prior;
cout << p->data << endl;
}
}
void DestoryList(DLinklist &L) {
while (L->next != NULL)
DeleteNextNode(L);
free(L);
L = NULL;
}