Simple implementation of Dictionary in C
You could create a dll using make.bat
(it require clang.exe)
clang -shared -o library\dictionary.dll -I include src\Dictionary.c -l set -l hash -l linkedlist -L library
N.B.
It requires that the library
folder exists and contains linkedlist
, hash
and set
libraries
First of all implement your structure with the data you want. This must contain dictionary_node_t node;
struct int_item {
dictionary_node_t node;
const char* key;
int value;
};
Function | Parametrs | Return | Explanation | ||
---|---|---|---|---|---|
dictionary_table_new | size_t | The desired size of the hashmap | dictionary_table_t* | Pointer to the dictionary_table created or NULL on failure | Create the dictionary_table stucture with desired hasmap size |
dictionary_table_insert | dictionary_table_t* | Pointer to the dictionary_table | dictionary_node_t* | Pointer to the inserted item or NULL on failure | Adds an item to the dictionary |
dictionary_node_t* | Pointer to the item to be insert | ||||
size_t | Size of the data to compare in the structure In the above example the length of the int type |
||||
dictionary_table_search | dictionary_table_t* | Pointer to the dictionary_table | dictionary_node_t* | Pointer to the funded item or NULL if not | Returns item of the dictionary with same value of passed one if any |
dictionary_node_t* | Pointer to the item to be search | ||||
size_t | Size of the data to compare in the structure In the above example the length of the int type |
||||
dictionary_table_remove | dictionary_table_t* | Pointer to the dictionary_table | dictionary_node_t* | Pointer to the removed item or NULL on failure | Remove a dictionary item with the same value as the one passed in and return it |
dictionary_node_t* | Pointer to the item to be remove | ||||
size_t | Size of the data to compare in the structure In the above example the length of the int type |
Create executable using example.bat
(it require clang.exe)
clang -shared -o library\dictionary.dll -I include src\Dictionary.c -l set -l hash -l linkedlist -L library
N.B.
It requires that the examples/bin
folder exists.
Copy linkedlist.dll
, hash.dll
and set.dll
from library
folder to examples/bin
folder
./examples/bin/Example.exe