public class MyQueueCircle {
public int[] elem;
public int frout;
public int rear;
public MyQueueCircle(){
elem = new int[10];
this.frout = 0;
this.rear = 0;
}
public boolean enQueue(int value){
if((this.rear+1)%this.elem.length == frout){
return false;
}
this.elem[rear] = value;
this.rear = (this.rear+1)%10;
return true;
}
public boolean isEmpty(){
if(this.frout == this.rear){
return true;
}
else {
return false;
}
}
public boolean isFull() {
if((this.rear+1)%10 == this.frout){
return true;
}
return false;
}
public boolean deQueue(){
if(isEmpty()){
return false;
}
this.frout = (this.frout+1)%this.elem.length;
return true;
}
public int Front(){
if(isEmpty()){
return-1;
}
return elem[frout];
}
public int Rear(){
if(isEmpty()){
return -1;
}
int index = 0;
if(rear == 0){
index = this.elem.length - 1;
}
else {
index = rear-1;
}
return elem[index];
}
}