算法
|
用法 |
說明 |
adjacent_find
|
FwdIt adjacent_find(FwdIt first,FwdIt last);
FwdIt adjacent_find(FwdIt first,FwdIt last,Pred pr);
|
在[first,last)查找相同元素的首次出現(xiàn)或能使pr(elem,nextElem)為true的元素的位置
,函數(shù)查找成功返回位置,失敗返回last
|
binary_search
|
bool binary_search(FwdIt first,FwdIt last,const T& val);
bool binary_search(FwdIt first,FwdIt last,const T& val,Pred pr);
|
在區(qū)間[first,last)中查找元素val,如果找到返回true,否則返回false,第二種形式pr用于設(shè)定查找準(zhǔn)則
|
count
|
size_t count(InIt first,InIt last,const T& val);
|
返回區(qū)間[first,last)上val出現(xiàn)的次數(shù)
|
count_if
|
size_t count_if(InIt first,InIt last,Pred pr);
|
返回區(qū)間[first,last)上滿足條件pr(elem)的元素個(gè)數(shù)
|
equal
|
bool equal(InIt1 first,InIt1 last,InIt2 x);
bool equal(InIt1 first,InIt1 last,InIt2 x,Pred pr);
|
判斷[first,last)與x開始的區(qū)間的元素是否相等,pr用于指定判斷函數(shù)
|
equal
|
pair<FwdIt,FwdIt> equal_range(FwdIt first,FwdIt
last,const T& val);
pair<FwdIt,FwdIt> equal_range(FwdIt first,FwdIt last,const T& val,Pred
pr);
|
返回元素val第一次出現(xiàn)的位置和最后出現(xiàn)的位置的下一位組成的對,pr指定比較算法
|
lower_bound
|
FwdIt lower_bound(FwdIt first,FwdIt last,const T&
val);
FwdIt lower_bound(FwdIt first,FwdIt last,const T& val,Pred pr);
|
返回已排序序列[first,last)中val首次出現(xiàn)的位置,pr指定比較算法
|
upper_bound
|
FwdIt upper_bound(FwdIt first,FwdIt last,const T&
val);
FwdIt upper_bound(FwdIt first,FwdIt last,const T& val,Pred pr);
|
返回已排序序列[first,last)中val最后一次出現(xiàn)的下一個(gè)位置,pr指定比較算法
|
find
|
InIt find(InIt first,InIt last,const T& val);
|
在[first,last)之間查找元素val,如果找到返回位置,找不到返回last
|
find_if
|
InIt find_if(InIt first,InIt last, Pred pr);
|
在[first,last)之間查找能使函數(shù)pr返回true的元素,找到返回位置,否則返回last
|
find_end
|
FwdIt1 find_end(FwdIt1 first1,FwdIt1 last1,FwdIt2 first2,FwdIt2
last2);
FwdIt1 find_end(FwdIt1 first1,FwdIt1 last1,FwdIt2 first2,FwdIt2 last2, Pred
pr);
|
在[first1,last1)之間查找[first2,last2)最后出現(xiàn)的位置,如果找到返回位置,失敗返回last1,第二個(gè)函數(shù)的pr函數(shù)用于比較兩個(gè)容器的元素,在兩個(gè)容器的元素相等時(shí)返回true
|
find_first_of
|
FwdIt1 find_first_of(FwdIt1 first1,FwdIt1 last1,FwdIt2 first2,FwdIt2
last2);
FwdIt1 find_first_of(FwdIt1 first1,FwdIt1 last1,FwdIt2 first2,FwdIt2 last2, Pred pr);
|
在[first1,last1)之間查找第一次出現(xiàn)[first2,last2)中元素的位置,找到返回位置,失敗返回last1,第二個(gè)函數(shù)pr用于比較兩個(gè)容器的元素是否相等
|
for_each
|
Fun for_each(InIt first,InIt last, Fun f);
|
對[first,last)上的所有元素執(zhí)行函數(shù)f(elem),返回值常被忽略
|
includes
|
bool includes(InIt1 first1,InIt1 last1,InIt2 first2,InIt2 last2);
bool includes(InIt1 first1,InIt1 last1,InIt2 first2,InIt2 last2, Pred pr);
|
判斷已排序序列[first1,last1)中是否包含區(qū)間已排序區(qū)間[first2,last2),pr指定元素的順序
|
mismatch
|
pair<InIt1,InIt2> mismatch(InIt1 first,InIt1
last,InIt2 x);
pair<InIt1,InIt2> mismatch(InIt1 first,InIt1 last,InIt2 x, Pred pr);
|
返回序列[first,last)與x開始的序列第一個(gè)不匹配的位置的兩個(gè)迭代器組成的對
|
max
|
const T& max(const T& x,const T& y);
const T& max(const T& x,const T& y, Pred pr);
|
返回x,y之間的較大者,pr(elem1,elem2)用于指定比較規(guī)則
|
max_element
|
FwdIt max_element(FwdIt first,FwdIt last);
FwdIt max_element(FwdIt first,FwdIt last, Pred pr);
|
返回區(qū)間[first,last)上最大值的位置,pr(elem1,elem2)用于指定比較規(guī)則
|
min
|
const T& min(const T& x,const T& y);
const T& min(const T& x,const T& y, Pred pr);
|
返回x,y之間的較小者,pr(elem1,elem2)用于指定比較規(guī)則
|
min_element
|
FwdIt min_element(FwdIt first,FwdIt last);
FwdIt min_element(FwdIt first,FwdIt last, Pred pr);
|
返回區(qū)間[first,last)上的最小值的位置,pr(elem1,elem2)用于指定比較規(guī)則
|
search
|
FwdIt1 search(FwdIt1 first1,FwdIt1 last1,FwdIt2 first2,FwdIt2 last2);
FwdIt1 search(FwdIt1 first1,FwdIt1 last1,FwdIt2 first2,FwdIt2 last2, Pred pr);
|
在[first1,last1)中查找子區(qū)間[first2,last2),如果找到返回在第一個(gè)區(qū)間中的位置,失敗返回last1,第二種形式pr函數(shù)用于設(shè)定比較函數(shù)
|
search_n
|
FwdIt search_n(FwdIt first,FwdIt last,Dist n,const T& val);
FwdIt search_n(FwdIt first,FwdIt last,Dist n,const T& val, Pred pr);
|
在[first,last)中查找連續(xù)n個(gè)val,如果找到返回在區(qū)間中的位置,失敗返回last,第二種形式pr用于設(shè)定比較函數(shù)
|