aGrUM  0.20.2
a C++ library for (probabilistic) graphical models
gum::ArgMaxSet< GUM_SCALAR_VAL, GUM_SCALAR_SEQ > Struct Template Reference

Class to handle efficiently argMaxSet. More...

#include <agrum/tools/multidim/patterns/argMaxSet.h>

+ Collaboration diagram for gum::ArgMaxSet< GUM_SCALAR_VAL, GUM_SCALAR_SEQ >:

Public Member Functions

Idx size () const
 Gives the size. More...
 
const GUM_SCALAR_VAL & value () const
 Returns the value on which comparison are made. More...
 
bool exists (const GUM_SCALAR_SEQ &elem) const
 
CNL
 ArgMaxSet ()
 Constructor. More...
 
 ArgMaxSet (const GUM_SCALAR_VAL &val, const GUM_SCALAR_SEQ &elem)
 Constructor. More...
 
 ArgMaxSet (const ArgMaxSet< GUM_SCALAR_VAL, GUM_SCALAR_SEQ > &src)
 Copy Constructor. More...
 
ArgMaxSet< GUM_SCALAR_VAL, GUM_SCALAR_SEQ > & operator= (const ArgMaxSet< GUM_SCALAR_VAL, GUM_SCALAR_SEQ > &src)
 Constructor. More...
 
 ~ArgMaxSet ()
 Destructor. More...
 
void * operator new (size_t s)
 Allocators and Deallocators redefinition. More...
 
void operator delete (void *p)
 Constructor. More...
 
Iterators
SequenceIteratorSafe< GUM_SCALAR_SEQ > beginSafe () const
 Iterator beginning. More...
 
SequenceIteratorSafe< GUM_SCALAR_SEQ > endSafe () const
 Iterator end. More...
 
Operators
ArgMaxSet< GUM_SCALAR_VAL, GUM_SCALAR_SEQ > & operator+= (const GUM_SCALAR_SEQ &elem)
 Ajout d'un élément. More...
 
ArgMaxSet< GUM_SCALAR_VAL, GUM_SCALAR_SEQ > & operator+= (const ArgMaxSet< GUM_SCALAR_VAL, GUM_SCALAR_SEQ > &src)
 Use to insert the content of another set inside this one. More...
 
const GUM_SCALAR_SEQ & operator[] (const Idx i) const
 Gives the ith element. More...
 
bool operator== (const ArgMaxSet< GUM_SCALAR_VAL, GUM_SCALAR_SEQ > &compared) const
 Compares two ArgMaxSet to check if they are equals. More...
 
bool operator!= (const ArgMaxSet< GUM_SCALAR_VAL, GUM_SCALAR_SEQ > &compared) const
 Ajout d'un élément. More...
 
bool operator< (const ArgMaxSet< GUM_SCALAR_VAL, GUM_SCALAR_SEQ > &compared) const
 Checks if val is lower or higher from the compared ArgMaxSet val. More...
 
bool operator> (const ArgMaxSet< GUM_SCALAR_VAL, GUM_SCALAR_SEQ > &compared) const
 Ajout d'un élément. More...
 
bool operator<= (const ArgMaxSet< GUM_SCALAR_VAL, GUM_SCALAR_SEQ > &compared) const
 Ajout d'un élément. More...
 
bool operator>= (const ArgMaxSet< GUM_SCALAR_VAL, GUM_SCALAR_SEQ > &compared) const
 Ajout d'un élément. More...
 

Friends

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

Detailed Description

template<typename GUM_SCALAR_VAL, typename GUM_SCALAR_SEQ>
struct gum::ArgMaxSet< GUM_SCALAR_VAL, GUM_SCALAR_SEQ >

Class to handle efficiently argMaxSet.

A class containing the set of object assoicated to a maximum

This set contains the ids of the obj.

Definition at line 57 of file argMaxSet.h.

Constructor & Destructor Documentation

◆ ArgMaxSet() [1/3]

template<typename GUM_SCALAR_VAL , typename GUM_SCALAR_SEQ >
gum::ArgMaxSet< GUM_SCALAR_VAL, GUM_SCALAR_SEQ >::ArgMaxSet ( )

Constructor.

Definition at line 41 of file argMaxSet_tpl.h.

