GRASS Programmer's Manual 6.4.1(2011)
|
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 typedef union _dglHeapData 00026 { 00027 void *pv; 00028 int n; 00029 unsigned int un; 00030 long l; 00031 unsigned long ul; 00032 00033 } dglHeapData_u; 00034 00035 00036 typedef struct _dglHeapNode 00037 { 00038 long key; 00039 dglHeapData_u value; 00040 unsigned char flags; 00041 00042 } dglHeapNode_s; 00043 00044 typedef struct _dglHeap 00045 { 00046 00047 long index; /* last node / number of current nodes (complete-binary-tree array representation ...) */ 00048 long count; /* number of allocated nodes in ->pnode array */ 00049 long block; /* allocation block size expressed in number of nodes */ 00050 dglHeapNode_s *pnode; /* the node-array */ 00051 00052 } dglHeap_s; 00053 00054 extern void dglHeapInit(dglHeap_s * pheap); 00055 00056 00057 typedef void (*dglHeapCancelItem_fn) (dglHeap_s * pheap, 00058 dglHeapNode_s * pitem); 00059 extern void dglHeapFree(dglHeap_s * pheap, 00060 dglHeapCancelItem_fn pfnCancelItem); 00061 00062 extern int dglHeapInsertMax(dglHeap_s * pheap, 00063 long key, 00064 unsigned char flags, dglHeapData_u value); 00065 00066 extern int dglHeapExtractMax(dglHeap_s * pheap, dglHeapNode_s * pnoderet); 00067 00068 extern int dglHeapInsertMin(dglHeap_s * pheap, 00069 long key, 00070 unsigned char flags, dglHeapData_u value); 00071 00072 extern int dglHeapExtractMin(dglHeap_s * pheap, dglHeapNode_s * pnoderet); 00073 00074 #endif