From cf8da8a8dfd8c4db4d1f9be92aca9ae453a1df4e Mon Sep 17 00:00:00 2001 From: sjunges Date: Fri, 24 Jul 2015 11:58:35 +0200 Subject: [PATCH] wrappers for common tuples added Former-commit-id: 47041c364178770044aa0dc259003e7c9dffddf2 --- src/storage/StateActionPair.h | 47 ++++++++++++++++++++++++++++ src/storage/StateActionTargetTuple.h | 35 +++++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 src/storage/StateActionPair.h create mode 100644 src/storage/StateActionTargetTuple.h diff --git a/src/storage/StateActionPair.h b/src/storage/StateActionPair.h new file mode 100644 index 000000000..09fede4a2 --- /dev/null +++ b/src/storage/StateActionPair.h @@ -0,0 +1,47 @@ +#ifndef STATEACTIONPAIR_H +#define STATEACTIONPAIR_H + +#include + +namespace storm { + namespace storage { + class StateActionPair { + std::pair stateActionPair; + + public: + StateActionPair(std::pair const& sap) : stateActionPair(sap) {} + StateActionPair(uint_fast64_t state, uint_fast64_t action) : stateActionPair(std::make_pair(state, action)) {} + + uint_fast64_t getState() const { + return stateActionPair.first; + } + + uint_fast64_t getAction() const { + return stateActionPair.second; + } + + friend bool operator==(StateActionPair const& p1, StateActionPair const& p2) { + return p1.stateActionPair == p2.stateActionPair; + } + + friend bool operator!=(StateActionPair const& p1, StateActionPair const& p2) { + return p1.stateActionPair != p2.stateActionPair; + } + + + }; + } +} + +namespace std { + template<> + struct hash { + size_t operator()(storm::storage::StateActionPair const& sap) { + return (sap.getState() << 3 ^ sap.getAction()); + } + }; + +} + +#endif /* STATEACTIONPAIR_H */ + diff --git a/src/storage/StateActionTargetTuple.h b/src/storage/StateActionTargetTuple.h new file mode 100644 index 000000000..b354a30c6 --- /dev/null +++ b/src/storage/StateActionTargetTuple.h @@ -0,0 +1,35 @@ + +#ifndef STATEACTIONTARGETTUPLE_H +#define STATEACTIONTARGETTUPLE_H + +#include + +namespace storm { + namespace storage { + struct StateActionTarget { + uint_fast64_t state; + uint_fast64_t action; + uint_fast64_t target; + + }; + + inline std::string to_string(StateActionTarget const& sat) { + return std::to_string(sat.state) + "_" + std::to_string(sat.action) + "_" + std::to_string(sat.target); + } + + } +} + +namespace std { + template<> + struct hash { + bool operator()(storm::storage::StateActionTarget const& sat) const { + return (sat.state ^ sat.target) << 3 | sat.action; + } + }; + +} + + +#endif /* STATEACTIONTARGETTUPLE_H */ +