![](https://img-blog.csdnimg.cn/20201014180756919.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
STL
文章平均质量分 59
伐尘
这个作者很懒,什么都没留下…
展开
-
【C++】vector.push_back()具体拷贝机制,超级详细哦
观察vector.push_back()具体拷贝机制。转载 2022-09-05 17:52:57 · 6740 阅读 · 0 评论 -
【C++】c++编译错误-- C2678 二进制“=”: 没有找到接受“_Ty”类型的左操作数的运算符(或没有可接受的转换)
【C++】c++编译错误-- C2678 二进制“=”: 没有找到接受“_Ty”类型的左操作数的运算符(或没有可接受的转换)代码://by 鸟哥 reverse引起的编译错误//有疑问请留言或加群 1032082534#include<iostream>#include<algorithm>#include<vector>using namespace std;class Point3d{ double x,y,z; public:原创 2022-05-11 10:44:24 · 3638 阅读 · 0 评论 -
【STL】List容器的splice及std::partition用法
【STL】List容器的splice及std::partition用法list容器內建splice這個函數,可以將容器依指定範圍切割,以及std的partition可以對容器中的元素進行條件篩選並排續,稱著記憶猶新趕快記錄下來用法。#include <list>#include <iostream>#include <algorithm>#include <random>#include <string>using namespa转载 2022-05-05 10:24:05 · 347 阅读 · 0 评论 -
【STL】for_each()算法
【STL】for_each()算法一、for_each()概述for_each()算法非常灵活,允许你以不同的方式访问、处理、修改每一个元素因此,for_each()既属于非更易型算法,又属于更易型算法备注:自C++11起,range-based for循环提供了更方便更自然的行为。因此,for_each()可能逐渐降低其重要性二、for_each()语法头文件:<algorithm>相关语法:对区间[beg,end)中的每一个元素调用op(elem)返回op(它已在转载 2022-04-29 17:53:44 · 1976 阅读 · 0 评论 -
【STL】删除元素 remove、erase
【STL】删除元素 remove、eraseSTL功能很强大,但是说到删除元素,不少人会觉得有些上头。删除元素,第一印象可能就是erase和remove。removeremove,在STL不止一个,有全局std::remove函数,list容器中,还有一个名为remove的成员函数;两个函数的名称完全一样,很多人傻傻分不清。有以下几点区别:std::remove适用于很多容器,list只是其中之一;而list的成员函数remove,既然是成员函数,肯定是它独享咯!std::remove转载 2022-04-27 09:21:53 · 1624 阅读 · 0 评论 -
【STL】C++ 使用erase-remove_if惯用法
【STL】C++ 使用erase-remove_if惯用法第一种我想删除所有将.first值设置为4的对.stopPoints.erase(std::remove_if(stopPoints.begin(),stopPoints.end(),[&](const stopPointPair stopPoint)-> bool { return stopPoint.first == 4; }));第二种#include <vector> // the general-pur原创 2022-04-26 18:01:59 · 1781 阅读 · 0 评论 -
std::map c++两个map合并成一个map ,c++多个map的合并
std::map c++两个map合并成一个map ,c++多个map的合并两个map合并成一个map,用insert()函数就可以了,看代码:#include <map>#include <iostream>int main(){ std::map<int, int> v1 = {{1, 1}, {2, 1}, {3, 1}, {4, 1}, {5, 1}}; std::map<int, int> v2 = {转载 2022-04-14 15:59:17 · 2134 阅读 · 0 评论 -
[STL] algorithm中find系列函数总结
C++ algorithm中find系列函数总结主要是对find , find_first_of , find_end , find_if , find_if_not这五函数做个总结:#include<iostream>#include<map>#include<vector>#include<string>#include<algorithm>using namespace std;bool isOld(int a) { i转载 2022-03-26 13:37:24 · 345 阅读 · 0 评论 -
std::unordered_map 的按照vaule排序
一、 概述大家都知道map是有序容器,但它本身是按照key升序排列,而我们有时候需要的是按value排序,有需求就有实现,当然,如果key有重复的,std::unordered_map,也会有按照vaule 排序的操作的时候,又不想找其他的排序算法,std::sort是首选。但是需要转换一下vector,因为map或者std::unordered_map不适配std::sort。二、实现将map添加到vector容器中,这样我们就可以针对每一项进行操作,进行比较通过for循环实现map转移进vect原创 2022-03-11 22:48:15 · 1008 阅读 · 0 评论 -
两个 vector 怎么合并?
一、 概述今天做个工程,之前存在有多个vector想合并成一个再做处理,上网查了一下,比较简单的就两种方法一种是vector的insert方法,一种是stl的merge方式,当然,还有遍列元素的方式。二、实现1) vector的insert方式:(以下为将vec1和vec2的内容合并到vec3中)vector<string>vec1,vec2,vec3; //... vec1,vec2赋值 vec3.insert(vec3.end(),vec1.begin(),vec1.end原创 2022-03-11 09:29:51 · 12024 阅读 · 0 评论 -
[STL] map按value值查找——find_if的使用
[STL] map按value值查找——find_if的使用335046781 2012-05-09 15:29:00 1587 收藏 3原文链接:http://www.cnblogs.com/xufeiyang/archive/2012/05/09/2491871.html收起最近是经常使用stl中的map,于是就想记一些关于map的东西。这一篇中会讲到map按照value值查找的方法,就是find_if函数。大家都知道在map中,排序是按照key值排的,map自带的find方法也是按着ke转载 2021-11-28 18:19:06 · 3328 阅读 · 0 评论