Sorry if this sounds a bit too specific, but an answer to my problem would be an answer to a much broader problem. So here's my problem's context:
In an Abstract Data Types excersize, I'm constructing a "Glue Layer" between two ADTs - Scheduler and Heap - called Container. Scheduler provides it with a compare function, and it should pass into Heap a function that returns the negative result of that compare function for any input. The reason for this is that Heap is a maximum heap, but Scheduler requires the drawing of a minimum element. I am not allowed to change Heap into a minimum heap or AT ALL. Likely, I am not allowed to change Scheduler's compare function to return the negative of what it normally returns, or again, AT ALL. It is up to Container to invert the function and feed it to Heap. The question is how the hell can it do it?!
The types i'm using are:
typedef void* Data;
typedef int (*DataCompareFunc)(const Data data1,const Data data2);
Scheduler calls the function:
Container* ContainerCreate(DataCompareFunc compFunc)
And HeapCreate's signature is:
Heap* HeapCreate(DataCompareFunc compFunc);
In what way can ContainerCreate
transfer a negated function into HeapCreate
?