typedef struct {
int Data[10000];
int top1;
int top2;
} CQueue;
CQueue* cQueueCreate() {
CQueue *newQueue = (CQueue *)malloc(sizeof(CQueue));
newQueue->top1 = -1;
newQueue->top2 = 10000;
return newQueue;
}
void cQueueAppendTail(CQueue* obj, int value) {
obj->Data[++(obj->top1)] = value;
}
int cQueueDeleteHead(CQueue* obj) {
if(obj->top2 != 10000){
return obj->Data[(obj->top2)++];
}
if(obj->top1 == -1)
return -1;
while(obj->top1 != -1){
obj->Data[--(obj->top2)] = obj->Data[(obj->top1)--];
}
return obj->Data[(obj->top2)++];
}
void cQueueFree(CQueue* obj) {
free(obj);
}