public boolean decreasePriority ( E key , double priority ) { Entry < E > entry = getEntry ( key ) ; if ( entry == null ) { entry = makeEntry ( key ) ; } if ( compare ( priority , entry . priority ) >= 0 ) { return false ; } entry . priority = priority ; heapifyDown ( entry ) ; return true ; }
Demotes a key in the queue adding it if it wasn t there already . If the specified priority is better than the current priority nothing happens . If you decrease the priority on a non - present key it will get added but at it s old implicit priority of Double . NEGATIVE_INFINITY .