aGrUM  0.14.2
fusionContext.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005 by Christophe GONZALES and Pierre-Henri WUILLEMIN *
3  * {prenom.nom}_at_lip6.fr *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
27 // =========================================================================
28 #ifndef GUM_FUSION_CONTEXT_H
29 #define GUM_FUSION_CONTEXT_H
30 // =========================================================================
32 // =========================================================================
34 // =========================================================================
38 // =========================================================================
39 
40 namespace gum {
41 
50  typedef HashTableConstIteratorSafe< LeafPair*, std::vector< Size > >
52 
53 
54  template < bool isInitial = false >
55  class FusionContext {
56  public:
57  // ==========================================================================
59  // ==========================================================================
61 
62  // ###################################################################
64  // ###################################################################
66 
67  // ###################################################################
69  // ###################################################################
71 
72  // ============================================================================
74  // ============================================================================
75  void* operator new(size_t s) {
77  }
78  void operator delete(void* p) {
80  }
81 
83 
84  // ==========================================================================
86  // ==========================================================================
88 
89  // ###################################################################
91  // ###################################################################
92  public:
95  }
96 
97  private:
99  return __leaf2Pair.exists(l);
100  }
102  return false;
103  }
104 
105  // ###################################################################
107  // ###################################################################
108  public:
111  }
112 
113  private:
116 
117 
118  // ###################################################################
120  // ###################################################################
121  public:
124  }
125 
126  private:
129 
130  public:
133  }
134 
135  private:
138 
139 
140  // ###################################################################
144  // ###################################################################
145  public:
148  }
149 
150  private:
153 
155 
156  public:
157  // ==========================================================================
159  // ==========================================================================
161 
162  // ###################################################################
164  // ###################################################################
165  bool addPair(LeafPair* p);
166 
167  // ###################################################################
169  // ###################################################################
170  bool updatePair(LeafPair* p);
171 
172  // ###################################################################
174  // ###################################################################
175  bool removePair(LeafPair* p);
176 
177 
178  pair_iterator beginPairs() { return __pairsHeap.allValues().beginSafe(); }
179  pair_iterator endPairs() { return __pairsHeap.allValues().endSafe(); }
180 
182 
183  // ==========================================================================
185  // ==========================================================================
187 
188  // ###################################################################
190  // ###################################################################
191  LeafPair* top() { return !__pairsHeap.empty() ? __pairsHeap.top() : nullptr; }
192 
193  // ###################################################################
195  // ###################################################################
196  double topLikelyhood() {
197  return !__pairsHeap.empty() ? __pairsHeap.topPriority() : 1.0;
198  }
199 
201 
202  // ==========================================================================
204  // ==========================================================================
206 
207  // ###################################################################
209  // ###################################################################
210  AbstractLeaf* leaf() { return __leaf; }
211 
212  // ###################################################################
214  // ###################################################################
216  return __leaf2Pair.getWithDefault(l, nullptr);
217  }
218 
219  // ###################################################################
221  // ###################################################################
222  public:
225  }
226 
227  private:
230  return Set< LeafPair* >();
231  }
233 
234  public:
235  std::string toString();
236 
237  private:
239 
241 
243  };
244 
245 
246 } /* namespace gum */
247 
249 
250 #endif // GUM_FUSION_CONTEXT_H
Set< LeafPair *> __associatedPairs(Int2Type< false >)
Template trick for efficient development.
Priority queues in which the same element can appear several times.
HashTableConstIteratorSafe< LeafPair *, std::vector< Size > > pair_iterator
Definition: fusionContext.h:51
Headers of the abstract Leaf class.
bool __updateAssociatedLeaf(AbstractLeaf *, Int2Type< true >)
<agrum/FMDP/learning/datastructure/leaves/fusionContext.h>
Definition: fusionContext.h:55
bool __updateAllAssociatedLeaves(Int2Type< true >)
bool __updateAllAssociatedLeaves(Int2Type< false >)
bool removePair(LeafPair *p)
pair_iterator endPairs()
bool __containsAssociatedLeaf(AbstractLeaf *l, Int2Type< false >)
Definition: fusionContext.h:98
<agrum/FMDP/learning/datastructure/leaves/abstractLeaf.h>
Definition: abstractLeaf.h:50
Safe Const Iterators for hashtables.
Definition: hashTable.h:1915
<agrum/FMDP/learning/datastructure/leaves/leafPair.h>
Definition: leafPair.h:48
Set< LeafPair *> __associatedPairs(Int2Type< true >)
AbstractLeaf * leaf()
LeafPair * leafAssociatedPair(AbstractLeaf *l)
gum is the global namespace for all aGrUM entities
Definition: agrum.h:25
bool __deassociateLeaf(AbstractLeaf *, Int2Type< true >)
Set< LeafPair *> associatedPairs()
The class for generic Hash Tables.
Definition: hashTable.h:676
bool __associateLeaf(AbstractLeaf *, Int2Type< true >)
FusionContext(AbstractLeaf *)
Default constructor.
Representation of a setA Set is a structure that contains arbitrary elements.
Definition: set.h:162
bool __deassociateLeaf(AbstractLeaf *, Int2Type< false >)
bool __associateLeaf(AbstractLeaf *, Int2Type< false >)
bool __containsAssociatedLeaf(AbstractLeaf *, Int2Type< true >)
Templates for fusion context class.
bool addPair(LeafPair *p)
bool deassociateLeaf(AbstractLeaf *l)
void deallocate(void *pDeallocatedObject, const size_t &objectSize)
Deallocates an object.
HashTable< AbstractLeaf *, LeafPair *> __leaf2Pair
bool containsAssociatedLeaf(AbstractLeaf *l)
Definition: fusionContext.h:93
MultiPriorityQueue< LeafPair *, double, std::less< double > > __pairsHeap
bool __updateAssociatedLeaf(AbstractLeaf *, Int2Type< false >)
LeafPair * top()
bool updateAllAssociatedLeaves()
void * allocate(const size_t &objectSize)
Allocates a block.
~FusionContext()
Default destructor.
static SmallObjectAllocator & instance()
bool associateLeaf(AbstractLeaf *l)
std::string toString()
AbstractLeaf * __leaf
bool updateAssociatedLeaf(AbstractLeaf *l)
Headers of the leaf pair class.
bool updatePair(LeafPair *p)
A MultiPriorityQueue is a heap in which each element has a mutable priority and duplicates are allowe...
pair_iterator beginPairs()
some utils for topology : NodeId, Edge, Arc and consorts ...