41  {
42  GUM_CONSTRUCTOR(ArgMaxSet);
44  }
ArgMaxSet()
Constructor.
Definition: argMaxSet_tpl.h:41
Sequence< GUM_SCALAR_SEQ > * argMaxSeq__
The very bone of the ArgMaxSet.
Definition: argMaxSet.h:194

◆ ArgMaxSet() [2/3]

template<typename GUM_SCALAR_VAL , typename GUM_SCALAR_SEQ >
gum::ArgMaxSet< GUM_SCALAR_VAL, GUM_SCALAR_SEQ >::ArgMaxSet ( const GUM_SCALAR_VAL &  val,
const GUM_SCALAR_SEQ &  elem 
)

Constructor.

Definition at line 50 of file argMaxSet_tpl.h.

References gum::Set< Key, Alloc >::emplace().

52  {
53  GUM_CONSTRUCTOR(ArgMaxSet);
55  argMaxSeq__->insert(elem);
56  val__ = val;
57  }
GUM_SCALAR_VAL val__
Definition: argMaxSet.h:195
ArgMaxSet()
Constructor.
Definition: argMaxSet_tpl.h:41
Sequence< GUM_SCALAR_SEQ > * argMaxSeq__
The very bone of the ArgMaxSet.
Definition: argMaxSet.h:194
void insert(const Key &k)
Insert an element at the end of the sequence.
Definition: sequence_tpl.h:409
+ Here is the call graph for this function:

◆ ArgMaxSet() [3/3]

template<typename GUM_SCALAR_VAL , typename GUM_SCALAR_SEQ >
gum::ArgMaxSet< GUM_SCALAR_VAL, GUM_SCALAR_SEQ >::ArgMaxSet ( const ArgMaxSet< GUM_SCALAR_VAL, GUM_SCALAR_SEQ > &  src)

Copy Constructor.

Definition at line 63 of file argMaxSet_tpl.h.

References gum::Set< Key, Alloc >::emplace().

64  {
65  GUM_CONS_CPY(ArgMaxSet);
67  this->operator+=(src);
68  val__ = src.value();
69  }
GUM_SCALAR_VAL val__
Definition: argMaxSet.h:195
ArgMaxSet< GUM_SCALAR_VAL, GUM_SCALAR_SEQ > & operator+=(const GUM_SCALAR_SEQ &elem)
Ajout d&#39;un élément.
Definition: argMaxSet_tpl.h:99
ArgMaxSet()
Constructor.
Definition: argMaxSet_tpl.h:41
Sequence< GUM_SCALAR_SEQ > * argMaxSeq__
The very bone of the ArgMaxSet.
Definition: argMaxSet.h:194
+ Here is the call graph for this function:

◆ ~ArgMaxSet()

template<typename GUM_SCALAR_VAL , typename GUM_SCALAR_SEQ >
gum::ArgMaxSet< GUM_SCALAR_VAL, GUM_SCALAR_SEQ >::~ArgMaxSet ( )

Destructor.

Definition at line 85 of file argMaxSet_tpl.h.

References gum::Set< Key, Alloc >::emplace().

85  {
86  GUM_DESTRUCTOR(ArgMaxSet);
87  delete argMaxSeq__;
88  }
ArgMaxSet()
Constructor.
Definition: argMaxSet_tpl.h:41
Sequence< GUM_SCALAR_SEQ > * argMaxSeq__
The very bone of the ArgMaxSet.
Definition: argMaxSet.h:194
+ Here is the call graph for this function:

Member Function Documentation

◆ beginSafe()

template<typename GUM_SCALAR_VAL , typename GUM_SCALAR_SEQ >
SequenceIteratorSafe< GUM_SCALAR_SEQ > gum::ArgMaxSet< GUM_SCALAR_VAL, GUM_SCALAR_SEQ >::beginSafe ( ) const
inline

Iterator beginning.

Definition at line 109 of file argMaxSet.h.

109  {
110  return argMaxSeq__->beginSafe();
111  }
iterator_safe beginSafe() const
Returns a safe begin iterator.
Definition: sequence_tpl.h:628
Sequence< GUM_SCALAR_SEQ > * argMaxSeq__
The very bone of the ArgMaxSet.
Definition: argMaxSet.h:194

◆ endSafe()

template<typename GUM_SCALAR_VAL , typename GUM_SCALAR_SEQ >
SequenceIteratorSafe< GUM_SCALAR_SEQ > gum::ArgMaxSet< GUM_SCALAR_VAL, GUM_SCALAR_SEQ >::endSafe ( ) const
inline

