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