You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

158 lines
6.1 KiB

  1. #ifndef STORM_STORAGE_MAXIMALENDCOMPONENT_H_
  2. #define STORM_STORAGE_MAXIMALENDCOMPONENT_H_
  3. #include <unordered_map>
  4. #include <boost/container/flat_set.hpp>
  5. #include "src/storage/sparse/StateType.h"
  6. namespace storm {
  7. namespace storage {
  8. /*!
  9. * This class represents a maximal end-component of a nondeterministic model.
  10. */
  11. class MaximalEndComponent {
  12. public:
  13. typedef boost::container::flat_set<sparse::state_type> set_type;
  14. typedef std::unordered_map<uint_fast64_t, set_type> map_type;
  15. typedef map_type::iterator iterator;
  16. typedef map_type::const_iterator const_iterator;
  17. /*!
  18. * Creates an empty MEC.
  19. */
  20. MaximalEndComponent();
  21. /*!
  22. * Creates an MEC by copying the given one.
  23. *
  24. * @param other The MEC to copy.
  25. */
  26. MaximalEndComponent(MaximalEndComponent const& other);
  27. /*!
  28. * Assigns the contents of the given MEC to the current one via copying.
  29. *
  30. * @param other The MEC whose contents to copy.
  31. */
  32. MaximalEndComponent& operator=(MaximalEndComponent const& other);
  33. /*!
  34. * Creates an MEC by moving the given one.
  35. *
  36. * @param other The MEC to move.
  37. */
  38. MaximalEndComponent(MaximalEndComponent&& other);
  39. /*!
  40. * Assigns the contents of the given MEC to the current one via moving.
  41. *
  42. * @param other The MEC whose contents to move.
  43. */
  44. MaximalEndComponent& operator=(MaximalEndComponent&& other);
  45. /*!
  46. * Adds the given state and the given choices to the MEC.
  47. *
  48. * @param state The state for which to add the choices.
  49. * @param choices The choices to add for the state.
  50. */
  51. void addState(uint_fast64_t state, set_type const& choices);
  52. /*!
  53. * Adds the given state and the given choices to the MEC.
  54. *
  55. * @param state The state for which to add the choices.
  56. * @param choices The choices to add for the state.
  57. */
  58. void addState(uint_fast64_t state, set_type&& choices);
  59. /*!
  60. * Retrieves the choices for the given state that are contained in this MEC under the assumption that the
  61. * state is in the MEC.
  62. *
  63. * @param state The state for which to retrieve the choices.
  64. * @return A set of choices of the state in the MEC.
  65. */
  66. set_type const& getChoicesForState(uint_fast64_t state) const;
  67. /*!
  68. * Retrieves the choices for the given state that are contained in this MEC under the assumption that the
  69. * state is in the MEC.
  70. *
  71. * @param state The state for which to retrieve the choices.
  72. * @return A set of choices of the state in the MEC.
  73. */
  74. set_type& getChoicesForState(uint_fast64_t state);
  75. /*!
  76. * Removes the given state and all of its choices from the MEC.
  77. *
  78. * @param state The state to remove froom the MEC.
  79. */
  80. void removeState(uint_fast64_t state);
  81. /*!
  82. * Retrieves whether the given state is contained in this MEC.
  83. *
  84. * @param state The state for which to query membership in the MEC.
  85. * @return True if the given state is contained in the MEC.
  86. */
  87. bool containsState(uint_fast64_t state) const;
  88. /*!
  89. * Retrieves whether the given choice for the given state is contained in the MEC.
  90. *
  91. * @param state The state for which to check whether the given choice is contained in the MEC.
  92. * @param choice The choice for which to check whether it is contained in the MEC.
  93. * @return True if the given choice is contained in the MEC.
  94. */
  95. bool containsChoice(uint_fast64_t state, uint_fast64_t choice) const;
  96. /*!
  97. * Retrieves the set of states contained in the MEC.
  98. *
  99. * @return The set of states contained in the MEC.
  100. */
  101. set_type getStateSet() const;
  102. /*!
  103. * Retrieves an iterator that points to the first state and its choices in the MEC.
  104. *
  105. * @return An iterator that points to the first state and its choices in the MEC.
  106. */
  107. iterator begin();
  108. /*!
  109. * Retrieves an iterator that points past the last state and its choices in the MEC.
  110. *
  111. * @return An iterator that points past the last state and its choices in the MEC.
  112. */
  113. iterator end();
  114. /*!
  115. * Retrieves an iterator that points to the first state and its choices in the MEC.
  116. *
  117. * @return An iterator that points to the first state and its choices in the MEC.
  118. */
  119. const_iterator begin() const;
  120. /*!
  121. * Retrieves an iterator that points past the last state and its choices in the MEC.
  122. *
  123. * @return An iterator that points past the last state and its choices in the MEC.
  124. */
  125. const_iterator end() const;
  126. // Declare the streaming operator as a friend function.
  127. friend std::ostream& operator<<(std::ostream& out, MaximalEndComponent const& component);
  128. private:
  129. // This stores the mapping from states contained in the MEC to the choices in this MEC.
  130. map_type stateToChoicesMapping;
  131. };
  132. }
  133. }
  134. #endif /* STORM_STORAGE_MAXIMALENDCOMPONENT_H_ */