So i'm having trouble figuring how to overcome this.
Take for example, i have a red black tree implementation that works with items:
typedef unsigned long int Key;
struct rbt_node{
Item item;
int color;
Key key;
struct rbt_node* parent;
struct rbt_node* left;
struct rbt_node* right;
};
then in an Item.h i define the structure i'll be using, for example:
typedef struct _something* Item;
That way i'm decoupling the Item holded from the tree implementation. The problem arises if i want to reuse the ADT for other types.
At the moment i would have to define a Item2.h, and copy rbt.c/rbt.h to rbt2.c/rbt2.h and change them to use Item2.h and change the functions names. Isn't there any cleaner way?
I found this http://stackoverflow.com/questions/3274472/c-double-linked-list-with-abstract-data-type, but it seems to have some problems depending on the architecture and size of the structures, which i'm not really very knowledgeable.
I'm looking for this kind of usage:
rbt_insert(rbt_of_something, something);
rbt_insert(rbt_of_somethingElse, somethingElse);
Thanks