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-08-05 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             : #ifdef LB_GCC_4_4_OR_LATER
      26             : #  include <parallel/algorithm>
      27             : #endif
      28             : 
      29             : namespace lunchbox
      30             : {
      31             : /** std::sort using parallel sorting where available @version 1.9.1 */
      32             : #ifdef LB_GCC_4_4_OR_LATER
      33             : using std::__parallel::sort;
      34             : #else
      35             : using std::sort;
      36             : #endif
      37             : 
      38             : /** Find the element in the given vector. @version 1.0 */
      39             : template< typename T > typename std::vector< T >::iterator
      40           0 : find( std::vector< T >& container, const T& element )
      41           0 :     { return std::find( container.begin(), container.end(), element ); }
      42             : 
      43             : /** Find the element in the given vector. @version 1.0 */
      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 ); }
      47             : 
      48             : /** Find the element matching the predicate @version 1.0 */
      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 );}
      52             : 
      53             : /** Find the element matching the predicate @version 1.0 */
      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 );}
      57             : 
      58             : /** Uniquely sort and eliminate duplicates in a container. @version 1.9.1 */
      59             : template< typename C > void usort( C& c )
      60             : {
      61             :     std::sort( c.begin(), c.end( ));
      62             :     c.erase( std::unique( c.begin(), c.end( )), c.end( ));
      63             : }
      64             : 
      65             : }
      66             : 
      67             : #endif // LUNCHBOX_ALGORITHM_H

Generated by: LCOV version 1.10