#include <stdio.h>
#include <stdlib.h>
typedef struct Node {
int data;
struct Node *prior, *next;
} DNode, *DLinkList;
int InitList() {
DNode *l = (DNode *)malloc(sizeof(DNode));
if (l == NULL) return -1;
l->prior = l;
l->next = l;
return 1;
}
int InsertNextNode(DNode *p, DNode *s) {
if (p == NULL || s == NULL) return -1;
s->next = p->next;
p->next->prior = s;
s->prior = p;
p->next = s;
return 1;
}
int DeleteNextNode(DNode *p) {
if (p == NULL) return -1;
DNode *q = p->next;
p->next = q->next;
q->next->prior = p;
free(q);
return 1;
}
int Empty(DLinkList l) {
if (l->next == l) return 1;
else return -1;
}
int isTail(DLinkList l, DNode *p) {
if (p->next == l) return 1;
else return -1;
}
网友评论