heap.h

Go to the documentation of this file.
00001 /* LIBDGL -- a Directed Graph Library implementation
00002  * Copyright (C) 2002 Roberto Micarelli
00003  *
00004  * This program is free software; you can redistribute it and/or modify
00005  * it under the terms of the GNU General Public License as published by
00006  * the Free Software Foundation; either version 2 of the License, or
00007  * (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00017  */
00018 
00019 /* best view tabstop=4
00020  */
00021 
00022 #ifndef _DGL_HEAP_H_
00023 #define _DGL_HEAP_H_
00024 
00025 __BEGIN_DECLS
00026 
00027 typedef union _dglHeapData
00028 {
00029         void *                  pv;
00030         int                             n;
00031         unsigned int    un;
00032         long                    l;
00033         unsigned long   ul;
00034 
00035 } dglHeapData_u;
00036 
00037 
00038 typedef struct _dglHeapNode
00039 {
00040         long                    key;
00041         dglHeapData_u   value;
00042         unsigned char   flags;
00043 
00044 } dglHeapNode_s;
00045 
00046 typedef struct _dglHeap {
00047 
00048         long                            index; /* last node / number of current nodes (complete-binary-tree array representation ...) */
00049         long                            count; /* number of allocated nodes in ->pnode array */
00050         long                            block; /* allocation block size expressed in number of nodes */
00051         dglHeapNode_s *         pnode; /* the node-array */
00052 
00053 } dglHeap_s;
00054 
00055 extern void     dglHeapInit             (
00056                                                         dglHeap_s *             pheap
00057                                                         );
00058 
00059 
00060 typedef void (*dglHeapCancelItem_fn)(dglHeap_s * pheap, dglHeapNode_s * pitem);
00061 extern void     dglHeapFree             (
00062                                                         dglHeap_s *             pheap,
00063                                                         dglHeapCancelItem_fn pfnCancelItem
00064                                                         );
00065 
00066 extern int      dglHeapInsertMax        (
00067                                                         dglHeap_s *             pheap ,
00068                                                         long                    key ,
00069                                                         unsigned char   flags ,
00070                                                         dglHeapData_u   value
00071                                                         );
00072 
00073 extern int      dglHeapExtractMax(
00074                                                         dglHeap_s *     pheap,
00075                                                         dglHeapNode_s * pnoderet
00076                                                         );
00077 
00078 extern int      dglHeapInsertMin        (
00079                                                         dglHeap_s *     pheap ,
00080                                                         long                    key ,
00081                                                         unsigned char   flags ,
00082                                                         dglHeapData_u   value
00083                                                         );
00084 
00085 extern int      dglHeapExtractMin(
00086                                                         dglHeap_s *     pheap,
00087                                                         dglHeapNode_s * pnoderet
00088                                                         );
00089 
00090 __END_DECLS
00091 #endif

Generated on Sun Apr 6 17:32:44 2008 for GRASS by  doxygen 1.5.5