74 #ifndef SLIP_STL_ALGO_EXT_HPP
75 #define SLIP_STL_ALGO_EXT_HPP
147 template<
typename _InputIterator,
148 typename _MaskIterator,
149 typename _OutputIterator,
150 typename _UnaryOperation>
153 _MaskIterator mask_first,
154 _OutputIterator result,
155 _UnaryOperation unary_op,
156 typename std::iterator_traits<_MaskIterator>::value_type value=
typename std::iterator_traits<_MaskIterator>::value_type(1))
158 assert(first != last);
159 for ( ; first != last; ++first, ++result, ++mask_first)
161 if(*mask_first == value)
163 *result = unary_op(*first);
234 template<
typename _InputIterator1,
235 typename _InputIterator2,
236 typename _MaskIterator,
237 typename _OutputIterator,
238 typename _BinaryOperation>
241 _MaskIterator mask_first,
242 _InputIterator2 first2,
243 _OutputIterator result,
244 _BinaryOperation binary_op,
245 typename std::iterator_traits<_MaskIterator>::value_type value=
typename std::iterator_traits<_MaskIterator>::value_type(1))
247 assert(first1 != last1);
248 for ( ; first1 != last1; ++first1, ++first2,++result, ++mask_first)
250 if(*mask_first == value)
252 *result = binary_op(*first1, *first2);
303 template<
typename _InputIterator,
304 typename _OutputIterator,
305 typename _UnaryOperation,
309 _OutputIterator result,
310 _UnaryOperation unary_op,
313 assert(first != last);
314 for ( ; first != last; ++first, ++result)
318 *result = unary_op(*first);
372 template<
typename _InputIterator1,
373 typename _InputIterator2,
374 typename _OutputIterator,
375 typename _BinaryOperation,
379 _InputIterator2 first2,
380 _OutputIterator result,
381 _BinaryOperation binary_op,
384 assert(first1 != last1);
385 for ( ; first1 != last1; ++first1, ++first2,++result)
389 *result = binary_op(*first1, *first2);
426 template<
typename _ForwardIterator,
typename _MaskIterator>
429 _ForwardIterator last,
430 _MaskIterator mask_first,
431 typename std::iterator_traits<_MaskIterator>::value_type value=
typename std::iterator_traits<_MaskIterator>::value_type(1))
433 if (first == last)
return first;
434 bool nul_mask =
true;
435 _ForwardIterator result = first;
438 while (++first != last)
440 if(*mask_first == value)
450 return (nul_mask ? last : result);
481 template<
typename _ForwardIterator,
typename Predicate>
486 if (first == last)
return first;
488 while(!pred(*first++)&& first != last)
491 if(first == last)
return last;
493 _ForwardIterator result = first;
494 while (first != last)
496 if(pred(*first) && (*first > *result))
539 template<
typename _ForwardIterator,
typename _MaskIterator,
typename _Compare>
542 _MaskIterator mask_first,_Compare comp,
543 typename std::iterator_traits<_MaskIterator>::value_type value=
typename std::iterator_traits<_MaskIterator>::value_type(1))
545 if (first == last)
return first;
546 bool nul_mask =
true;
547 _ForwardIterator result = first;
550 while (++first != last)
552 if(*mask_first == value)
554 if(comp(*result,*first))
562 return (nul_mask ? last : result);
563 if (first == last)
return first;
601 template<
typename _ForwardIterator,
typename _Compare,
typename Predicate>
604 Predicate pred,_Compare comp)
606 if (first == last)
return first;
608 while(!pred(*first++)&& first != last)
611 if(first == last)
return last;
613 _ForwardIterator result = first;
614 while (first != last)
616 if(pred(*first) && comp(*result,*first))
656 template<
typename _ForwardIterator,
typename _MaskIterator>
659 _MaskIterator mask_first,
660 typename std::iterator_traits<_MaskIterator>::value_type value=
typename std::iterator_traits<_MaskIterator>::value_type(1))
662 if (first == last)
return first;
663 bool nul_mask =
true;
664 _ForwardIterator result = first;
667 while (++first != last)
669 if(*mask_first == value)
679 return (nul_mask ? last : result);
715 template<
typename _ForwardIterator,
typename _MaskIterator,
typename _Compare>
718 _MaskIterator mask_first,_Compare comp,
719 typename std::iterator_traits<_MaskIterator>::value_type value=
typename std::iterator_traits<_MaskIterator>::value_type(1))
752 template<
typename _ForwardIterator,
typename Predicate>
757 if (first == last)
return first;
759 while(!pred(*first++)&& first != last)
762 if(first == last)
return last;
764 _ForwardIterator result = first;
765 while (first != last)
767 if(pred(*first) && (*first < *result))
814 template<
typename _ForwardIterator,
typename _Compare,
typename Predicate>
817 Predicate pred,_Compare comp)
825 #endif //SLIP_STL_ALGO_EXT_HPP
_OutputIterator transform_if(_InputIterator first, _InputIterator last, _OutputIterator result, _UnaryOperation unary_op, _Predicate pred)
Perform an operation on a sequence according to a Predicate.
_OutputIterator transform_mask_bin(_InputIterator1 first1, _InputIterator1 last1, _MaskIterator mask_first, _InputIterator2 first2, _OutputIterator result, _BinaryOperation binary_op, typename std::iterator_traits< _MaskIterator >::value_type value=typename std::iterator_traits< _MaskIterator >::value_type(1))
Perform an operation on corresponding elements of two sequences according to a mask sequence...
_ForwardIterator max_element_if(_ForwardIterator first, _ForwardIterator last, Predicate pred)
Return the maximum element in a range according to a predicate or last if the predicate is never veri...
_ForwardIterator min_element_if_compare(_ForwardIterator first, _ForwardIterator last, Predicate pred, _Compare comp)
Return the minimum element in a range using comparison functor according to a predicate or return las...
_ForwardIterator min_element_mask_compare(_ForwardIterator first, _ForwardIterator last, _MaskIterator mask_first, _Compare comp, typename std::iterator_traits< _MaskIterator >::value_type value=typename std::iterator_traits< _MaskIterator >::value_type(1))
Return the minimum element in a range using comparison functor according to a mask sequence or return...
_ForwardIterator max_element_mask(_ForwardIterator first, _ForwardIterator last, _MaskIterator mask_first, typename std::iterator_traits< _MaskIterator >::value_type value=typename std::iterator_traits< _MaskIterator >::value_type(1))
Return the maximum element in a range according to a mask sequence or return last if no value verify ...
_ForwardIterator min_element_mask(_ForwardIterator first, _ForwardIterator last, _MaskIterator mask_first, typename std::iterator_traits< _MaskIterator >::value_type value=typename std::iterator_traits< _MaskIterator >::value_type(1))
Return the minimum element in a range according to a mask sequence or return last if no value verify ...
_OutputIterator transform_mask_un(_InputIterator first, _InputIterator last, _MaskIterator mask_first, _OutputIterator result, _UnaryOperation unary_op, typename std::iterator_traits< _MaskIterator >::value_type value=typename std::iterator_traits< _MaskIterator >::value_type(1))
Perform an operation on a sequence according to a mask sequence.
_ForwardIterator min_element_if(_ForwardIterator first, _ForwardIterator last, Predicate pred)
Return the minimum element in a range according to a predicate or return last if the predicate is nev...
_ForwardIterator max_element_if_compare(_ForwardIterator first, _ForwardIterator last, Predicate pred, _Compare comp)
Return the maximum element in a range using comparison functor according to a predicate or return las...
_ForwardIterator max_element_mask_compare(_ForwardIterator first, _ForwardIterator last, _MaskIterator mask_first, _Compare comp, typename std::iterator_traits< _MaskIterator >::value_type value=typename std::iterator_traits< _MaskIterator >::value_type(1))
Return the maximum element in a range using comparison functor according to a mask sequence or return...