C++ 标准模板库
来源:互联网 发布:万网云新建数据库 编辑:程序博客网 时间:2024/06/13 20:55
- C++ Bitsets
- C++ Double-Ended Queues
- C++ Lists
- C++ Maps
- C++ Multimaps
- C++ Multisets
- C++ Priority Queues
- C++ Queues
- C++ Sets
- C++ Stacks
- C++ Vectors
- Iterators
C++链表:
Lists将元素按顺序储存在链表中. 与 向量(vectors)相比, 它允许快速的插入和删除,但是随机访问却比较慢.
assign()给list赋值back()返回最后一个元素begin()返回指向第一个元素的迭代器clear()删除所有元素empty()如果list是空的则返回trueend()返回末尾的迭代器erase()删除一个元素front()返回第一个元素get_allocator()返回list的配置器insert()插入一个元素到list中max_size()返回list能容纳的最大元素数量merge()合并两个listpop_back()删除最后一个元素pop_front()删除第一个元素push_back()在list的末尾添加一个元素push_front()在list的头部添加一个元素rbegin()返回指向第一个元素的逆向迭代器remove()从list删除元素remove_if()按指定条件删除元素rend()指向list末尾的逆向迭代器resize()改变list的大小reverse()把list的元素倒转size()返回list中的元素个数sort()给list排序splice()合并两个listswap()交换两个listunique()删除list中重复的元素程序实现:
list<int> charList;
int i = 0;
for (int i = 0; i < 10; i++)
{
charList.push_back(i + 65);
}
list<int>::iterator theIterator;
charList.unique();//unique()函数删除链表中所有重复的元素
charList.sort();//sort()函数为链表排序,默认是升序
charList.pop_back();//pop_back()函数删除链表的最后一个元素
for (theIterator = charList.begin(); theIterator != charList.end(); theIterator++)
cout << *theIterator<<endl;
cout << "链表的第一个元素"<<charList.front()<<endl;
int i = 0;
for (int i = 0; i < 10; i++)
{
charList.push_back(i + 65);
}
list<int>::iterator theIterator;
charList.unique();//unique()函数删除链表中所有重复的元素
charList.sort();//sort()函数为链表排序,默认是升序
charList.pop_back();//pop_back()函数删除链表的最后一个元素
for (theIterator = charList.begin(); theIterator != charList.end(); theIterator++)
cout << *theIterator<<endl;
cout << "链表的第一个元素"<<charList.front()<<endl;
C++ Queues(队列)
C++队列是一种容器适配器,它给予程序员一种先进先出(FIFO)的数据结构。
back()返回最后一个元素empty()如果队列空则返回真front()返回第一个元素pop()删除第一个元素push()在末尾加入一个元素size()返回队列中元素的个数程序实现:
queue<int> intQueue;
for (int i = 0; i < 10; i++)
{
intQueue.push(i);
}
while (intQueue.size())
{
printf("%d\n", intQueue.front());
intQueue.pop();
}
0 0
- C++:标准模板库(STL)
- C++:标准模板库vector
- C++:标准模板库map
- C++:标准模板库string
- C++:标准模板库Sort
- C++STL标准模板库
- C++:STL(标准模板库)
- C++_标准模板库(STL)
- C++:标准库和标准模板库STL概述
- stdlib 标准C 模板库函数
- 模板与标准模板库
- C++中的标准模板库STL及容器
- C++,VC++,MFC,STL(standard template library,标准模板库)
- 【C/C++学院】(12)C++标准模板库STL
- c++primer——模板,标准库特殊设施
- C++PP Chapter XVI String类和标准模板库
- 【C++】 C++标准模板库(一) Vector
- 【C++】 C++标准模板库(二) Lists
- iOS开发从入门到精通--修改app应用的名称,添加AppIcon,LaunchImage
- poj 2236 Wireless Network 并查集
- codeforces 682C. Alyona and the Tree
- URL
- c# sqladapter 与sqldataReader
- C++ 标准模板库
- 支付宝支付
- 将mysql数据导入mongodb
- Web.xml配置详解之context-param
- GsonFormat的使用
- 把 Nginx 创建为 Windows 的一个服务
- Android:使用ButterKnife注解绑定控件后报NullPointException
- linux 命令总结(持续更新)
- OPENCV2 NO FREE.HPP