public int splitByDistance(ArrayModifiableDBIDs ind,int begin,int end,DoubleDataStore tpro,Random rand){
  DBIDArrayIter it=ind.iter();
  double rmin=Double.MAX_VALUE * .5, rmax=-Double.MAX_VALUE * .5;
  int minInd=begin, maxInd=end - 1;
  for (it.seek(begin); it.getOffset() < end; it.advance()) {
    double currEle=tpro.doubleValue(it);
    rmin=Math.min(currEle,rmin);
    rmax=Math.max(currEle,rmax);
  }
  if (rmin != rmax) {
    double rs=rmin + rand.nextDouble() * (rmax - rmin);
    while (minInd < maxInd) {
      double currEle=tpro.doubleValue(it.seek(minInd));
      if (currEle > rs) {
        while (minInd < maxInd && tpro.doubleValue(it.seek(maxInd)) > rs) {
          maxInd--;
        }
        if (minInd == maxInd) {
          break;
        }
        ind.swap(minInd,maxInd);
        maxInd--;
      }
      minInd++;
    }
  }
 else {
    minInd=(begin + end) >>> 1;
  }
  return minInd;
}

public int splitByDistance ( ArrayModifiableDBIDs ind , int begin , int end , DoubleDataStore tpro , Random rand ) { DBIDArrayIter it = ind . iter ( ) ; double rmin = Double . MAX_VALUE * .5 , rmax = - Double . MAX_VALUE * .5 ; int minInd = begin , maxInd = end - 1 ; for ( it . seek ( begin ) ; it . getOffset ( ) < end ; it . advance ( ) ) { double currEle = tpro . doubleValue ( it ) ; rmin = Math . min ( currEle , rmin ) ; rmax = Math . max ( currEle , rmax ) ; } if ( rmin != rmax ) { double rs = rmin + rand . nextDouble ( ) * ( rmax - rmin ) ; while ( minInd < maxInd ) { double currEle = tpro . doubleValue ( it . seek ( minInd ) ) ; if ( currEle > rs ) { while ( minInd < maxInd && tpro . doubleValue ( it . seek ( maxInd ) ) > rs ) { maxInd -- ; } if ( minInd == maxInd ) { break ; } ind . swap ( minInd , maxInd ) ; maxInd -- ; } minInd ++ ; } } else { minInd = ( begin + end ) > > > 1 ; } return minInd ; }
split the data set by distances .
