aGrUM  0.16.0
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 88 of file actionSet.h.

Constructor & Destructor Documentation

◆ ActionSet() [1/2]

gum::ActionSet::ActionSet ( )
inline

Constructor.

Definition at line 98 of file actionSet.h.

98  {
99  GUM_CONSTRUCTOR(ActionSet);
101  }
Sequence< Idx > * __actionSeq
The very bone of the ActionSet.
Definition: actionSet.h:217
ActionSet()
Constructor.
Definition: actionSet.h:98

◆ ActionSet() [2/2]

gum::ActionSet::ActionSet ( const ActionSet src)
inline

Constructor.

Definition at line 103 of file actionSet.h.

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

103  {
104  GUM_CONSTRUCTOR(ActionSet);
106  for (auto idi = src.beginSafe(); idi != src.endSafe(); ++idi)
107  __actionSeq->insert(*idi);
108  }
Sequence< Idx > * __actionSeq
The very bone of the ActionSet.
Definition: actionSet.h:217
ActionSet()
Constructor.
Definition: actionSet.h:98
void insert(const Key &k)
Insert an element at the end of the sequence.
Definition: sequence_tpl.h:408
+ Here is the call graph for this function:

◆ ~ActionSet()

gum::ActionSet::~ActionSet ( )
inline

Destructor.

Definition at line 120 of file actionSet.h.

120  {
121  GUM_DESTRUCTOR(ActionSet);
122  delete __actionSeq;
123  }
Sequence< Idx > * __actionSeq
The very bone of the ActionSet.
Definition: actionSet.h:217
ActionSet()
Constructor.
Definition: actionSet.h:98

Member Function Documentation

◆ beginSafe()

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

Iterator beginning.

Definition at line 145 of file actionSet.h.

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

145  {
146  return __actionSeq->beginSafe();
147  }
Sequence< Idx > * __actionSeq
The very bone of the ActionSet.
Definition: actionSet.h:217
iterator_safe beginSafe() const
Returns a safe begin iterator.
Definition: sequence_tpl.h:627
+ Here is the caller graph for this function:

◆ endSafe()

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

Iterator end.

Definition at line 152 of file actionSet.h.

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

152 { return __actionSeq->endSafe(); }
const iterator_safe & endSafe() const noexcept
Returns the safe end iterator.
Definition: sequence_tpl.h:634
Sequence< Idx > * __actionSeq
The very bone of the ActionSet.
Definition: actionSet.h:217
+ Here is the caller graph for this function:

◆ exists()

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

Definition at line 213 of file actionSet.h.

Referenced by operator==().

213 { return __actionSeq->exists(elem); }
Sequence< Idx > * __actionSeq
The very bone of the ActionSet.
Definition: actionSet.h:217
bool exists(const Key &k) const
Check the existence of k in the sequence.
Definition: sequence_tpl.h:402
+ Here is the caller graph for this function:

◆ operator delete()

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

Constructor.

Definition at line 131 of file actionSet.h.

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

131  {
133  }
ActionSet()
Constructor.
Definition: actionSet.h:98
void deallocate(void *pDeallocatedObject, const size_t &objectSize)
Deallocates an object.
static SmallObjectAllocator & instance()
+ Here is the call graph for this function:

◆ operator new()

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

Allocators and Deallocators redefinition.

Definition at line 128 of file actionSet.h.

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

128  {
130  }
void * allocate(const size_t &objectSize)
Allocates a block.
static SmallObjectAllocator & instance()
+ Here is the call graph for this function:

◆ operator!=()

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

Ajout d'un élément.

Definition at line 202 of file actionSet.h.

202  {
203  return !(*this == compared);
204  }

◆ operator+=() [1/2]

ActionSet& gum::ActionSet::operator+= ( const Idx elem)
inline

Ajout d'un élément.

Definition at line 164 of file actionSet.h.

