stl操作4
来源:互联网 发布:c语言的函数库大全 编辑:程序博客网 时间:2024/05/19 08:36
容器大小的操作
c.size() c.max_size() c.empty() c.resize(n) c.resize(n,t)
注意:resize操作可能会是迭代器失效
#include <iostream>#include <vector>#include <list>#include <deque>using namespace std;int main( int argc, char ** argv ){list<int> lst;lst.push_back(10);lst.push_back(20);lst.push_back(30);cout<<"size: "<<lst.size()<<endl;list<int>::size_type count = lst.size();cout<<"size_type size: "<<count<<endl;cout<<"max_size: "<<lst.max_size()<<endl;if( not lst.empty() ){cout<<"not empty"<<endl;}else{cout<<"empty"<<endl;}lst.resize(10);for(list<int>::iterator itr = lst.begin(); itr!=lst.end(); ++itr ){cout<<*itr<<endl;}lst.resize(20,-1);for(list<int>::iterator itr = lst.begin(); itr != lst.end(); ++itr ){cout<<*itr<<endl;}lst.resize(2);for(list<int>::iterator itr = lst.begin(); itr != lst.end(); ++itr ){cout<<*itr<<endl;}return 0;}
0 0
- stl操作4
- STL的堆操作
- STL的erase操作
- STL 容器 操作
- stl删除操作
- STL erase操作
- STL 堆操作
- STL Heap操作
- STL中的heap操作
- STL 堆操作 .
- STL文件操作简介
- STL操作序列
- stl中的堆操作
- STL 堆操作
- C++ stl 队列操作
- STL容器删除操作
- STL map 一般操作
- STL操作总结
- 流氓软件导致主页被篡改成2345.com的分析,包括解决方法
- JRTPLIB rtp 实时流媒体传输
- VB学习笔记——VB中Excel应用2
- js的Prototype属性 解释及常用方法
- boost库之bind(与function配合使用)
- stl操作4
- Makefile 文件自动生成方法
- 【javascript】substr和substring的使用区别
- 【Android UI设计与开发】第06期:底部菜单栏(一)使用TabActivity实现底部菜单栏
- flash的不同分类
- 在普通pc上装虚拟机,并在虚拟机上Mac OS苹果系统
- 内部类
- 九度OJ题目1000:计算a+b
- IBInspectable / IBDesignable (只能用于Swift?)