随笔分类 -  STL浅谈

摘要:list即双向链表。 #include<iostream> #include<list> using namespace std; int main() { //构造 list<int> li; //插入元素 //头插 li.emplace_front(2); //尾插 li.emplace_bac 阅读全文
posted @ 2020-04-30 10:18 你的名字_子集 阅读(326) 评论(0) 推荐(1)
摘要:deque即数组形式的双端队列。 #include<iostream> #include<deque> #include<algorithm> using namespace std; int main() { //构造 deque<int> d = { 2,6,8 }; //遍历 for (deq 阅读全文
posted @ 2020-04-29 10:10 你的名字_子集 阅读(243) 评论(0) 推荐(0)
摘要:set即集合,主要用来去除重复元素。 #include<iostream> #include<set> #include<unordered_set> using namespace std; int main() { //构造 set<int> s{ 2,6,8,3,6,9 }; //遍历 for 阅读全文
posted @ 2020-04-28 10:18 你的名字_子集 阅读(310) 评论(0) 推荐(0)
摘要:Map是STL的一个关联容器,它提供一对一的数据处理能力,其中第一个称为关键字,每个关键字只能在Map中出现一次,第二个称为该关键字的值(常称为键值对)。 #include<iostream> #include<map> #include<unordered_map> #include<algori 阅读全文
posted @ 2020-04-27 18:02 你的名字_子集 阅读(253) 评论(0) 推荐(0)
摘要:queue即队列,一种先进先出的数据结构。 #include<iostream> #include<queue> using namespace std; int main() { //构造 queue<int> q; //一般空参构造 //入队 q.push(2); q.push(6); q.pu 阅读全文
posted @ 2020-04-08 10:16 你的名字_子集 阅读(318) 评论(0) 推荐(0)
摘要:stack即栈,一种先进后出的数据结构。 这次会在stack的基础上讲两个实际应用,以及讲一下stringstream。 直接上代码! 1、stack基础 #include<iostream> #include<stack> using namespace std; int main() { //构 阅读全文
posted @ 2020-04-07 10:04 你的名字_子集 阅读(301) 评论(0) 推荐(0)
摘要:vector即动态数组,也叫向量。 直接上代码! #include<iostream> #include<vector> #include<algorithm> using namespace std; int main() { //构造 vector<int> v1(3); //构造一个大小为3的 阅读全文
posted @ 2020-04-06 10:08 你的名字_子集 阅读(444) 评论(1) 推荐(0)
摘要:为什么要写STL浅谈这个系列,因为最近我在准备蓝桥杯,刷题的时候经常要用到STL,准备补一补,但一直没有找到一个好的视频和资料,最开始准备跟着c语言中文网学,但觉得太繁杂了,最后在b站(b站上计算机类的教学视频挺多的)上找了一个视频学的。这个系列相当于我的一个整理。 这个系列只是浅谈,但刷题应该够了 阅读全文
posted @ 2020-04-05 21:59 你的名字_子集 阅读(264) 评论(0) 推荐(0)