Algorithm.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00012 #ifndef ZYPP_BASE_ALGORITHM_H
00013 #define ZYPP_BASE_ALGORITHM_H
00014
00015 #include <algorithm>
00016
00018 namespace zypp
00019 {
00020
00029 template <class _Iterator, class _Filter, class _Function>
00030 inline int invokeOnEach( _Iterator begin_r, _Iterator end_r,
00031 _Filter filter_r,
00032 _Function fnc_r )
00033 {
00034 int cnt = 0;
00035 for ( _Iterator it = begin_r; it != end_r; ++it )
00036 {
00037 if ( filter_r( *it ) )
00038 {
00039 ++cnt;
00040 if ( ! fnc_r( *it ) )
00041 return -cnt;
00042 }
00043 }
00044 return cnt;
00045 }
00046
00055 template <class _Iterator, class _Function>
00056 inline int invokeOnEach( _Iterator begin_r, _Iterator end_r,
00057 _Function fnc_r )
00058 {
00059 int cnt = 0;
00060 for ( _Iterator it = begin_r; it != end_r; ++it )
00061 {
00062 ++cnt;
00063 if ( ! fnc_r( *it ) )
00064 return -cnt;
00065 }
00066 return cnt;
00067 }
00068
00070 }
00072 #endif // ZYPP_BASE_ALGORITHM_H