A
<cstdlib>
abort <numeric>
accumulate <memory>
allocator <array>
array <memory> auto_ptr
B
<iterator>
back_inserter <new>
bad_alloc <new>
bad_array_new_length <typeinfo>
bad_cast <iterator>
begin <random>
bernoulli_distribution <functional>
bind <bitset>
bitset <iostream> boolalpha
C
<iostream>
cerr <iostream>
cin <regex>
cmatch <algorithm>
copy <algorithm>
count <algorithm>
count_if <iostream>
cout <functional>
cref <regex> csub_match
D
<iostream>
dec <iostream>
default_float_engine <random>
default_random_engine <deque>
deque <stdexcept> domain_error
E
<iterator>
end <iostream>
endl <iostream>
ends <algorithm>
equal_range <exception> exception
F
<algorithm>
fill <algorithm>
fill_n <algorithm>
find <algorithm>
find_end <algorithm>
find_first_of <algorithm>
find_if <iostream>
fixed <iostream>
flush <algorithm>
for_each <utility>
forward <forward_list>
forward_list <cstdlib>
free <iterator>
front_inserter <fstream>
fstream <functional> function
G
<tuple>
get <string>
getline <functional> greater
H
<functional>
hash <iostream>
hex <iostream> hexfloat
I
<fstream>
ifstream <initializer_list>
initializer_list <iterator>
inserter <iostream>
internal <iosbase>
ios_base <cctype>
isalpha <cctype>
islower <cctype>
isprint <cctype>
ispunct <cctype>
isspace <iostream>
istream <iterator>
istream_iterator <sstream>
istringstream <cctype> isupper
L
<iostream>
left <functional>
less <functional>
less_equal <list>
list <stdexcept>
logic_error <algorithm>
lower_bound <cmath> lround
M
<iterator>
make_move_iterator <utility>
make_pair <memory>
make_shared <tuple>
make_tuple <cstdlib>
malloc <map>
map <algorithm>
max <algorithm>
max_element <functional>
mem_fn <algorithm>
min <utility>
move <map>
multimap <set> multiset
<functional>
negate <iostream>
noboolalpha <random>
normal_distribution <iostream>
noshowbase <iostream>
noshowpoint <iostream>
noskipws <functional>
not1 <new>
nothrow nothrow_t <new>
<iostream>
nounitbuf <iostream>
nouppercase <algorithm> nth_element
O
<iostream>
oct <fstream>
ofstream <iostream>
ostream <iterator>
ostream_iterator <sstream>
ostringstream <stdexcept> out_of_range
P
<utility>
pair <algorithm>
partial_sort <functional>
placeholders ::_1 <functional>
placeholders<functional>
plus <queue>
priority_queue ptrdiff_t <cstddef>
Q
<queue> queue
R
<random>
rand <random>
random_device <stdexcept>
range_error <functional>
ref <regex>
regex <regex>
regex_constants <regex>
regex_error <regex>
regex_match <regex>
regex_replace <regex>
regex_search <type_traits>
remove_pointer <type_traits>
remove_reference <algorithm>
replace <algorithm>
replace_copy <iterator>
reverse_iterator <iostream>
right <stdexcept> runtime_error
S
<iostream>
scientific <set>
set <algorithm>
set_difference <algorithm>
set_intersection <algorithm>
set_union <iomanip>
setfill <iomanip>
setprecision <iomanip>
setw <memory>
shared_ptr <iostream>
showbase <iostream>
showpoint size_t <cstddef>
<iostream>
skipws <regex>
smatch <algorithm>
sort <cmath>
sqrt <regex>
sregex_iterator <regex>
ssub_match <algorithm>
stable_sort <stack>
stack <string>
stoi <cstring>
strcmp <cstring>
strcpy <string>
string <sstream>
stringstream <cstring>
strlen <cstring>
strncpy <string>
strtod <utility> swap
T
<exception>
terminate <ctime>
time <cctype>
tolower <cctype>
toupper <algorithm>
transform <tuple>
tuple <tuple>
tuple_element <tuple>
tuple_size <typeinfo> type_info
U
<exception>
unexpected <random>
uniform_int_distribution <random>
uniform_real_distribution <memory>
uninitialized_copy <memory>
uninitialized_fill <algorithm>
unique <algorithm>
unique_copy <memory>
unique_ptr <iostream>
unitbuf <unordered_map>
unordered_map <unordered_map>
unordered_multimap <unordered_set>
unordered_multiset <unordered_set>
unordered_set <algorithm>
upper_bound <iostream> uppercase
V
<vector> vector
W
<memory> weak_ptr
在泛型编程中我们接触到了标准库中的算法,指示了解了算法的特性,并没有对其接口深入了解,下面是常见算法的使用方式及其接口
1、beg 和 end 表示元素范围的迭代器,算法对一个由 beg 和 end
表示的序列进行操作
2、beg2,end2 是表示第二个输入序列开始和末尾位置的迭代器如果没有 end2
则表示第二个序列和第一个序列长度相同。beg 和 beg2
的类型可以不匹配,但需要保证对两个序列中的元素都可以执行特定操作或调用给定的可调用对象。
3、dest
表示目的序列的迭代器。对于给定输入序列,算法需要生成多少元素,目的序列必须保证能保存相同多的元素。
4、unaryPred 和 binaryPred
是一元和二元谓词,分别接收一个和两个参数,都是来自输入序列的元素,两个谓词都可以返回可作用条件的类型
5、comp 是一个二元谓词,满足关联容器对关键字虚的要求
6、unaryOp 和 binaryOp
是可调用对象,可分别适用来自输入序列的一个和两个实参来调用
每个算法都提供两个重载,一个版本适用相等运算符比较,第二版本适用提供的 unaryPred 和 binaryPred 比较元素
对于序列中的元素进行排序,排序和划分算法都提供了多种策略,每个排序和划分算法都提供了稳定和不稳定的版本