GRASS GIS 7 Programmer's Manual  7.5.svn(2017)-r71746
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
heap.h
Go to the documentation of this file.
1 /* LIBDGL -- a Directed Graph Library implementation
2  * Copyright (C) 2002 Roberto Micarelli
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
19 /* best view tabstop=4
20  */
21 
22 #ifndef _DGL_HEAP_H_
23 #define _DGL_HEAP_H_
24 
25 typedef union _dglHeapData
26 {
27  void *pv;
28  int n;
29  unsigned int un;
30  long l;
31  unsigned long ul;
32 
34 
35 
36 typedef struct _dglHeapNode
37 {
38  long key;
40  unsigned char flags;
41 
43 
44 typedef struct _dglHeap
45 {
46 
47  long index; /* last node / number of current nodes (complete-binary-tree array representation ...) */
48  long count; /* number of allocated nodes in ->pnode array */
49  long block; /* allocation block size expressed in number of nodes */
50  dglHeapNode_s *pnode; /* the node-array */
51 
52 } dglHeap_s;
53 
54 extern void dglHeapInit(dglHeap_s * pheap);
55 
56 
57 typedef void (*dglHeapCancelItem_fn) (dglHeap_s * pheap,
58  dglHeapNode_s * pitem);
59 extern void dglHeapFree(dglHeap_s * pheap,
60  dglHeapCancelItem_fn pfnCancelItem);
61 
62 extern int dglHeapInsertMax(dglHeap_s * pheap,
63  long key,
64  unsigned char flags, dglHeapData_u value);
65 
66 extern int dglHeapExtractMax(dglHeap_s * pheap, dglHeapNode_s * pnoderet);
67 
68 extern int dglHeapInsertMin(dglHeap_s * pheap,
69  long key,
70  unsigned char flags, dglHeapData_u value);
71 
72 extern int dglHeapExtractMin(dglHeap_s * pheap, dglHeapNode_s * pnoderet);
73 
74 #endif
dglHeapNode_s * pnode
Definition: heap.h:50
long key
Definition: heap.h:38
dglHeapData_u value
Definition: heap.h:39
void dglHeapFree(dglHeap_s *pheap, dglHeapCancelItem_fn pfnCancelItem)
Definition: heap.c:37
Definition: heap.h:44
union _dglHeapData dglHeapData_u
void dglHeapInit(dglHeap_s *pheap)
Definition: heap.c:29
long index
Definition: heap.h:47
struct _dglHeapNode dglHeapNode_s
void(* dglHeapCancelItem_fn)(dglHeap_s *pheap, dglHeapNode_s *pitem)
Definition: heap.h:57
long l
Definition: heap.h:30
int dglHeapInsertMax(dglHeap_s *pheap, long key, unsigned char flags, dglHeapData_u value)
Definition: heap.c:111
long count
Definition: heap.h:48
unsigned char flags
Definition: heap.h:40
unsigned int un
Definition: heap.h:29
void * pv
Definition: heap.h:27
struct _dglHeap dglHeap_s
int dglHeapInsertMin(dglHeap_s *pheap, long key, unsigned char flags, dglHeapData_u value)
Definition: heap.c:52
int dglHeapExtractMin(dglHeap_s *pheap, dglHeapNode_s *pnoderet)
Definition: heap.c:79
long block
Definition: heap.h:49
int n
Definition: heap.h:28
int dglHeapExtractMax(dglHeap_s *pheap, dglHeapNode_s *pnoderet)
Definition: heap.c:138
unsigned long ul
Definition: heap.h:31