libFirm 1.20
Priority Queue

A priority queue. More...

Typedefs

typedef struct pqueue_t pqueue_t
 priority queue

Functions

pqueue_tnew_pqueue (void)
 Creates a new priority queue.
void del_pqueue (pqueue_t *q)
 Frees all memory allocated by the priority queue.
void pqueue_put (pqueue_t *q, void *data, int priority)
 Inserts a new element into a priority queue.
void * pqueue_pop_front (pqueue_t *q)
 Returns and removes the first element, ie.
size_t pqueue_length (const pqueue_t *q)
 Get the length of the priority queue.
int pqueue_empty (const pqueue_t *q)
 Returns true if queue is empty.

Detailed Description

A priority queue.

Implementation based on a heap datastructure


Typedef Documentation

typedef struct pqueue_t pqueue_t

priority queue

Definition at line 41 of file pqueue.h.


Function Documentation

void del_pqueue ( pqueue_t q)

Frees all memory allocated by the priority queue.

Parameters:
qThe priority queue to destroy.
pqueue_t* new_pqueue ( void  )

Creates a new priority queue.

Returns:
A priority queue of initial length 0.
int pqueue_empty ( const pqueue_t q)

Returns true if queue is empty.

Parameters:
qThe priority queue.
Returns:
1 if the queue is empty, 0 otherwise.
size_t pqueue_length ( const pqueue_t q)

Get the length of the priority queue.

Parameters:
qThe priority queue.
Returns:
The length of the queue.
void* pqueue_pop_front ( pqueue_t q)

Returns and removes the first element, ie.

that one with the highest priority, from the queue.

Parameters:
qThe priority queue.
Returns:
The first element of the queue. Asserts if queue is empty.
void pqueue_put ( pqueue_t q,
void *  data,
int  priority 
)

Inserts a new element into a priority queue.

Parameters:
qThe priority queue the element should be inserted to.
dataThe actual data which should be stored in the queue.
priorityThe priority for the data.