};
[Copy to clipboard]View Code CPP
1 //LinkQueue-operations.h 链队列的基本操作 2
3
4 Status InitQueue(LinkQueue &Q)
5 {//构造一个空队列Q。 6
7 if(!(Q.front=Q.rear=(QueuePtr)malloc(sizeof(QNode)))) 8 exit(OVERFLOW);
9 Q.front->next=NULL;
10 return OK;
11 }
12
13 Status DestroyQueue(LinkQueue &Q)
14 {//销毁队列。 15
16 while(Q.front)
17 {
18 Q.rear=Q.front->next;
19 free(Q.front);
20 Q.front=Q.rear;
21 }
22 return OK;
23 }
24
25 Status ClearQueue(LinkQueue &Q)
26 {//清空队列。 27
28 QueuePtr p,q;
29 Q.rear=Q.front;
30 p=Q.front->next;
31 Q.front->next=NULL;
32 while(p)
33 {//释放每一个结点。 34
35 q=p;
36 p=p->next;
37 free(q);
38 }
39 return OK;
百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说教育文库资料-树的孩子兄弟表示法及相关操作(2)在线全文阅读。
相关推荐: