gather.hppGo to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00014 #ifndef ADOBE_ALGORITHM_GATHER_HPP
00015 #define ADOBE_ALGORITHM_GATHER_HPP
00016
00017 #include <algorithm>
00018
00019 #include <boost/bind.hpp>
00020 #include <boost/range/begin.hpp>
00021 #include <boost/range/end.hpp>
00022
00023
00024
00064
00065
00066 namespace adobe {
00067
00068
00069
00075 template <
00076 typename Iter,
00077 typename Pred>
00078 std::pair<Iter,Iter> gather ( Iter first, Iter last, Iter pivot, Pred pred )
00079 {
00080
00081
00082 return std::make_pair (
00083 std::stable_partition ( first, pivot, !boost::bind ( pred, _1 )),
00084 std::stable_partition ( pivot, last, boost::bind ( pred, _1 )) );
00085 }
00086
00087
00088
00094 template <
00095 typename BidirectionalRange,
00096 typename Pred>
00097 std::pair<
00098 typename boost::range_iterator<BidirectionalRange>::type,
00099 typename boost::range_iterator<BidirectionalRange>::type>
00100 gather (
00101 BidirectionalRange &range,
00102 typename boost::range_iterator<BidirectionalRange>::type pivot,
00103 Pred pred )
00104 {
00105 return adobe::gather ( boost::begin ( range ), pivot, boost::end ( range ), pred );
00106 }
00107
00108
00109
00110 }
00111
00112
00113
00114 #endif
00115
|