diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..400163b2f9460c8e3348a2912733a75cbfaf62f8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,83 @@ + +# Created by https://www.toptal.com/developers/gitignore/api/c,visualstudiocode +# Edit at https://www.toptal.com/developers/gitignore?templates=c,visualstudiocode + +### C ### +# Prerequisites +*.d + +# Object files +*.o +*.ko +*.obj +*.elf + +# Linker output +*.ilk +*.map +*.exp + +# Precompiled Headers +*.gch +*.pch + +# Libraries +*.lib +*.a +*.la +*.lo + +# Shared objects (inc. Windows DLLs) +*.dll +*.so +*.so.* +*.dylib + +# Executables +*.exe +*.out +*.app +*.i*86 +*.x86_64 +*.hex + +# Debug files +*.dSYM/ +*.su +*.idb +*.pdb + +# Kernel Module Compile Results +*.mod* +*.cmd +.tmp_versions/ +modules.order +Module.symvers +Mkfile.old +dkms.conf + +### VisualStudioCode ### +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +*.code-workspace + +# Local History for Visual Studio Code +.history/ + +### VisualStudioCode Patch ### +# Ignore all local history of files +.history +.ionide + +# Support for Project snippet scope +!.vscode/*.code-snippets + +# End of https://www.toptal.com/developers/gitignore/api/c,visualstudiocode + +# Custom gitignore for project +hashtable +cmake-build-debug +.idea diff --git a/README.md b/README.md index 1011f408998b0c6f263ce2a162c0fe0487dc1423..e3f7ebf5699f719c0fb135ce3de0f59942d47381 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,21 @@ # progseq-hashtable -12e travail pratique du cours de programmation séquentielle, 1er année (2021-2022). \ No newline at end of file +- **Class** : Programmation séquentielle en C +- **Creation date** : 18 janvier 2022 +- **Description** : 12e travail pratique + +## Makefile configuration + +### Compile the project +> `make` + +Use this command to compile the project. + +### Clean the project +> `make clean` + +Use this command to clean the project. + +## Run the project +Execute the `hashtable` file. +> ./hashtable diff --git a/hashtable.c b/hashtable.c new file mode 100644 index 0000000000000000000000000000000000000000..0d286e44ae75b609cf8f8475fab4f6be8b6d0da0 --- /dev/null +++ b/hashtable.c @@ -0,0 +1,37 @@ +/* Author : Dario GENGA + * Date : 18.01.2022 + * Description : Hash library. + */ + +#include "hashtable.h" +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +hm *hm_create(unsigned int length) { + return NULL; +} + +void hm_destroy(hm **hm) { + +} + +hm *hm_set(hm *hm, const char *const key, const char *const value) { + return NULL; +} + +char *hm_get(const hm *const hm, const char *const key) { + return NULL; +} + +char *hm_rm(hm *hm, const char *const key) { + return NULL; +} + +char *hmo_str(const hm *const hm) { + return NULL; +} + +void hm_print(const hm *const hm) { + return NULL; +} diff --git a/hashtable.h b/hashtable.h new file mode 100644 index 0000000000000000000000000000000000000000..167b257b0aa3c80030f279824e9d20bc8157745e --- /dev/null +++ b/hashtable.h @@ -0,0 +1,38 @@ +/* Author : Dario GENGA + * Date : 18.01.2022 + * Description : Hash library. + */ + +#ifndef _HASHTABLE_H +#define _HASHTABLE_H +#include <stdio.h> +#include <stdlib.h> +#include <stdbool.h> + +typedef struct hm_t { + struct entry_t **entries; + int length; +} hm; + +typedef struct entry_t { + char *key; + char *value; + struct entry_t *next; +} entry; + +// création d'un pointeur vers une hm +hm *hm_create(unsigned int length); +// destruction de la hm et libération de la mémoire +void hm_destroy(hm **hm); +// insère la paire key-value dans la hm. si key est déjà présente écraser value dans la hm. +hm *hm_set(hm *hm, const char *const key, const char *const value); +// retourne la valeur associé à la clé, key +char *hm_get(const hm *const hm, const char *const key); +// retire une clé de la hm et la retourne +char *hm_rm(hm *hm, const char *const key); +// convertit la hm en chaîne de caractères +char *hm_to_str(const hm *const hm); +// affiche le contenu de la hm +void hm_print(const hm *const hm); + +#endif diff --git a/main.c b/main.c new file mode 100644 index 0000000000000000000000000000000000000000..df0280e64212cccf9b2028951c8713148afd51ff --- /dev/null +++ b/main.c @@ -0,0 +1,11 @@ +/* Author : Dario GENGA + * Date : 18.01.2022 + * Description : Hash library. + */ + +#include <stdio.h> +#include <stdlib.h> + +int main() { + return EXIT_SUCCESS; +} diff --git a/makefile b/makefile new file mode 100644 index 0000000000000000000000000000000000000000..5dccb7b95f0ccd06caa945e6b9c387d0d37a5eed --- /dev/null +++ b/makefile @@ -0,0 +1,13 @@ +LIB=-lm +CC=gcc -Wall -Wextra -g + +hashtable: hashtable.o main.o + $(CC) $^ -fsanitize=address -fsanitize=leak -o $@ $(LIB) + +hashtable.o: hashtable.c hashtable.h + $(CC) -c $< $(LIB) +main.o: main.c + $(CC) -c $< $(LIB) + +clean: + rm -f *.o hashtable diff --git a/sources/hashmap.pdf b/sources/hashmap.pdf new file mode 100644 index 0000000000000000000000000000000000000000..85eb29c844205396f843c0968b1f56aa4e01102d Binary files /dev/null and b/sources/hashmap.pdf differ