src/priority_queue.c File Reference

Priority queue implementation. More...

#include "priority_queue.h"
#include "type_limits.h"
#include "debug.h"
#include <stdlib.h>
#include <errno.h>
#include <sys/types.h>
Include dependency graph for priority_queue.c:

Go to the source code of this file.

Data Structures

struct  element
 An element in the priority queue. More...

Functions

static int upheap (priority_queue_t *pq, size_t n)
 Restore the heap property by moving an element upwards.
static int downheap (priority_queue_t *pq, size_t n)
 Restore the heap property by moving an element downwards.
int priority_queue_new (priority_queue_t **pq, size_t capacity)
 Creates a new priority queue.
int priority_queue_free (priority_queue_t *pq)
 Frees a priority queue.
int priority_queue_get_size (priority_queue_t *pq, size_t *size)
 Gets the size of the 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.

Detailed Description

Priority queue implementation.

Definition in file priority_queue.c.


Function Documentation

static int downheap ( priority_queue_t pq,
size_t  n 
) [static]

Restore the heap property by moving an element downwards.

Parameters:
pq the priority queue
n the index of the element to move downwards
Returns:
the operation error code

Definition at line 109 of file priority_queue.c.

References element::key.

Referenced by priority_queue_change_key(), and priority_queue_remove_max().

Here is the caller graph for this function:

static int upheap ( priority_queue_t pq,
size_t  n 
) [static]

Restore the heap property by moving an element upwards.

Parameters:
pq the priority queue
n the index of the element to move upwards
Returns:
the operation error code

Definition at line 74 of file priority_queue.c.

References element::key.

Referenced by priority_queue_add(), and priority_queue_change_key().

Here is the caller graph for this function:


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