refactor: rename TernaryTrie to Trie
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
Jef Roosens 2022-11-29 11:27:28 +01:00
parent cc8cfaeace
commit 4bcdd5c4d9
Signed by: Jef Roosens
GPG key ID: B75D4F293C7052DB
5 changed files with 95 additions and 98 deletions

View file

@ -29,7 +29,7 @@ static const size_t charset_len = sizeof(charset) - 1;
*
* You can (and should) redefine this in your c-file with the concrete fields.
*/
typedef struct ttrie TernaryTrie;
typedef struct ttrie Trie;
typedef enum entry_type { Redirect, Paste, Unknown } EntryType;
@ -45,7 +45,7 @@ Entry *entry_new(EntryType type, const char *string);
*
* @return a pointer to an empty Trie struct
*/
TernaryTrie *ternarytrie_init();
Trie *trie_init();
/**
* Populate trie with entries stored in the given file.
@ -54,14 +54,14 @@ TernaryTrie *ternarytrie_init();
* @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);
int trie_populate(Trie *trie, const char *file_path);
/**
* De-allocate a trie by freeing the memory occupied by this trie.
*
* @param trie which should be freed
*/
void ternarytrie_free(TernaryTrie *trie);
void trie_free(Trie *trie);
/**
* Search for an entry in the trie.
@ -70,7 +70,7 @@ void ternarytrie_free(TernaryTrie *trie);
* @param key key representing the entry
* @return pointer to entry; NULL if not found
*/
Entry *ternarytrie_search(TernaryTrie *trie, const char *key);
Entry *trie_search(Trie *trie, const char *key);
/**
* Add a string to this trie.
@ -81,7 +81,7 @@ Entry *ternarytrie_search(TernaryTrie *trie, const char *key);
* @return true if the trie was changed by this operation, false if it was
* already present
*/
bool ternarytrie_add(TernaryTrie *trie, const char *key, Entry *entry);
bool trie_add(Trie *trie, const char *key, Entry *entry);
/**
* Add an entry by generating a random string as the key.
@ -91,7 +91,7 @@ bool ternarytrie_add(TernaryTrie *trie, const char *key, Entry *entry);
* @param secure whether to generate a longer, more secure random key
* @return the generated key
*/
char *ternarytrie_add_random(TernaryTrie *trie, Entry *entry, bool secure);
char *trie_add_random(Trie *trie, Entry *entry, bool secure);
/**
* Remove an entry from this trie given its key.
@ -101,7 +101,7 @@ char *ternarytrie_add_random(TernaryTrie *trie, Entry *entry, bool secure);
* @return true if the entry was present and has been removed, false if it was
* not present
*/
bool ternarytrie_remove(TernaryTrie *trie, const char *key);
bool trie_remove(Trie *trie, const char *key);
/**
* Returns the number of entries in this trie.
@ -109,6 +109,6 @@ bool ternarytrie_remove(TernaryTrie *trie, const char *key);
* @param trie
* @return the number of entries in this trie
*/
size_t ternarytrie_size(TernaryTrie *trie);
size_t trie_size(Trie *trie);
#endif // AD3_TERNARYTRIE