BILIST.CPP
资源名称:C++100.rar [点击查看]
上传用户:wszmarenbt
上传日期:2013-04-26
资源大小:2552k
文件大小:1k
源码类别:
Windows编程
开发平台:
Visual C++
- //THE IMPLEMENTATION OF THE CLASS "LIST"
- //FILE BILIST.CPP
- #include "BILIST.H"
- void LIST::Build_HT(int Data)
- {
- NODE *BUFFER;
- BUFFER=new NODE;
- BUFFER->DATA=Data;
- if(HEAD==0)
- {
- HEAD=BUFFER;
- HEAD->NEXT=0;
- HEAD->PREVIOUS=0;
- TAIL=HEAD;
- }
- else
- {
- TAIL->NEXT=BUFFER;
- BUFFER->PREVIOUS=TAIL;
- BUFFER->NEXT=0;
- TAIL=BUFFER;
- }
- }
- void LIST::Build_TH(int Data)
- {
- NODE *NEWNODE;
- NEWNODE=new NODE;
- NEWNODE->DATA=Data;
- if(TAIL==0)
- {
- TAIL=NEWNODE;
- TAIL->NEXT=0;
- TAIL->PREVIOUS=0;
- HEAD=TAIL;
- }
- else
- {
- NEWNODE->PREVIOUS=0;
- NEWNODE->NEXT=HEAD;
- HEAD->PREVIOUS=NEWNODE;
- HEAD=NEWNODE;
- }
- }
- void LIST::DISPLAY_HT()
- {
- NODE *TEMP;
- TEMP=HEAD;
- printf("nDISPLAY THE LIST FROM HEAD TO TAIL:n");
- while(TEMP!=0)
- {
- printf("%d ",TEMP->DATA);
- TEMP=TEMP->NEXT;
- }
- }
- void LIST::DISPLAY_TH()
- {
- NODE *TEMP;
- TEMP=TAIL;
- printf("nDISPLAY THE LIST FROM TAIL TO HEAD:n");
- while(TEMP!=0)
- {
- printf("%d ",TEMP->DATA);
- TEMP=TEMP->PREVIOUS;
- }
- }
- void LIST::CLEAR()
- {
- NODE *TEMP_HEAD=HEAD;
- if (TEMP_HEAD==0) return;
- do
- {
- NODE *TEMP_NODE=TEMP_HEAD;
- TEMP_HEAD=TEMP_HEAD->NEXT;
- delete TEMP_NODE;
- }
- while (TEMP_HEAD!=0);
- }