-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathC++ STL.txt
41 lines (41 loc) · 1.01 KB
/
C++ STL.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
C++ stl
sort(v.begin(),v.end)
binary_search(a,a+10,2) returns bool value
reverse(v.begin(),v.end())
*max_element(v.bein(),v.end())
* min_element
accumulate(v.begin(),v.end()) summation of vector
count(v.begin(),v end(),x) count occurence of x
find(v.begin(),v.end(),x)
lower_bound(v.begin(),v.end(),x) immediate less than x in v
upper_bound
v.erase(v.begin+1)
v.erase(unique(v.begin(),v.end()),v.end()) remove duplicate
next_permutation(v.begin(),v.end())
prev_permutation
distance(v.begin(),v.end())
all_of
any_of
none_of
copy_n
iota()
is_partition
partition(v.begin(),v.end(),[](int x){
return x%2==0;
});
stable_partition(beg,end,cond)
partition_point(beg,end,cond)
newv = v.apply([](int x){ return x=x+5})
v.sum()
v.min()
v.max()
newv=v.shift(2)
v.cshift(2) circlatory shift
v1.swap(v2)
_builtin_popcount(x) no. of setbits in an integer
returns int
_builtin_popcountl(x) long
_builtin_poocountll(x) long long
_builtin_parity(x) return true for odd parity
_builtin_clz(x) count leading zeros
_builtin_ctz(x) count trailing zeros