00001 /*************************************************************************** 00002 * Copyright (C) 2010 by Matthias Ihrke * 00003 * ihrke@nld.ds.mpg.de 00004 * * 00005 * This program is free software; you can redistribute it and/or modify * 00006 * it under the terms of the GNU General Public License as published by * 00007 * the Free Software Foundation; either version 2 of the License, or * 00008 * (at your option) any later version. * 00009 * * 00010 * This program is distributed in the hope that it will be useful, * 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00013 * GNU General Public License for more details. * 00014 * * 00015 * You should have received a copy of the GNU General Public License * 00016 * aint with this program; if not, write to the * 00017 * Free Software Foundation, Inc., * 00018 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 00019 ***************************************************************************/ 00020 00047 #ifndef PQUEUE_H 00048 # define PQUEUE_H 00049 #include "definitions.h" 00050 #include <stdio.h> 00051 00052 #ifdef __cplusplus 00053 extern "C" { 00054 #endif 00055 00056 /*----------------------------------------------------------- 00057 - Priority Queue 00058 ---------------------------------------------------------*/ 00059 00062 struct pqueue { 00063 double priority; 00064 void *content; 00065 struct pqueue *next; 00066 }; 00067 typedef struct pqueue PQnode; 00068 00071 typedef struct { 00072 PQnode *root; 00073 } PriorityQueue; 00074 00075 00076 /* -------------- FUNCTIONS ---------------- */ 00077 PriorityQueue* pq_init(); 00078 void pq_insert( PriorityQueue *pq, void *c, double prior ); 00079 void* pq_pop( PriorityQueue *pq ); 00080 PQnode* pq_pop_node( PriorityQueue *pq ); 00081 void pq_print( FILE *out, PriorityQueue *pq ); 00082 00083 void pq_free( PriorityQueue *pq ); 00084 00086 PQnode* pqnode_init( void *c, double priority ); 00087 void pqnode_print( FILE *out, PQnode *N ); 00088 void pqnode_free( PQnode *n ); 00092 #ifdef __cplusplus 00093 } 00094 #endif 00095 00096 #endif /* PQUEUE_H */