code: protected void convertNeighbors(DBIDRange ids, DBIDRef ix, boolean square, KNNList neighbours, DoubleArray dist, IntegerArray ind) {
      for(DoubleDBIDListIter iter = neighbours.iter(); iter.valid(); iter.advance()) {
        if(DBIDUtil.equal(iter, ix)) {
          continue; // Skip query point
        }
        double d = iter.doubleValue();
        dist.add(square ? (d * d) : d);
        ind.add(ids.getOffset(iter));
      }
    }
docs: Load a neighbor query result into a double and and integer array, also
  removing the query point. This is necessary, because we have to modify the
  distances.
  
  TODO: sort by index, not distance
  
  @param ids Indexes
  @param ix Current Object
  @param square Use squared distances
  @param neighbours Neighbor list
  @param dist Output distance array
  @param ind Output index array