1. STL常見非變異算法
2. STL常見變異算法
2.1 Copy - 對數據的各類拷貝
2.2 Swap - 對數據內容的交換
2.3 Transform - 對兩組數據之間進行運算
2.4 Replace - 兩組數據之間的內容進行替換
2.5 Fill和Generate - 初始化時進行填充
2.6 Remove - 根據判別條件去掉某些數據
2.7 排序算法
2.7.1 sort
- 特殊數據需要重新定義運算符
operator<
2.7.2 partial_sort
- 對部分數據排序
2.7.3 binary_search
- 先sort,再使二叉樹搜索
2.7.4 merge
- 先sort,再將兩組數據merge
2.7.5 include
- 先sort,再查找兩組數據中元素包含的情況(重復數據的次數也考慮在內)
2.7.6
2.8 基于heap的算法
2.8.1 make_heap
- 構造一個二叉樹,父節點>子節點
2.8.2 push_heap
- 添加一個新的節點,并根據需要重構二叉樹
2.8.3 pop_heap
- 剔除特定節點,并根據需要重構二叉樹。
2.8.4 sort_heap
- 從小到大得到二叉樹中的節點數值
2.9 泛型數值算法
include <numeric>
2.9.1 accumulate
2.9.2 inner_product
2.9.3 paritial_sum
2.9.4 adjacent_difference
3. Traits的使用
By convention, traits are always implemented as structs. Another convention is that the structs used to implement traits are knows as trait classes.