8template<
typename BeliefType>
13template<
typename BeliefType>
15 return gatheredBeliefs.size();
18template<
typename BeliefType>
21 return gatheredBeliefs[id];
24template<
typename BeliefType>
27 "Unknown belief observation " << belief.observation() <<
". Observations are in [0," << beliefToIdMap.size());
29 STORM_LOG_THROW(
id !=
InvalidBeliefId, storm::exceptions::OutOfRangeException,
"Belief " << belief.toString() <<
" is not present in this collector.");
33template<
typename BeliefType>
38template<
typename BeliefType>
40 return id < gatheredBeliefs.size();
43template<
typename BeliefType>
45 if (
auto const obs = belief.observation(); obs < beliefToIdMap.size()) {
46 auto const [begin, end] = beliefToIdMap[obs].equal_range(
typename BeliefType::BeliefHash{}(belief));
47 for (
auto it = begin; it != end; ++it) {
48 if (gatheredBeliefs[it->second] == belief) {
56template<
typename BeliefType>
64template<
typename BeliefType>
66 auto const obs = inputBelief.observation();
67 auto const hash =
typename BeliefType::BeliefHash{}(inputBelief);
68 if (obs >= beliefToIdMap.size()) {
69 beliefToIdMap.resize(
static_cast<uint64_t
>(obs) + 1);
71 auto const id = gatheredBeliefs.size();
72 gatheredBeliefs.push_back(std::move(inputBelief));
73 beliefToIdMap[obs].emplace(hash,
id);
Interns beliefs and assigns them consecutive identifiers.
bool containsBelief(BeliefType const &belief) const
BeliefId getIdOptional(BeliefType const &belief) const
BeliefType const & getBeliefFromId(BeliefId const &id) const
BeliefId addBelief(BeliefType &&inputBelief)
Adds a fresh belief and returns its ID.
BeliefId getNumberOfBeliefIds() const
BeliefId getIdOrAddBelief(BeliefType &&belief)
Checks if the given belief has already been collected before.
bool containsId(BeliefId const &id) const
BeliefId getIdFromBelief(BeliefType const &belief) const
bool isEqual(BeliefId const &first, BeliefId const &second) const
#define STORM_LOG_ASSERT(cond, message)
#define STORM_LOG_THROW(cond, exception, message)
constexpr BeliefId InvalidBeliefId