33 #ifndef _GLIBCXX_PROFILE_PROFILER_ALGOS_H
34 #define _GLIBCXX_PROFILE_PROFILER_ALGOS_H 1
36 namespace __gnu_profile
39 template<
typename _Container>
41 __insert_top_n(_Container& __output,
42 const typename _Container::value_type& __value,
43 typename _Container::size_type __n)
45 typename _Container::iterator __it = __output.begin();
46 typename _Container::size_type __count = 0;
56 if (__it == __output.end())
66 __output.insert(__it, __value);
70 template<
typename _Container>
72 __top_n(
const _Container& __input, _Container& __output,
73 typename _Container::size_type __n)
76 typename _Container::const_iterator __it;
77 for (__it = __input.begin(); __it != __input.end(); ++__it)
78 __insert_top_n(__output, *__it, __n);
82 template<
typename _InputIterator,
typename _Function>
84 __for_each(_InputIterator __first, _InputIterator __last, _Function __f)
86 for (; __first != __last; ++__first)
92 template<
typename _ForwardIterator,
typename _Tp>
94 __remove(_ForwardIterator __first, _ForwardIterator __last,
99 _ForwardIterator __result = __first;
101 for(; __first != __last; ++__first)
102 if(!(*__first == __value))
104 *__result = *__first;