I am having trouble getting over this.
Take, for example, I have a red ebony implementation that works with elements:
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 Item.h I define the structure that I will use, for example:
typedef struct _something* Item;
That way, I untie the element held from the tree implementation. The problem occurs if I want to reuse ADT for other types.
For now, I will need to define Item2.h and copy rbt.c / rbt.h to rbt2.c / rbt2.h and change them to use Item2.h and change the function names. Is there a cleaner way?
C , , , , .
:
rbt_insert(rbt_of_something, something);
rbt_insert(rbt_of_somethingElse, somethingElse);