02 2021 档案
摘要:std::map的实现 template <typename Pair> struct Select1st_ { const typename Pair::first_type& operator()(const Pair& x) const { return x.first; } }; templ
阅读全文
摘要:1、概念: 标准库的std::map、std::mulitmap、std::set、 std::multiset统称为关联式容器,其底层数据结构是基于红黑树实现的。 红黑树作为一种二叉树,满足以下规则: 1)每个节点不是红色就是黑色 2)根节点为黑色 3)如果节点为红色,其子节点必须为黑色 4)任何
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要:c++11之前,标准库里的哈希容器是std::hash_set、std::hash_multiset、std::hash_map、std::hash_multisetmap; c++11之后,他们的名字改成了std::unorder_set、std::unorder_multiset、std::un
阅读全文
摘要:valgrind是很好的检查内存泄漏的工具 使用命令: $ valgrind --tool=memcheck --log-file=/root/valgrind_log_all --leak-check=full --error-limit=no --show-reachable=yes --tra
阅读全文
摘要:void Printf(const char* s) { while (*s) { std::cout << *s++; } } template <typename T, typename... Types> void Printf(const char* s, const T& firstArg
阅读全文
摘要:std::bitset<size_t size> 1、bitset提供了位操作,模板参数就是位的个数; 2、其内部数据结构是long数组,一个long可以表示32位,所以避免浪费,最好取32的倍数 3、bitset提供转std::string的接口,其构造函数入参也支持std::string, 需要
阅读全文

浙公网安备 33010602011771号