@Override
  public void update(int id, double value) {
    checkIdInRange(id);
    int pos = idToPos[id];
    if (pos < 0) {
      throw new IllegalStateException(
        "The heap does not contain: " + id + ". Use the contains method to check this before calling update");
    }
    double prev = posToValue[pos];
    posToValue[pos] = value;
    int cmp = compareIdPos(value, prev, id, pos);
    if (cmp > 0) {
      percolateDown(pos);
    } else if (cmp < 0) {
      percolateUp(pos);
    }
  }
@param elements the number of elements that can be stored in this heap. Currently the heap cannot be resized or
                shrunk/trimmed after initial creation. elements-1 is the maximum id that can be stored in this heap
planetiler-core/src/main/java/com/onthegomap/planetiler/collection/ArrayDoubleMinHeap.java