Xyst test code coverage report
Current view: top level - Inciter/AMR - active_element_store.hpp (source / functions) Coverage Total Hit
Commit: 1fb74642dd9d7732b67f32dec2f2762e238d3fa7 Lines: 100.0 % 12 12
Test Date: 2025-08-13 22:46:33 Functions: 100.0 % 4 4
Legend: Lines:     hit not hit
Branches: + taken - not taken # not executed
Branches: 66.7 % 6 4

             Branch data     Line data    Source code
       1                 :             : #ifndef AMR_active_element_store_h
       2                 :             : #define AMR_active_element_store_h
       3                 :             : 
       4                 :             : #include <set>
       5                 :             : #include <cassert>
       6                 :             : 
       7                 :             : namespace AMR {
       8                 :             : 
       9                 :             :     class active_element_store_t {
      10                 :             :         private:
      11                 :             :             std::set<size_t> active_elements;
      12                 :             :         public:
      13                 :             : 
      14                 :             :             //! Non-const-ref access to state
      15                 :       13616 :             std::set<size_t>& data() { return active_elements; }
      16                 :             : 
      17                 :             :             /**
      18                 :             :              * @brief Function to add active elements
      19                 :             :              *
      20                 :             :              * @param id The master_id this should map to
      21                 :             :              */
      22                 :     1206885 :             void add(size_t id)
      23                 :             :             {
      24                 :             :                 // Check if that active element already exists
      25                 :             :                 // cppcheck-suppress assertWithSideEffect
      26         [ -  + ]:     1206885 :                 assert( !exists(id) );
      27                 :     1206885 :                 active_elements.insert(id);
      28                 :     1206885 :             }
      29                 :             : 
      30                 :       62945 :             void erase(size_t id)
      31                 :             :             {
      32                 :       62945 :                 active_elements.erase(id);
      33                 :       62945 :             }
      34                 :             : 
      35                 :             :             /**
      36                 :             :              * @brief function to check if an active element exists in the
      37                 :             :              * active_elements store
      38                 :             :              *
      39                 :             :              * @param id The id of the element to check
      40                 :             :              *
      41                 :             :              * @return A bool for if the element was found or no
      42                 :             :              */
      43                 :     2905214 :             bool exists(size_t id) const
      44                 :             :             {
      45 [ +  - ][ +  + ]:     2905214 :                 if (active_elements.find(id) != active_elements.end())
      46                 :             :                 {
      47                 :     1500706 :                     return true;
      48                 :             :                 }
      49                 :     1404508 :                 return false;
      50                 :             :             }
      51                 :             : 
      52                 :             :             void replace(size_t old_id, size_t new_id)
      53                 :             :             {
      54                 :             :                 erase(old_id);
      55                 :             :                 add(new_id);
      56                 :             :             }
      57                 :             :     };
      58                 :             : }
      59                 :             : 
      60                 :             : #endif // guard
        

Generated by: LCOV version 2.0-1