private void rotateUp(int index) {
                PQElement<T> x = heap.get(index);
                while (index > 0) {
                        int parentIndex = (index - 1) / 2;
                        PQElement<T> y = heap.get(parentIndex);
                        if (orientation && x.priority >= y.priority)
                                break;
                        if (!orientation && x.priority <= y.priority)
                                break;
                        set(index, y);
                        index = parentIndex;
                }
                set(index, x);
        }