Skip to content

tuem/sftrie

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sftrie: a compact trie representation for integer alphabets

Usage

  1. Copy include/sftrie to your include path

  2. Include header

#include <sftrie/set.hpp>
  1. Build trie
using text = std::string; // you can also use u16string, u32string, etc.
std::vector<text> texts = ...;
sftrie::set<text> index(texts.begin()), texts.end());
  1. Search texts
text pattern = "...";
auto searcher = index.searcher();
// exact matching
std::cout << searcher.exists(pattern) ? "found" : "not found" << std::endl;
// common-prefix search
for(const auto& entry: searcher.prefix(pattern))
	std::cout << entry << std::endl;
// predictive search
for(const auto& entry: searcher.predict(pattern))
	std::cout << entry << std::endl;