开始设计
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
#ifndef INCLUDED_C_NLPTRIE_H
|
||||
#define INCLUDED_C_NLPTRIE_H
|
||||
|
||||
#ifndef INCLUDED_C_BASE_H
|
||||
#include <c_Base.h>
|
||||
#endif /*INCLUDED_C_BASE_H*/
|
||||
|
||||
#ifndef INCLUDED_C_NLPSTRINGLIST_H
|
||||
#include <c_NlpStringList.h>
|
||||
#endif /*INCLUDED_C_NLPSTRINGLIST_H*/
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------ */
|
||||
/* */
|
||||
|
||||
typedef struct c_NlpTrieNode_t c_NlpTrieNode_t;
|
||||
|
||||
typedef struct {
|
||||
c_NlpTrieNode_t* root;
|
||||
c_size_t size;
|
||||
}c_NlpTrie_t;
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------ */
|
||||
/* */
|
||||
|
||||
c_err_t c_NlpTrie_Init(c_NlpTrie_t* self);
|
||||
|
||||
void c_NlpTrie_Destroy(c_NlpTrie_t* self);
|
||||
|
||||
c_err_t c_NlpTrie_Insert(c_NlpTrie_t* self, const char* word);
|
||||
|
||||
c_bool_t c_NlpTrie_Contains(c_NlpTrie_t* self, const char* word);
|
||||
|
||||
c_bool_t c_NlpTrie_HasStartWith(c_NlpTrie_t* self, const char* word);
|
||||
|
||||
c_err_t c_NlpTrie_LongestPrefixOf(c_NlpTrie_t* self, const char* text, char* result, size_t res_max_len);
|
||||
|
||||
c_size_t c_NlpTrie_LongestPrefixOfLen(c_NlpTrie_t* self, const char* text);
|
||||
|
||||
c_err_t c_NlpTrie_KeysWithPrefix(c_NlpTrie_t* self, const char* prefix, c_NlpStringList_t* output);
|
||||
|
||||
c_err_t c_NlpTrie_KeysThatMatch(c_NlpTrie_t* self, const char* pattern, c_NlpStringList_t* output);
|
||||
|
||||
c_err_t c_NlpTrie_Delete(c_NlpTrie_t* self, const char* word);
|
||||
|
||||
/**
|
||||
* @brief Resets and purges all words and branches inside the Trie while preserving the root instance.
|
||||
* @param self Pointer to the active Trie instance.
|
||||
* @return c_err_t C_ERR_OK on successful clearing, or C_ERR_PARAM if the pointer instance is invalid.
|
||||
*/
|
||||
c_err_t c_NlpTrie_Clear(c_NlpTrie_t* self);
|
||||
|
||||
#endif /*INCLUDED_C_NLPTRIE_H*/
|
||||
Reference in New Issue
Block a user