1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
| #include <stdio.h> #include <stdlib.h>
typedef struct DNode{ int data; struct DNode *prior, *next; }DNode, *DLinklist;
bool InitDLinkList(DLinklist &L) { L = (DNode *) malloc (sizeof(DNode)); if (L == NULL)return false; L->prior = NULL; L->next = NULL; return true; }
void testDLinklist() { DLinklist L; InitDLinkList(L); }
bool Empty(DLinklist L) { if (L->next == NULL) return true; else return false; }
bool InsertNextDNode(DNode *p, DNode *s) { if (p ==NULL || s == NULL) return false;
s->next = p->next; if (p->next != NULL) p->next->prior = s; s->prior = p; p->next = s; return true;
}
|