Skip to content

benedict-tshaba/clist

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

81 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This Project aims to implement the LIST data structure as in Python to be usable in a C project. i.e. We aim to create a 'type' of 'list' which will be generic and can contain an int,float,char, etc. as allowed in c. This is just a research project to see if the same concepts that work in Python (an intepreted language) can be applied to a compiled language like C.

Example Usage:

#include <stdio.h>
#include "clist.h"

int main() {
table_t t = create();
int i = 6;
double pi = 3.1415;
const char *strings[] = {"Kevin","Adam","Carl"};

append(t, I, &i); // I represents an integer. S = string, D = double.
append(t, D, &pi);
for(int j=0; j<3; j++) {
	append(t, S, &strings[j]);
}

print(t); // should print: 6 3.1415 Kevin Adam Carl
sort_asc(t); // sorts the list in place
print(t); // should print: 3.1415 6 Adam Carl Kevin

libr8(t); //dont forget to free your list after use, lest you leak memory.
return 0;
}

Other supported functions are remove, prepend, and pop.

About

An implementation of a Generic LIST type.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published