Quinoa all test code coverage report
Current view: top level - Base - Flip_map.hpp (source / functions) Hit Total Coverage
Commit: -128-NOTFOUND Lines: 5 5 100.0 %
Date: 2024-04-29 14:42:33 Functions: 2 2 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 2 4 50.0 %

           Branch data     Line data    Source code
       1                 :            : // *****************************************************************************
       2                 :            : /*!
       3                 :            :   \file      src/Base/Flip_map.hpp
       4                 :            :   \copyright 2012-2015 J. Bakosi,
       5                 :            :              2016-2018 Los Alamos National Security, LLC.,
       6                 :            :              2019-2021 Triad National Security, LLC.
       7                 :            :              All rights reserved. See the LICENSE file for details.
       8                 :            :   \brief     Flip a std::map yielding a multimap sorted by std::map::value_type
       9                 :            :   \details   Flip a std::map yielding a multimap sorted by std::map::value_type.
      10                 :            :     Credit goes to Oli Charlesworth: http://stackoverflow.com/a/5056797
      11                 :            : */
      12                 :            : // *****************************************************************************
      13                 :            : #ifndef Flip_map_h
      14                 :            : #define Flip_map_h
      15                 :            : 
      16                 :            : namespace tk {
      17                 :            : 
      18                 :            : //! Flip a std::pair of arbitrary types
      19                 :            : //! \param[in] p std::pair of arbitrary types, A and B
      20                 :            : //! \return std::pair of arbitrary types, B and A
      21                 :            : template< typename A, typename B >
      22                 :          3 : std::pair< B, A > flip_pair( const std::pair< A ,B >& p )
      23                 :          3 : { return std::pair< B, A >( p.second, p.first ); }
      24                 :            : 
      25                 :            : //! Flip a std::map of arbitrary types, yielding a std::multimap sorted by
      26                 :            : //! std::map::value_type.
      27                 :            : //! \param[in] src std::map of arbitrary key and value pairs of types A and B
      28                 :            : //! \return std::multimap of arbitrary key and value pairs of types B and A
      29                 :            : template< typename A, typename B >
      30         [ +  - ]:          1 : std::multimap< B, A > flip_map( const std::map< A, B >& src ) {
      31                 :            :   std::multimap< B, A > dst;
      32         [ +  - ]:          1 :   std::transform( src.begin(), src.end(), std::inserter(dst, dst.begin()), 
      33                 :            :                   flip_pair< A ,B > );
      34                 :          1 :   return dst;
      35                 :            : }
      36                 :            : 
      37                 :            : } // tk::
      38                 :            : 
      39                 :            : #endif // Flip_map_h

Generated by: LCOV version 1.14