Giter Club home page Giter Club logo

libdsc's Introduction

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.

libdsc's People

Contributors

cm-jones avatar

Stargazers

kakuty avatar Koreancoco avatar Antonio Davide avatar fearless avatar Blue DeviL avatar  avatar  avatar  avatar Michael Johnson avatar Brian Hayes avatar Vivek T. avatar Elias Kasnaktsoglou avatar Alexey Kosenko avatar  avatar  avatar  avatar  avatar An Le avatar

Watchers

 avatar  avatar

libdsc's Issues

Add docstrings to header files

The function prototypes inside the header files for each container are not accompanied by docstrings describing their purpose, arguments, and return values.

Modify DSCList to implement a doubly linked list

Modify DSCList to implement a doubly linked list

Description

DSCList implements a singly linked list. To enhance the functionality of this library, modify DSCList so that it implements a doubly linked list.

Tasks

  1. Update the DSCNode structure:

    • Add a new member prev of type DSCNode * to store the pointer to the previous node.
  2. Modify the DSCList structure:

    • Add a new member tail of type DSCList * to store the pointer to the last node in the list.
  3. Update the dsc_list_create() function:

    • Initialize the tail member of the newly created list to NULL.
  4. Update the dsc_list_destroy() function:

    • Ensure that all nodes are properly freed and the head and tail pointers are set to NULL after destruction.
  5. Modify the dsc_list_push_front() function:

    • Update the prev pointer of the new node to NULL.
    • If the list is empty, set the tail pointer to the new node.
  6. Implement a new function dsc_list_push_back():

    • Create a new function to insert a node at the end of the list.
    • Update the next pointer of the current last node to the new node.
    • Update the prev pointer of the new node to the current last node.
    • Update the tail pointer to the new node.
  7. Update the dsc_list_insert_after() function:

    • Modify the function to handle the prev pointers correctly when inserting a node after a specific node.
    • Update the tail pointer if the new node is inserted at the end of the list.
  8. Implement a new function dsc_list_insert_before():

    • Create a new function to insert a node before a specific node in the list.
    • Update the prev and next pointers accordingly.
    • Update the head pointer if the new node is inserted at the beginning of the list.
  9. Update the dsc_list_pop_front() function:

    • Modify the function to handle the prev pointer of the new head node.
    • Update the tail pointer if the list becomes empty after removing the front node.
  10. Implement a new function dsc_list_pop_back():

    • Create a new function to remove the last node from the list.
    • Update the next pointer of the new last node to NULL.
    • Update the tail pointer to the new last node.
  11. Update the dsc_list_remove() and dsc_list_remove_all() functions:

    • Modify these functions to handle the prev and next pointers correctly when removing nodes from the list.
    • Update the head and tail pointers if necessary.
  12. Update the dsc_list_get_head() function:

    • Rename the function to dsc_list_get_front() for consistency.
  13. Implement a new function dsc_list_get_tail():

    • Create a new function to retrieve the last node of the list using the tail pointer.
  14. Update the documentation:

    • Modify the comments and documentation to reflect the changes made to the linked list implementation.
    • Provide clear explanations and examples of how to use the new doubly linked list functions.
  15. Update the unit tests:

    • Modify the existing unit tests to cover the new doubly linked list implementation.
    • Add new test cases to ensure the correctness of the new functions and the proper handling of edge cases.
  16. Update the README and other relevant documentation:

    • Mention the support for doubly linked lists in the README file.
  17. Perform thorough testing:

    • Compile the library with the modifications and ensure there are no compilation errors.
    • Run the updated unit tests and verify that all tests pass successfully.
    • Test the doubly linked list implementation with various scenarios and edge cases to ensure its correctness and robustness.
  18. Refactor and optimize (optional):

    • Review the modified code and look for any opportunities to refactor and optimize the implementation.
    • Consider any potential performance improvements or code simplifications.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.