#include <stdlib.h>
template <typename T>
void BubbleSort(T iData[], size_t iBegin, size_t iEnd)
{
bool bHasChange = false;
T iTmp;
size_t p = iEnd;
while(iEnd >= iBegin)
{
bHasChange = false;
p = iEnd;
while(p >= iBegin)
{
if (iData[p]<iData[p-1])
{
iTmp = iData[p];
iData[p] = iData[p-1];
iData[p-1] = iTmp;
bHasChange = true;
}
if (p == iBegin)
break;
p--;
}
iBegin++;
if (!bHasChange)
return;
}
return;
}