会员
周边
新闻
博问
闪存
赞助商
YouClaw
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
ho966
博客园
首页
新随笔
联系
订阅
管理
上一页
1
···
4
5
6
7
8
9
10
11
12
13
下一页
2021年2月27日
rb_tree红黑树
摘要: 1、概念: 标准库的std::map、std::mulitmap、std::set、 std::multiset统称为关联式容器,其底层数据结构是基于红黑树实现的。 红黑树作为一种二叉树,满足以下规则: 1)每个节点不是红色就是黑色 2)根节点为黑色 3)如果节点为红色,其子节点必须为黑色 4)任何
阅读全文
posted @ 2021-02-27 16:02 ho966
阅读(161)
评论(0)
推荐(0)
2021年2月25日
hash_set和hash_multiset
摘要: 1 #include "MyHashTable.h" 2 template <typename Tp> 3 struct Identity 4 { 5 const Tp& operator()(const Tp& x) const { return x; } 6 }; 7 template <typ
阅读全文
posted @ 2021-02-25 20:43 ho966
阅读(82)
评论(0)
推荐(0)
hash_map和hash_multimap
摘要: hash_map 1 template <class Pair> 2 struct Select1st 3 { 4 const typename Pair::first_type& operator()(const Pair& x) const 5 { 6 return x.first; 7 } 8
阅读全文
posted @ 2021-02-25 20:42 ho966
阅读(168)
评论(0)
推荐(0)
hash_table
摘要: c++11之前,标准库里的哈希容器是std::hash_set、std::hash_multiset、std::hash_map、std::hash_multisetmap; c++11之后,他们的名字改成了std::unorder_set、std::unorder_multiset、std::un
阅读全文
posted @ 2021-02-25 20:40 ho966
阅读(136)
评论(0)
推荐(0)
2021年2月18日
valgrind的局限性
摘要: valgrind是很好的检查内存泄漏的工具 使用命令: $ valgrind --tool=memcheck --log-file=/root/valgrind_log_all --leak-check=full --error-limit=no --show-reachable=yes --tra
阅读全文
posted @ 2021-02-18 11:29 ho966
阅读(258)
评论(0)
推荐(0)
2021年2月5日
利用模板变参实现简单的printf
摘要: void Printf(const char* s) { while (*s) { std::cout << *s++; } } template <typename T, typename... Types> void Printf(const char* s, const T& firstArg
阅读全文
posted @ 2021-02-05 13:02 ho966
阅读(152)
评论(0)
推荐(0)
2021年2月3日
std::bitset
摘要: std::bitset<size_t size> 1、bitset提供了位操作,模板参数就是位的个数; 2、其内部数据结构是long数组,一个long可以表示32位,所以避免浪费,最好取32的倍数 3、bitset提供转std::string的接口,其构造函数入参也支持std::string, 需要
阅读全文
posted @ 2021-02-03 11:30 ho966
阅读(435)
评论(0)
推荐(0)
2021年1月30日
关键字
摘要: 1、noexcept 告知编译器不会丢出异常异常,可以放心优化。对于std::vetcor,其申请新申请内存成长时,元素的移植构造函数必须有noexcept关键字,否则只会调用拷贝构造 用法: void foo() noexcept {} 2、override 告知编译器该函数是继承父类函数的,编译
阅读全文
posted @ 2021-01-30 14:56 ho966
阅读(74)
评论(0)
推荐(0)
类型别名Type Alias
摘要: 以前定义一个类型都是用typedef, 例如一个函数指针的类型 typedef void(*func)(void) c++新特性支持下面这样去定义,效果一样 using func = void(*)(void)
阅读全文
posted @ 2021-01-30 14:12 ho966
阅读(118)
评论(0)
推荐(0)
c++智能指针shared_ptr、weak_ptr、unique_ptr
摘要: 使用c++智能指针需要包含头文件<memory>,对于SGI版本的STL, shared_ptr、weak_ptr实现在<bits/shared_ptr.h>中,unique_ptr实现在<bits/unique_ptr.h>中 1、 shared_ptr 作用:通过应用计数实现自动释放指针,用户不
阅读全文
posted @ 2021-01-30 11:02 ho966
阅读(256)
评论(0)
推荐(0)
上一页
1
···
4
5
6
7
8
9
10
11
12
13
下一页
公告