随笔分类 -  STL库

摘要:1 #include 2 #include 3 #include 4 using namespace std; 5 6 //map常规用法 7 void main1() 8 { 9 //映射 10 map mymap; 11 mymap.insert(pair("司令6", 16)); 12 mymap.insert(pair("司令2"... 阅读全文
posted @ 2018-03-23 10:15 喵小喵~ 阅读(141) 评论(0) 推荐(0)
摘要:1 #define _SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS 2 #include 3 #include 4 #include 5 #include 6 #include 7 using namespace std; 8 9 //hash_set常规用法 10 void main() 11 { 12 ////哈希表不... 阅读全文
posted @ 2018-03-22 23:23 喵小喵~ 阅读(252) 评论(0) 推荐(0)
摘要:1 #include 2 //红黑树(自动保证平衡,自动生成平衡查找树) 3 #include 4 #include 5 #include 6 using namespace std; 7 8 9 void main() 10 { 11 //红黑树,每一个结点都是一个链表的头结点 12 multiset myset{ 1,2,3,3,3,3,4 };... 阅读全文
posted @ 2018-03-22 22:47 喵小喵~ 阅读(151) 评论(0) 推荐(0)
摘要:1 #include 2 //红黑树(自动保证平衡,自动生成平衡查找树) 3 #include 4 #include 5 #include 6 using namespace std; 7 8 //红黑树增删查改 9 void main1() 10 { 11 set myset{ 1,2,10,3,5 }; 12 myset.insert(14); 1... 阅读全文
posted @ 2018-03-22 22:39 喵小喵~ 阅读(158) 评论(0) 推荐(0)
摘要:1 #include 2 //string的本质也是容器 3 #include 4 #include 5 using namespace std; 6 7 void main() 8 { 9 string str1 = "1234"; 10 string str2 = "345"; 11 string str3 = str1 + str2; 12... 阅读全文
posted @ 2018-03-22 22:24 喵小喵~ 阅读(153) 评论(0) 推荐(0)
摘要:1 #include 2 //位运算,处理二进制非常方便,线性存储 3 #include 4 #include 5 using namespace std; 6 7 void main() 8 { 9 //bitset mybit(255);//1111 1111 10 //for (int i = 7; i >= 0; i--) 11 //{ ... 阅读全文
posted @ 2018-03-22 22:03 喵小喵~ 阅读(129) 评论(0) 推荐(0)
摘要:1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 7 8 void main1() 9 { 10 //优先队列 11 priority_queue myq; 12 myq.push(1); 13 myq.push(2); 14 myq.pu... 阅读全文
posted @ 2018-03-22 21:08 喵小喵~ 阅读(138) 评论(0) 推荐(0)
摘要:1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 using namespace std; 8 9 10 void main() 11 { 12 //默认deque 13 queue myq; 14 //默认链式队列 15 queue> myli... 阅读全文
posted @ 2018-03-22 20:45 喵小喵~ 阅读(114) 评论(0) 推荐(0)
摘要:1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 8 9 void main() 10 { 11 //声明栈,默认是deque(因为删除插入效率比较高) 12 stack mystack; 13 //声明链式栈 14 sta... 阅读全文
posted @ 2018-03-22 19:22 喵小喵~ 阅读(117) 评论(0) 推荐(0)
摘要:1 #include 2 #include 3 #include 4 using namespace std; 5 //序列容器的模板类,可对线性排列中指定类型的元素进行排序,并且和矢量一样, 6 //也允许快速随机访问任何元素和在容器后面高效插入和删除。 7 //deque(双端队列),内存实体是分块数据类型,在堆上(优秀与vector与list) 8 //能快速地增删查... 阅读全文
posted @ 2018-03-22 19:17 喵小喵~ 阅读(131) 评论(0) 推荐(0)
摘要:1 #include 2 #include 3 #include 4 using namespace std; 5 6 //array是栈上的数组,自动回收,不能增删查改 7 8 9 //算法迭代函数 10 void change(int &x) 11 { 12 x += 1; 13 } 14 15 void main() 16 { 17 arra... 阅读全文
posted @ 2018-03-22 18:48 喵小喵~ 阅读(108) 评论(0) 推荐(0)
摘要:代码示例 阅读全文
posted @ 2018-03-22 18:40 喵小喵~ 阅读(120) 评论(0) 推荐(0)
摘要:1 #include 2 #include //类型索引 3 #include //红黑树 4 #include 5 using namespace std; 6 7 class myclass 8 { 9 10 }; 11 12 void main() 13 { 14 //索引与string进行映射 15 unordered_map mytype;/... 阅读全文
posted @ 2018-03-15 22:31 喵小喵~ 阅读(187) 评论(0) 推荐(0)
摘要:创建vector数组 1 vector<int> myint{ 1,2,3,4,5 }; 尾部插入 1 for (int i = 10; i < 20; i++) 2 { 3 myint.push_back(i); 4 5 } 读取头部和尾部 1 cout << myint.front() << e 阅读全文
posted @ 2018-03-12 14:51 喵小喵~ 阅读(303) 评论(0) 推荐(0)
摘要:初始化一个链表 1 list<int> mylist{ 1,2,3,4,6 }; 链表排序 1 mylist.sort(); 链表反转 1 mylist.reverse(); 链表删除头部和尾部 1 mylist.pop_back();//删除尾部 2 mylist.pop_front();//删除 阅读全文
posted @ 2018-02-01 19:00 喵小喵~ 阅读(147) 评论(0) 推荐(0)