4#ifndef _H_FACILITES_UTILITY
5#define _H_FACILITIES_UTILITY
19template <
class FwdIt,
class UniPred,
class BinPred>
20inline std::pair<FwdIt, FwdIt>
adjacent_find_if (
const FwdIt& first,
const FwdIt& last, UniPred if_pred, BinPred adj_pred )
22 FwdIt i = std::find_if( first, last, if_pred );
24 if (i != last) i = std::find_if( ++i, last, if_pred );
26 if (adj_pred ( (*j), (*i) ))
return std::make_pair(j,i);
28 while (!(if_pred(*i)) && (i != last)) ++i;
30 return std::make_pair(last, last);
33template <
class FwdIt,
class UniPred,
class BinPred>
45 std::vector<FwdIt> itvec;
46 std::pair<FwdIt, FwdIt> adjpr1 =
adjacent_find_if( first, last, if_pred, adj_pred );
47 if (adjpr1.second == last)
return itvec;
49 itvec.push_back( adjpr1.first);
50 itvec.push_back( adjpr1.second );
51 std::pair<FwdIt, FwdIt> adjpr2;
53 while ((itvec.size() < N) && (adjpr1.second != last)) {
55 if (adjpr2.second == last)
return std::vector<FwdIt>();
56 if (adj_pred((*adjpr1.second), (*adjpr2.second))) itvec.push_back(adjpr2.second);
59 itvec.push_back(adjpr2.first);
60 itvec.push_back(adjpr2.second);
62 adjpr1.second = adjpr2.second;
std::vector< FwdIt > adjacent_find_multiple(const FwdIt &first, const FwdIt &last, UniPred if_pred, BinPred adj_pred, unsigned N=2)
std::pair< FwdIt, FwdIt > adjacent_find_if(const FwdIt &first, const FwdIt &last, UniPred if_pred, BinPred adj_pred)