#ifndef __JTOOLS__JMULTISET__ #define __JTOOLS__JMULTISET__ #include "JTools/JAbstractMultiMap.hh" #include "JTools/JSet.hh" /** * \author mdejong */ namespace JTOOLS {} namespace JPP { using namespace JTOOLS; } namespace JTOOLS { /** * Simple data structure for an abstract multidimensional map of equidistant elements. * * This class implements the JAbstractMultiMap interface. */ template struct JMultiSet : public virtual JAbstractMultiMap, public JMultiSet { typedef JAbscissa_t abscissa_type; typedef JMultiKey key_type; using JMultiSet::operator(); /** * Default constructor. */ JMultiSet() : JMultiSet() {} /** * Constructor. * * \param bounds bounds */ JMultiSet(const JSet& bounds) : JMultiSet(bounds) { this->bounds = bounds; } /** * Set bounds. * * \param index index of dimension * \param bounds bounds * \return true if correctly set; else false */ bool set(unsigned int index, const JSet& bounds) { if (index == N - 1) { this->bounds = bounds; } else if (index < N - 1) { return static_cast&>(*this).set(index, bounds); } return false; } /** * Get abscissa values as a function of given key. * * \param key key * \return abscissa values */ virtual const JSet& operator()(const key_type& key) const override { return bounds; } protected: JSet bounds; }; /** * Terminator class of recursive class JMultiSet. * This class provides for dummy implementations of interface methods. */ template struct JMultiSet<0, JAbscissa_t> { protected: typedef JAbscissa_t abscissa_type; friend class JMultiSet<1, JAbscissa_t>; /** * Default constructor. */ JMultiSet() {} /** * Constructor. * * \param bounds bounds */ JMultiSet(const JSet& bounds) {} /** * This method does nothing. * * \param index index * \param bounds bounds * \return false */ bool set(unsigned int index, const JSet& bounds) const { return false; } /** * Dummy operator. */ void operator()() const {} }; /** * Helper method for JMultiSet. * * \param bounds bounds * \return multidimensional set */ template inline JMultiSet make_multiset(const JSet& bounds) { return JMultiSet(bounds); } } #endif