#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. [UE4]移动设备贴图消失

    pc版本是支持直接使用psd文件作为贴图文件,但移动设备就不支持了.

  2. ERROR 1045 (28000): Access denied for user 'hive'@'localhost' (using password: YES)

    [root@master native]# mysql -uhive -pEnter password: ERROR 1045 (28000): Access denied for user 'hiv ...

  3. centos7环境下的Mysql5.7.22安装

    参考网站: https://blog.csdn.net/vipbupafeng/article/details/80271089 1.下载 官网链接:https://dev.mysql.com/dow ...

  4. 21. orcle导出sql脚本时,提示“超出打开游标最大数”

    1.解决办法:修改下打开游标最大数即可 SQL> show parameter open_cursors;NAME                                  TYPE   ...

  5. quartz 定时任务的增删改

    参考:  https://blog.csdn.net/llmys/article/details/81069863

  6. springsource-tool-suite插件各个历史版本

    转自:https://blog.csdn.net/zhen_6137/article/details/79384798 目前spring官网(http://spring.io/tools/sts/al ...

  7. python生成可执行文件保护源码

    工作中由于需要防止源代泄漏,需要将源代码隐藏,找到两种方法: 1.使用python生成的pyc文件. 这种方法的优点就是pyc文件生成很容易,缺点则是很容易通过工具得到源码,并且python版本不一致 ...

  8. kafka offset 设置

    from kafka import KafkaConsumer from kafka import TopicPartition from kafka.structs import OffsetAnd ...

  9. Supervisor 进程管理工具

    简介: Supervisor 进程管理工具 一.安装 shell > yum -y install python-pip shell > pip install supervisor # ...

  10. Python中的操作符重载

    运算符重载是指在方法中拦截内置的操作----当类的实例出现在内置操作中,Python会自动调用自定义的办法,并且返回自定义方法的操作结果.     类可以重载python的操作符 操作符重载使我们的对 ...