<commit_before>#include <stdio.h>
#include <stdlib.h>

#define string char *
typedef struct node_struct
{
    string value;
    struct node_struct *next;
}
node;

int QuickHash10(string name);
int StringLen(string s);
node *NewNode(string strVal);
void AddToBucket(node **bucket, string value);
void AddToHashtable(node *hashtable[], string value);

int main()
{
    /* Create empty array */
    node *tmp[10];
    for (int i = 0; i < 10; i++)
        tmp[i] = NULL;

    /* Create new nodes */
    

    AddToHashtable(tmp, "Five");
    AddToHashtable(tmp, "Twelve5");
    AddToHashtable(tmp, "Four4");
    AddToHashtable(tmp, "One6");

    AddToBucket(&tmp[QuickHash10("One")], "One");
    AddToBucket(&tmp[QuickHash10("Zero")], "Zero");
    AddToBucket(&tmp[QuickHash10("Seven")], "Seven");


    /* Debug */
    for (int i = 0; i < 10; i++)
    {
        if (tmp[i] != NULL)
            printf("tmp[%i]->%s\n",i, tmp[i]->value);
    }
    printf("\n");

    printf("tmp[4]->next-> %s\n", tmp[4]->next->value);
    printf("tmp[4]->next-> %s\n", tmp[4]->next->next->value);
    printf("tmp[4]->next-> %s\n", tmp[4]->next->next->next->value);
    printf("\n");

    printf("%i\n", QuickHash10("Seven"));



    return 0;
}

void AddToHashtable(node *hashtable[], string value)
{
    int hashValue = QuickHash10(value);
    AddToBucket(&hashtable[hashValue], value);
}


/**
 * @brief  
 * @note   
 * @param  *bucket: Array bucket
 * @param  value: String value to set the new node
 * @retval None
 */
void AddToBucket(node **bucket, string value)
{
    node *tmp = *bucket;

    /* Base case */
    if (*bucket == NULL)
    {
        *bucket = NewNode(value);
    }

    /* Recursive case */
    else
    {
        AddToBucket(&tmp->next, value);
    }

}


/**
 * @brief  Malloc a new node in HEAP memory of size node
 * @note   
 * @param  strVal: 
 * @retval returns a pointer to the newly generated node
 */
node *NewNode(string strVal)
{
    node *tmp = malloc(sizeof(node));
    tmp->value = strVal;
    tmp->next = NULL;
    return tmp;
}

/**<commit_msg>finished comments<commit_after>#include <stdio.h>
#include <stdlib.h>

#define string char *
typedef struct node_struct
{
    string value;
    struct node_struct *next;
}
node;

int QuickHash10(string name);
int StringLen(string s);
node *NewNode(string strVal);
void AddToBucket(node **bucket, string value);
void AddToHashtable(node *hashtable[], string value);

int main()
{
    /* Create empty array */
    node *tmp[10];
    for (int i = 0; i < 10; i++)
        tmp[i] = NULL;

    /* Create new nodes */
    

    AddToHashtable(tmp, "Five");
    AddToHashtable(tmp, "Twelve5");
    AddToHashtable(tmp, "Four4");
    AddToHashtable(tmp, "One6");

    AddToBucket(&tmp[QuickHash10("One")], "One");
    AddToBucket(&tmp[QuickHash10("Zero")], "Zero");
    AddToBucket(&tmp[QuickHash10("Seven")], "Seven");


    /* Debug */
    for (int i = 0; i < 10; i++)
    {
        if (tmp[i] != NULL)
            printf("tmp[%i]->%s\n",i, tmp[i]->value);
    }
    printf("\n");

    printf("tmp[4]->next-> %s\n", tmp[4]->next->value);
    printf("tmp[4]->next-> %s\n", tmp[4]->next->next->value);
    printf("tmp[4]->next-> %s\n", tmp[4]->next->next->next->value);
    printf("\n");

    printf("%i\n", QuickHash10("Seven"));



    return 0;
}


/**
 * @brief  Add a string to an existing hashtable
 * @note   This will calculate the hash value of the string and palce it in a bucket
 * @param  *hashtable[]: Pointer to an existing hashtable
 * @param  value: String value to add to the hash table
 * @retval None
 */
void AddToHashtable(node *hashtable[], string value)
{
    int hashValue = QuickHash10(value);
    AddToBucket(&hashtable[hashValue], value);
}

/**
 * @brief  Add a string value to a linked list bucket
 * @note   
 * @param  *bucket: existing linked list
 * @param  value: String value to set the new node
 * @retval None
 */
void AddToBucket(node **bucket, string value)
{
    node *tmp = *bucket;

    /* Base case */
    if (*bucket == NULL)
        *bucket = NewNode(value);

    /* Recursive case */
    else
        AddToBucket(&tmp->next, value);
}

/**
 * @brief  Malloc a new node in HEAP memory of size node
 * @note   
 * @param  strVal: 
 * @retval returns a pointer to the newly generated node
 */
node *NewNode(string strVal)
{
    node *tmp = malloc(sizeof(node));
    tmp->value = strVal;
    tmp->next = NULL;
    return tmp;
}

/**
{'fraction_non_alphanumeric': 0.17389340560072267, 'fraction_numerical': 0.013550135501355014, 'mean_word_length': 3.011775362318841, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1207329', 'n_tokens_mistral': 1601, 'n_tokens_neox': 1525, 'n_words': 410}