31 #ifndef GUM_ACTION_SET_H 32 #define GUM_ACTION_SET_H 36 #include <agrum/tools/core/argMaxSet.h> 37 #include <agrum/tools/core/functors.h> 38 #include <agrum/tools/core/inline.h> 39 #include <agrum/tools/core/smallobjectallocator/smallObjectAllocator.h> 41 #include <agrum/tools/multidim/implementations/multiDimFunctionGraph.h> 42 #include <agrum/tools/multidim/utils/FunctionGraphUtilities/terminalNodePolicies/SetTerminalNodePolicy.h> 44 #include <agrum/FMDP/fmdp.h> 57 template <
typename GUM_SCALAR >
64 const GUM_SCALAR&
operator()(
const GUM_SCALAR& x,
const GUM_SCALAR& y)
const {
65 if (x > y) {
return x; }
66 if (x < y) {
return y; }
99 GUM_CONSTRUCTOR(ActionSet);
100 _actionSeq_ =
new Sequence< Idx >();
104 GUM_CONSTRUCTOR(ActionSet);
105 _actionSeq_ =
new Sequence< Idx >();
106 for (
auto idi = src.beginSafe(); idi != src.endSafe(); ++idi)
107 _actionSeq_->insert(*idi);
111 _actionSeq_ =
new Sequence< Idx >();
112 for (
auto idi = src.beginSafe(); idi != src.endSafe(); ++idi)
113 _actionSeq_->insert(*idi);
121 GUM_DESTRUCTOR(ActionSet);
128 void*
operator new(size_t s) {
return SmallObjectAllocator::instance().allocate(s); }
130 SmallObjectAllocator::instance().deallocate(p,
sizeof(ActionSet));
161 _actionSeq_->insert(elem);
169 for (
auto iter = src.beginSafe(); iter != src.endSafe(); ++iter)
170 if (!_actionSeq_->exists(*iter)) _actionSeq_->insert(*iter);
178 for (
auto iter = src.beginSafe(); iter != src.endSafe(); ++iter)
179 if (_actionSeq_->exists(*iter)) _actionSeq_->erase(*iter);
192 for (
auto iter = compared.beginSafe(); iter != compared.endSafe(); ++iter)
193 if (!_actionSeq_->exists(*iter))
return false;
194 for (
auto iter =
this->beginSafe(); iter !=
this->endSafe(); ++iter)
195 if (!compared.exists(*iter))
return false;
207 bool exists(
const Idx& elem)
const {
return _actionSeq_->exists(elem); }
213 friend std::ostream& operator<<(std::ostream& streamy,
const ActionSet& objy) {
214 streamy << objy._actionSeq_->toString();
const GUM_SCALAR & operator()(const GUM_SCALAR &x, const GUM_SCALAR &y) const
bool operator==(const ActionSet &compared) const
Compares two ActionSet to check if they are equals.
Size size() const
Gives the size.
A class to store the optimal actions.
INLINE void emplace(Args &&... args)
ActionSet(const ActionSet &src)
Constructor.
void * operator new(size_t s)
Allocators and Deallocators redefinition.
bool exists(const Idx &elem) const
SequenceIteratorSafe< Idx > endSafe() const
Iterator end.
ActionSet & operator=(const ActionSet &src)
Constructor.
ActionSet & operator+=(const ActionSet &src)
Use to insert the content of another set inside this one.
ActionSet & operator-=(const ActionSet &src)
Use to insert the content of another set inside this one.
SequenceIteratorSafe< Idx > beginSafe() const
Iterator beginning.
Sequence< Idx > * _actionSeq_
The very bone of the ActionSet.
ActionSet & operator+=(const Idx &elem)
Ajout d'un élément.
bool operator!=(const ActionSet &compared) const
Ajout d'un élément.
const Idx & operator[](const Idx i) const
Gives the ith element.
void operator delete(void *p)
Constructor.
<agrum/FMDP/planning/actionSet.h>