|
Blender
V2.59
|
00001 /* 00002 * $Id: BLI_heap.h 34966 2011-02-18 13:58:08Z jesterking $ 00003 * 00004 * ***** BEGIN GPL LICENSE BLOCK ***** 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU General Public License 00008 * as published by the Free Software Foundation; either version 2 00009 * of the License, or (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software Foundation, 00018 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00019 * 00020 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. 00021 * All rights reserved. 00022 * 00023 * The Original Code is: none of this file. 00024 * 00025 * Contributor(s): Brecht Van Lommel 00026 * 00027 * ***** END GPL LICENSE BLOCK ***** 00028 */ 00029 00030 #ifndef BLI_HEAP_H 00031 #define BLI_HEAP_H 00032 00038 struct Heap; 00039 struct HeapNode; 00040 typedef struct Heap Heap; 00041 typedef struct HeapNode HeapNode; 00042 00043 typedef void (*HeapFreeFP)(void *ptr); 00044 00045 /* Creates a new heap. BLI_memarena is used for allocating nodes. Removed nodes 00046 are recycled, so memory usage will not shrink. */ 00047 Heap* BLI_heap_new (void); 00048 void BLI_heap_free (Heap *heap, HeapFreeFP ptrfreefp); 00049 00050 /* Insert heap node with a value (often a 'cost') and pointer into the heap, 00051 duplicate values are allowed. */ 00052 HeapNode* BLI_heap_insert (Heap *heap, float value, void *ptr); 00053 00054 /* Remove a heap node. */ 00055 void BLI_heap_remove (Heap *heap, HeapNode *node); 00056 00057 /* Return 0 if the heap is empty, 1 otherwise. */ 00058 int BLI_heap_empty (Heap *heap); 00059 00060 /* Return the size of the heap. */ 00061 int BLI_heap_size (Heap *heap); 00062 00063 /* Return the top node of the heap. This is the node with the lowest value. */ 00064 HeapNode* BLI_heap_top (Heap *heap); 00065 00066 /* Pop the top node off the heap and return it's pointer. */ 00067 void* BLI_heap_popmin (Heap *heap); 00068 00069 /* Return the value or pointer of a heap node. */ 00070 float BLI_heap_node_value (HeapNode *heap); 00071 void* BLI_heap_node_ptr (HeapNode *heap); 00072 00073 #endif 00074