C++之Effective STL学习笔记Item14】的更多相关文章

使用reserve来避免不必要的重新分配! The reserve member function allows you to minimize the number ofreallocations that must be performed, thus avoiding the costs of reallocationand iterator/pointer/reference invalidation. 使用size函数获取容器中的元素个数,使用capacity函数获取容器已分配的内容可…
Effective STL 学习笔记 39 ~ 41 */--> div.org-src-container { font-size: 85%; font-family: monospace; } pre.src { background-color:#2e3436; color:#fefffe; } p {font-size: 15px} li {font-size: 15px} Table of Contents Make Predicate pure Function Make Funct…
Effective STL 学习笔记 Item 38 : Design functor classes for pass-by-value */--> div.org-src-container { font-size: 85%; font-family: monospace; } pre.src { background-color:#f8f4d7 } p {font-size: 15px} li {font-size: 15px} 严格来讲, C 和 C++ 都不支持将函数作为参数,真正作为…
Effective STL 学习笔记 Item 34: 了解哪些算法希望输入有序数据 */--> div.org-src-container { font-size: 85%; font-family: monospace; } pre.src { background-color:#f8f4d7 } p {font-size: 15px} li {font-size: 15px} 有些个算法对有序的和无序的数据都能应用,但多数情况下,他们在输入数据有序时才最有用. 下列算法要求输入数据必须有序…
Effective STL 学习笔记 32 ~ 33 */--> div.org-src-container { font-size: 85%; font-family: monospace; } pre.src { background-color:#f8f4d7 } p {font-size: 15px} li {font-size: 15px} Table of Contents 记得 Remove 后要 Erase remove, container, pointer 1 记得 Remo…
Effective STL 学习笔记 31:排序算法 */--> div.org-src-container { font-size: 85%; font-family: monospace; } pre.src { background-color:#f8f4d7 } p {font-size: 15px} li {font-size: 15px} Table of Contents partial_sort nth_element stability partition 总结 1 parti…
Effective STL 学习笔记 Item 30: 保证目标区间足够大 */--> div.org-src-container { font-size: 85%; font-family: monospace; } p {font-size: 15px} li {font-size: 14px} Table of Contents 1. 容器区间与算法 2. back_inserter 3. front_inserter 4. inserter 5. inserter & reserve…
Effective STL 学习笔记 Item 26: Prefer Iterator to reverse_iterator and const_rever_itertor */--> div.org-src-container { font-size: 85%; font-family: monospace; } Table of Contents 1. Iterator 的类型 2. 迭代器之间的转换 3. Iterator is Special 4. 总结: 1 Iterator 的类型…
Effective STL 学习笔记: Item 22 ~ 24 */--> div.org-src-container { font-size: 85%; font-family: monospace; } Table of Contents 1. 避免 \(set \& multiset\) 在原位改变 Key 2. Consider replacing associative containers with sorted vectors 3. Choose carefully betw…
Effective STL 学习笔记 Item 21:Comparison Function 相关 */--> div.org-src-container { font-size: 85%; font-family: monospace; } Table of Contents 1. Always have comparison functions return false for equal values 2. Strict Weak Ordering 1 Always have compar…