aGrUM  0.16.0
scoringCache.h
Go to the documentation of this file.
1 
34 #ifndef GUM_LEARNING_SCORING_CACHE_H
35 #define GUM_LEARNING_SCORING_CACHE_H
36 
37 #include <utility>
38 
39 #include <agrum/agrum.h>
41 
42 namespace gum {
43 
44  namespace learning {
45 
46 
59  template < template < typename > class ALLOC = std::allocator >
60  class ScoringCache : private ALLOC< NodeId > {
61  public:
63  using allocator_type = ALLOC< NodeId >;
64 
65  // ##########################################################################
67  // ##########################################################################
69 
71  ScoringCache(const allocator_type& alloc = allocator_type());
72 
75 
77  ScoringCache(const ScoringCache< ALLOC >& from, const allocator_type& alloc);
78 
81 
84 
86  virtual ScoringCache< ALLOC >* clone() const;
87 
89  virtual ScoringCache< ALLOC >* clone(const allocator_type& alloc) const;
90 
92  virtual ~ScoringCache();
93 
95 
96 
97  // ##########################################################################
99  // ##########################################################################
101 
104 
107 
109 
110 
111  // ##########################################################################
113  // ##########################################################################
115 
117 
121  void insert(const IdSet< ALLOC >& idset, double score);
122 
124 
128  void insert(IdSet< ALLOC >&& idset, double score);
129 
131 
134  void erase(const IdSet< ALLOC >& idset);
135 
137 
138  bool exists(const IdSet< ALLOC >& idset);
139 
141 
143  double score(const IdSet< ALLOC >& idset);
144 
146  void clear();
147 
149  std::size_t size() const;
150 
153 
155 
156 
157 #ifndef DOXYGEN_SHOULD_SKIP_THIS
158 
159  private:
162  double,
163  ALLOC< std::pair< IdSet< ALLOC >, double > > >
164  __scores;
165 
166 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
167  };
168 
169  } /* namespace learning */
170 
171 } /* namespace gum */
172 
173 
174 // always include the template implementation
176 
177 
178 #endif /* GUM_LEARNING_SCORING_CACHE_H */
virtual ~ScoringCache()
destructor
A class for storing a pair of sets of NodeIds, the second one corresponding to a conditional set...
Definition: idSet.h:48
void erase(const IdSet< ALLOC > &idset)
removes a score (if it exists)
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.
Definition: agrum.h:25
The class for generic Hash Tables.
Definition: hashTable.h:679
std::size_t size() const
returns the number of scores saved in the cache
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
ALLOC< NodeId > allocator_type
type for the allocators passed in arguments of methods
Definition: scoringCache.h:63
void clear()
removes all the stored scores
double score(const IdSet< ALLOC > &idset)
returns a given score
ScoringCache< ALLOC > & operator=(const ScoringCache< ALLOC > &from)
copy operator
void insert(const IdSet< ALLOC > &idset, double score)
insert a new score into the cache
ScoringCache(const allocator_type &alloc=allocator_type())
default constructor
virtual ScoringCache< ALLOC > * clone() const
virtual copy constructor
a cache for caching scores and independence tests resultsCaching previously computed scores or the re...
Definition: scoringCache.h:60
allocator_type getAllocator() const
returns the allocator used by the translator
bool exists(const IdSet< ALLOC > &idset)
indicates whether a given score exists