随笔分类 -  STL Template(C++)

C++ STL模板等
摘要:1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 class Base{ 8 public: 9 int data; 10 Base(int y):data(y){} 11 }; 12 Base *pt(int x){ 13... 阅读全文
posted @ 2017-07-29 10:19 PKICA 阅读(5665) 评论(2) 推荐(0) 编辑
摘要:sort属于C++范畴,在algorithm头文件中,下面直奔主题,给大家一个清晰明了的认识.qsort有C,和C++两个版本. qsort的compare函数原型 //comp ,也就说,如果the first < the second 返回-1,;如果the first > the second 阅读全文
posted @ 2017-04-23 11:12 PKICA 阅读(688) 评论(0) 推荐(0) 编辑
摘要:transform的功能类似于for_each,但是transform,传参数一次拷贝,返回时一次拷贝,不能保证按序执行,而for_each传参使用引用,不需要拷贝,可以保证有序执行。 std::transform Defined in header <algorithm> template< cl 阅读全文
posted @ 2017-04-16 10:52 PKICA 阅读(861) 评论(0) 推荐(0) 编辑
摘要:Output: [5] [7] [7] [5] 5 [5] [7] [7] [5] 5 阅读全文
posted @ 2017-04-06 12:31 PKICA 阅读(288) 评论(0) 推荐(0) 编辑
摘要:Return iterator to lower bound Return iterator to upper bound 阅读全文
posted @ 2017-02-21 16:14 PKICA 阅读(266) 评论(0) 推荐(0) 编辑
摘要:http://blog.csdn.net/lwbeyond/article/details/7313204# 1.底层结构不同:map——>红黑树,unordered_map——>哈希桶 2.使用场景:期望有序则用map,期望效率高则用unordered_map 3.效率:map低——>O(logN 阅读全文
posted @ 2016-09-24 16:49 PKICA 阅读(18) 评论(0) 推荐(0) 编辑
摘要:类tuple与array最本质的区别当数tuple元组元素类型可以不一样,而统一数组array的元素类型必须一样。 本文主要举例: tuple_size Example 123456789101112131415161718192021222324252627 // tuple example #i 阅读全文
posted @ 2015-10-12 20:59 PKICA 阅读(504) 评论(0) 推荐(0) 编辑
摘要:Example 12345678910111213141516171819202122 // vector::data #include <iostream> #include <vector> int main () { std::vector<int> myvector (5); int* p 阅读全文
posted @ 2015-10-07 21:33 PKICA 阅读(11559) 评论(0) 推荐(3) 编辑

点击右上角即可分享
微信分享提示