Does Java rearrange? : Suppose I have a priority queue

    class Node{
            public int id;
            public int dist = Integer.MAX_VALUE;
            public Node(int id) { this.id = id; }
    }
    
    Queue<Node> q = new PriorityQueue<>((a, b) -> Integer.compare(a.dist, b.dist));

Then if I did (suppose one/two are nodes objects)

    one.dist = 1;
    two.dist = 2;
    q.offer(one);
    q.offer(two);
    two.dist = -1;

What will be the behavior of the queue? Will `two` appear before now?


Thanks!