#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<iterator>
#include<map>
#include<fstream>
#include <string>
#include <hash_map>
using namespace std;
int main()
{
/* //vector have not push_front
vector<string> vstr(10,"str");
vector<string>::iterator itvs=vstr.begin();
vstr.push_back("lll");
vstr.push_back("dddddd");
vstr.pop_back();

for(itvs=vstr.begin(); itvs!=vstr.end(); itvs++)
{
cout<<*itvs<<"***";
}
cout<<vstr.back()<<vstr.size()<<vstr.front()<<endl;
//list
list<string> slist;
slist.push_back("aaa");
slist.push_back("hhh");
slist.push_front("***");
list<string>::iterator it=slist.begin();
slist.insert(it,"front");
for(it=slist.begin(); it!=slist.end(); it++)
{
cout<<*it<<"___";

}
cout<<endl;
slist.sort();
slist.erase(--it);//it 指向最后一个元素的下一个元素
for(it=slist.begin(); it!=slist.end(); it++)
{
cout<<*it<<"___";

}

//map

map<string,int> one;
one["the"]=3;

one.insert(map<string ,int>::value_type("as",2));/////!!!注意格式
map<string ,int>::iterator itmap=one.begin();
cout<<itmap->first<<":";
cout<<itmap->second;
one.erase("the");
ifstream in("in.txt");
string word;
//统计单词个数
while(in>>word){
one[word]+=1;
}
for(itmap=one.begin();itmap!=one.end();itmap++)
{
cout<<itmap->first<<":"<<itmap->second<<endl;
}

//set have not push pop
set<int> a;
a.insert(19);
a.clear();
cout<<a.count(0);//统计指定键的个数
for(int i=0;i<10;i++)
{
a.insert(i);
}
//集合无序,没有sort,映射也没有sort*/
/////////////以下编译不通过
hash_map<int, string> mp;
mp[9527] = "唐伯虎点秋香";
mp[10000] = "百万富翁的生活";
mp[88888] = "白领的工资底线";

if(mp.find(10000) != mp.end())
{
cout<<"lll" <<end;//....
}

}

c++ stl常用的更多相关文章

  1. C++ STL 常用算术和生成算法

    C++ STL 常用算术和生成算法 accumulate() accumulate: 对指定范围内的元素求和,然后结果再加上一个由val指定的初始值. #include<numeric> ...

  2. C++ STL 常用拷贝和替换算法

    C++ STL 常用拷贝和替换算法 copy() 复制 vector<int> vecIntA; vecIntA.push_back(1); vecIntA.push_back(3); v ...

  3. C++ STL 常用排序算法

    C++ STL 常用排序算法 merge() 以下是排序和通用算法:提供元素排序策略 merge: 合并两个有序序列,存放到另一个序列. 例如: vecIntA,vecIntB,vecIntC是用ve ...

  4. C++ STL 常用查找算法

    C++ STL 常用查找算法 adjacent_find() 在iterator对标识元素范围内,查找一对相邻重复元素,找到则返回指向这对元素的第一个元素的迭代器.否则返回past-the-end. ...

  5. C++ STL 常用遍历算法

    C++ STL 常用遍历算法 STL的容器算法迭代器的设计理念 1) STL的容器通过类模板技术,实现数据类型和容器模型的分离 2) STL的迭代器技术实现了遍历容器的统一方法:也为STL的算法提供了 ...

  6. STL常用结构与方法简明总结

    C++常用的数据结构 序列式容器 vector(向量.有序数列),list(双向链表),deque(双端队列) 适配器容器 stack(栈),queue(队列) 关联式容器 map(映射.键值对二叉树 ...

  7. STL常用序列容器

    这里简要的记述一下STL常用容器的实现原理,要点等内容. vector vector是比较常用的stl容器,用法与数组是非类似,其内部实现是连续空间分配,与数组的不同之处在于可弹性增加空间,而arra ...

  8. C++STL 常用 函数 用法

    学完c++快一年了,感觉很有遗憾,因为一直没有感觉到c++的强大之处,当时最大的感觉就是这个东西的输入输出比C语言要简单好写. 后来我发现了qt,opencv,opengl,原来,c++好玩的狠. 在 ...

  9. C++中STL常用容器的优点和缺点

    我们常用到的STL容器有vector.list.deque.map.multimap.set和multiset,它们究竟有何区别,各自的优缺点是什么,为了更好的扬长避短,提高程序性能,在使用之前需要我 ...

  10. C++ STL常用容器浅析

    首先要理解什么是容器,在C++中容器被定义为:在数据存储上,有一种对象类型,它可以持有其它对象或指向其它对象的指针,这种对象类型就叫做容器.简单来说 容器就是包含其他类的对象们的对象,当然这种(容器) ...

随机推荐

  1. Linux修改本地时间

    1.Linux时间调整 1)安装ntp(目的同步时间) yum install ntp 2)修改文件 vi /etc/ntp.conf 添加 server ntp.sjtu.edu.cn perfer ...

  2. spark1.0属性配置以及spark-submit简单使用

    在spark1.0中属性支持三种配置方式: 1.代码 在代码中构造SparkConf时指定master.appname或者key-value等 val conf = new SparkConf(); ...

  3. php do while循环实例

    do-while循环和while循环非常相似,其区别只是在于do-while保证必须执行一次,而while在表达式不成立时则可能不做任何操作. do-while 循环只有一种语法: do { stat ...

  4. nodejs中https请求失败,无报错

    今天群里一位同学在做练习的时候,采用https例子: // curl -k https://localhost:8000/ const https = require('https'); const ...

  5. 〈Android 群英传-神兵利器〉第7章一个的寂寞与一群人的狂欢

    |---第7章一个的寂寞与一群人的狂欢 |---7.1如何解决问题 |---Chrome浏览器 |---Chrome开发者工具 |---Chrome插件(Json-Handle:Json格式化查看工具 ...

  6. linux 之 压缩 / 解压

    压缩解压 tar 即可压缩也可以解压 c 压缩 如果没有z.j参数,则表示,只打包,不压缩. 就说, t 查看 z 以gzip方式压缩 相当于 gzip ?.. j 以bzip方式压缩 bzip2 ? ...

  7. 黑盒测试用例设计——PICT

    一.简单用法   在PICT安装目录下新建一个txt文本.把参数填入txt文本中.[内容包括(注意格式<ParamName> : <Value1>, <Value2> ...

  8. JAVA 常用注解( JDK, Spring, AspectJ )

    JDK自带注解   @Override   表示当前方法覆盖了父类的方法   @Deprecation   表示方法已经过时,方法上有横线,使用时会有警告   @SuppviseWarnings    ...

  9. leetcode171

    public class Solution { private int ConvertToC(char c) { ; switch (c) { case 'A': case 'a': rnt = ; ...

  10. Activity服务类-6 ManagementService服务类

    一共含有17个方法 // 获取包含了Activiti数据库模式的{表名.行计数}项的映射.Map<String, Long> getTableCount();//获取诸如任务.执行之类的A ...