A uni project I have involves sorting a very large set of data into two different lists, one which has a bunch of data on a city or country, and another which has that same data (on a city, this time), but also with some coordinates, like so:
//used for cities and countries in the textual mode
typedef struct node{
int year;
int month;
float temp;
char* name;
struct node* next;
struct node* prev;
} node_t;
//used for cities in the graphical mode
typedef struct City{
node_t data;
float latitude;
float longitude;
} City;
That is the way I set this up, but it doesn't allow me to use the same functions, because the pointers I have are to 'node', not 'City'. I could make them both like the second one, but putting half a million entries in memory, each with two empty floats would be kind of unnecessary and problematic.
I'm looking to use the same functions for both of them. The functions are your usual linked list ones, like sorted insertion and such. I was trying to use void pointers before, casting them as needed, but that means my functions must have two parts to them.
I'm looking to change the uhh... structure of my structs, so that they allow me to use the same functions simply, without the need for casts, or with a minimal one at least.
They are quite similar as you can see, but nothing comes to mind. Any ideas would be greatly appreciated. Cheers!