#include <qDebug>#define NUM_TEST 1024struct CTest { CTest( double x ) : mX(x) {} ~CTest( void ) { qDebug() << "destruct " << mX; } bool operator < ( const CTest & t ) const { return mX < t.mX; }// data double mX; QString mDummy;};int main(int argc, char *argv[]){ (void) argc; (void) argv; QList <CTest> theList; for (int i = 0; i < NUM_TEST; ++i) theList.append(CTest(double(qrand()) / RAND_MAX)); qSort(theList.begin(), theList.end()); return 0;}
#include <qDebug>#define NUM_TEST 8struct CTest { CTest( double x ) : mX(x) {} ~CTest( void ) { qDebug() << "destruct " << mX; } bool operator < ( const CTest & t ) const { return mX < t.mX; } // data double mX; QString mDummy;};int main(int argc, char *argv[]){ (void) argc; (void) argv; QList <CTest> theList; qDebug() << "\nAppending"; for (int i = 0; i < NUM_TEST; ++i) theList.append(CTest(double(qrand()) / RAND_MAX)); qDebug() << "\nSorting"; qSort(theList.begin(), theList.end());// qSort(theList); qDebug() << "\nEnd"; return 0;}
C++ (Qt) theList.append( CTest(double(qrand()) / RAND_MAX));