?? sequencequeue.java
字號:
public class SequenceQueue implements Queue
{
Object Entry[];
int size;
int maxSize;
static final int MAX = 20;
public SequenceQueue()
{
Entry = new Object[MAX];
size = 0;
maxSize = MAX;
}
public SequenceQueue(int s)
{
Entry = new Object[s];
size = 0;
maxSize = s;
}
public void enqueue (Object element) //入隊
{
if(size < maxSize)
{
Entry[size] = element;
size++;
}
else
System.out.println("Queue is full,sorry! ");
}
public Object dequeue() throws EmptyQueueException//出隊
{
Object result = Entry[0];
if(size > 0)
{
for(int index = 0; index < size-1; index++)
{
Entry[index] = Entry[index+1];
}
size--;
}
else
throw new EmptyQueueException();
return result;
}
public void display()
{
for(int index = 0; index < size; index++)
System.out.print(" "+Entry[index]);
System.out.print("\n");
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -