美文网首页C/C++编程技巧
C++:vector元素排序

C++:vector元素排序

作者: AI秘籍 | 来源:发表于2020-04-18 10:30 被阅读0次

vector内元素按升序存储:

#include <opencv2/opencv.hpp>
#include <iostream>
 
#pragma comment(lib,"opencv_world341.lib")
 
using namespace cv;
using namespace std;
int main()
{
    vector<Point2f> pts_v{ Point2f(100,200),Point2f(300,150),Point2f(200,400) };
    sort(pts_v.begin(), pts_v.end(), 
            [](Point2f pts1, Point2f pts2) {return pts1.x < pts2.x; });
    cout << pts_v << endl;
 
    return 0;
}
 
 
//
vector<Rect> temp;
std::sort(temp.begin(), temp.end(), 
          [](Rect& rect1, Rect& rect2) { return rect1.x < rect2.x; }
         );
image.png

参考:

  1. https://blog.csdn.net/sss_369/article/details/88983580

相关文章

  • C++:vector元素排序

    vector内元素按升序存储: 参考: https://blog.csdn.net/sss_369/article...

  • C++ 常用代码

    vector 迭代器遍历 C++ 函数模板 冒泡排序 快速排序

  • STL容器使用积累

    vector 头文件 初始化 插入数据 删除数据 容器大小 访问元素 反转、排序操作 heap c++中的堆是通过...

  • #拖延症# 需要看的文章的记录

    C++ 对vector等STL标准容器进行排序操作--csdn该篇文章通过对vector排序的总结,明白stl是一...

  • C++ STL 之 vectot(三)

    今天我们继续更新 C++ STL 中 vector 容器的使用 vector 容器增加元素 vector 容器增加...

  • 2018-12-24 #STL#

    C++ vector删除符合条件的元素 两点:algorithm::remove,vector.erase()cp...

  • C++ STL 之 vectot(四)

    今天我们继续更新 C++ STL 中 vector 容器的使用 vector 容器删除元素 使用 clear() ...

  • C++:vector erase删除符合条件的元素

    绪 C++ vector中实际删除元素使用的是容器vecrot中std::vector::erase()方法。C+...

  • STL | vector的使用(续)

    写在前面: 很久之前写过关于C++ STL中vector容器的基本用法,最近涉及到了vector容器元素的删除,发...

  • STL容器(1)-vector类

    STL vector vector是C++中的动态数组,支持动态扩容同时再末尾添加元素的时间复杂度控制在o(1) ...

网友评论

    本文标题:C++:vector元素排序

    本文链接:https://www.haomeiwen.com/subject/pdzmvhtx.html