16 #ifndef INCLUDE_NN_NLIB_SUCCINCT_TRIE_H_ 17 #define INCLUDE_NN_NLIB_SUCCINCT_TRIE_H_ 25 #include "nn/nlib/Swap.h" 27 #if defined(_MSC_VER) && defined(nx_succinct_EXPORTS) 28 #undef NLIB_VIS_PUBLIC 29 #define NLIB_VIS_PUBLIC NLIB_WINEXPORT 39 NLIB_DEFMOVE_PIMPL(
Trie);
41 TriePrivate* tmp = rhs.prv_;
42 rhs.prv_ = this->prv_;
46 typedef bool (*MatchCallback)(
const char* first,
const char* last, uint32_t nodeid,
48 void Match(
const char* cstr, MatchCallback callback,
void* user_obj) NLIB_NOEXCEPT {
49 this->Match(cstr,
nlib_strlen(cstr), callback, user_obj);
51 void Match(
const char* cstr, MatchCallback callback) NLIB_NOEXCEPT {
52 this->Match(cstr,
nlib_strlen(cstr), callback,
nullptr);
54 void Match(
const void* data,
size_t n, MatchCallback callback,
56 void Match(
const void* data,
size_t n, MatchCallback callback) NLIB_NOEXCEPT {
57 Match(data, n, callback,
nullptr);
60 void MatchBackward(
const void* data,
size_t n, MatchCallback callback,
62 void MatchBackward(
const void* data,
size_t n, MatchCallback callback) NLIB_NOEXCEPT {
63 MatchBackward(data, n, callback,
nullptr);
65 errno_t GetCommonPrefixWords(
const void* prefix,
size_t n,
73 MatchCallback callback,
void* user_obj,
bool isfwd)
NLIB_NOEXCEPT;
94 return AddWords(str, strlen(str));
98 struct TrieBuilderPrivate;
99 TrieBuilderPrivate* prv_;
106 NLIB_DEFINE_STD_SWAP(::nlib_ns::succinct::Trie)
107 NLIB_DEFINE_STD_SWAP(::nlib_ns::succinct::TrieBuilder)
109 #if defined(_MSC_VER) && defined(nx_succinct_EXPORTS) 110 #undef NLIB_VIS_PUBLIC 111 #define NLIB_VIS_PUBLIC NLIB_WINIMPORT 114 #endif // INCLUDE_NN_NLIB_SUCCINCT_TRIE_H_ Class to create a Trie object.
Defines the basic classes that form the basis to Rank and Select operations.
Defines the class for constructing and accessing a LOUDS succinct tree.
void swap(Trie &rhs) noexcept
Swaps the contents of an object.
void Match(const char *cstr, MatchCallback callback, void *user_obj) noexcept
Inspects the string to detect the target string registered in Trie.
constexpr Trie() noexcept
Instantiates the object.
void Match(const char *cstr, MatchCallback callback) noexcept
Runs Match(cstr, callback, NULL).
#define NLIB_DISALLOW_COPY_AND_ASSIGN(TypeName)
Prohibits use of the copy constructor and assignment operator for the class specified by TypeName...
void Match(const void *data, size_t n, MatchCallback callback) noexcept
Runs Match(data, n, callback, NULL).
~TrieBuilder() noexcept
Destructor.
The class for realloc-based implementations of C string vectors.
Implements Trie using LOUDS.
bool AddWords(const char *str) noexcept
Adds a string from an array containing a set of target strings. The strings must be delimited by newl...
constexpr TrieBuilder() noexcept
Instantiates the object.
~Trie() noexcept
Destructor.
#define NLIB_NOEXCEPT
Defines noexcept geared to the environment, or the equivalent.
#define NLIB_CEXPR
Defines constexpr if it is available for use. If not, holds an empty string.
void MatchBackward(const void *data, size_t n, MatchCallback callback) noexcept
Runs MatchBackward(data, n, callback, NULL).
The class for writing binary to streams (to OutputStream).
#define NLIB_FINAL
Defines final if it is available for use. If not, holds an empty string.
The class for reading binary from streams (from InputStream).
The class for realloc-based implementations of vectors with POD-type elements.