about summary refs log tree commit diff stats
path: root/prefix_search.h
blob: dd2f535259568df42390724ad8ab77e2ade18180 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#ifndef PREFIX_SEARCH_H_5CFCF783
#define PREFIX_SEARCH_H_5CFCF783

#include <map>
#include <string>

class prefix_search {
  public:
    void add(std::string prefix);
    int match(std::string in) const;
    
  private:
    struct node {
      std::map<int, struct node> children;
      bool match;
      
      node() : match(false) {}
    };
    
    node top;
};

#endif /* end of include guard: PREFIX_SEARCH_H_5CFCF783 */