1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
void vec_sort (vector<double> &m)
{
const
static vector<unsigned int> harr =
{ 0, //terminal condition for sort
1,4,19,87, 388,1725,7661,34015, 151030,670574,2977348,13219428,
999999999 //terminal condition for find index
};
const unsigned int size = m.size();
unsigned int i;
unsigned int j, dx = 1;
while(size > harr[dx]) dx++;
while(--dx)
{
const unsigned int &hdx = harr[dx];
for(i = 1; i < size; i++)
{
const double temp = m[i];
for(j = i; (j >= hdx) && (m[j-hdx] > temp); j -= hdx)
{
m[j] = m[j-hdx];
}
m[j] = temp;
}
}
}
| |