nlib
nn::nlib::succinct::Trie Class Referencefinal

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=NULL) noexcept
 Inspects the string to detect the target string registered in Trie. More...
 
void Match (const void *data, size_t n, MatchCallback callback, void *user_obj=NULL) noexcept
 Inspects the data to detect the target pattern. More...
 
void MatchBackward (const void *data, size_t n, MatchCallback callback, void *user_obj=NULL) noexcept
 Inspects the data backwards to detect the target pattern. More...
 
errno_t GetCommonPrefixWords (const void *prefix, size_t n, ReallocCstringVec *vec) noexcept
 Lists the data with a common prefix in dictionary order. More...
 
void Reset () noexcept
 Returns the object to the state immediately after the constructor is called.
 
Basic Member Functions
 Trie () noexcept
 Instantiates the object.
 
 ~Trie () noexcept
 Destructor.
 
Trieassign (Trie &rhs, move_tag)
 Assigns the object by using swap for a move.
 
 Trie (Trie &rhs, move_tag)
 Instantiates the object by using swap for a move.
 
 Trie (Trie &&rhs)
 Instantiates the object (move constructor). This function is useful when using C++11.
 
Trieoperator= (Trie &&rhs)
 Move assignment operator. This function is useful when using C++11.
 
void swap (Trie &rhs) noexcept
 Swaps the contents of an object.
 
bool Init () noexcept
 Resets the contents of an object. More...
 
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...
 

Detailed Description

Implements Trie using LOUDS.

Description
Trie can be used with a compact data size. Used by creating using TrieBuilder, or importing it using the Import method.

Definition at line 20 of file Trie.h.

Member Typedef Documentation

nn::nlib::succinct::Trie::MatchCallback

User-defined callback function.

Parameters
[in]firstPointer to the head of the target term (tail when a reverse search).
[in]lastThe end of the target term (immediately before the term when a reverse search).
[in]nodeidThe ID of the detected term (not a continuous value).
[in,out]user_objPointer to the user-specified object.
Returns
Continues analysis if true. Ends the process when false.
Description
Called when the string (pattern) is detected. Developers will write a process to handle each.

Definition at line 34 of file Trie.h.

Member Function Documentation

nn::nlib::succinct::Trie::Export ( BinaryWriter w) const
noexcept

Writes the object to the file.

Parameters
[in]wWrite out object.
Returns
Returns true when successful.
Description
The written data can be read and restored using the Import function. The data is always written little endian.
nn::nlib::succinct::Trie::GetCommonPrefixWords ( const void *  prefix,
size_t  n,
ReallocCstringVec vec 
)
noexcept

Lists the data with a common prefix in dictionary order.

Parameters
[in]prefixPointer to the prefix.
[in]nLength of the prefix.
[out]vecVector where the string that has prefix as a prefix is stored.
Returns
Returns 0 on success.
nn::nlib::succinct::Trie::Import ( BinaryReader r)
noexcept

Reads the written object.

Parameters
[in]rRead out object.
Returns
Returns true when import is successful.
nn::nlib::succinct::Trie::Init ( )
inlinenoexcept

Resets the contents of an object.

Returns
Returns true.

Definition at line 30 of file Trie.h.

nn::nlib::succinct::Trie::Match ( const char *  cstr,
MatchCallback  callback,
void *  user_obj = NULL 
)
inlinenoexcept

Inspects the string to detect the target string registered in Trie.

Parameters
[in]cstrString that terminates at null.
[in]callbackCallback function called when the term is detected.
[in,out]user_objPointer to the user-specified object.

Definition at line 36 of file Trie.h.

nn::nlib::succinct::Trie::Match ( const void *  data,
size_t  n,
MatchCallback  callback,
void *  user_obj = NULL 
)
noexcept

Inspects the data to detect the target pattern.

Parameters
[in]dataPointer to the head of the data to be inspected.
[in]nData size.
[in]callbackCallback function called when the pattern is detected.
[in,out]user_objPointer to the user-specified object.
nn::nlib::succinct::Trie::MatchBackward ( const void *  data,
size_t  n,
MatchCallback  callback,
void *  user_obj = NULL 
)
noexcept

Inspects the data backwards to detect the target pattern.

Parameters
[in]dataPointer to the tail of the data to be inspected.
[in]nData size.
[in]callbackCallback function called when the pattern is detected.
[in,out]user_objPointer to the user-specified object.

The documentation for this class was generated from the following files: