AIToolbox
A library that offers tools for AI problem solving.
FasterTrie.hpp
Go to the documentation of this file.
1 #ifndef AI_TOOLBOX_FACTORED_FASTER_TRIE_HEADER_FILE
2 #define AI_TOOLBOX_FACTORED_FASTER_TRIE_HEADER_FILE
3 
4 #include <random>
7 
8 namespace AIToolbox::Factored {
16  class FasterTrie {
17  public:
18  using Entry = std::pair<size_t, PartialFactors>;
19  using Entries = std::vector<Entry>;
20 
30 
41  size_t insert(PartialFactors pf);
42 
53  void erase(size_t id, const PartialFactors & pf);
54 
68  std::vector<size_t> filter(const Factors & f) const;
69 
85  std::tuple<Entries, Factors> reconstruct(const PartialFactors & pf, bool remove = false);
86 
92  size_t size() const;
93 
97  const Factors & getF() const;
98 
99  private:
100  Factors F;
101  size_t counter_;
102 
103  std::vector<std::vector<Entries>> keys_;
104 
105  mutable std::ranlux24_base rand_; // Fastest engine possible, don't care about quality
106  mutable std::vector<std::vector<size_t>> orders_;
107  };
108 }
109 
110 #endif
AIToolbox::Factored::FasterTrie::Entry
std::pair< size_t, PartialFactors > Entry
Definition: FasterTrie.hpp:18
AIToolbox::Factored::PartialFactors
std::pair< PartialKeys, PartialValues > PartialFactors
Definition: Types.hpp:65
AIToolbox::Factored::FasterTrie::Entries
std::vector< Entry > Entries
Definition: FasterTrie.hpp:19
AIToolbox::Factored::FasterTrie::insert
size_t insert(PartialFactors pf)
This function inserts a new id using the input as a key.
AIToolbox::Factored::FasterTrie
This class is a generally faster implementation of a Trie.
Definition: FasterTrie.hpp:16
AIToolbox::Factored::FasterTrie::reconstruct
std::tuple< Entries, Factors > reconstruct(const PartialFactors &pf, bool remove=false)
This function returns a set of Entries which match the input and each other.
AIToolbox::Factored::FasterTrie::filter
std::vector< size_t > filter(const Factors &f) const
This function returns all ids of the keys that match the input Factors.
AIToolbox::Factored::FasterTrie::getF
const Factors & getF() const
This function returns a reference of the internal Factors space.
AIToolbox::Factored::FasterTrie::FasterTrie
FasterTrie(Factors f)
Basic constructor.
AIToolbox::Factored::Factors
std::vector< size_t > Factors
Definition: Types.hpp:62
Core.hpp
AIToolbox::Factored::FasterTrie::size
size_t size() const
This function returns the number of keys in the FasterTrie.
AIToolbox::Factored::FasterTrie::erase
void erase(size_t id, const PartialFactors &pf)
This function erases the id with the input key.
AIToolbox::Factored
Definition: GraphUtils.hpp:12
Types.hpp