aGrUM  0.20.3
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  }
Sequence< GUM_SCALAR_SEQ > * _argMaxSeq_
The very bone of the ArgMaxSet.
Definition: argMaxSet.h:177
ArgMaxSet()
Constructor.
Definition: argMaxSet_tpl.h:41

◆ 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().

51  {
52  GUM_CONSTRUCTOR(ArgMaxSet);
54  _argMaxSeq_->insert(elem);
55  _val_ = val;
56  }
Sequence< GUM_SCALAR_SEQ > * _argMaxSeq_
The very bone of the ArgMaxSet.
Definition: argMaxSet.h:177
GUM_SCALAR_VAL _val_
Definition: argMaxSet.h:178
ArgMaxSet()
Constructor.
Definition: argMaxSet_tpl.h:41
void insert(const Key &k)
Insert an element at the end of the sequence.
Definition: sequence_tpl.h:393
+ 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 62 of file argMaxSet_tpl.h.

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

63  {
64  GUM_CONS_CPY(ArgMaxSet);
66  this->operator+=(src);
67  _val_ = src.value();
68  }
Sequence< GUM_SCALAR_SEQ > * _argMaxSeq_
The very bone of the ArgMaxSet.
Definition: argMaxSet.h:177
GUM_SCALAR_VAL _val_
Definition: argMaxSet.h:178
ArgMaxSet< GUM_SCALAR_VAL, GUM_SCALAR_SEQ > & operator+=(const GUM_SCALAR_SEQ &elem)
Ajout d&#39;un élément.
Definition: argMaxSet_tpl.h:98
ArgMaxSet()
Constructor.
Definition: argMaxSet_tpl.h:41
+ 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 84 of file argMaxSet_tpl.h.

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

84  {
85  GUM_DESTRUCTOR(ArgMaxSet);
86  delete _argMaxSeq_;
87  }
Sequence< GUM_SCALAR_SEQ > * _argMaxSeq_
The very bone of the ArgMaxSet.
Definition: argMaxSet.h:177
ArgMaxSet()
Constructor.
Definition: argMaxSet_tpl.h:41
+ 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 107 of file argMaxSet.h.

107 { return _argMaxSeq_->beginSafe(); }
Sequence< GUM_SCALAR_SEQ > * _argMaxSeq_
The very bone of the ArgMaxSet.
Definition: argMaxSet.h:177
iterator_safe beginSafe() const
Returns a safe begin iterator.
Definition: sequence_tpl.h:603

◆ 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 112 of file argMaxSet.h.

112 { return _argMaxSeq_->endSafe(); }
const iterator_safe & endSafe() const noexcept
Returns the safe end iterator.
Definition: sequence_tpl.h:610
Sequence< GUM_SCALAR_SEQ > * _argMaxSeq_
The very bone of the ArgMaxSet.
Definition: argMaxSet.h:177

◆ 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 173 of file argMaxSet.h.

173 { return _argMaxSeq_->exists(elem); }
Sequence< GUM_SCALAR_SEQ > * _argMaxSeq_
The very bone of the ArgMaxSet.
Definition: argMaxSet.h:177
bool exists(const Key &k) const
Check the existence of k in the sequence.
Definition: sequence_tpl.h:387

◆ 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 91 of file argMaxSet.h.

91  {
93  p,
94  sizeof(ArgMaxSet< GUM_SCALAR_VAL, GUM_SCALAR_SEQ >));
95  }
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.

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 141 of file argMaxSet.h.

141  {
142  return !(*this == compared);
143  }

◆ 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 98 of file argMaxSet_tpl.h.

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

98  {
99  _argMaxSeq_->insert(elem);
100  return *this;
101  }
Sequence< GUM_SCALAR_SEQ > * _argMaxSeq_
The very bone of the ArgMaxSet.
Definition: argMaxSet.h:177
void insert(const Key &k)
Insert an element at the end of the sequence.
Definition: sequence_tpl.h:393
+ 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 108 of file argMaxSet_tpl.h.

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

