/** Initialize your data structure here. Set the size of the queue to be k. *//** Checks whether the circular queue is empty or not. */
bool myCircularQueueIsEmpty(MyCircularQueue* obj){return(obj->rear)==(obj->front)?true:false;}/** Checks whether the circular queue is full or not. */
bool myCircularQueueIsFull(MyCircularQueue* obj){return(obj->rear+1)%(obj->capacity)==(obj->front)?true:false;}
MyCircularQueue*myCircularQueueCreate(int k){
MyCircularQueue *obj=(MyCircularQueue *)malloc(sizeof(MyCircularQueue));
obj->capacity=k+1;
obj->front=obj->rear=0;
obj->base=(int*)malloc(sizeof(int)*obj->capacity);return obj;}/** Insert an element into the circular queue. Return true if the operation is successful. */
bool myCircularQueueEnQueue(MyCircularQueue* obj,int value){assert(obj);if(myCircularQueueIsFull(obj))return false;else{
obj->base[obj->rear]=value;
obj->rear=(obj->rear+1)%obj->capacity;return true;}}/** Delete an element from the circular queue. Return true if the operation is successful. */
bool myCircularQueueDeQueue(MyCircularQueue* obj){if(myCircularQueueIsEmpty(obj))return false;else{
obj->front=(obj->front+1)%obj->capacity;return true;}}/** Get the front item from the queue. */intmyCircularQueueFront(MyCircularQueue* obj){assert(obj);if(myCircularQueueIsEmpty(obj))return-1;else{return obj->base[obj->front];}}/** Get the last item from the queue. */intmyCircularQueueRear(MyCircularQueue* obj){assert(obj);if(myCircularQueueIsEmpty(obj))return-1;elsereturn obj->base[((obj->rear)-1+(obj->capacity))%obj->capacity];}voidmyCircularQueueFree(MyCircularQueue* obj){free(obj->base);free(obj);}/**
* Your MyCircularQueue struct will be instantiated and called as such:
* MyCircularQueue* obj = myCircularQueueCreate(k);
* bool param_1 = myCircularQueueEnQueue(obj, value);
* bool param_2 = myCircularQueueDeQueue(obj);
* int param_3 = myCircularQueueFront(obj);
* int param_4 = myCircularQueueRear(obj);
* bool param_5 = myCircularQueueIsEmpty(obj);
* bool param_6 = myCircularQueueIsFull(obj);
* myCircularQueueFree(obj);
*/