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);
129 return SmallObjectAllocator::instance().allocate(s);
132 SmallObjectAllocator::instance().deallocate(p,
sizeof(ActionSet));
146 return actionSeq__->beginSafe();
165 actionSeq__->insert(elem);
173 for (
auto iter = src.beginSafe(); iter != src.endSafe(); ++iter)
174 if (!actionSeq__->exists(*iter)) actionSeq__->insert(*iter);
182 for (
auto iter = src.beginSafe(); iter != src.endSafe(); ++iter)
183 if (actionSeq__->exists(*iter)) actionSeq__->erase(*iter);
196 for (
auto iter = compared.beginSafe(); iter != compared.endSafe(); ++iter)
197 if (!actionSeq__->exists(*iter))
return false;
198 for (
auto iter =
this->beginSafe(); iter !=
this->endSafe(); ++iter)
199 if (!compared.exists(*iter))
return false;
203 return !(*
this == compared);
213 bool exists(
const Idx& elem)
const {
return actionSeq__->exists(elem); }
219 friend std::ostream& operator<<(std::ostream& streamy,
const ActionSet& objy) {
220 streamy << objy.actionSeq__->toString();
Sequence< Idx > * actionSeq__
The very bone of the ActionSet.
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.
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>