18 #ifndef LUNCHBOX_ALGORITHM_H
19 #define LUNCHBOX_ALGORITHM_H
21 #include <lunchbox/compiler.h>
25 #ifdef LB_GCC_4_4_OR_LATER
26 # include <parallel/algorithm>
32 #ifdef LB_GCC_4_4_OR_LATER
33 using std::__parallel::sort;
39 template<
typename T >
typename std::vector< T >::iterator
40 find( std::vector< T >& container,
const T& element )
41 {
return std::find( container.begin(), container.end(), element ); }
44 template<
typename T >
typename std::vector< T >::const_iterator
45 find(
const std::vector< T >& container,
const T& element )
46 {
return std::find( container.begin(), container.end(), element ); }
49 template<
typename T,
typename P >
typename std::vector< T >::iterator
50 find_if( std::vector< T >& container,
const P& predicate )
51 {
return std::find_if( container.begin(), container.end(), predicate );}
54 template<
typename T,
typename P >
typename std::vector<T>::const_iterator
55 find_if( std::vector< const T >& container,
const P& predicate )
56 {
return std::find_if( container.begin(), container.end(), predicate );}
59 template<
typename C >
void usort( C& c )
61 std::sort( c.begin(), c.end( ));
62 c.erase( std::unique( c.begin(), c.end( )), c.end( ));
67 #endif // LUNCHBOX_ALGORITHM_H
std::vector< T >::iterator find_if(std::vector< T > &container, const P &predicate)
Find the element matching the predicate.
std::vector< T >::iterator find(std::vector< T > &container, const T &element)
Find the element in the given vector.
void usort(C &c)
Uniquely sort and eliminate duplicates in a container.