Tessil / hat-trie

C++ implementation of a fast and memory efficient HAT-trie
MIT License
792 stars 114 forks source link

Add longest_prefix method #14

Closed Tessil closed 6 years ago

Tessil commented 6 years ago

Add a longest_prefix method to find the key in the trie which is the longest prefix of a given value (#13).

tsl::htrie_set<char> map = {"/foo", "/foo/bar"};

map.longest_prefix("/foo"); // returns "/foo"
map.longest_prefix("/foo/baz"); // returns "/foo"
map.longest_prefix("/foo/bar/baz"); // returns "/foo/bar"
map.longest_prefix("/foo/bar/"); // returns "/foo/bar"
map.longest_prefix("/bar"); // returns end()
map.longest_prefix(""); // returns end()