aGrUM  0.14.2
leafPair.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_LEAF_PAIR_H
29 #define GUM_LEAF_PAIR_H
30 // =========================================================================
32 // =========================================================================
35 // =========================================================================
36 
37 namespace gum {
38 
48  class LeafPair {
49  public:
50  // ==========================================================================
52  // ==========================================================================
54 
55  // ###################################################################
57  // ###################################################################
58  LeafPair(AbstractLeaf* l1, AbstractLeaf* l2) : __l1(l1), __l2(l2) {
59  GUM_CONSTRUCTOR(LeafPair);
60  }
61 
62  // ###################################################################
64  // ###################################################################
65  ~LeafPair() { GUM_DESTRUCTOR(LeafPair); }
66 
67  // ============================================================================
69  // ============================================================================
70  void* operator new(size_t s) {
72  }
73  void operator delete(void* p) {
75  }
76 
78 
79  // ==========================================================================
81  // ==========================================================================
83 
84  // ###################################################################
86  // ###################################################################
87  void updateLikelyhood();
88 
89  // ###################################################################
91  // ###################################################################
92  double likelyhood();
93 
95 
96  // ###################################################################
98  // ###################################################################
99  AbstractLeaf* firstLeaf() { return __l1; }
100  AbstractLeaf* secondLeaf() { return __l2; }
101 
102  // ###################################################################
104  // ###################################################################
105  bool contains(NodeId testedId) {
106  return __l1->contains(testedId) || __l2->contains(testedId);
107  }
108 
109  // ###################################################################
111  // ###################################################################
113  return new ComposedLeaf(leafId, __l1, __l2);
114  }
115 
117  return l == __l1 ? __l2 : __l1;
118  }
119 
120  std::string toString();
121 
122  private:
125 
128  };
129 
130 
131 } /* namespace gum */
132 
133 
134 #endif // GUM_LEAF_PAIR_H
virtual bool contains(NodeId testedId) const
Returns true if abstractleaf has leaf in it.
Definition: abstractLeaf.h:90
Headers of the abstract leaf class.
Headers of the abstract Leaf class.
AbstractLeaf * convert2Leaf(NodeId leafId) const
Returns a leaf matching data and having given id as id.
Definition: leafPair.h:112
<agrum/FMDP/learning/datastructure/leaves/abstractLeaf.h>
Definition: abstractLeaf.h:50
~LeafPair()
Default destructor.
Definition: leafPair.h:65
<agrum/FMDP/learning/datastructure/leaves/leafPair.h>
Definition: leafPair.h:48
gum is the global namespace for all aGrUM entities
Definition: agrum.h:25
AbstractLeaf * otherLeaf(AbstractLeaf *l) const
Definition: leafPair.h:116
double __likelyhood2
Definition: leafPair.h:127
AbstractLeaf * __l2
Definition: leafPair.h:124
AbstractLeaf * secondLeaf()
Definition: leafPair.h:100
void deallocate(void *pDeallocatedObject, const size_t &objectSize)
Deallocates an object.
<agrum/FMDP/learning/datastructure/leaves/composedLeaf.h>
Definition: composedLeaf.h:45
LeafPair(AbstractLeaf *l1, AbstractLeaf *l2)
Default constructor.
Definition: leafPair.h:58
void * allocate(const size_t &objectSize)
Allocates a block.
double __likelyhood1
Definition: leafPair.h:126
AbstractLeaf * firstLeaf()
Definition: leafPair.h:99
static SmallObjectAllocator & instance()
std::string toString()
Definition: leafPair.cpp:82
double likelyhood()
Updates GStatistic.
Definition: leafPair.cpp:74
Size NodeId
Type for node ids.
Definition: graphElements.h:97
AbstractLeaf * __l1
Definition: leafPair.h:123
bool contains(NodeId testedId)
Returns true if pair has leaf in it.
Definition: leafPair.h:105
void updateLikelyhood()
Updates GStatistic.
Definition: leafPair.cpp:39
some utils for topology : NodeId, Edge, Arc and consorts ...