📄 queuefortree.cpp
字号:
#include "stdafx.h"
#include <vld.h>
#include <stdlib.h>
#include <stdio.h>
#include <memory.h>
#include "..\\header\\Bitree.h"
Status InitQueue(LinkQueue& Q)
{
Q.front = Q.rear = (QueuePtr)malloc(sizeof(QNode));
if(!Q.front) exit(OVERFLOW);
Q.front->next = NULL;
return OK;
}
Status DestroyQueue(LinkQueue& Q)
{
while(Q.front)
{
Q.rear = Q.front->next;
free(Q.front);
Q.front = Q.rear;
}
return OK;
}
Status EnQueue(LinkQueue& Q, BiTNode* e)
{
if(e==NULL) return ERROR;
QNode* p = (QueuePtr)malloc(sizeof(QNode));
if(!p) exit(OVERFLOW);
p->data = e;
p->next = NULL;
Q.rear->next = p;
Q.rear = p;
return OK;
}
Status DeQueue(LinkQueue& Q, BiTNode* e)
{
if(Q.front == Q.rear) return ERROR;
QNode* p = Q.front->next;
*e = (*p->data);
Q.front->next = p->next;
if(Q.rear == p) Q.rear = Q.front;
free(p);
p = NULL;
return OK;
}
bool IsQueueEmpty(LinkQueue Q)
{
return (Q.front == Q.rear);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -