Blender V2.61 - r43446

BLI_edgehash.h

Go to the documentation of this file.
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): Daniel Dunbar
00024  *
00025  * ***** END GPL LICENSE BLOCK *****
00026  */
00027  
00028 #ifndef BLI_EDGEHASH_H
00029 #define BLI_EDGEHASH_H
00030 
00037 struct EdgeHash;
00038 struct EdgeHashIterator;
00039 typedef struct EdgeHash EdgeHash;
00040 typedef struct EdgeHashIterator EdgeHashIterator;
00041 
00042 typedef void    (*EdgeHashFreeFP)(void *key);
00043 
00044 EdgeHash*       BLI_edgehash_new        (void);
00045 void            BLI_edgehash_free       (EdgeHash *eh, EdgeHashFreeFP valfreefp);
00046 
00047     /* Insert edge (v0,v1) into hash with given value, does
00048      * not check for duplicates.
00049      */
00050 void            BLI_edgehash_insert     (EdgeHash *eh, unsigned int v0, unsigned int v1, void *val);
00051 
00052     /* Return value for given edge (v0,v1), or NULL if
00053      * if key does not exist in hash. (If need exists 
00054      * to differentiate between key-value being NULL and 
00055      * lack of key then see BLI_edgehash_lookup_p().
00056      */
00057 void*           BLI_edgehash_lookup     (EdgeHash *eh, unsigned int v0, unsigned int v1);
00058 
00059     /* Return pointer to value for given edge (v0,v1),
00060      * or NULL if key does not exist in hash.
00061      */
00062 void**          BLI_edgehash_lookup_p   (EdgeHash *eh, unsigned int v0, unsigned int v1);
00063 
00064     /* Return boolean true/false if edge (v0,v1) in hash. */
00065 int             BLI_edgehash_haskey     (EdgeHash *eh, unsigned int v0, unsigned int v1);
00066 
00067     /* Return number of keys in hash. */
00068 int             BLI_edgehash_size       (EdgeHash *eh);
00069 
00070     /* Remove all edges from hash. */
00071 void            BLI_edgehash_clear      (EdgeHash *eh, EdgeHashFreeFP valfreefp);
00072 
00073 /***/
00074 
00080 EdgeHashIterator*   BLI_edgehashIterator_new        (EdgeHash *eh);
00081 
00082     /* Free an EdgeHashIterator. */
00083 void                BLI_edgehashIterator_free       (EdgeHashIterator *ehi);
00084 
00085     /* Retrieve the key from an iterator. */
00086 void                BLI_edgehashIterator_getKey     (EdgeHashIterator *ehi, unsigned int *v0_r, unsigned int *v1_r);
00087     
00088     /* Retrieve the value from an iterator. */
00089 void*               BLI_edgehashIterator_getValue   (EdgeHashIterator *ehi);
00090 
00091     /* Set the value for an iterator. */
00092 void                BLI_edgehashIterator_setValue   (EdgeHashIterator *ehi, void *val);
00093 
00094     /* Steps the iterator to the next index. */
00095 void                BLI_edgehashIterator_step       (EdgeHashIterator *ehi);
00096 
00097     /* Determine if an iterator is done. */
00098 int                 BLI_edgehashIterator_isDone     (EdgeHashIterator *ehi);
00099 
00100 #endif