Iterator end.

Definition at line 116 of file argMaxSet.h.

116  {
117  return argMaxSeq__->endSafe();
118  }
const iterator_safe & endSafe() const noexcept
Returns the safe end iterator.
Definition: sequence_tpl.h:635
Sequence< GUM_SCALAR_SEQ > * argMaxSeq__
The very bone of the ArgMaxSet.
Definition: argMaxSet.h:194

◆ exists()

template<typename GUM_SCALAR_VAL , typename GUM_SCALAR_SEQ >
bool gum::ArgMaxSet< GUM_SCALAR_VAL, GUM_SCALAR_SEQ >::exists ( const GUM_SCALAR_SEQ &  elem) const
inline

Definition at line 188 of file argMaxSet.h.

188  {
189  return argMaxSeq__->exists(elem);
190  }
bool exists(const Key &k) const
Check the existence of k in the sequence.
Definition: sequence_tpl.h:403
Sequence< GUM_SCALAR_SEQ > * argMaxSeq__
The very bone of the ArgMaxSet.
Definition: argMaxSet.h:194

◆ operator delete()

template<typename GUM_SCALAR_VAL , typename GUM_SCALAR_SEQ >
void gum::ArgMaxSet< GUM_SCALAR_VAL, GUM_SCALAR_SEQ >::operator delete ( void *  p)
inline

Constructor.

Definition at line 93 of file argMaxSet.h.

93  {
95  p,
96  sizeof(ArgMaxSet< GUM_SCALAR_VAL, GUM_SCALAR_SEQ >));
97  }
void deallocate(void *pDeallocatedObject, const size_t &objectSize)
Deallocates an object.
static SmallObjectAllocator & instance()

◆ operator new()

template<typename GUM_SCALAR_VAL , typename GUM_SCALAR_SEQ >
void* gum::ArgMaxSet< GUM_SCALAR_VAL, GUM_SCALAR_SEQ >::operator new ( size_t  s)
inline

Allocators and Deallocators redefinition.

Definition at line 90 of file argMaxSet.h.

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

◆ operator!=()

template<typename GUM_SCALAR_VAL , typename GUM_SCALAR_SEQ >
bool gum::ArgMaxSet< GUM_SCALAR_VAL, GUM_SCALAR_SEQ >::operator!= ( const ArgMaxSet< GUM_SCALAR_VAL, GUM_SCALAR_SEQ > &  compared) const
inline

Ajout d'un élément.

Definition at line 151 of file argMaxSet.h.

152  {
153  return !(*this == compared);
154  }

◆ operator+=() [1/2]

template<typename GUM_SCALAR_VAL , typename GUM_SCALAR_SEQ >
ArgMaxSet< GUM_SCALAR_VAL, GUM_SCALAR_SEQ > & gum::ArgMaxSet< GUM_SCALAR_VAL, GUM_SCALAR_SEQ >::operator+= ( const GUM_SCALAR_SEQ &  elem)

Ajout d'un élément.

Definition at line 99 of file argMaxSet_tpl.h.

References gum::Set< Key, Alloc >::emplace().

100  {
101  argMaxSeq__->insert(elem);
102  return *this;
103  }
Sequence< GUM_SCALAR_SEQ > * argMaxSeq__
The very bone of the ArgMaxSet.
Definition: argMaxSet.h:194
void insert(const Key &k)
Insert an element at the end of the sequence.
Definition: sequence_tpl.h:409
+ Here is the call graph for this function:

◆ operator+=() [2/2]

template<typename GUM_SCALAR_VAL , typename GUM_SCALAR_SEQ >
ArgMaxSet< GUM_SCALAR_VAL, GUM_SCALAR_SEQ > & gum::ArgMaxSet< GUM_SCALAR_VAL, GUM_SCALAR_SEQ >::operator+= ( const ArgMaxSet< GUM_SCALAR_VAL, GUM_SCALAR_SEQ > &  src)

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

Definition at line 110 of file argMaxSet_tpl.h.

References gum::Set< Key, Alloc >::emplace().

