LCOV - code coverage report
Current view: top level - lunchbox - algorithm.h (source / functions) Hit Total Coverage
Test: lcov2.info Lines: 0 2 0.0 %
Date: 2014-10-01 Functions: 0 1 0.0 %

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2013, Stefan.Eilemann@epfl.ch
       3             :  *
       4             :  * This library is free software; you can redistribute it and/or modify it under
       5             :  * the terms of the GNU Lesser General Public License version 2.1 as published
       6             :  * by the Free Software Foundation.
       7             :  *
       8             :  * This library is distributed in the hope that it will be useful, but WITHOUT
       9             :  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
      10             :  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
      11             :  * details.
      12             :  *
      13             :  * You should have received a copy of the GNU Lesser General Public License
      14             :  * along with this library; if not, write to the Free Software Foundation, Inc.,
      15             :  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
      16             :  */
      17             : 
      18             : #ifndef LUNCHBOX_ALGORITHM_H
      19             : #define LUNCHBOX_ALGORITHM_H
      20             : 
      21             : #include <lunchbox/compiler.h>
      22             : #include <algorithm>
      23             : #include <vector>
      24             : 
      25             : #ifndef __MINGW32__ // MinGW does not provide the header
      26             : #  ifdef LB_GCC_4_4_OR_LATER
      27             : #    include <parallel/algorithm>
      28             : #    define LB_USE_STD_PARALLEL
      29             : #  endif
      30             : #endif
      31             : 
      32             : namespace lunchbox
      33             : {
      34             : /** std::sort using parallel sorting where available @version 1.9.1 */
      35             : #ifdef LB_USE_STD_PARALLEL
      36             : using std::__parallel::sort;
      37             : #else
      38             : using std::sort;
      39             : #endif
      40             : 
      41             : /** Find the element in the given vector. @version 1.0 */
      42             : template< typename T > typename std::vector< T >::iterator
      43           0 : find( std::vector< T >& container, const T& element )
      44           0 :     { return std::find( container.begin(), container.end(), element ); }
      45             : 
      46             : /** Find the element in the given vector. @version 1.0 */
      47             : template< typename T > typename std::vector< T >::const_iterator
      48             : find( const std::vector< T >& container, const T& element )
      49             :     { return std::find( container.begin(), container.end(), element ); }
      50             : 
      51             : /** Find the element matching the predicate @version 1.0 */
      52             : template< typename T, typename P > typename std::vector< T >::iterator
      53             : find_if( std::vector< T >& container, const P& predicate )
      54             :     { return std::find_if( container.begin(), container.end(), predicate );}
      55             : 
      56             : /** Find the element matching the predicate @version 1.0 */
      57             : template< typename T, typename P > typename std::vector<T>::const_iterator
      58             : find_if( std::vector< const T >& container, const P& predicate )
      59             :     { return std::find_if( container.begin(), container.end(), predicate );}
      60             : 
      61             : /** Uniquely sort and eliminate duplicates in a container. @version 1.9.1 */
      62             : template< typename C > void usort( C& c )
      63             : {
      64             :     std::sort( c.begin(), c.end( ));
      65             :     c.erase( std::unique( c.begin(), c.end( )), c.end( ));
      66             : }
      67             : 
      68             : }
      69             : 
      70             : #endif // LUNCHBOX_ALGORITHM_H

Generated by: LCOV version 1.10