list 容器 排序函数.xml
struct Point { double x,y,z; };
制定排序规则,重载()运算符:
(一) 按x值的大小 进行升序排序
class ascend_x { public: bool operator()(const Point &t1,Point &t2) {return t1.x<t2.x;} };
(二) 按y值的大小 进行升序排序
class ascend_y { public: bool operator()(const tag_Point &t1,tag_Point &t2) {return t1.y<t2.y;} }; list<Point> list_point; list_point.push_back(point); .... ....
对list_point中的元素按x进行升序排序
list_point.sort(ascend_x()) // 里面参数为ascend_x()
这样 list_point中的元素 就按指定的排序规则进行排序了
本文使用 书画小说软件 发布,内容与软件无关,书画小说软件 更惬意的读、更舒心的写、更轻松的发布。

浙公网安备 33010602011771号