65,187
社区成员




void sort(CMetric* metric,vector<CIndexObject*> &arr,CIndexObject* pivot, int fromIndex, int toIndex)
{
int i=fromIndex, j=toIndex;
CIndexObject *temp = arr[fromIndex];
double tempDistance=metric->getDistance(temp,pivot);
if ( fromIndex < toIndex )
{
while( i < j )
{
while( i<j && tempDistance<= metric->getDistance(arr[j],pivot))
{
j --;
}
if (i<j)
{
arr[i++] = arr[j];
}
while( i<j && metric->getDistance(arr[i],pivot) <= tempDistance)
{
i++;
}
if (i<j)
{
arr[j--] = arr[i];
}
}
arr[i] = temp;
sort(metric,arr,pivot,fromIndex, i-1);
sort(metric,arr,pivot,i+1,toIndex);
}
}