libdsc is an open-source C library featuring robust, efficient, and generic implementations of the following containers:
- Vectors: similar to
std::vector
- Lists: similar to
std::list
- Stacks: similar to
std::stack
- Queues: similar to
std::queue
- Sets: similar to
std::unordered_set
- Maps: similar to
std::unordered_map
The APIs closely resemble those found for the corresponding containers in the C++ Standard Library, which provides familiarity and ease of use to C++ developers.
The current version of libdsc is 0.1.0-alpha.
To build libdsc yourself, follow these steps:
-
Clone the repository:
git clone https://github.com/cm-jones/libdsc.git
-
Change into the project directory:
cd libdsc
-
Compile the library using the provided Makefile:
make
This will generate the static library (
libdsc.a
) and the shared library (libdsc.so
) in the project's root directory. -
(Optional) Install the library and header files:
sudo make install
This will copy the library files to
/usr/local/lib
and the header file to/usr/local/include
.
To use libdsc in your C project, follow these steps:
-
Obtain the library files:
- Either compile the library yourself (see Build section below) or download the pre-compiled library files.
-
Include the header file in your C source file:
#include <libdsc.h>
-
Link against the library when compiling your program:
- If using a static (
libdsc.a
) or shared (libdsc.so
) library:Make sure to add the library directory to yourgcc -o program program.c -L/path/to/library -ldsc
LD_LIBRARY_PATH
environment variable.
- If using a static (
-
Use the library functions in your code, for example:
DSCSet set = dsc_set_init(DSC_TYPE_INT); if (!set) { // Handle memory allocation error ... } for (size_t i = 0; i < 100; ++i) { DSCError errno; if ((errno = dsc_set_insert(set, i)) != DSC_ERROR_OK) { // Handle error code ... } } // Use other set functions as needed ... dsc_set_deinit(set);
Detailed documentation for libdsc can be found under docs/.
If you find any issues or have suggestions for improvements, feel free to open an issue or submit a pull request.
This project is licensed under the GNU General Public License v3.0.