diff options
Diffstat (limited to 'prefix_search.h')
-rw-r--r-- | prefix_search.h | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/prefix_search.h b/prefix_search.h new file mode 100644 index 0000000..dd2f535 --- /dev/null +++ b/prefix_search.h | |||
@@ -0,0 +1,23 @@ | |||
1 | #ifndef PREFIX_SEARCH_H_5CFCF783 | ||
2 | #define PREFIX_SEARCH_H_5CFCF783 | ||
3 | |||
4 | #include <map> | ||
5 | #include <string> | ||
6 | |||
7 | class prefix_search { | ||
8 | public: | ||
9 | void add(std::string prefix); | ||
10 | int match(std::string in) const; | ||
11 | |||
12 | private: | ||
13 | struct node { | ||
14 | std::map<int, struct node> children; | ||
15 | bool match; | ||
16 | |||
17 | node() : match(false) {} | ||
18 | }; | ||
19 | |||
20 | node top; | ||
21 | }; | ||
22 | |||
23 | #endif /* end of include guard: PREFIX_SEARCH_H_5CFCF783 */ | ||