hash_table_l1


"/home/yossef/notes/git/projects/hash_table/hash_table_l1.md"

path: git/projects/hash_table/hash_table_l1.md

- **fileName**: hash_table_l1
- **Created on**: 2025-03-30 15:21:08

explain hash table using c lang ;)

structure for the projects

  [4.0K]  ./
├── [4.0K]  src/
│   ├── [7.1K]  hash_table.c # the main functional file 
│   ├── [ 762]  hash_table.h
│   ├── [ 598]  prime.c # check for prime elements
│   └── [  64]  prime.h
├── [  38]  build* # for run
├── [ 23K]  main*
├── [ 884]  main.c # main file
├── [ 166]  Makefile # for run
└── [  16]  readme.md
1 directory, 9 files

starting with the main file

#include "src/hash_table.h" // having the main functions for hash table
#include <stdio.h>

int main() {
    ht_hash_table *ht = ht_new(); // creating a new hash table

    ht_insert(ht, "1", "ahmed"); // inserting a new item in the hash table
    ht_insert(ht, "1", "yo");
    ht_insert(ht, "2", "foo");
    ht_insert(ht, "3", "yoi");
    ht_insert(ht, "4", "bar");
    ht_insert(ht, "5", "aya");
    ht_insert(ht, "6", "sra");
    ht_insert(ht, "7", "ooo");
    ht_insert(ht, "8", "joo");
    ht_insert(ht, "9", "soliman");

    const char* key = "7";
    char* value = ht_search(ht, key); // searching using the key
    printf("the value of the %s is : %s \n", key, value); 

    ht_delete(ht, key); // deleting using the key
    printf("** deleting the key %s **\n", key);

    ht_print(ht); // print all the item in the hash table

    ht_table_delete(ht); // starting free the memory from the hash table

    return 0;
};
Important

every file have too files one with .c and other with .h if you forget ;)
the .c write the function implementation on it and the other .h allow
to import and export the function ot anothor place

continue:./hash_table_l2.md
before:[[]]