📄 singlequeue.java
字号:
class SingleQueue
{
int size;
SingleColorSet[] queue;
int head;
int rear;
SingleQueue()
{
size = 15;
queue = new SingleColorSet[size];
head = 0;
rear = 0;
}
/**
* put a new SingleColorSet object into the queue
* @i the object to put into the queue*/
public void enQueue(SingleColorSet i)
{
queue[rear] = i;
rear = (rear+1)%size;
}
/**
* delete SingleColorSet object from the queue
* @return the first object of the queue*/
public SingleColorSet deQueue()
{
SingleColorSet temp = queue[head];
head = (head+1)%size;
return temp;
}
/**
* @return the colorSet after the current*/
public SingleColorSet getNext()
{
// System.out.println("Next BarQueue:"+queue[(head+1)%size].getColor0()+","+queue[(head+1)%size].getColor1()+","+queue[(head+1)%size].getColor2()+"," );
SingleColorSet temp = queue[head];
return temp;
}
/**
* @return length of the queue*/
public int getQueLen()
{
return (rear+size-head)%size;
}
/* public static void main(String[] args)
{
SingleQueue queue = new SingleQueue();
queue.enQueue(1);
queue.enQueue(2);
//System.out.println((queue.rear-queue.head+queue.size)%queue.size);
//System.out.println(queue.deQueue());
//System.out.println(queue.deQueue());
System.out.println(queue.getQueLen());
}
*/
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -