Skip to content

A versatile and memory-efficient C library for implementing generic doubly linked lists. Designed to be directly embedded in user-defined data structures, this library facilitates flexible and efficient list operations, suitable for a wide range of applications.

License

Notifications You must be signed in to change notification settings

harshithsunku/GenericEmbeddableDoublyLinkedList

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GenericEmbeddableDoublyLinkedList (dll_t)

A high-performance, embeddable, and generic doubly linked list implementation in C. Designed for efficient and flexible integration into various data structures without the need for separate list nodes.

Features

  • Embeddable Design: Directly integrate dll_t into user-defined structures for seamless doubly linked list functionality.
  • Generic Implementation: Suitable for any data type, enhancing reusability and flexibility.
  • Efficient Memory Usage: No additional allocations for list management, reducing memory overhead.
  • Easy Traversal: Straightforward API for navigating through the list elements.

Getting Started

Prerequisites

  • A standard C compiler (e.g., GCC).
  • Basic knowledge of C programming and data structures.

Installation

Clone the repository:

git clone https://github.com/harshithsunku/GenericEmbeddableDoublyLinkedList.git

Usage

  1. Include dll_t in Your Structure:

    typedef struct {
        int data; // Your data
        dll_t link; // Embeddable list node
    } my_data_t;
  2. Initialize the List:

    dll_t my_list;
    dll_init(&my_list); // Initialize the list head
  3. Add Elements to the List:

    my_data_t element;
    dll_insert_after(&my_list, &element.link); // Insert element
  4. Iterate Over the List:

    printf("List contents:\n");
    dll_t *iter;
    dll_traverse(&list_head, iter) {
        my_data_t *item = container_of(iter, my_data_t, link);
        printf("Data: %d\n", item->data);
    }   
    
    my_data_t *temp;
    dll_traverse_entry(temp, &list_head, link, my_data_t){
        printf("Data: %d\n", temp->data);
    }   
  5. Remove Elements:

    dll_remove(&element.link); // Remove element from the list

Documentation

Detailed API documentation is available in docs/api.md.

Contributing

Contributions are welcome! Please read the contributing guidelines to get started.

License

This project is licensed under the GNU General Public License v3 (GPLv3).

GPLv3 License

Acknowledgements

  • Thanks to all contributors and users of the GenericEmbeddableDoublyLinkedList project.

About

A versatile and memory-efficient C library for implementing generic doubly linked lists. Designed to be directly embedded in user-defined data structures, this library facilitates flexible and efficient list operations, suitable for a wide range of applications.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published