aGrUM  0.13.2
gum::ActionSet Class Reference

A class to store the optimal actions. More...

#include <agrum/FMDP/planning/actionSet.h>

+ Collaboration diagram for gum::ActionSet:

Public Member Functions

Size size () const
 Gives the size. More...
 
bool exists (const Idx &elem) const
 
CNL
 ActionSet ()
 Constructor. More...
 
 ActionSet (const ActionSet &src)
 Constructor. More...
 
ActionSetoperator= (const ActionSet &src)
 Constructor. More...
 
 ~ActionSet ()
 Destructor. More...
 
void * operator new (size_t s)
 Allocators and Deallocators redefinition. More...
 
void operator delete (void *p)
 Constructor. More...
 
Iterators
SequenceIteratorSafe< IdxbeginSafe () const
 Iterator beginning. More...
 
SequenceIteratorSafe< IdxendSafe () const
 Iterator end. More...
 
Operators
ActionSetoperator+= (const Idx &elem)
 Ajout d'un élément. More...
 
ActionSetoperator+= (const ActionSet &src)
 Use to insert the content of another set inside this one. More...
 
ActionSetoperator-= (const ActionSet &src)
 Use to insert the content of another set inside this one. More...
 
const Idxoperator[] (const Idx i) const
 Gives the ith element. More...
 
bool operator== (const ActionSet &compared) const
 Compares two ActionSet to check if they are equals. More...
 
bool operator!= (const ActionSet &compared) const
 Ajout d'un élément. More...
 

Friends

std::ostream & operator<< (std::ostream &streamy, const ActionSet &objy)
 

Detailed Description

A class to store the optimal actions.

Stores the ids of optimal actions. To be used as leaves on optimal policy tree or function graph

Definition at line 85 of file actionSet.h.

Constructor & Destructor Documentation

gum::ActionSet::ActionSet ( )
inline

Constructor.

Definition at line 95 of file actionSet.h.

95  {
96  GUM_CONSTRUCTOR(ActionSet)
97  __actionSeq = new Sequence< Idx >();
98  }
Sequence< Idx > * __actionSeq
The very bone of the ActionSet.
Definition: actionSet.h:214
ActionSet()
Constructor.
Definition: actionSet.h:95
unsigned long Idx
Type for indexes.
Definition: types.h:43
gum::ActionSet::ActionSet ( const ActionSet src)
inline

Constructor.

Definition at line 100 of file actionSet.h.

References beginSafe(), endSafe(), and gum::SequenceImplementation< Key, Alloc, Gen >::insert().

100  {
101  GUM_CONSTRUCTOR(ActionSet)
102  __actionSeq = new Sequence< Idx >();
103  for (auto idi = src.beginSafe(); idi != src.endSafe(); ++idi)
104  __actionSeq->insert(*idi);
105  }
SequenceIteratorSafe< Idx > beginSafe() const
Iterator beginning.
Definition: actionSet.h:142
Sequence< Idx > * __actionSeq
The very bone of the ActionSet.
Definition: actionSet.h:214
SequenceIteratorSafe< Idx > endSafe() const
Iterator end.
Definition: actionSet.h:149
ActionSet()
Constructor.
Definition: actionSet.h:95
unsigned long Idx
Type for indexes.
Definition: types.h:43

+ Here is the call graph for this function:

gum::ActionSet::~ActionSet ( )
inline

Destructor.

Definition at line 117 of file actionSet.h.

117  {
118  GUM_DESTRUCTOR(ActionSet)
119  delete __actionSeq;
120  }
Sequence< Idx > * __actionSeq
The very bone of the ActionSet.
Definition: actionSet.h:214
ActionSet()
Constructor.
Definition: actionSet.h:95

Member Function Documentation

SequenceIteratorSafe< Idx > gum::ActionSet::beginSafe ( ) const
inline

Iterator beginning.

Definition at line 142 of file actionSet.h.

Referenced by ActionSet(), operator+=(), operator-=(), operator=(), operator==(), and gum::StructuredPlaner< GUM_SCALAR >::optimalPolicy2String().

142  {
143  return __actionSeq->beginSafe();
144  }
Sequence< Idx > * __actionSeq
The very bone of the ActionSet.
Definition: actionSet.h:214
iterator_safe beginSafe() const
Returns a safe begin iterator.
Definition: sequence_tpl.h:623

+ Here is the caller graph for this function:

SequenceIteratorSafe< Idx > gum::ActionSet::endSafe ( ) const
inline

Iterator end.

Definition at line 149 of file actionSet.h.

Referenced by ActionSet(), operator+=(), operator-=(), operator=(), operator==(), and gum::StructuredPlaner< GUM_SCALAR >::optimalPolicy2String().

149 { return __actionSeq->endSafe(); }
const iterator_safe & endSafe() const noexcept
Returns the safe end iterator.
Definition: sequence_tpl.h:630
Sequence< Idx > * __actionSeq
The very bone of the ActionSet.
Definition: actionSet.h:214

+ Here is the caller graph for this function:

bool gum::ActionSet::exists ( const Idx elem) const
inline

Definition at line 210 of file actionSet.h.

Referenced by operator==().

210 { return __actionSeq->exists(elem); }
Sequence< Idx > * __actionSeq
The very bone of the ActionSet.
Definition: actionSet.h:214
bool exists(const Key &k) const
Check the existence of k in the sequence.
Definition: sequence_tpl.h:399

+ Here is the caller graph for this function:

void gum::ActionSet::operator delete ( void *  p)
inline

Constructor.

Definition at line 128 of file actionSet.h.

References gum::SmallObjectAllocator::deallocate(), and gum::SmallObjectAllocator::instance().

128  {
130  }
ActionSet()
Constructor.
Definition: actionSet.h:95
void deallocate(void *pDeallocatedObject, const size_t &objectSize)
Deallocates an object.
static SmallObjectAllocator & instance()

+ Here is the call graph for this function:

void* gum::ActionSet::operator new ( size_t  s)
inline

Allocators and Deallocators redefinition.

Definition at line 125 of file actionSet.h.

References gum::SmallObjectAllocator::allocate(), and gum::SmallObjectAllocator::instance().

125  {
127  }
void * allocate(const size_t &objectSize)
Allocates a block.
static SmallObjectAllocator & instance()

+ Here is the call graph for this function:

bool gum::ActionSet::operator!= ( const ActionSet compared) const
inline

Ajout d'un élément.

Definition at line 199 of file actionSet.h.

199  {
200  return !(*this == compared);
201  }
ActionSet& gum::ActionSet::operator+= ( const Idx elem)
inline

Ajout d'un élément.

Definition at line 161 of file actionSet.h.

161  {
162  __actionSeq->insert(elem);
163  return *this;
164  }
Sequence< Idx > * __actionSeq
The very bone of the ActionSet.
Definition: actionSet.h:214
void insert(const Key &k)
Insert an element at the end of the sequence.
Definition: sequence_tpl.h:405
ActionSet& gum::ActionSet::operator+= ( const ActionSet src)
inline

Use to insert the content of another set inside this one.

Definition at line 169 of file actionSet.h.

References beginSafe(), and endSafe().

169  {
170  for (auto iter = src.beginSafe(); iter != src.endSafe(); ++iter)
171  if (!__actionSeq->exists(*iter)) __actionSeq->insert(*iter);
172  return *this;
173  }
Sequence< Idx > * __actionSeq
The very bone of the ActionSet.
Definition: actionSet.h:214
bool exists(const Key &k) const
Check the existence of k in the sequence.
Definition: sequence_tpl.h:399
void insert(const Key &k)
Insert an element at the end of the sequence.
Definition: sequence_tpl.h:405

