private void percolateUp(int pos) {
    assert pos != 0;
    if (pos == 1) {
      return;
    }
    final int id = posToId[pos];
    final double val = posToValue[pos];
    // the finish condition (index==0) is covered here automatically because we set vals[0]=-inf
    int parent;
    double parentValue;
    while (compareIdPos(val, parentValue = posToValue[parent = parent(pos)], id, parent) < 0) {
      posToValue[pos] = parentValue;
      idToPos[posToId[pos] = posToId[parent]] = pos;
      pos = parent;
    }
    posToId[pos] = id;
    posToValue[pos] = val;
    idToPos[posToId[pos]] = 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