2011-02-18 13:58:08 +00:00
|
|
|
/*
|
2008-04-16 22:40:48 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
2005-08-21 20:48:45 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
2008-04-16 22:40:48 +00:00
|
|
|
* of the License, or (at your option) any later version.
|
2005-08-21 20:48:45 +00:00
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2005-08-21 20:48:45 +00:00
|
|
|
*
|
|
|
|
* Contributor(s): Daniel Dunbar
|
|
|
|
*
|
2008-04-16 22:40:48 +00:00
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
2005-08-21 20:48:45 +00:00
|
|
|
*/
|
|
|
|
|
2012-02-17 18:59:41 +00:00
|
|
|
#ifndef __BLI_EDGEHASH_H__
|
|
|
|
#define __BLI_EDGEHASH_H__
|
2005-08-21 20:48:45 +00:00
|
|
|
|
2011-10-22 15:35:49 +00:00
|
|
|
/** \file BLI_edgehash.h
|
2011-02-18 13:58:08 +00:00
|
|
|
* \ingroup bli
|
|
|
|
* \author Daniel Dunbar
|
|
|
|
* \brief A general unordered 2-int pair hash table ADT.
|
|
|
|
*/
|
|
|
|
|
2005-08-21 20:48:45 +00:00
|
|
|
struct EdgeHash;
|
2005-08-23 02:29:22 +00:00
|
|
|
struct EdgeHashIterator;
|
2005-08-21 20:48:45 +00:00
|
|
|
typedef struct EdgeHash EdgeHash;
|
2005-08-23 02:29:22 +00:00
|
|
|
typedef struct EdgeHashIterator EdgeHashIterator;
|
2005-08-21 20:48:45 +00:00
|
|
|
|
2012-05-12 20:39:39 +00:00
|
|
|
typedef void (*EdgeHashFreeFP)(void *key);
|
2005-08-21 20:48:45 +00:00
|
|
|
|
2013-08-18 00:36:04 +00:00
|
|
|
enum {
|
|
|
|
EDGEHASH_FLAG_ALLOW_DUPES = (1 << 0), /* only checked for in debug mode */
|
|
|
|
};
|
|
|
|
|
2013-08-24 13:08:55 +00:00
|
|
|
EdgeHash *BLI_edgehash_new_ex(const char *info,
|
|
|
|
const unsigned int nentries_reserve);
|
|
|
|
EdgeHash *BLI_edgehash_new(const char *info);
|
2012-05-12 20:39:39 +00:00
|
|
|
void BLI_edgehash_free(EdgeHash *eh, EdgeHashFreeFP valfreefp);
|
|
|
|
void BLI_edgehash_insert(EdgeHash *eh, unsigned int v0, unsigned int v1, void *val);
|
2013-08-24 16:06:18 +00:00
|
|
|
void BLI_edgehash_reinsert(EdgeHash *eh, unsigned int v0, unsigned int v1, void *val);
|
2012-05-12 20:39:39 +00:00
|
|
|
void *BLI_edgehash_lookup(EdgeHash *eh, unsigned int v0, unsigned int v1);
|
|
|
|
void **BLI_edgehash_lookup_p(EdgeHash *eh, unsigned int v0, unsigned int v1);
|
2013-04-22 12:00:37 +00:00
|
|
|
bool BLI_edgehash_haskey(EdgeHash *eh, unsigned int v0, unsigned int v1);
|
2012-05-12 20:39:39 +00:00
|
|
|
int BLI_edgehash_size(EdgeHash *eh);
|
|
|
|
void BLI_edgehash_clear(EdgeHash *eh, EdgeHashFreeFP valfreefp);
|
2013-08-18 00:36:04 +00:00
|
|
|
void BLI_edgehash_flag_set(EdgeHash *eh, unsigned short flag);
|
|
|
|
void BLI_edgehash_flag_clear(EdgeHash *eh, unsigned short flag);
|
|
|
|
|
2012-05-12 20:39:39 +00:00
|
|
|
EdgeHashIterator *BLI_edgehashIterator_new(EdgeHash *eh);
|
|
|
|
void BLI_edgehashIterator_free(EdgeHashIterator *ehi);
|
|
|
|
void BLI_edgehashIterator_getKey(EdgeHashIterator *ehi, unsigned int *v0_r, unsigned int *v1_r);
|
|
|
|
void *BLI_edgehashIterator_getValue(EdgeHashIterator *ehi);
|
|
|
|
void BLI_edgehashIterator_setValue(EdgeHashIterator *ehi, void *val);
|
|
|
|
void BLI_edgehashIterator_step(EdgeHashIterator *ehi);
|
2013-04-22 12:00:37 +00:00
|
|
|
bool BLI_edgehashIterator_isDone(EdgeHashIterator *ehi);
|
2005-08-23 02:29:22 +00:00
|
|
|
|
2013-08-24 13:47:57 +00:00
|
|
|
#define BLI_EDGEHASH_SIZE_GUESS_FROM_LOOPS(totloop) ((totloop) / 2)
|
|
|
|
#define BLI_EDGEHASH_SIZE_GUESS_FROM_POLYS(totpoly) ((totpoly) * 2)
|
|
|
|
|
|
|
|
|
2005-08-21 20:48:45 +00:00
|
|
|
#endif
|