docs: protected double computeDensity(DoubleDBIDList referenceDists, DoubleDBIDListIter iter, int index) {
      final int size = referenceDists.size();
      final double xDist = iter.seek(index).doubleValue();
  
      int lef = index, rig = index;
      double sum = 0.;
      double lef_d = (--lef >= 0) ? xDist - iter.seek(lef).doubleValue() : Double.POSITIVE_INFINITY;
      double rig_d = (++rig < size) ? iter.seek(rig).doubleValue() - xDist : Double.POSITIVE_INFINITY;
      for(int i = 0; i < k; ++i) {
        if(lef >= 0 && rig < size) {
          // Prefer n or m?
          if(lef_d < rig_d) {
            sum += lef_d;
            // Update left
            lef_d = (--lef >= 0) ? xDist - iter.seek(lef).doubleValue() : Double.POSITIVE_INFINITY;
          }
          else {
            sum += rig_d;
            // Update right
            rig_d = (++rig < size) ? iter.seek(rig).doubleValue() - xDist : Double.POSITIVE_INFINITY;
          }
        }
        else if(lef >= 0) {
          // Choose left, since right is not available.
          sum += lef_d;
          // update left
          lef_d = (--lef >= 0) ? xDist - iter.seek(lef).doubleValue() : Double.POSITIVE_INFINITY;
        }
        else if(rig < size) {
          // Choose right, since left is not available
          sum += rig_d;
          // Update right
          rig_d = (++rig < size) ? iter.seek(rig).doubleValue() - xDist : Double.POSITIVE_INFINITY;
        }
        else {
          // Not enough objects in database?
          throw new IndexOutOfBoundsException("Less than k objects?");
        }
      }
      return k / sum;
    }