![](https://img-blog.csdnimg.cn/20201014180756918.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
STL
文章平均质量分 54
Maccy37
这个作者很懒,什么都没留下…
展开
-
set关联容器去除重复地图点出现问题 error: no match for ‘operator<’ (operand types are ‘const Point’ and ‘const Point
set中每个元素只包含一个关键字,set支持高效关键字查询---检查一个关键字是否在set中。vector<sweep::MetricPoint2D> carpetPoint;set<Point> gridPoint;void DealMap::onRobotPoseReceived(const geometry_msgs::PoseStampedPtr ptrRobotPose){ if (robot_state->device_state.carpet原创 2021-12-07 21:13:13 · 1645 阅读 · 0 评论 -
堆-heap
priority queue可以借用堆(heap),binary heap是一种complete binary tree(完全二叉树)完全二叉树:binary tree除最底层叶节点之外,是填满,最底层叶节点由左到右不得有空隙。用vector来存储所有节点,vector的第0个元素保留设为(无限大或者无限小),完全二叉树某个节点位于vector的 i 处,其左节点位于vector的2i处,其右边节点位于vector的2i+1处(隐式表述法)。heap可分为max-heap和min-heap.原创 2021-12-16 00:14:06 · 992 阅读 · 0 评论 -
queue 和 deque
一.queue:队列只能访问queue<T>容器适配器第一个元素和最后一个元素.只能在容器的末尾添加新元素,只能从头部移除元素.queue容器的头文件: #include <queue> using namespace std;queue容器的成员函数见下表:函数成员 函数功能 front() 访问第一个元素 back() 访问最后一个元素 push() 在 queue 的尾部添加一个元素 pop().原创 2021-01-22 10:16:21 · 469 阅读 · 0 评论 -
vector容器添加元素
基础不牢,在容器vector上撞墙,做做笔记来吸取教训vector添加元素,我原来的代码vector<MetricPoint2D> Smooth::smoothPath(const vector<MetricPoint2D> &path){ int length = path.size(); vector<MetricPoint2D> smoothPath; smoothPath.clear(); for (int原创 2021-01-05 21:26:34 · 1871 阅读 · 0 评论 -
关于priority_queue(优先队列)的一些误解
主要参考博客:https://blog.csdn.net/weixin_36888577/article/details/79937886优先队列的定义:priority_queue<Type, Container, Functional>Type 就是数据类型,Container 就是容器类型(Container必须是用数组实现的容器,比如vector,deque等等,但不能用 list。STL里面默认用的是vector),Functional 就是比较的方式,当需要用自定义的数据类型原创 2020-11-18 10:57:53 · 492 阅读 · 0 评论 -
STL的函数erase()
void prunePlan(const geometry_msgs::PoseStamped& global_pose, std::vector<geometry_msgs::PoseStamped>& plan, std::vector<geometry_msgs::PoseStamped>& global_plan){ ROS_ASSERT(global_plan.size() >= plan.size()); std::vec.原创 2020-10-30 15:34:47 · 282 阅读 · 0 评论 -
C++ STL关于map插入元素和map的排序
map插入元素:map<uint32_t,string> temp;方式1:temp[1]="template";方式2:temp.insert(pair<uint32_t,string>(1,"template"));方式3:temp.insert(make_pair(1,"template"));pair实际上是一个结构体,其主要的两个成员是first和second,因此:for(const auto&i :temp){ cout<.原创 2020-09-28 14:00:59 · 3522 阅读 · 0 评论 -
LeetCode 238 除自身以外数组的乘积
参考链接:https://leetcode-cn.com/problems/product-of-array-except-self/solution/chu-zi-shen-yi-wai-shu-zu-de-cheng-ji-by-leetcode-/解题思路:利用索引左侧所有数字的乘积和右侧所有数字的乘积(前缀和后缀)相乘来解决.我的解法:class Solution {public: vector<int> productExceptSelf(vector...原创 2020-06-05 16:07:36 · 214 阅读 · 1 评论