CArray排序

来源:互联网 发布:mac可用的魔兽世界插件 编辑:程序博客网 时间:2024/06/05 06:59

 

http://www.codeguru.com/forum/archive/index.php/t-215414.html

 

这篇贴子帮了大忙。有一个回贴这样说到:

 

#include <algorithm>
...
// Note the *only* change is the template type!
CArray<unsigned char, unsigned char> MyCArray;
//...
std::sort( MyCArray.GetData(), MyCArray.GetData() + MyCArray.GetSize());

It doesn't matter whether it's a CArray of strings, ints, chars, doubles, widgets, or your own class. As long as the items are comparable using operator < (which is what std::sort uses internally), the std::sort will work.

 

当然,sort()里如果用到自定义比较函数,自己写了。。。

转载出处:http://blog.csdn.net/zhouworld16/article/details/6198347

下载示例:http://download.csdn.net/detail/qq_23992597/9504004

1 0