diff --git a/DoubleLink.txt b/DoubleLink.txt new file mode 100644 index 0000000000000000000000000000000000000000..f390c8af1c7ad8774c85b256a5a988ec3a7c387f --- /dev/null +++ b/DoubleLink.txt @@ -0,0 +1,60 @@ +include"DList.h" +#include +#include +Position MakeNode(Item i) +{ + PNode p = NULL; + p = (PNode)malloc(sizeof(Node)); + if(p!=NULL) + { + p->data = i; + p->previous = NULL; + p->next = NULL; + } + return p; + +void FreeNode(PNode p) +{ + free(p); +} +DList * InitList() +{ + DList *plist = (DList *)malloc(sizeof(DList)); + PNode head = MakeNode(0); + if(plist!=NULL) + { + if(head!=NULL) + { + plist->head = head; + plist->tail = head; + plist->size = 0; + } + else + return NULL; + } + return plist; +} +void ClearList(DList *plist) +{ + PNode temp,p; + p = GetTail(plist); + while(!IsEmpty(plist)) + { + temp = GetPrevious(p); + FreeNode(p); + p = temp; + plist->tail = temp; + plist->size--; + } +} + +Position GetHead(DList *plist) +{ + return plist->head; +} + +Position GetTail(DList *plist) +{ + return plist->tail; +} + diff --git "a/\346\226\260\345\273\272\346\226\207\346\234\254\346\226\207\346\241\243.txt" "b/\346\226\260\345\273\272\346\226\207\346\234\254\346\226\207\346\241\243.txt" new file mode 100644 index 0000000000000000000000000000000000000000..bfd68798444f43f1fd311e9ee8768c6a618969eb --- /dev/null +++ "b/\346\226\260\345\273\272\346\226\207\346\234\254\346\226\207\346\241\243.txt" @@ -0,0 +1 @@ +fsfsf