자바로 큐(queue) 구현하기


자바로 큐(queue) 구현하기

자바로 큐를 구현하려면 먼저 아래의 두 가지를 import해준다. import java.util.LinkedList; import java.util.Queue; 그리고 다음과 같이 선언을 해서 사용한다. Queue<Integer> que = new LinkedList<Integer>(); 매소드는 다음과 같다. offer : 값 삽입, poll : 값 삭제, peek : 값 반환 이다. 큐는 먼저 들어간 것이 가장 나중에 나온다는 것을 알면 된다. 자세한 내용은 다음의 주소를 참고하면 좋다. https://docs.oracle.com/javase/7/docs/api/java/util/Queue.html Queue (Java Platform SE 7 ) Type Parameters: E - the type of elements held in this collection All Superinterfaces: Collection <E>, Iterable <E> All Known Subin...


#구현 #자바 #큐

원문링크 : 자바로 큐(queue) 구현하기