1*ab8db090SAndroid Build Coastguard Worker #ifndef MARISA_TRIE_H_ 2*ab8db090SAndroid Build Coastguard Worker #define MARISA_TRIE_H_ 3*ab8db090SAndroid Build Coastguard Worker 4*ab8db090SAndroid Build Coastguard Worker #include "marisa/keyset.h" 5*ab8db090SAndroid Build Coastguard Worker #include "marisa/agent.h" 6*ab8db090SAndroid Build Coastguard Worker 7*ab8db090SAndroid Build Coastguard Worker namespace marisa { 8*ab8db090SAndroid Build Coastguard Worker namespace grimoire { 9*ab8db090SAndroid Build Coastguard Worker namespace trie { 10*ab8db090SAndroid Build Coastguard Worker 11*ab8db090SAndroid Build Coastguard Worker class LoudsTrie; 12*ab8db090SAndroid Build Coastguard Worker 13*ab8db090SAndroid Build Coastguard Worker } // namespace trie 14*ab8db090SAndroid Build Coastguard Worker } // namespace grimoire 15*ab8db090SAndroid Build Coastguard Worker 16*ab8db090SAndroid Build Coastguard Worker class Trie { 17*ab8db090SAndroid Build Coastguard Worker friend class TrieIO; 18*ab8db090SAndroid Build Coastguard Worker 19*ab8db090SAndroid Build Coastguard Worker public: 20*ab8db090SAndroid Build Coastguard Worker Trie(); 21*ab8db090SAndroid Build Coastguard Worker ~Trie(); 22*ab8db090SAndroid Build Coastguard Worker 23*ab8db090SAndroid Build Coastguard Worker void build(Keyset &keyset, int config_flags = 0); 24*ab8db090SAndroid Build Coastguard Worker 25*ab8db090SAndroid Build Coastguard Worker void mmap(const char *filename); 26*ab8db090SAndroid Build Coastguard Worker void map(const void *ptr, std::size_t size); 27*ab8db090SAndroid Build Coastguard Worker 28*ab8db090SAndroid Build Coastguard Worker void load(const char *filename); 29*ab8db090SAndroid Build Coastguard Worker void read(int fd); 30*ab8db090SAndroid Build Coastguard Worker 31*ab8db090SAndroid Build Coastguard Worker void save(const char *filename) const; 32*ab8db090SAndroid Build Coastguard Worker void write(int fd) const; 33*ab8db090SAndroid Build Coastguard Worker 34*ab8db090SAndroid Build Coastguard Worker bool lookup(Agent &agent) const; 35*ab8db090SAndroid Build Coastguard Worker void reverse_lookup(Agent &agent) const; 36*ab8db090SAndroid Build Coastguard Worker bool common_prefix_search(Agent &agent) const; 37*ab8db090SAndroid Build Coastguard Worker bool predictive_search(Agent &agent) const; 38*ab8db090SAndroid Build Coastguard Worker 39*ab8db090SAndroid Build Coastguard Worker std::size_t num_tries() const; 40*ab8db090SAndroid Build Coastguard Worker std::size_t num_keys() const; 41*ab8db090SAndroid Build Coastguard Worker std::size_t num_nodes() const; 42*ab8db090SAndroid Build Coastguard Worker 43*ab8db090SAndroid Build Coastguard Worker TailMode tail_mode() const; 44*ab8db090SAndroid Build Coastguard Worker NodeOrder node_order() const; 45*ab8db090SAndroid Build Coastguard Worker 46*ab8db090SAndroid Build Coastguard Worker bool empty() const; 47*ab8db090SAndroid Build Coastguard Worker std::size_t size() const; 48*ab8db090SAndroid Build Coastguard Worker std::size_t total_size() const; 49*ab8db090SAndroid Build Coastguard Worker std::size_t io_size() const; 50*ab8db090SAndroid Build Coastguard Worker 51*ab8db090SAndroid Build Coastguard Worker void clear(); 52*ab8db090SAndroid Build Coastguard Worker void swap(Trie &rhs); 53*ab8db090SAndroid Build Coastguard Worker 54*ab8db090SAndroid Build Coastguard Worker private: 55*ab8db090SAndroid Build Coastguard Worker scoped_ptr<grimoire::trie::LoudsTrie> trie_; 56*ab8db090SAndroid Build Coastguard Worker 57*ab8db090SAndroid Build Coastguard Worker // Disallows copy and assignment. 58*ab8db090SAndroid Build Coastguard Worker Trie(const Trie &); 59*ab8db090SAndroid Build Coastguard Worker Trie &operator=(const Trie &); 60*ab8db090SAndroid Build Coastguard Worker }; 61*ab8db090SAndroid Build Coastguard Worker 62*ab8db090SAndroid Build Coastguard Worker } // namespace marisa 63*ab8db090SAndroid Build Coastguard Worker 64*ab8db090SAndroid Build Coastguard Worker #endif // MARISA_TRIE_H_ 65