+ Here is the call graph for this function:

ActionSet& gum::ActionSet::operator-= ( const ActionSet src)
inline

Use to insert the content of another set inside this one.

Definition at line 178 of file actionSet.h.

References beginSafe(), and endSafe().

178  {
179  for (auto iter = src.beginSafe(); iter != src.endSafe(); ++iter)
180  if (__actionSeq->exists(*iter)) __actionSeq->erase(*iter);
181  return *this;
182  }
Sequence< Idx > * __actionSeq
The very bone of the ActionSet.
Definition: actionSet.h:214
void erase(const Key &k)
Remove an element from the sequence.
Definition: sequence_tpl.h:450
bool exists(const Key &k) const
Check the existence of k in the sequence.
Definition: sequence_tpl.h:399

+ Here is the call graph for this function:

ActionSet& gum::ActionSet::operator= ( const ActionSet src)
inline

Constructor.

Definition at line 107 of file actionSet.h.

References beginSafe(), endSafe(), and gum::SequenceImplementation< Key, Alloc, Gen >::insert().

107  {
109  for (auto idi = src.beginSafe(); idi != src.endSafe(); ++idi)
110  __actionSeq->insert(*idi);
111  return *this;
112  }
Sequence< Idx > * __actionSeq
The very bone of the ActionSet.
Definition: actionSet.h:214
void insert(const Key &k)
Insert an element at the end of the sequence.
Definition: sequence_tpl.h:405

+ Here is the call graph for this function:

bool gum::ActionSet::operator== ( const ActionSet compared) const
inline

Compares two ActionSet to check if they are equals.

Definition at line 192 of file actionSet.h.

References beginSafe(), endSafe(), and exists().

192  {
193  for (auto iter = compared.beginSafe(); iter != compared.endSafe(); ++iter)
194  if (!__actionSeq->exists(*iter)) return false;
195  for (auto iter = this->beginSafe(); iter != this->endSafe(); ++iter)
196  if (!compared.exists(*iter)) return false;
197  return true;
198  }
SequenceIteratorSafe< Idx > beginSafe() const
Iterator beginning.
Definition: actionSet.h:142
Sequence< Idx > * __actionSeq
The very bone of the ActionSet.
Definition: actionSet.h:214
SequenceIteratorSafe< Idx > endSafe() const
Iterator end.
Definition: actionSet.h:149
bool exists(const Key &k) const
Check the existence of k in the sequence.
Definition: sequence_tpl.h:399

+ Here is the call graph for this function:

const Idx& gum::ActionSet::operator[] ( const Idx  i) const
inline

Gives the ith element.

Definition at line 187 of file actionSet.h.

187 { return __actionSeq->atPos(i); }
const Key & atPos(Idx i) const
Returns the object at the pos i.
Definition: sequence_tpl.h:497
Sequence< Idx > * __actionSeq
The very bone of the ActionSet.
Definition: actionSet.h:214
Size gum::ActionSet::size ( ) const
inline

Gives the size.

Definition at line 208 of file actionSet.h.

Referenced by gum::IDecisionStrategy::initialize(), gum::E_GreedyDecider::stateOptimalPolicy(), and gum::SDYNA::takeAction().

208 { return __actionSeq->size(); }
Size size() const noexcept
Returns the size of the sequence.
Definition: sequence_tpl.h:35
Sequence< Idx > * __actionSeq
The very bone of the ActionSet.
Definition: actionSet.h:214

+ Here is the caller graph for this function:

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  streamy,
const ActionSet objy 
)
friend

Definition at line 216 of file actionSet.h.

216  {
217  streamy << objy.__actionSeq->toString();
218  return streamy;
219  }

Member Data Documentation

Sequence< Idx >* gum::ActionSet::__actionSeq
private

The very bone of the ActionSet.

Definition at line 214 of file actionSet.h.


The documentation for this class was generated from the following file: