www.gusucode.com > VC++写的小闹钟源程序源码程序 > VC++写的小闹钟源程序源码程序\code\List.cpp
#include "List.h" //------------------------------------------------------------ bool CreateNode(LPEVENTNODE &p, int hour, int min, int second, TCHAR* s) { if( NULL != p) return false; p = new EVENTNODE ; p->iHour = hour; p->iMin = min; p->iSecond = second; lstrcpy(p->szConten, s); p->next = NULL; return true; } //------------------------------------------------------------ bool DelNode(LPEVENTNODE &p) { if( NULL == p) return false; delete p; p = NULL; return true; } //------------------------------------------------------------- bool MordifyNode(LPEVENTNODE &p, int hour, int min, int second, TCHAR* s) { if(p == NULL) return false; p->iHour = hour; p->iMin = min; p->iSecond = second; lstrcpy(p->szConten, s); return true; } //------------------------------------------------------------ bool InitList(EVENTLIST &L) { L.head = NULL; L.size = 0; return true; } //------------------------------------------------------------ bool AddListNode(EVENTLIST &L, LPEVENTNODE p) { if( NULL == p) return false; LPEVENTNODE temp = NULL; if(NULL == L.head ) L.head = p; else { temp = L.head; while (NULL != temp->next ) temp = temp->next; temp->next = p; } L.size += 1; return true; } //------------------------------------------------------------- bool DelListNod(EVENTLIST &L, LPEVENTNODE &p) { if(NULL == L.head || NULL == p ) return false; LPEVENTNODE tempPass = NULL, tempDel = NULL; if(p == L.head) { tempDel = L.head; L.head = L.head->next; DelNode(tempDel); } else { tempPass = L.head; while (tempPass->next != p && NULL != tempPass->next) tempPass = tempPass->next; if(NULL != tempPass) { tempDel = tempPass->next; tempPass->next = tempPass->next->next; DelNode(tempDel); } else return false; } L.size -= - 1; return true; } //-------------------------------------------------------------- //Download by http://www.NewXing.com bool CleanList(EVENTLIST &L) { if(NULL == L.head) return false; LPEVENTNODE temp1 = NULL, temp2 = NULL; temp1 = L.head; while(NULL != temp1->next) { temp2 = temp1->next; DelNode(temp1); temp1 = temp2; } L.size = 0; return true; } //--------------------------------------------------------------