date: 2020/01/10


http://www.cplusplus.com/reference/algorithm/

http://c.biancheng.net/view/343.html


#include <algorithm> 


vector<int> vec;
sort(vec.begin(), vec.end());

string str;
sort(str.begin(), str.end(), greater<char>());

vector<string> strs;
sort(strs.begin(), strs.end(), [](string a, string b){return a+b<b+a;});

int array[10];
sort(array, array + 10);

list<int> lst;
lst.sort();


// 1. swap函数
int a, b;
swap(a, b);

// 2. 中间变量
int c = b;
a = b;
b = c;

// 3. 异或原位交换
a ^= b;
b ^= a;
a ^= b;

// 容器的swap
vector<int> a, b;
a.swap(b)


int a, b;
int c = min(a, b);


vector<int> vec;
vector<int>::iterator it = min_element(vec.begin(), vec.end());
int value = *it;


vector<int> vec;
reverse(vec.begin(), vec.end());