Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00031
00044 template<typename InputIterator, typename UnaryFunction>
00045 UnaryFunction claw::inplace_for_each
00046 ( InputIterator first, InputIterator last, UnaryFunction f )
00047 {
00048 for (; first!=last; ++first)
00049 f(*first);
00050
00051 return f;
00052 }
00053
00054
00067 template<typename ForwardIterator1, typename ForwardIterator2>
00068 ForwardIterator1 claw::find_first_not_of
00069 ( ForwardIterator1 first1, ForwardIterator1 last1,
00070 ForwardIterator2 first2, ForwardIterator2 last2 )
00071 {
00072 for ( ; first1!=last1; ++first1 )
00073 {
00074 bool found(false);
00075 for ( ForwardIterator2 it(first2); !found && (it!=last2); ++it )
00076 found = *first1 == *it;
00077
00078 if (!found)
00079 return first1;
00080 }
00081
00082 return last1;
00083 }
00084
00085
00111 template<typename ForwardIterator1, typename ForwardIterator2,
00112 typename ForwardIterator3>
00113 std::size_t claw::replace
00114 ( ForwardIterator1 first, ForwardIterator1 last,
00115 ForwardIterator2 e1_first, ForwardIterator2 e1_last,
00116 ForwardIterator3 e2_first, ForwardIterator3 e2_last )
00117 {
00118 if ( (e1_first == e1_last) || (e2_first == e2_last) )
00119 return 0;
00120
00121 std::size_t count(0);
00122
00123 for ( ; first != last; ++first )
00124 {
00125 bool stop(false);
00126 ForwardIterator3 r(e2_first);
00127
00128 for (ForwardIterator2 it=e1_first; !stop && (it!=e1_last); ++it)
00129 {
00130 if ( *first == *it )
00131 {
00132 *first = *r;
00133 ++count;
00134 stop = true;
00135 }
00136 else
00137 {
00138 ForwardIterator3 n=r;
00139 ++n;
00140 if (n!=e2_last)
00141 r = n;
00142 }
00143 }
00144 }
00145
00146 return count;
00147 }