@Override public boolean add(E value, double priority) { return this.delegate.add(this.getOrCreateWrappedEntry(value), priority); }
/** * Increases the priority (=decrease the given double value) of the element. * If the element ins not part of the queue, it is added. If the new priority * is lower than the existing one, the method returns <tt>false</tt> * * @return <tt>true</tt> if the elements priority was decreased. */ @Override public boolean decreaseKey(E value, double cost) { // If the element is not yet present in the heap, simply add it. int index = indices[this.getIndex(value)]; if (index < 0) { return this.add(value, cost); } /* * If the cost should be increased, we cannot do this. Therefore we * return false. */ double oldCost = costs[index]; if (oldCost < cost) return false; // update costs in array siftUp(index, value, cost); return true; }