111  {
112  for (auto iter = src.beginSafe(); iter != src.endSafe(); ++iter)
113  if (!argMaxSeq__->exists(*iter)) argMaxSeq__->insert(*iter);
114  return *this;
115  }
bool exists(const Key &k) const
Check the existence of k in the sequence.
Definition: sequence_tpl.h:403
Sequence< GUM_SCALAR_SEQ > * argMaxSeq__
The very bone of the ArgMaxSet.
Definition: argMaxSet.h:194
void insert(const Key &k)
Insert an element at the end of the sequence.
Definition: sequence_tpl.h:409
+ Here is the call graph for this function:

◆ operator<()

template<typename GUM_SCALAR_VAL , typename GUM_SCALAR_SEQ >
bool gum::ArgMaxSet< GUM_SCALAR_VAL, GUM_SCALAR_SEQ >::operator< ( const ArgMaxSet< GUM_SCALAR_VAL, GUM_SCALAR_SEQ > &  compared) const
inline

Checks if val is lower or higher from the compared ArgMaxSet val.

Definition at line 159 of file argMaxSet.h.

References gum::ArgMaxSet< GUM_SCALAR_VAL, GUM_SCALAR_SEQ >::val__.

160  {
161  return val__ < compared.value() ? true : false;
162  }
GUM_SCALAR_VAL val__
Definition: argMaxSet.h:195

◆ operator<=()

template<typename GUM_SCALAR_VAL , typename GUM_SCALAR_SEQ >
bool gum::ArgMaxSet< GUM_SCALAR_VAL, GUM_SCALAR_SEQ >::operator<= ( const ArgMaxSet< GUM_SCALAR_VAL, GUM_SCALAR_SEQ > &  compared) const
inline

Ajout d'un élément.

Definition at line 167 of file argMaxSet.h.

168  {
169  return !(*this > compared);
170  }

◆ operator=()

template<typename GUM_SCALAR_VAL , typename GUM_SCALAR_SEQ >
ArgMaxSet< GUM_SCALAR_VAL, GUM_SCALAR_SEQ > & gum::ArgMaxSet< GUM_SCALAR_VAL, GUM_SCALAR_SEQ >::operator= ( const ArgMaxSet< GUM_SCALAR_VAL, GUM_SCALAR_SEQ > &  src)

Constructor.

Definition at line 73 of file argMaxSet_tpl.h.

References gum::Set< Key, Alloc >::emplace().

74  {
75  this->argMaxSeq__->clear();
76  this->operator+=(src);
77  val__ = src.value();
78  return *this;
79  }
void clear()
Clear the sequence.
Definition: sequence_tpl.h:272
GUM_SCALAR_VAL val__
Definition: argMaxSet.h:195
ArgMaxSet< GUM_SCALAR_VAL, GUM_SCALAR_SEQ > & operator+=(const GUM_SCALAR_SEQ &elem)
Ajout d&#39;un élément.
Definition: argMaxSet_tpl.h:99
Sequence< GUM_SCALAR_SEQ > * argMaxSeq__
The very bone of the ArgMaxSet.
Definition: argMaxSet.h:194
+ Here is the call graph for this function:

◆ operator==()

template<typename GUM_SCALAR_VAL , typename GUM_SCALAR_SEQ >
bool gum::ArgMaxSet< GUM_SCALAR_VAL, GUM_SCALAR_SEQ >::operator== ( const ArgMaxSet< GUM_SCALAR_VAL, GUM_SCALAR_SEQ > &  compared) const

Compares two ArgMaxSet to check if they are equals.

Definition at line 121 of file argMaxSet_tpl.h.

References gum::Set< Key, Alloc >::emplace().

122  {
123  if (val__ != compared.value()) return false;
124  for (auto iter = compared.beginSafe(); iter != compared.endSafe(); ++iter)
125  if (!argMaxSeq__->exists(*iter)) return false;
126  for (auto iter = this->beginSafe(); iter != this->endSafe(); ++iter)
127  if (!compared.exists(*iter)) return false;
128  return true;
129  }
SequenceIteratorSafe< GUM_SCALAR_SEQ > endSafe() const
Iterator end.
Definition: argMaxSet.h:116
GUM_SCALAR_VAL val__
Definition: argMaxSet.h:195
bool exists(const Key &k) const
Check the existence of k in the sequence.
Definition: sequence_tpl.h:403
SequenceIteratorSafe< GUM_SCALAR_SEQ > beginSafe() const
Iterator beginning.
Definition: argMaxSet.h:109
Sequence< GUM_SCALAR_SEQ > * argMaxSeq__
The very bone of the ArgMaxSet.
Definition: argMaxSet.h:194
+ Here is the call graph for this function:

