chore: added some comments

This commit is contained in:
Jef Roosens 2022-11-21 14:46:53 +01:00
parent 494946d24a
commit 689a878978
Signed by: Jef Roosens
GPG key ID: B75D4F293C7052DB
2 changed files with 23 additions and 14 deletions

View file

@ -30,6 +30,13 @@ typedef struct ttrie TernaryTrie;
*/
TernaryTrie* ternarytrie_init();
/**
* Populate trie with entries stored in the given file.
*
* @param trie
* @param file_path path to file containing entries
* @return amount of entries added; -1 if an error occured
*/
int ternarytrie_populate(TernaryTrie* trie, const char* file_path);
/**
@ -43,24 +50,26 @@ void ternarytrie_free(TernaryTrie* trie);
* Search whether a string is contained in this trie.
*
* @param trie
* @param string
* @return true if the string is contained within this trie, false otherwise
* @param key
* @return pointer to payload string; NULL if not found
*/
char * ternarytrie_search(TernaryTrie* trie, const char* string);
char * ternarytrie_search(TernaryTrie* trie, const char* key);
/**
* Add a string to this trie.
*
* @param trie
* @param string
* @param key
* @param payload payload to add
* @return true if the trie was changed by this operation, false if it was already present
*/
bool ternarytrie_add(TernaryTrie* trie, const char* string, const char *payload);
bool ternarytrie_add(TernaryTrie* trie, const char* key, const char *payload);
/**
* Add a payload by generating a random string as the key.
*
* @param trie
* @param payload payload to add
* @return the generated key
*/
char *ternarytrie_add_random(TernaryTrie *trie, const char *payload);
@ -72,10 +81,10 @@ char *ternarytrie_add_random(TernaryTrie *trie, const char *payload);
* Removing the string from the trie should not free the string's memory.
*
* @param trie
* @param string
* @param key
* @return true if the string was present and has been removed, false if it was not present
*/
bool ternarytrie_remove(TernaryTrie* trie, const char* string);
bool ternarytrie_remove(TernaryTrie* trie, const char* key);
/**
* Returns the number of strings in this trie.