nlib
|
Implements Trie using LOUDS. More...
#include "nn/nlib/succinct/Trie.h"
Public Types | |
typedef bool(* | MatchCallback) (const char *first, const char *last, uint32_t nodeid, void *user_obj) |
User-defined callback function. More... | |
Public Member Functions | |
void | Match (const char *cstr, MatchCallback callback, void *user_obj) noexcept |
Inspects the string to detect the target string registered in Trie. More... | |
void | Match (const char *cstr, MatchCallback callback) noexcept |
A parameter omitted version of the above function which passes nullptr as a parameter. | |
void | Match (const void *data, size_t n, MatchCallback callback, void *user_obj) noexcept |
Inspects the data to detect the target pattern. More... | |
void | Match (const void *data, size_t n, MatchCallback callback) noexcept |
A parameter omitted version of the above function which passes nullptr as a parameter. | |
void | MatchBackward (const void *data, size_t n, MatchCallback callback, void *user_obj) noexcept |
Inspects the data backwards to detect the target pattern. More... | |
void | MatchBackward (const void *data, size_t n, MatchCallback callback) noexcept |
A parameter omitted version of the above function which passes nullptr as a parameter. | |
errno_t | GetCommonPrefixWords (const void *prefix, size_t n, ReallocCstringVec *vec) noexcept |
Lists the data with a common prefix in dictionary order. More... | |
std::pair< errno_t, Nlist< uint32_t > > | GetCommonPrefixWords (const void *prefix, size_t n) noexcept |
Returns a list of nodeid of data that have common prefix. More... | |
size_t | MemSize () const noexcept |
Returns the amount of memory explicitly allocated by the class. More... | |
Constructor, Destructor, and Initialization | |
constexpr | Trie () noexcept |
Instantiates the object with default parameters (default constructor). Requires initialization with Init() after execution. | |
~Trie () noexcept | |
Destructor. | |
Trie & | assign (Trie &rhs, move_tag) |
Corresponds to a move assignment operator. | |
Trie (Trie &rhs, move_tag) | |
Corresponds to a move constructor. | |
Trie (Trie &&rhs) | |
Instantiates the object (move constructor). | |
Trie & | operator= (Trie &&rhs) |
Move assignment operator. | |
bool | Init () noexcept |
Initializes an object. Returns true if successful. | |
void | Reset () noexcept |
Resets this object to the state immediately after the default constructor was executed. | |
Importing and Exporting | |
bool | Export (BinaryWriter *w) const noexcept |
Writes the object to the file. More... | |
bool | Import (BinaryReader *r) noexcept |
Reads the written object. More... | |
Implements Trie using LOUDS.
TrieBuilder
, or importing it using the Import
method. nn::nlib::succinct::Trie::MatchCallback |
User-defined callback function.
[in] | first | Pointer to the head of the target term (tail when a reverse search). |
[in] | last | The end of the target term (immediately before the term when a reverse search). |
[in] | nodeid | The ID of the detected term (not a continuous value). |
[in,out] | user_obj | Pointer to the user-specified object. |
true
. Ends the process when false
.
|
noexcept |
Writes the object to the file.
[in] | w | Write out object. |
true
when successful.Import
function. The data is always written little endian.
|
noexcept |
Lists the data with a common prefix in dictionary order.
[in] | prefix | Pointer to the prefix. |
[in] | n | Length of the prefix. |
[out] | vec | Vector where the string that has prefix as a prefix is stored. |
0
on success.
|
noexcept |
Returns a list of nodeid
of data that have common prefix.
[in] | prefix | Pointer to the prefix. |
[in] | n | Length of the prefix. |
nodeid
.nodeid
is an integer passed to the parameter of MatchCallback
.
|
noexcept |
Reads the written object.
[in] | r | Read out object. |
true
when import is successful.
|
inlinenoexcept |
|
noexcept |
Inspects the data to detect the target pattern.
[in] | data | Pointer to the head of the data to be inspected. |
[in] | n | Data size. |
[in] | callback | Callback function called when the pattern is detected. |
[in,out] | user_obj | Pointer to the user-specified object. |
|
noexcept |
Inspects the data backwards to detect the target pattern.
[in] | data | Pointer to the tail of the data to be inspected. |
[in] | n | Data size. |
[in] | callback | Callback function called when the pattern is detected. |
[in,out] | user_obj | Pointer to the user-specified object. |
|
noexcept |
Returns the amount of memory explicitly allocated by the class.
© Nintendo Co., Ltd. All rights reserved.