QT中使用快速排序

今天想到了用QT做一个快速排序,所以研究了一下。 因为用习惯了,C++的std::sort,就算是C的时候也用得是stdlib.h中的qsort。

手写板 手写板的快排其实不难,只是自从用C++打ACM之后就很少裸敲了。

其中C语言 stdlib 功 能: 使用快速排序例程进行排序 用 法: void qsort(void base,int nelem,int width,int (*fcmp)(const void ,const void *)); 参数: 1 待排序数组首地址 2 数组中待排序元素数量 3 各元素的占用空间大小 4 指向函数的指针,用于确定排序的顺序 这个库函数在QT中是支持的,但是我现在是用不太来这个东西,而且这个的函数对STL的排序不太支持。

接着用标准库中< algorithm >的sort排序,这是C++中一个专门针对泛型数据排序的中可以吧 ,可是写在qt中却无法识别sort、std::sort。其实可以理解String转化为QString,所以我们猜测 是qSort。 用法和sort差不多。

Header: < algorithm> Namespace: std

bool CapitySort(const SVideoChip msVideoFirst,const SVideoChip msVideoSecond) {return (msVideoFirst.mi64VideoCapacity < msVideoSecond.mi64VideoCapacity); } void * VideoSort(QList<SVideoChip>* msVideoChipList) {qSort(msVideoChipList->begin(),msVideoChipList->end(),CapitySort);// std::sort(msVideoChipList->begin(),msVideoChipList->end(),CapitySort); }

躲在某一地点,想念一个站在来路,

QT中使用快速排序

相关文章:

你感兴趣的文章:

标签云: