#include
#include
typedef struct QNode{
QElemType data;
struct Qnode * next;
}Qnode,*QueuePtr;
typedef struct{
QueuePtr front;
QueuePtr rear ;
}LinkQueue;
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 QueueEmpty(LinkQueue Q){
return(Q.front == Q.rear);
}
Status GetHead(LinkQueue Q, QElemType&e){
if(Q.front == Q.rear)return ERROR;
e =Q.front->next->data;
return OK;
}