AIToolbox
A library that offers tools for AI problem solving.
Trie.hpp
Go to the documentation of this file.
1 #ifndef AI_TOOLBOX_FACTORED_TRIE_HEADER_FILE
2 #define AI_TOOLBOX_FACTORED_TRIE_HEADER_FILE
3 
6 
7 namespace AIToolbox::Factored {
23  class Trie {
24  public:
33  Trie(Factors F);
34 
40  Factors getF() const;
41 
51  void reserve(size_t size);
52 
71  size_t insert(const PartialFactors & pf);
72 
78  size_t size() const;
79 
107  std::vector<size_t> filter(const Factors & f, size_t offset = 0) const;
108 
126  std::vector<size_t> filter(const PartialFactors & pf) const;
127 
136  std::vector<size_t> refine(const std::vector<size_t> & ids, const PartialFactors & pf) const;
137 
147  void erase(size_t id);
148 
161  void erase(size_t id, const PartialFactors & pf);
162 
168  const Factors & getFactors() const;
169 
170  private:
176  std::vector<size_t> getAllIds() const;
177 
178  Factors F;
179  size_t counter_;
180 
181  std::vector<std::vector<std::vector<size_t>>> ids_;
182  };
183 }
184 
185 #endif
IndexMap.hpp
AIToolbox::Factored::PartialFactors
std::pair< PartialKeys, PartialValues > PartialFactors
Definition: Types.hpp:65
AIToolbox::Factored::Trie::getF
Factors getF() const
This function returns the set state space for the Trie.
AIToolbox::Factored::Trie::size
size_t size() const
This function returns the number of insertions performed on the Trie.
AIToolbox::Factored::Trie::insert
size_t insert(const PartialFactors &pf)
This function inserts a new id using the input as a key.
AIToolbox::Factored::Factors
std::vector< size_t > Factors
Definition: Types.hpp:62
AIToolbox::Factored::Trie::filter
std::vector< size_t > filter(const Factors &f, size_t offset=0) const
This function returns all ids where their key matches the input Factors.
AIToolbox::Factored::Trie::Trie
Trie(Factors F)
Basic constructor.
AIToolbox::Factored
Definition: GraphUtils.hpp:12
Types.hpp
AIToolbox::Factored::Trie::reserve
void reserve(size_t size)
This function reserves memory for at least size elements.
AIToolbox::Factored::Trie::refine
std::vector< size_t > refine(const std::vector< size_t > &ids, const PartialFactors &pf) const
This function refines the input ids with the supplied filter.
AIToolbox::Factored::Trie::getFactors
const Factors & getFactors() const
This function returns a reference to the underlying Factors.
AIToolbox::Factored::Trie
This class organizes data ids as if in a trie.
Definition: Trie.hpp:23
AIToolbox::Factored::Trie::erase
void erase(size_t id)
This function removes the input id from the trie.