code: @SuppressWarnings("unchecked")
      private void decreaseKey(ReflectedHandle<K, V> n, K newKey) {
          if (n.inner == null && free != n) {
              throw new IllegalArgumentException("Invalid handle!");
          }
  
          int c;
          if (comparator == null) {
              c = ((Comparable<? super K>) newKey).compareTo(n.key);
          } else {
              c = comparator.compare(newKey, n.key);
          }
          if (c > 0) {
              throw new IllegalArgumentException("Keys can only be decreased!");
          }
          n.key = newKey;
          if (c == 0 || free == n) {
              return;
          }
  
          // actual decrease
          AddressableHeap.Handle<K, HandleMap<K, V>> nInner = n.inner;
          if (n.minNotMax) {
              // we are in the min heap, easy case
              n.inner.decreaseKey(newKey);
          } else {
              // we are in the max heap, remove
              nInner.delete();
              ReflectedHandle<K, V> nOuter = nInner.getValue().outer;
              nOuter.inner = null;
              nOuter.minNotMax = false;
  
              // remove min
              AddressableHeap.Handle<K, HandleMap<K, V>> minInner = nInner.getValue().otherInner;
              ReflectedHandle<K, V> minOuter = minInner.getValue().outer;
              minInner.delete();
              minOuter.inner = null;
              minOuter.minNotMax = false;
  
              // update key
              nOuter.key = newKey;
  
              // reinsert both
              insertPair(nOuter, minOuter);
          }
      }
docs: Decrease the key of an element.
  
  @param n
  the element
  @param newKey
  the new key