DoctorWho406 / C_Dictionary

Simple implementation of Dictionary in C

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

C_Dictionary

Simple implementation of Dictionary in C

Usage

You could create a dll using make.bat (it require clang.exe)

Command with 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

API

First of all implement your structure with the data you want. This must contain dictionary_node_t node;

Example

struct int_item {
    dictionary_node_t node;
    const char* key;
    int value;
};

Functions

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

Example

Create executable using example.bat (it require clang.exe)

Command with 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

Run it

./examples/bin/Example.exe

About

Simple implementation of Dictionary in C


Languages

Language:C 98.7%Language:Batchfile 1.3%