109  {
110  for (auto iter = src.beginSafe(); iter != src.endSafe(); ++iter)
111  if (!_argMaxSeq_->exists(*iter)) _argMaxSeq_->insert(*iter);
112  return *this;
113  }
Sequence< GUM_SCALAR_SEQ > * _argMaxSeq_
The very bone of the ArgMaxSet.
Definition: argMaxSet.h:177
bool exists(const Key &k) const
Check the existence of k in the sequence.
Definition: sequence_tpl.h:387
void insert(const Key &k)
Insert an element at the end of the sequence.
Definition: sequence_tpl.h:393
+ 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 148 of file argMaxSet.h.

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

148  {
149  return _val_ < compared.value() ? true : false;
150  }
GUM_SCALAR_VAL _val_
Definition: argMaxSet.h:178

◆ 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 154 of file argMaxSet.h.

154  {
155  return !(*this > compared);
156  }

◆ 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 72 of file argMaxSet_tpl.h.

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

73  {
74  this->_argMaxSeq_->clear();
75  this->operator+=(src);
76  _val_ = src.value();
77  return *this;
78  }
void clear()
Clear the sequence.
Definition: sequence_tpl.h:264
Sequence< GUM_SCALAR_SEQ > * _argMaxSeq_
The very bone of the ArgMaxSet.
Definition: argMaxSet.h:177
GUM_SCALAR_VAL _val_
Definition: argMaxSet.h:178
ArgMaxSet< GUM_SCALAR_VAL, GUM_SCALAR_SEQ > & operator+=(const GUM_SCALAR_SEQ &elem)
Ajout d&#39;un élément.
Definition: argMaxSet_tpl.h:98
+ 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 119 of file argMaxSet_tpl.h.

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

120  {
121  if (_val_ != compared.value()) return false;
122  for (auto iter = compared.beginSafe(); iter != compared.endSafe(); ++iter)
123  if (!_argMaxSeq_->exists(*iter)) return false;
124  for (auto iter = this->beginSafe(); iter != this->endSafe(); ++iter)
125  if (!compared.exists(*iter)) return false;
126  return true;
127  }
SequenceIteratorSafe< GUM_SCALAR_SEQ > endSafe() const
Iterator end.
Definition: argMaxSet.h:112
Sequence< GUM_SCALAR_SEQ > * _argMaxSeq_
The very bone of the ArgMaxSet.
Definition: argMaxSet.h:177
bool exists(const Key &k) const
Check the existence of k in the sequence.
Definition: sequence_tpl.h:387
SequenceIteratorSafe< GUM_SCALAR_SEQ > beginSafe() const
Iterator beginning.
Definition: argMaxSet.h:107
GUM_SCALAR_VAL _val_
Definition: argMaxSet.h:178
+ 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 151 of file argMaxSet.h.

151  {
152  return compared < *this;
153  }

◆ 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 157 of file argMaxSet.h.

157  {
158  return !(*this < compared);
159  }

◆ 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 135 of file argMaxSet.h.

135 { return _argMaxSeq_->atPos(i); }
Sequence< GUM_SCALAR_SEQ > * _argMaxSeq_
The very bone of the ArgMaxSet.
Definition: argMaxSet.h:177
const Key & atPos(Idx i) const
Returns the object at the pos i.
Definition: sequence_tpl.h:483

◆ 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 166 of file argMaxSet.h.

166 { 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:177

◆ 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 171 of file argMaxSet.h.

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

171 { return _val_; }
GUM_SCALAR_VAL _val_
Definition: argMaxSet.h:178

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 181 of file argMaxSet.h.

181  {
182  streamy << "Value : " << objy.value() << " - Set : " << objy._argMaxSeq_->toString();
183  return streamy;
184  }

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 177 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: