code: @Override
      @SuppressWarnings("unchecked")
      @LogarithmicTime(amortized = true)
      public K deleteMin() {
          if (size + insertionBufferSize == 0) {
              throw new NoSuchElementException();
          }
  
          // where is the minimum
          boolean deleteFromInsertionBuffer = false;
          if (size == 0) {
              deleteFromInsertionBuffer = true;
          } else if (insertionBufferSize > 0) {
              K arrayMin = array[0];
              K insertionBufferMin = insertionBuffer[insertionBufferMinPos];
              if (comparator == null) {
                  if (((Comparable<? super K>) insertionBufferMin).compareTo(arrayMin) < 0) {
                      deleteFromInsertionBuffer = true;
                  }
              } else {
                  if (comparator.compare(insertionBufferMin, arrayMin) < 0) {
                      deleteFromInsertionBuffer = true;
                  }
              }
          }
  
          K result;
          if (deleteFromInsertionBuffer) {
              result = insertionBuffer[insertionBufferMinPos];
              insertionBuffer[insertionBufferMinPos] = insertionBuffer[insertionBufferSize - 1];
              insertionBuffer[insertionBufferSize - 1] = null;
              insertionBufferSize--;
              insertionBufferMinPos = 0;
              if (comparator == null) {
                  for (int i = 1; i < insertionBufferSize; i++) {
                      if (((Comparable<? super K>) insertionBuffer[i])
                              .compareTo(insertionBuffer[insertionBufferMinPos]) < 0) {
                          insertionBufferMinPos = i;
                      }
                  }
              } else {
                  for (int i = 1; i < insertionBufferSize; i++) {
                      if (comparator.compare(insertionBuffer[i], insertionBuffer[insertionBufferMinPos]) < 0) {
                          insertionBufferMinPos = i;
                      }
                  }
              }
          } else {
              result = array[0];
              size--;
              array[0] = array[size];
              array[size] = null;
              if (size > 1) {
                  if (comparator == null) {
                      fixdown(0);
                  } else {
                      fixdownWithComparator(0);
                  }
              }
              if (minCapacity <= array.length && 4 * size < array.length) {
                  ensureCapacity(array.length / 2);
              }
          }
  
          return result;
      }
docs: {@inheritDoc}