Blender V2.61 - r43446
|
00001 /* 00002 * ***** BEGIN GPL LICENSE BLOCK ***** 00003 * 00004 * This program is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU General Public License 00006 * as published by the Free Software Foundation; either version 2 00007 * of the License, or (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 Foundation, 00016 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00017 * 00018 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. 00019 * All rights reserved. 00020 * 00021 * The Original Code is: none of this file. 00022 * 00023 * Contributor(s): Brecht Van Lommel 00024 * 00025 * ***** END GPL LICENSE BLOCK ***** 00026 */ 00027 00028 #ifndef BLI_HEAP_H 00029 #define BLI_HEAP_H 00030 00036 struct Heap; 00037 struct HeapNode; 00038 typedef struct Heap Heap; 00039 typedef struct HeapNode HeapNode; 00040 00041 typedef void (*HeapFreeFP)(void *ptr); 00042 00043 /* Creates a new heap. BLI_memarena is used for allocating nodes. Removed nodes 00044 are recycled, so memory usage will not shrink. */ 00045 Heap* BLI_heap_new (void); 00046 void BLI_heap_free (Heap *heap, HeapFreeFP ptrfreefp); 00047 00048 /* Insert heap node with a value (often a 'cost') and pointer into the heap, 00049 duplicate values are allowed. */ 00050 HeapNode* BLI_heap_insert (Heap *heap, float value, void *ptr); 00051 00052 /* Remove a heap node. */ 00053 void BLI_heap_remove (Heap *heap, HeapNode *node); 00054 00055 /* Return 0 if the heap is empty, 1 otherwise. */ 00056 int BLI_heap_empty (Heap *heap); 00057 00058 /* Return the size of the heap. */ 00059 int BLI_heap_size (Heap *heap); 00060 00061 /* Return the top node of the heap. This is the node with the lowest value. */ 00062 HeapNode* BLI_heap_top (Heap *heap); 00063 00064 /* Pop the top node off the heap and return it's pointer. */ 00065 void* BLI_heap_popmin (Heap *heap); 00066 00067 /* Return the value or pointer of a heap node. */ 00068 float BLI_heap_node_value (HeapNode *heap); 00069 void* BLI_heap_node_ptr (HeapNode *heap); 00070 00071 #endif 00072