1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#ifndef AMR_active_element_store_h
#define AMR_active_element_store_h

#include <set><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <cassert><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.

namespace AMR {

    class active_element_store_t {
        private:
            std::set<size_t> active_elements;
        public:

            //! Non-const-ref access to state
            std::set<size_t>& data() { return active_elements; }

            /**
             * @brief Function to add active elements
             *
             * @param id The master_id this should map to
             */
            void add(size_t id)
            {
                // Check if that active element already exists
                // cppcheck-suppress assertWithSideEffect
                assert( !exists(id) );
                active_elements.insert(id);
            }

            void erase(size_t id)
            {
                active_elements.erase(id);
            }

            /**
             * @brief function to check if an active element exists in the
             * active_elements store
             *
             * @param id The id of the element to check
             *
             * @return A bool for if the element was found or no
             */
            bool exists(size_t id) const
            {
                if (active_elements.find(id) != active_elements.end())
                {
                    return true;
                }
                return false;
            }

            void replace(size_t old_id, size_t new_id)
            {
                erase(old_id);
                add(new_id);
            }
    };
}

#endif // guard