aGrUM  0.16.0
leafPair.h
Go to the documentation of this file.
1 
30 // =========================================================================
31 #ifndef GUM_LEAF_PAIR_H
32 #define GUM_LEAF_PAIR_H
33 // =========================================================================
35 // =========================================================================
38 // =========================================================================
39 
40 namespace gum {
41 
51  class LeafPair {
52  public:
53  // ==========================================================================
55  // ==========================================================================
57 
58  // ###################################################################
60  // ###################################################################
61  LeafPair(AbstractLeaf* l1, AbstractLeaf* l2) : __l1(l1), __l2(l2) {
62  GUM_CONSTRUCTOR(LeafPair);
63  }
64 
65  // ###################################################################
67  // ###################################################################
68  ~LeafPair() { GUM_DESTRUCTOR(LeafPair); }
69 
70  // ============================================================================
72  // ============================================================================
73  void* operator new(size_t s) {
75  }
76  void operator delete(void* p) {
78  }
79 
81 
82  // ==========================================================================
84  // ==========================================================================
86 
87  // ###################################################################
89  // ###################################################################
90  void updateLikelyhood();
91 
92  // ###################################################################
94  // ###################################################################
95  double likelyhood();
96 
98 
99  // ###################################################################
101  // ###################################################################
102  AbstractLeaf* firstLeaf() { return __l1; }
103  AbstractLeaf* secondLeaf() { return __l2; }
104 
105  // ###################################################################
107  // ###################################################################
108  bool contains(NodeId testedId) {
109  return __l1->contains(testedId) || __l2->contains(testedId);
110  }
111 
112  // ###################################################################
114  // ###################################################################
116  return new ComposedLeaf(leafId, __l1, __l2);
117  }
118 
120  return l == __l1 ? __l2 : __l1;
121  }
122 
123  std::string toString();
124 
125  private:
128 
131  };
132 
133 
134 } /* namespace gum */
135 
136 
137 #endif // GUM_LEAF_PAIR_H
virtual bool contains(NodeId testedId) const
Returns true if abstractleaf has leaf in it.
Definition: abstractLeaf.h:93
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
AbstractLeaf * convert2Leaf(NodeId leafId) const
Returns a leaf matching data and having given id as id.
Definition: leafPair.h:115
<agrum/FMDP/learning/datastructure/leaves/abstractLeaf.h>
Definition: abstractLeaf.h:53
~LeafPair()
Default destructor.
Definition: leafPair.h:68
<agrum/FMDP/learning/datastructure/leaves/leafPair.h>
Definition: leafPair.h:51
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Definition: agrum.h:25
AbstractLeaf * otherLeaf(AbstractLeaf *l) const
Definition: leafPair.h:119
double __likelyhood2
Definition: leafPair.h:130
AbstractLeaf * __l2
Definition: leafPair.h:127
AbstractLeaf * secondLeaf()
Definition: leafPair.h:103
void deallocate(void *pDeallocatedObject, const size_t &objectSize)
Deallocates an object.
<agrum/FMDP/learning/datastructure/leaves/composedLeaf.h>
Definition: composedLeaf.h:48
LeafPair(AbstractLeaf *l1, AbstractLeaf *l2)
Default constructor.
Definition: leafPair.h:61
void * allocate(const size_t &objectSize)
Allocates a block.
double __likelyhood1
Definition: leafPair.h:129
AbstractLeaf * firstLeaf()
Definition: leafPair.h:102
static SmallObjectAllocator & instance()
std::string toString()
Definition: leafPair.cpp:85
double likelyhood()
Updates GStatistic.
Definition: leafPair.cpp:77
Size NodeId
Type for node ids.
Definition: graphElements.h:98
AbstractLeaf * __l1
Definition: leafPair.h:126
bool contains(NodeId testedId)
Returns true if pair has leaf in it.
Definition: leafPair.h:108
void updateLikelyhood()
Updates GStatistic.
Definition: leafPair.cpp:42
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.