Skip to content

C double linked list library that can hold heterogeneous data, achieved through the extensive use of void pointers.

License

Notifications You must be signed in to change notification settings

Ransomware3301/heterogeneous_double_linked_list_library

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 

Repository files navigation

heterogeneous_double_linked_list_library

C (ANSI 89) double linked list library that can hold heterogeneous data, achieved through the extensive use of void pointers.


Brief Introduction:

This library implements double linked lists in C (ANSI 89), which are an "extension" of simply linked list due to the fact that the former have bidirectional links and the latter only have unidirectional links.

Another feature of this library is the ability to store heterogeneous data types in a single list, thus behaving similarly to heterogeneous elements lists in other higher-level programming languages (e.g. Python, Kotlin, etc...)

The heterogeneous characteristic is achieved through the use of void pointers.

In particular, the supported data types are:

  • string
  • All C basic types, which are:
    • short int
    • unsigned short int
    • int
    • unsigned int
    • long int
    • unsigned long int
    • float
    • double
    • char

Data Packets

To make the library capable of working with and creating lists that hold heterogeneous data types, each list item contains a struct data type defined as:

/* Heterogeneous Data Packet Definition */
typedef struct hetdata
{
    void *val;
    type_t type;
    char *format;
}
hetdata_t;

This particular object, which I like to call "data packet", contains 3 fields: val, type and format:

  • val is a void pointer (void*) that points to a memory cell that contains some data
  • type is an integer (from 0 to 9, extremes included) that enumerates all the data types supported by the library, and it's used to describe the data pointed by val
  • format is a string containing the formatting characters required for the correct input/output of that particular data type

And it's thanks to this struct that the library can hold heterogeneous data in a single list.


About

C double linked list library that can hold heterogeneous data, achieved through the extensive use of void pointers.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages