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: all of this file. 00022 * 00023 * Contributor(s): none yet. 00024 * 00025 * ***** END GPL LICENSE BLOCK ***** 00026 */ 00027 00028 #ifndef BLI_GHASH_H 00029 #define BLI_GHASH_H 00030 00036 #ifdef __cplusplus 00037 extern "C" { 00038 #endif 00039 00040 typedef unsigned int (*GHashHashFP) (const void *key); 00041 typedef int (*GHashCmpFP) (const void *a, const void *b); 00042 typedef void (*GHashKeyFreeFP) (void *key); 00043 typedef void (*GHashValFreeFP) (void *val); 00044 00045 typedef struct Entry { 00046 struct Entry *next; 00047 00048 void *key, *val; 00049 } Entry; 00050 00051 typedef struct GHash { 00052 GHashHashFP hashfp; 00053 GHashCmpFP cmpfp; 00054 00055 Entry **buckets; 00056 struct BLI_mempool *entrypool; 00057 int nbuckets, nentries, cursize; 00058 } GHash; 00059 00060 typedef struct GHashIterator { 00061 GHash *gh; 00062 int curBucket; 00063 struct Entry *curEntry; 00064 } GHashIterator; 00065 00066 /* *** */ 00067 00068 GHash* BLI_ghash_new (GHashHashFP hashfp, GHashCmpFP cmpfp, const char *info); 00069 void BLI_ghash_free (GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp); 00070 void BLI_ghash_insert(GHash *gh, void *key, void *val); 00071 void * BLI_ghash_lookup(GHash *gh, const void *key); 00072 int BLI_ghash_remove(GHash *gh, void *key, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp); 00073 int BLI_ghash_haskey(GHash *gh, void *key); 00074 int BLI_ghash_size (GHash *gh); 00075 00076 /* *** */ 00077 00086 GHashIterator* BLI_ghashIterator_new (GHash *gh); 00095 void BLI_ghashIterator_init(GHashIterator *ghi, GHash *gh); 00101 void BLI_ghashIterator_free (GHashIterator *ghi); 00102 00110 void* BLI_ghashIterator_getKey (GHashIterator *ghi); 00118 void* BLI_ghashIterator_getValue (GHashIterator *ghi); 00124 void BLI_ghashIterator_step (GHashIterator *ghi); 00132 int BLI_ghashIterator_isDone (GHashIterator *ghi); 00133 00134 /* *** */ 00135 00136 unsigned int BLI_ghashutil_ptrhash (const void *key); 00137 int BLI_ghashutil_ptrcmp (const void *a, const void *b); 00138 00139 unsigned int BLI_ghashutil_strhash (const void *key); 00140 int BLI_ghashutil_strcmp (const void *a, const void *b); 00141 00142 unsigned int BLI_ghashutil_inthash (const void *ptr); 00143 int BLI_ghashutil_intcmp (const void *a, const void *b); 00144 00145 typedef struct GHashPair { 00146 const void *first; 00147 int second; 00148 } GHashPair; 00149 00150 GHashPair* BLI_ghashutil_pairalloc (const void *first, int second); 00151 unsigned int BLI_ghashutil_pairhash (const void *ptr); 00152 int BLI_ghashutil_paircmp (const void *a, const void *b); 00153 void BLI_ghashutil_pairfree (void *ptr); 00154 00155 #ifdef __cplusplus 00156 } 00157 #endif 00158 00159 #endif /* BLI_GHASH_H */