首页
Python
Java
IOS
Andorid
NodeJS
JavaScript
HTML5
【
STL 小白学习(10) map
】的更多相关文章
STL 小白学习(10) map
map的构造函数 map<int, string> mapS; 数据的插入:用insert函数插入pair数据,下面举例说明 mapStudent.insert(pair<, "student_one")); mapStudent.insert(pair<, "student_two")); mapStudent.insert(pair<, "student_three")); map迭代器 map<int,…
STL初步学习(map)
3.map map作为一个映射,有两个参数,第一个参数作为关键值,第二个参数为对应的值,关键值是唯一的 在平时使用的数组中,也有点类似于映射的方法,例如a[10]=1,但其实我们的关键值和对应的值只能是int类型映射到其他类型,导致做许多题的不方便,而map类型的两个参数可以是任意数据类型 map的定义 #include<map> //头文件 using namespace std; map<typename,typename> a; //注意是两个参数 map<string…
C++ STL源代码学习(map,set内部heap篇)
stl_heap.h ///STL中使用的是大顶堆 /// Heap-manipulation functions: push_heap, pop_heap, make_heap, sort_heap. template <class _RandomAccessIterator, class _Distance, class _Tp> void __push_heap(_RandomAccessIterator __first, _Distance __holeIndex, _Distance…
STL 小白学习(1) 初步认识
#include <iostream> using namespace std; #include <vector> //动态数组 #include <algorithm>//算法 void PrintVector(int v) { cout << v<<" "; } /* STL 容器算法迭代器 基本语法 */ void test01() { vector<int> v; //定义一个容器 指定存放的元素类型 v…
STL 小白学习(9) 对组
void test01() { //构造方法 pair<, ); cout << p1.first << p1.second << endl; pair<, "assd"); cout << p2.first << p2.second << endl; pair<int, string> p3 = p2; }…
STL 小白学习(8) set 二叉树
#include <iostream> using namespace std; #include <set> void printSet(set<int> s) { for (set<int>::iterator it = s.begin(); it != s.end(); it++) { cout << *it << " "; } cout << endl; } //初始化 void test01(…
STL 小白学习(7) list
#include <iostream> using namespace std; #include <list> void printList(list<int>& mlist) { for (list<int>::iterator it = mlist.begin(); it != mlist.end(); it++) { cout << *it << " "; } cout << endl;…
STL 小白学习(5) stack栈
#include <iostream> #include <stack> //stack 不遍历 不支持随机访问 必须pop出去 才能进行访问 using namespace std; void test01() { //初始化 stack<int> s1; stack<int> s2(s1); //stack操作 //首先是压栈 s1.push(); s1.push(); s1.push(); //返回栈顶元素 cout << "栈顶…
STL 小白学习(6) queue
//queue 一端插入 另一端删除 //不能遍历(不提供迭代器) 不支持随机访问 #include <queue> #include <iostream> using namespace std; void test01() { queue<int> q1; q1.push();//尾部插入 q1.push(); q1.push(); q1.pop();//删除队头 cout << q1.back();//返回队尾元素 cout << q1.f…
STL 小白学习(4) deque
#include <iostream> #include <deque> //deque容器 双口 using namespace std; void printDeque(deque<int>& d) { for (deque<int>::iterator it = d.begin(); it != d.end(); it++) { cout << (*it) << " "; } cout <<…