◆ operator>()

template<typename GUM_SCALAR_VAL , typename GUM_SCALAR_SEQ >
bool gum::ArgMaxSet< GUM_SCALAR_VAL, GUM_SCALAR_SEQ >::operator> ( const ArgMaxSet< GUM_SCALAR_VAL, GUM_SCALAR_SEQ > &  compared) const
inline

Ajout d'un élément.

Definition at line 163 of file argMaxSet.h.

164  {
165  return compared < *this;
166  }

◆ operator>=()

template<typename GUM_SCALAR_VAL , typename GUM_SCALAR_SEQ >
bool gum::ArgMaxSet< GUM_SCALAR_VAL, GUM_SCALAR_SEQ >::operator>= ( const ArgMaxSet< GUM_SCALAR_VAL, GUM_SCALAR_SEQ > &  compared) const
inline

Ajout d'un élément.

Definition at line 171 of file argMaxSet.h.

172  {
173  return !(*this < compared);
174  }

◆ operator[]()

template<typename GUM_SCALAR_VAL , typename GUM_SCALAR_SEQ >
const GUM_SCALAR_SEQ& gum::ArgMaxSet< GUM_SCALAR_VAL, GUM_SCALAR_SEQ >::operator[] ( const Idx  i) const
inline

Gives the ith element.

Definition at line 142 of file argMaxSet.h.

142  {
143  return argMaxSeq__->atPos(i);
144  }
Sequence< GUM_SCALAR_SEQ > * argMaxSeq__
The very bone of the ArgMaxSet.
Definition: argMaxSet.h:194
const Key & atPos(Idx i) const
Returns the object at the pos i.
Definition: sequence_tpl.h:501

◆ size()

template<typename GUM_SCALAR_VAL , typename GUM_SCALAR_SEQ >
Idx gum::ArgMaxSet< GUM_SCALAR_VAL, GUM_SCALAR_SEQ >::size ( ) const
inline

Gives the size.

Definition at line 181 of file argMaxSet.h.

181 { return argMaxSeq__->size(); }
Size size() const noexcept
Returns the size of the sequence.
Definition: sequence_tpl.h:37
Sequence< GUM_SCALAR_SEQ > * argMaxSeq__
The very bone of the ArgMaxSet.
Definition: argMaxSet.h:194

◆ value()

template<typename GUM_SCALAR_VAL , typename GUM_SCALAR_SEQ >
const GUM_SCALAR_VAL& gum::ArgMaxSet< GUM_SCALAR_VAL, GUM_SCALAR_SEQ >::value ( ) const
inline

Returns the value on which comparison are made.

Definition at line 186 of file argMaxSet.h.

References gum::ArgMaxSet< GUM_SCALAR_VAL, GUM_SCALAR_SEQ >::val__.

186 { return val__; }
GUM_SCALAR_VAL val__
Definition: argMaxSet.h:195

Friends And Related Function Documentation

◆ operator<<

template<typename GUM_SCALAR_VAL , typename GUM_SCALAR_SEQ >
std::ostream& operator<< ( std::ostream &  streamy,
const ArgMaxSet< GUM_SCALAR_VAL, GUM_SCALAR_SEQ > &  objy 
)
friend

Definition at line 198 of file argMaxSet.h.

198  {
199  streamy << "Value : " << objy.value()
200  << " - Set : " << objy.argMaxSeq__->toString();
201  return streamy;
202  }

Member Data Documentation

◆ argMaxSeq__

template<typename GUM_SCALAR_VAL , typename GUM_SCALAR_SEQ >
Sequence< GUM_SCALAR_SEQ >* gum::ArgMaxSet< GUM_SCALAR_VAL, GUM_SCALAR_SEQ >::argMaxSeq__
private

The very bone of the ArgMaxSet.

Definition at line 194 of file argMaxSet.h.

◆ val__

template<typename GUM_SCALAR_VAL , typename GUM_SCALAR_SEQ >
GUM_SCALAR_VAL gum::ArgMaxSet< GUM_SCALAR_VAL, GUM_SCALAR_SEQ >::val__
private

The documentation for this struct was generated from the following files: