A doubly linked list library in C that can accept any data type that is wrapped within a struct and provides a set of requested methods.
It is implemented with opaque pointers for abstraction and security.
A brief changelog
- Added support for iterators (look below for more info)
- Changed ugly
dllistptr
to a more [user and C]-friendly naming convention, that islist_t
(important) - Renamed the library files to a more C-like naming convention, like this:
doubly_linked_list_adt.c/h
- Updated demo to include some of the iterator functionality
- This version was extensively tested with a multithreaded project, that used the list with about 10 datatypes
- Added a copy-constructor-like method to copy lists
- Binary search to access find the associated element in the list of iterators
- In big programs, compile with -O2 or -O3 to see the magic
[*] 2.1 - Upgraded search/ access of iterators (from linear to binary search)
[*] 2.0 - Iterators support
[*] 1.0 - Initial release
##Getting started with the library
-
You will need to copy the
doubly_linked_list_adt.c
anddoubly_linked_list_adt.h
files to your project and include the header file to your source code -
Implement the required functions for the library, stated here, in a source file and provide the prototypes in a header file
-
To use a list, declare a
list_t
variable and pass it todll_init
function -
Declare and prepare a Datatype dummy variable, allocate it with your function and call any of the
dll_insert*
variants (depending on your needs)N.B.: To add other elements to the list, don't allocate an object again, just update the previous one to insert it
-
When you're done with your list, only then you call the free_datatype function you've written
-
Finally, pass the
list_t
variable todll_destroy
function to deallocate the memory needed
##Documentation for each aspect of the project can be found here
For anything you might need, suggestion, bug report, create a new issue or a pull-request