
STL基础笔记
文章平均质量分 94
trainhui
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
STL基础笔记之string
#include<iostream>#include<string>using namespace std;void test01()//str.at(i),[]越界直接挂掉{ string str = "hello word"; for (int i = 0; i < str.size(); i++) { cout ...原创 2019-01-25 17:08:26 · 125 阅读 · 0 评论 -
STL中链表操作和正常的链表操作的比较
先写一个正常的链表操作,还有点小问题,谁看到了给我留言一下,帮我改一下,就是在删除的时候不能删除第一个元素,第二个就是删除的元素不能紧挨着,比如说有一组数据 1 2 3 5 2 25 2 2 2 4,我想删除2,那么就会报错,找了很长时间,真的找不出来了。#include<iostream>using namespace std;typedef struct node{...原创 2019-01-25 12:49:00 · 419 阅读 · 0 评论 -
STL中vector和multimap的结合使用
看了几天的stl,也有了一些初步的了解,其实stl就是c++的比较全的库函数,比如我们在学习c语言中肯定做过链表的反转,删除,插入等操作,但是stl给我们就提供了很大的帮助,不需要我们来自己一个一个自己来写在实现,我们只需要调用一个函数,就可以实现我们所需要的操作。vector和map都相当于一个容器,比如,一个班的学生就是一个大容器,我门想要将学生的1-10,11-20,,放在一个容器里,那...原创 2019-01-23 17:38:16 · 824 阅读 · 0 评论 -
STL中的vector的基本用法
#include<iostream>#include<vector>using namespace std;void printdata(vector<int> &v){ for (vector<int>::iterator it = v.begin(); it != v.end(); it++) { cout <&l...原创 2019-01-26 16:18:55 · 224 阅读 · 0 评论 -
STL中的谓词
谓词指的是普通函数或重载的operator返回值是bool类型的函数对象,也就是我们之前用的仿函数,如果operator接受的是一个参数,那么就叫一元谓词,如果接受的是两个参数,就叫二元谓词#include<iostream>#include<vector>#include<algorithm>using namespace std;struct ...原创 2019-02-01 13:27:25 · 425 阅读 · 0 评论 -
STLstack容器和queue容器,list容器
stack容器先进后出,没有迭代器,不支持遍历访问#include<iostream>#include<stack>using namespace std;void test01(){ stack<int>s; stack<int>s1; s.push(10); s.push(20); s.push(30); s...原创 2019-01-28 18:54:10 · 196 阅读 · 0 评论 -
STLset/multiset容器基础
#include<iostream>#include<algorithm>#include<set>using namespace std;void myprint(int val){ cout << val << " " ;}void test01(){ set<int>s1; s1.insert原创 2019-01-29 20:29:44 · 177 阅读 · 0 评论 -
STL map容器
#include<iostream>#include<map>using namespace std;void printData(map<int, int>&m){ for (map<int, int>::iterator it = m.begin(); it != m.end();it++) { cout <<...原创 2019-01-30 21:15:30 · 180 阅读 · 0 评论