摘要:
这是本小人书。原名是《using stl》STL概述STL的一个重要特点是数据结构和算法的分离。尽管这是个简单的概念,但这种分离确实使得STL变得非常通用。例如,由于STL的sort()函数是完全通用的,你可以用它来操作几乎任何数据集合,包括链表,容器和数组。要点STL算法作为模板函数提供。为了和其... 阅读全文
摘要:
1. 栈(stack)这种数据结构在计算机中是相当出名的。栈中的数据是先进后出的(First In Last Out, FILO)。栈只有一个出口,允许新增元素(只能在栈顶上增加)、移出元素(只能移出栈顶元素)、取得栈顶元素等操作。在STL中,栈是以别的容器作为底部结构,再将接口改变,使之符合栈的... 阅读全文
摘要:
2. map简介map是一类关联式容器。它的特点是增加和删除节点对迭代器的影响很小,除了那个操作节点,对其他的节点都没有什么影响。对于迭代器来说,可以修改实值,而不能修改key。3. map的功能自动建立Key - value的对应。key 和 value可以是任意你需要的类型。根据key值快速查找... 阅读全文
摘要:
STL 中的list容器 1 //对已string型list进行添加,删除,查找,插入操作 2 #include "stdafx.h" 3 #include 4 #include 5 #include 6 using namespace std; 7 8 int main() 9 {10 ... 阅读全文
摘要:
deque 提供了对首部数据进行删除/插入操作 1 //对一个int型的deque进行首尾添加操作 2 #include "stdafx.h" 3 #include 4 5 #include 6 using namespace std; 7 8 int main() 9 {10 de... 阅读全文
摘要:
vector。支持尾部添加/删除数据操作。// STL.cpp : 定义控制台应用程序的入口点。////vector是一个连续的向量,相当于数组。vector不建议除了尾部之外的数据添加删除操作。//vector::iterator 迭代器#include "stdafx.h"#include#in... 阅读全文
摘要:
auto_ptr 不可被共享,只能指向一个对象auto_ptr在构造时获取对某个对象的所有权(ownership),在析构时释放该对象。我们可以这样使用auto_ptr来提高代码安全性:int* p = new int(0);auto_ptr ap(p);从此我们不必关心应该何时释放p, 也不用担心... 阅读全文
摘要:
pair 提供了一对一的关系#include "stdafx.h"#include#include //#includeusing namespace std;int _tmain(int argc, _TCHAR* argv[]){ pairoPoint; //必须包含std ... 阅读全文
摘要:
1. 友元类#include using namespace std;class TV {public: friend class Tele; //这样Tele 就可以访问TV类了 TV():on_off(off),volume(20),channel(3),mod... 阅读全文