164  {
165  __actionSeq->insert(elem);
166  return *this;
167  }
Sequence< Idx > * __actionSeq
The very bone of the ActionSet.
Definition: actionSet.h:217
void insert(const Key &k)
Insert an element at the end of the sequence.
Definition: sequence_tpl.h:408

◆ operator+=() [2/2]

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

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

Definition at line 172 of file actionSet.h.

References beginSafe(), and endSafe().

172  {
173  for (auto iter = src.beginSafe(); iter != src.endSafe(); ++iter)
174  if (!__actionSeq->exists(*iter)) __actionSeq->insert(*iter);
175  return *this;
176  }
Sequence< Idx > * __actionSeq
The very bone of the ActionSet.
Definition: actionSet.h:217
bool exists(const Key &k) const
Check the existence of k in the sequence.
Definition: sequence_tpl.h:402
void insert(const Key &k)
Insert an element at the end of the sequence.
Definition: sequence_tpl.h:408
+ Here is the call graph for this function:

◆ operator-=()

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

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

Definition at line 181 of file actionSet.h.

References beginSafe(), and endSafe().

181  {
182  for (auto iter = src.beginSafe(); iter != src.endSafe(); ++iter)
183  if (__actionSeq->exists(*iter)) __actionSeq->erase(*iter);
184  return *this;
185  }
Sequence< Idx > * __actionSeq
The very bone of the ActionSet.
Definition: actionSet.h:217
bool exists(const Key &k) const
Check the existence of k in the sequence.
Definition: sequence_tpl.h:402
void erase(const Key &k)
Remove an element from the sequence.
Definition: sequence_tpl.h:453
+ Here is the call graph for this function:

◆ operator=()

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

Constructor.

Definition at line 110 of file actionSet.h.

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

110  {
112  for (auto idi = src.beginSafe(); idi != src.endSafe(); ++idi)
113  __actionSeq->insert(*idi);
114  return *this;
115  }
Sequence< Idx > * __actionSeq
The very bone of the ActionSet.
Definition: actionSet.h:217
void insert(const Key &k)
Insert an element at the end of the sequence.
Definition: sequence_tpl.h:408
+ Here is the call graph for this function:

◆ operator==()

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

Compares two ActionSet to check if they are equals.

Definition at line 195 of file actionSet.h.

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

195  {
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;
200  return true;
201  }
SequenceIteratorSafe< Idx > endSafe() const
Iterator end.
Definition: actionSet.h:152
Sequence< Idx > * __actionSeq
The very bone of the ActionSet.
Definition: actionSet.h:217
bool exists(const Key &k) const
Check the existence of k in the sequence.
Definition: sequence_tpl.h:402
SequenceIteratorSafe< Idx > beginSafe() const
Iterator beginning.
Definition: actionSet.h:145
+ Here is the call graph for this function:

◆ operator[]()

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

Gives the ith element.

Definition at line 190 of file actionSet.h.

190 { return __actionSeq->atPos(i); }
Sequence< Idx > * __actionSeq
The very bone of the ActionSet.
Definition: actionSet.h:217
const Key & atPos(Idx i) const
Returns the object at the pos i.
Definition: sequence_tpl.h:500

◆ size()

Size gum::ActionSet::size ( ) const
inline

Gives the size.

Definition at line 211 of file actionSet.h.

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

211 { return __actionSeq->size(); }
Size size() const noexcept
Returns the size of the sequence.
Definition: sequence_tpl.h:38
Sequence< Idx > * __actionSeq
The very bone of the ActionSet.
Definition: actionSet.h:217
+ Here is the caller graph for this function:

Friends And Related Function Documentation

◆ operator<<

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

Definition at line 219 of file actionSet.h.

219  {
220  streamy << objy.__actionSeq->toString();
221  return streamy;
222  }

Member Data Documentation

◆ __actionSeq

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

The very bone of the ActionSet.

Definition at line 217 of file actionSet.h.


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