Skip to content

Commit

Permalink
Cleaned up the documentation for HashC.h
Browse files Browse the repository at this point in the history
Changed up the description of some of the functions
for more clarity.
  • Loading branch information
kpluas21 committed May 7, 2023
1 parent 220f2e9 commit 82267ef
Showing 1 changed file with 28 additions and 13 deletions.
41 changes: 28 additions & 13 deletions Data_Structures/HashC/src/HashC.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef _HASHC_H
#define _HASHC_H
#ifndef HASHC_H
#define HASHC_H

/**
* @file HashC.h
Expand All @@ -16,8 +16,13 @@ typedef struct HashC HashC;
typedef struct HashC_pair HashC_pair;

/**
* @brief Our table will be made out of pairs which is our main data unit.
* Contains a string as its key and an int as the actual value
* @brief The main key-value pair data unit of our hash table.
*
* @var HashC_pair::key
* A string which serves as the key to look up the value
*
* @var HashC_pair::value
* The main value stored in the hash tables indices
*
*/
typedef struct HashC_pair {
Expand All @@ -26,13 +31,23 @@ typedef struct HashC_pair {
}HashC_pair;

/**
* @brief Our main table struct which contains our pairs. This is the main
* @brief The main hash table object which contains our pairs. This is the main
* object that users will interact with.
*
* @var HashC_table::max_size
* The maximum amount of key-value pairs allowed in the hash table. The default is 300 and this can be changed
* by modifying the DEFAULT_SIZE variable.
*
* @var HashC_table::size
* The amount of key-value pairs currently in the table
*
* @var HashC_table::table
* Pointer to a pointer of a HashC_pair object, in other words, it's a pointer to an array of HashC_pairs.
*
*/
typedef struct HashC_table {
size_t max_size; //The maximum amount of pairs allowed in the table
size_t size; //The amount of pairs currently in the table
size_t max_size;
size_t size;
HashC_pair **table;
}HashC_table;

Expand All @@ -41,15 +56,15 @@ typedef struct HashC_table {
* of pairs allowed is defined in the .c file and can be changed as needed. The current
* default is 100.
*
* @return HashC_table*
* @return A pointer to a valid HashC_table object, NULL otherwise.
*/
HashC_table *HashC_init(void);

/**
* @brief Attempts to insert a key-value pair into the hash table. This table uses
* open probing to avoid collisions.
*
* @param table
* @param table A pointer to a valid HashC_table object.
* @param key A string key
* @param value The value associated with the string key
*/
Expand All @@ -58,22 +73,22 @@ void HashC_insert(HashC_table *table, const char *key, int value);
/**
* @brief Attempts to search for the key provided in the table and returns the
* associated value
* @return int
* @return The integer value associated with the string key.
*/
int HashC_search(HashC_table *table, const char *key);

/**
* @brief Deletes and frees up any memory associated with the hash table provided
*
* @param table
* @param table A pointer to a valid HashC_table pointer.
*/
void HashC_delete(HashC_table **table);

/**
* @brief Returns the current number of key-value pairs stored in the table
*
* @param table
* @return size_t
* @param table A pointer to a valid HashC_table object.
* @return The number of key-value pairs in the table
*/
size_t HashC_table_size(HashC_table *table);

Expand Down

0 comments on commit 82267ef

Please sign in to comment.