Priority Queue

A max-priority queue. More...

Typedefs

typedef struct priority_queue priority_queue_t
 Opaque data type for a priority queue.

Functions

int priority_queue_new (priority_queue_t **pq, size_t size)
 Creates a new priority queue.
int priority_queue_free (priority_queue_t *pq)
 Frees a priority queue.
int priority_queue_add (priority_queue_t *pq, void *data, int key, size_t *pos)
 Adds an element to the priority queue.
int priority_queue_remove_max (priority_queue_t *pq, void **data)
 Remove the element with the maximum priority from the priority queue.
int priority_queue_change_key (priority_queue_t *pq, size_t pos, int key)
 Change the priority key of an element.
int priority_queue_get_size (priority_queue_t *pq, size_t *size)
 Gets the size of the priority queue.

Detailed Description

A max-priority queue.


Function Documentation

int priority_queue_add ( priority_queue_t pq,
void *  data,
int  key,
size_t *  pos 
)

Adds an element to the priority queue.

Parameters:
pq the priority queue to add the element to
data the element to be added
key the priority key of the element to be added
pos where to store the current position of the element in the heap
Returns:
the operation error code

Definition at line 242 of file priority_queue.c.

References element::data, and upheap().

Referenced by overlap_graph_remove_cycles().

Here is the call graph for this function:

Here is the caller graph for this function:

int priority_queue_change_key ( priority_queue_t pq,
size_t  pos,
int  key 
)

Change the priority key of an element.

Parameters:
pq the priority queue the element is in
pos the position of the element in the priority queue
key the new key
Returns:

Definition at line 309 of file priority_queue.c.

References downheap(), element::key, and upheap().

Here is the call graph for this function:

int priority_queue_free ( priority_queue_t pq  ) 

Frees a priority queue.

This operation does not free the data added to it by priority_queue_add().

Parameters:
pq the priority queue to free
Returns:
the operation error code

Definition at line 202 of file priority_queue.c.

Referenced by overlap_graph_remove_cycles().

Here is the caller graph for this function:

int priority_queue_get_size ( priority_queue_t pq,
size_t *  size 
)

Gets the size of the priority queue.

Parameters:
pq the priority queue
[out] size the number of elements contained in the priority queue
Returns:
the operation error code

Definition at line 222 of file priority_queue.c.

Referenced by overlap_graph_remove_cycles().

Here is the caller graph for this function:

int priority_queue_new ( priority_queue_t **  pq,
size_t  capacity 
)

Creates a new priority queue.

Parameters:
[out] pq the created priority queue
capacity the initial capacity of the priority queue
Returns:
the operation error code

Definition at line 158 of file priority_queue.c.

Referenced by overlap_graph_remove_cycles().

Here is the caller graph for this function:

int priority_queue_remove_max ( priority_queue_t pq,
void **  data 
)

Remove the element with the maximum priority from the priority queue.

Parameters:
pq the priority queue to remove the element from
[out] data the element with the maximum priority
Returns:
the operation error code

Definition at line 279 of file priority_queue.c.

References element::data, and downheap().

Referenced by overlap_graph_remove_cycles().

Here is the call graph for this function:

Here is the caller graph for this function:


Generated on Sun Nov 15 15:27:58 2009 for libbls by  doxygen 1.6.1