aGrUM  0.16.0
composedLeaf.h
Go to the documentation of this file.
1 
30 // =========================================================================
31 #ifndef GUM_COMPOSED_LEAF_H
32 #define GUM_COMPOSED_LEAF_H
33 // =========================================================================
35 // =========================================================================
36 
37 namespace gum {
38 
48  class ComposedLeaf : public AbstractLeaf {
49  public:
50  // ==========================================================================
52  // ==========================================================================
54 
55  // ###################################################################
57  // ###################################################################
59  AbstractLeaf(leafId), __l1(l1), __l2(l2) {
60  GUM_CONSTRUCTOR(ComposedLeaf);
61  }
62 
63  // ###################################################################
65  // ###################################################################
66  ~ComposedLeaf() { GUM_DESTRUCTOR(ComposedLeaf); }
67 
68  // ============================================================================
70  // ============================================================================
71  void* operator new(size_t s) {
73  }
74  void operator delete(void* p) {
76  }
77 
79 
80  // ###################################################################
82  // ###################################################################
83  double effectif(Idx moda) const {
84  return __l1->effectif(moda) + __l2->effectif(moda);
85  }
86  double total() const { return __l1->total() + __l2->total(); }
87 
88  // ###################################################################
90  // ###################################################################
91  bool contains(NodeId testedId) const {
92  return AbstractLeaf::contains(testedId) || __l1->contains(testedId)
93  || __l2->contains(testedId);
94  }
95 
96  Idx nbModa() const { return __l1->nbModa(); }
97 
98  std::string toString();
99 
100  private:
103  };
104 
105 
106 } /* namespace gum */
107 
108 
109 #endif // GUM_COMPOSED_LEAF_H
virtual bool contains(NodeId testedId) const
Returns true if abstractleaf has leaf in it.
Definition: abstractLeaf.h:93
Idx nbModa() const
Definition: composedLeaf.h:96
virtual double effectif(Idx) const =0
Gaves the leaf effectif for given modality.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
double effectif(Idx moda) const
Gaves the leaf effectif for given modality.
Definition: composedLeaf.h:83
AbstractLeaf * __l1
Definition: composedLeaf.h:101
<agrum/FMDP/learning/datastructure/leaves/abstractLeaf.h>
Definition: abstractLeaf.h:53
std::string toString()
bool contains(NodeId testedId) const
Returns true if abstractleaf has leaf in it.
Definition: composedLeaf.h:91
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Definition: agrum.h:25
~ComposedLeaf()
Default destructor.
Definition: composedLeaf.h:66
double total() const
Definition: composedLeaf.h:86
virtual Idx nbModa() const =0
ComposedLeaf(NodeId leafId, AbstractLeaf *l1, AbstractLeaf *l2)
Default constructor.
Definition: composedLeaf.h:58
void deallocate(void *pDeallocatedObject, const size_t &objectSize)
Deallocates an object.
<agrum/FMDP/learning/datastructure/leaves/composedLeaf.h>
Definition: composedLeaf.h:48
Size Idx
Type for indexes.
Definition: types.h:53
void * allocate(const size_t &objectSize)
Allocates a block.
static SmallObjectAllocator & instance()
AbstractLeaf * __l2
Definition: composedLeaf.h:102
virtual double total() const =0
Size NodeId
Type for node ids.
Definition: graphElements.h:98