Skip to content

A C library featuring generic implementations of essential data structures

License

Notifications You must be signed in to change notification settings

cm-jones/libdsc

Repository files navigation

logo

libdsc: Data Structures for C

build License: GPL v3

Description

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.

Version

The current version of libdsc is 0.1.0-alpha.

Build and Install

To build libdsc yourself, follow these steps:

  1. Clone the repository:

    git clone https://github.com/cm-jones/libdsc.git
    
  2. Change into the project directory:

    cd libdsc
    
  3. 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.

  4. (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.

Usage

To use libdsc in your C project, follow these steps:

  1. Obtain the library files:

    • Either compile the library yourself (see Build section below) or download the pre-compiled library files.
  2. Include the header file in your C source file:

    #include <libdsc.h>
  3. Link against the library when compiling your program:

    • If using a static (libdsc.a) or shared (libdsc.so) library:
      gcc -o program program.c -L/path/to/library -ldsc
      
      Make sure to add the library directory to your LD_LIBRARY_PATH environment variable.
  4. 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);

Documentation

Detailed documentation for libdsc can be found under docs/.

Contributing

If you find any issues or have suggestions for improvements, feel free to open an issue or submit a pull request.

License

This project is licensed under the GNU General Public License v3.0.

About

A C library featuring generic implementations of essential data structures

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published