LCOV - code coverage report
Current view: top level - data/include/mcrl2/data/detail - data_sequence_algorithm.h (source / functions) Hit Total Coverage
Test: mcrl2_coverage.info.cleaned Lines: 9 9 100.0 %
Date: 2024-03-08 02:52:28 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : // Author(s): Wieger Wesselink
       2             : // Copyright: see the accompanying file COPYING or copy at
       3             : // https://github.com/mCRL2org/mCRL2/blob/master/COPYING
       4             : //
       5             : // Distributed under the Boost Software License, Version 1.0.
       6             : // (See accompanying file LICENSE_1_0.txt or copy at
       7             : // http://www.boost.org/LICENSE_1_0.txt)
       8             : //
       9             : /// \file mcrl2/data/detail/data_sequence_algorithm.h
      10             : /// \brief add your file description here.
      11             : 
      12             : #ifndef MCRL2_DATA_DETAIL_DATA_SEQUENCE_ALGORITHM_H
      13             : #define MCRL2_DATA_DETAIL_DATA_SEQUENCE_ALGORITHM_H
      14             : 
      15             : #include "mcrl2/data/variable.h"
      16             : 
      17             : namespace mcrl2
      18             : {
      19             : 
      20             : namespace data
      21             : {
      22             : 
      23             : namespace detail
      24             : {
      25             : 
      26             : /// \brief Returns the intersection of two unordered sets, that are stored in ATerm lists.
      27             : /// \param x A sequence of data variables
      28             : /// \param y A sequence of data variables
      29             : /// \return The intersection of two sets.
      30             : inline
      31         504 : variable_list set_intersection(const variable_list& x, const variable_list& y)
      32             : {
      33         504 :   if (x == y)
      34             :   {
      35          69 :     return x;
      36             :   }
      37             : 
      38         435 :   std::vector<variable> result;
      39         877 :   for (const variable& v: x)
      40             :   {
      41         442 :     if (std::find(y.begin(), y.end(), v) != y.end())
      42             :     {
      43         326 :       result.push_back(v);
      44             :     }
      45             :   }
      46         435 :   return variable_list(result.begin(), result.end());
      47         435 : }
      48             : 
      49             : /// \brief Returns the difference of two unordered sets, that are stored in aterm lists.
      50             : /// \param x A sequence of data variables
      51             : /// \param y A sequence of data variables
      52             : /// \return The difference of two sets.
      53             : inline
      54             : variable_list set_difference(const variable_list& x, const variable_list& y)
      55             : {
      56             :   if (x == y)
      57             :   {
      58             :     return variable_list();
      59             :   }
      60             : 
      61             :   std::vector<variable> result;
      62             :   for (const variable& v: x)
      63             :   {
      64             :     if (std::find(y.begin(), y.end(), v) == y.end())
      65             :     {
      66             :       result.push_back(v);
      67             :     }
      68             :   }
      69             :   return variable_list(result.begin(), result.end());
      70             : }
      71             : 
      72             : } // namespace detail
      73             : 
      74             : } // namespace data
      75             : 
      76             : } // namespace mcrl2
      77             : 
      78             : #endif // MCRL2_DATA_DETAIL_DATA_SEQUENCE_ALGORITHM_H

Generated by: LCOV version 1.14