diff options
author | Fudgerboy <91767657+Fudgerboy@users.noreply.github.com> | 2024-04-14 05:02:38 +0000 |
---|---|---|
committer | Fudgerboy <91767657+Fudgerboy@users.noreply.github.com> | 2024-04-14 05:02:38 +0000 |
commit | 248d296234dc7ce76294c677bf2ca5e76c2f50d1 (patch) | |
tree | 5a38d5a5eb4cd6075e10de1583fde289c144cc91 /wk5/pset/speller/dictionary.c | |
parent | ba93a5dca5f93fe7b5761c251037d4f1860f9a43 (diff) |
Sat, Apr 13, 2024, 10:02 PM -07:00
Diffstat (limited to 'wk5/pset/speller/dictionary.c')
-rw-r--r-- | wk5/pset/speller/dictionary.c | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/wk5/pset/speller/dictionary.c b/wk5/pset/speller/dictionary.c new file mode 100644 index 0000000..a20c467 --- /dev/null +++ b/wk5/pset/speller/dictionary.c @@ -0,0 +1,54 @@ +// Implements a dictionary's functionality + +#include <ctype.h> +#include <stdbool.h> + +#include "dictionary.h" + +// Represents a node in a hash table +typedef struct node +{ + char word[LENGTH + 1]; + struct node *next; +} node; + +// TODO: Choose number of buckets in hash table +const unsigned int N = 26; + +// Hash table +node *table[N]; + +// Returns true if word is in dictionary, else false +bool check(const char *word) +{ + // TODO + return false; +} + +// Hashes word to a number +unsigned int hash(const char *word) +{ + // TODO: Improve this hash function + return toupper(word[0]) - 'A'; +} + +// Loads dictionary into memory, returning true if successful, else false +bool load(const char *dictionary) +{ + // TODO + return false; +} + +// Returns number of words in dictionary if loaded, else 0 if not yet loaded +unsigned int size(void) +{ + // TODO + return 0; +} + +// Unloads dictionary from memory, returning true if successful, else false +bool unload(void) +{ + // TODO + return false; +} |