voidptrdance

Example code for a blog post on generic programming in C
git clone https://git.tronto.net/voidptrdance
Download | Log | Files | Refs | README

PriorityQueue.h (242B)


      1 typedef void * T;
      2 typedef struct {
      3 	int (*priority)(T);
      4 } TDescription;
      5 
      6 typedef struct {
      7 	TDescription desc;
      8 	void *data;
      9 } PriorityQueue;
     10 
     11 PriorityQueue *NewPriorityQueue(TDescription);
     12 void Add(PriorityQueue *, T);
     13 T Pop(PriorityQueue *);