Queue

링버퍼를 사용하면 디큐(deque)시 발생하는 요소 이동 문제를 해결할 수 있다. 2021/01/05 - [분류 전체보기] - 자바(JAVA)로 큐(Queue) 구현하기 public class IntQueue { private int max; private int num; private int[] que; private int front; private int rear; // 예외 : 큐가 비어 있음 class EmptyIntQueueException extends RuntimeException{ } // 예외 : 큐가 가득 참 class OverflowIntQueueException extends RuntimeException{ } public IntQueue(int capacity){ num = fr..
public class IntAryQueue { private int max; // 큐 용량 private int num; // 현재 데이터 수 private int[] que; // 큐 본체 private int front; private int rear; // 예외 : 큐가 비어 있음 class EmptyIntQueueException extends RuntimeException{ } // 예외 : 큐가 가득 참 class OverflowIntQueueException extends RuntimeException{ } public IntAryQueue(int capacity){ num = front = rear = 0; max = capacity; try { que = new int[capacity]..
Queue는 선입선출(First In First Out)자료구조를 구현한 자바 인터페이스이다. 새 원소를 추가하는 add, 오래된 원소를 제거하는 remove, 가장 오래된 원소를 반환하지만 삭제하지 않는 peek 메서드가 있다. Deque(`덱(deck)`이라고 발음함)는 Queue 인터페이스의 확장이며 자료구조의 양끝에 원소를 추가하고 삭제할 수 있다. @Test public void queueInsertion(){ final Queue queue = new LinkedList(); queue.add("first"); queue.add("second"); queue.add("third"); Assert.assertEquals("first", queue.remove()); Assert.assertEqu..
깡냉쓰
'Queue' 태그의 글 목록