public void setPriority(T item, double newPriority) throws NoSuchElementException {
                int index;
                try {
                        index = map.get(item);
                } catch (NullPointerException npe) {
                        throw new NoSuchElementException();
                }
                PQElement<T> y = heap.get(index);
                double oldPriority = y.priority;
                y.priority = newPriority;
                if ((orientation && newPriority < oldPriority) || (!orientation && newPriority > oldPriority)) {
                        rotateUp(index);
                }
                else
                        rotateDown(index);
        }