#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. MySQL 报错记录

    #--------------------------------------------------------------------------------------------------- ...

  2. TSubobjectPtr和C++传统指针的区别

    转自:http://aigo.iteye.com/blog/2282142 主要有以下区别(1和2的前提条件要满足:指针所在的class必须是UObjcct的子类): 1,TSubobjectPtr指 ...

  3. 解决Sublime 3提示 Sublime Text Error while loading PyV8 binary

    转自:http://blog.initm.com/sublime-text/ 今天打开sublime遇到一个提示  如上图Sublime Text Error while loading PyV8 b ...

  4. css border-bottom(指定下边线的样式、宽度及颜色)

    border-bottom(指定下边线的样式.宽度及颜色) border-bottom: 值: border-bottom-style:值; border-bottom-color: 值; borde ...

  5. django路由初识

    静态文件配置 1.项目下面新建一个文件夹static settings.py中最后添加 STATICFILES_DIRS = [ os.path.join(BASE_DIR, "static ...

  6. 微软&中科大提出新型自动神经架构设计方法NAO

    近期,来自微软和中国科学技术大学的刘铁岩等人发表论文,介绍了一种新型自动神经架构设计方法 NAO,该方法由三个部分组成:编码器.预测器和解码器.实验证明,该方法所发现的架构在 CIFAR-10 上的图 ...

  7. virtualenv之python虚拟环境

    virtualEnv可以方便的解决不同项目中,对类库的依赖问题.首先将常用的类库安装在系统环境中,然后为每个项目安装独立的类库环境.这样子可以保证每个项目都运行在独立的类库环境中. virtualen ...

  8. rhel7配置ELK过程

    参考网站:https://www.cnblogs.com/hongdada/p/7887455.html https://my.oschina.net/codingcloud/blog/1615013 ...

  9. jap _spring _maven

    pom.xm <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3 ...

  10. Java架构技术知识点梳理

    Java程序员应该加以重视: 吃透基础技术 养成良好的阅读源码的习惯 有长期的技术学习规划 下面,我们来一起逐条看看,特别是第 3 个方法. 想要做到年薪50万,首先你自己必须是高水平的程序员! 能年 ...