import java.util.PriorityQueue;
public class Test {
public static class Number{
int val;
Number(int val) {
this.val = val;
}
}
public static void main(String[] args) {
Number one = new Number(1);
Number two = new Number(2);
Number three = new Number(3);
PriorityQueue<Number> pq = new PriorityQueue<>((n1, n2) -> n1.val - n2.val);
pq.add(one);
pq.add(two);
pq.add(three);
System.out.println(pq.peek().val); // 1번
one.val = 5;
System.out.println(pq.peek().val); // 2번
}
}
1번과 2번의 출력값은?
그 한국사 욕하면서 강의하는 사람 떠오르네 이거 틀리면 빨리 때려쳐라
PQ가 뭔지 모름 ㅠㅠ 그래도 안때려칠래
1,2
1,2
1,5 아닌가요..?
PQueue는 힙을 쓰는데 요소 넣고 뺴는 동작이 없으면 힙연산이 엄따