<aside> 📖 FIFO(First in First Out, 선입 선출), 입력과 출력을 한쪽 끝(front, rear)로 제한
</aside>
전체적인 구조
Class Stack {
private int rear = 0;
private int front = 0;
private Object[] queue;
private int QUEUE_MAX_SIZE;
public Queue(int QUEUE_MAX_SIZE) {
this.QUEUE_MAX_SIZE = QUEUE_MAX_SIZE;
this.queue = new Object[QUEUE_MAX_SIZE+1];
}
void enqueue(int data) {
...
}
void dequeue() {
...
}
boolean isEmpty() {
...
}
boolean isFull() {
...
}
}
enqueue : 데이터 삽입
void enqueue(Object data) {
if(isFull()) {
Error!
}
queue[rear++] = data;
}
dequeue : 데이터 출력
void dequeue() {
if(isEmpty()) {
Error!
}
queue[front++] = null;
}