1 개요[ | ]
- 자바 Class PriorityQueue
- java.util.PriorityQueue
Java
Copy
import java.util.PriorityQueue;
public class MyClass {
public static void main(String args[]) {
PriorityQueue<Integer> pq = new PriorityQueue<Integer>();
pq.add(3);
pq.add(1);
pq.add(4);
pq.add(2);
System.out.println( pq.toString() );
// [1, 2, 4, 3]
}
}
Java
Copy
import java.util.PriorityQueue;
import java.util.Collections;
public class MyClass {
public static void main(String args[]) {
PriorityQueue<Integer> pq = new PriorityQueue<Integer>(Collections.reverseOrder());
pq.add(3);
pq.add(1);
pq.add(4);
pq.add(2);
System.out.println( pq.toString() );
// [4, 2, 3, 1]
}
}
2 같이 보기[ | ]
3 참고[ | ]
편집자 Jmnote Jmnote bot
로그인하시면 댓글을 쓸 수 있습니다.