Project "C Language Data Structures" has come as an idea to supply C Language with some basic generic data structures, as follows:
Content/Documentation | Header File | Source File |
---|---|---|
AVL Tree | scl_avl_tree.h | scl_avl_tree.c |
Binary Search Tree | scl_bst_tree.h | scl_bst_tree.c |
Config File (Basic Utils for Error Handling) | scl_config.h | scl_config.c |
Double Linked List | scl_dlist.h | scl_dlist.c |
Function File | scl_func_types.h | scl_func_types.c |
Graph | scl_graph.h | scl_graph.c |
Hash Table | scl_hash_table.h | scl_hash_table.c |
Single Linked List | scl_list.h | scl_list.c |
Priority Queue | scl_priority_queue.h | scl_priority_queue.c |
Queue | scl_queue.h | scl_queue.c |
Red Black Tree | scl_rbk_tree.h | scl_rbk_tree.c |
Sorting Algorithms | scl_sort_algo.h | scl_sort_algo.c |
Stack | scl_stack.h | scl_stack.c |
Every single data structure from this project can be used in any scopes and with different data types, however you must follow a set of rules so you don't break the program. Every set of rules for every data structure can be found in Documentation folder from current project.
I tried for every known object to keep their function definitions as in C++ and also followed the standard naming of methods according to specific data structure.
It is very important not to use directly the members of the structure objects, however if you feel safe to access them by yourself there should be no problem.
In order to build and to install the project you must be sure that you are working on a LINUX environment or if you are on WINDOWS to use WSL(Windows Subsystem for Linux). Even if the building can pass on a windows system the executables generated will be incompatible.
The Project will create you two libraries: one dynamically generated and one statically generated. For static library there is no instalation process and you can play with the library ass you want (And link it statically to your future projects), however for the dynamic library the program should register the library into your system.
- Linux or WSL System
- GCC Compiler
- ldconfig (For library register)
For this step make sure that you opened a linux terminal service and have root privileges, also check if you had changed directory to the current working project ("C-language-Data-Structures").
If you want to build the libraries and to install (register) the dynamic library into your system you shall execute:
cd build
sudo make
After executing the following commands you will get prompt some messages showing you that building and installing proccess went successfully
<------ Building Dynamic Library Went Successfully ------->
<------ Building Static Library Went Successfully ------->
<------ Building Project Went Successfully ------->
<------ Installing Project Went Successfully ------->
If one of the above messages haven't showed, something went wrong so I encourage you to try ones again.
If you just want to build the libraries and not to register the dynami clibrary into your system you shall run:
cd build
sudo make build
In build directory will appear 2 files, representing the dynamic and static libraries.
If something went wrong and you want to rerun the building process you may run:
make clean # This command will delete libraries as well
After running the above commands, everything is set up and now you can use the library and its beauty!
If you installed either the dynamic library or the static library into your system then in your source file you shall include:
#include <scl_datastruct.h> // To include all data structures
#include <scl_avl_tree.h> // For AVL Tree and so on
And when you compile your program you shall link it as follows for dynamic library:
gcc -c your_file.c
gcc your_file.o -ldstruc -o your_file
For static library, first copy the library into your current working folder:
gcc -c your_file.c
gcc your_file.o -L. -ldstruc -o your_file
If the building process didn't pass you will not be able to use the libraries.
Some data structures have some examples for you to undestand what you should and what you should not. Also the examples will show you some untraditional ways to solve some things. In every example folder for different data structure exists one source file that will be a benchmark to test the power of data structures on your system. The benchmarks can run a little slow depending on your system.
For examples how to build and how to run the examples you must read the documentation related to the examples section. The link to documentation HERE.
Make sure after you are done with one data structure exaxmple to run:
make clean
I am very open for contributing, however if you want to take part of this project you will have to follow some set of rules:
- First you should respect the code styling, some references are C Style
- You should provide documentation (respecting doxygen standard) for every function or piece of code
- You should come with some tests or examples to show how to work with your new functions
- Be happy and don't stop coding :)