[Bf-blender-cvs] [6be4b39] master: GHash: add flag get/set for gset
Campbell Barton
noreply at git.blender.org
Tue Aug 12 05:29:53 CEST 2014
Commit: 6be4b395260816becfeb992d23045bbfa9d58355
Author: Campbell Barton
Date: Tue Aug 12 13:26:29 2014 +1000
Branches: master
https://developer.blender.org/rB6be4b395260816becfeb992d23045bbfa9d58355
GHash: add flag get/set for gset
===================================================================
M source/blender/blenlib/BLI_edgehash.h
M source/blender/blenlib/BLI_ghash.h
M source/blender/blenlib/intern/BLI_ghash.c
M source/blender/blenlib/intern/edgehash.c
===================================================================
diff --git a/source/blender/blenlib/BLI_edgehash.h b/source/blender/blenlib/BLI_edgehash.h
index a5ec69c..a045548 100644
--- a/source/blender/blenlib/BLI_edgehash.h
+++ b/source/blender/blenlib/BLI_edgehash.h
@@ -106,6 +106,8 @@ bool BLI_edgeset_add(EdgeSet *es, unsigned int v0, unsigned int v1);
void BLI_edgeset_insert(EdgeSet *es, unsigned int v0, unsigned int v1);
bool BLI_edgeset_haskey(EdgeSet *eh, unsigned int v0, unsigned int v1) ATTR_WARN_UNUSED_RESULT;
void BLI_edgeset_free(EdgeSet *es);
+void BLI_edgeset_flag_set(EdgeSet *es, unsigned int flag);
+void BLI_edgeset_flag_clear(EdgeSet *es, unsigned int flag);
/* rely on inline api for now */
BLI_INLINE EdgeSetIterator *BLI_edgesetIterator_new(EdgeSet *gs) { return (EdgeSetIterator *)BLI_edgehashIterator_new((EdgeHash *)gs); }
diff --git a/source/blender/blenlib/BLI_ghash.h b/source/blender/blenlib/BLI_ghash.h
index 313c419..dd3f62c 100644
--- a/source/blender/blenlib/BLI_ghash.h
+++ b/source/blender/blenlib/BLI_ghash.h
@@ -192,6 +192,8 @@ GSet *BLI_gset_new_ex(GSetHashFP hashfp, GSetCmpFP cmpfp, const char *info,
const unsigned int nentries_reserve) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT;
GSet *BLI_gset_new(GSetHashFP hashfp, GSetCmpFP cmpfp, const char *info) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT;
int BLI_gset_size(GSet *gs) ATTR_WARN_UNUSED_RESULT;
+void BLI_gset_flag_set(GSet *gs, unsigned int flag);
+void BLI_gset_flag_clear(GSet *gs, unsigned int flag);
void BLI_gset_free(GSet *gs, GSetKeyFreeFP keyfreefp);
void BLI_gset_insert(GSet *gh, void *key);
bool BLI_gset_add(GSet *gs, void *key);
diff --git a/source/blender/blenlib/intern/BLI_ghash.c b/source/blender/blenlib/intern/BLI_ghash.c
index 1227623..74d7fdc 100644
--- a/source/blender/blenlib/intern/BLI_ghash.c
+++ b/source/blender/blenlib/intern/BLI_ghash.c
@@ -972,6 +972,17 @@ void BLI_gset_free(GSet *gs, GSetKeyFreeFP keyfreefp)
{
BLI_ghash_free((GHash *)gs, keyfreefp, NULL);
}
+
+void BLI_gset_flag_set(GSet *gs, unsigned int flag)
+{
+ ((GHash *)gs)->flag |= flag;
+}
+
+void BLI_gset_flag_clear(GSet *gs, unsigned int flag)
+{
+ ((GHash *)gs)->flag &= ~flag;
+}
+
/** \} */
@@ -1010,6 +1021,8 @@ GSet *BLI_gset_pair_new(const char *info)
/**
* Measure how well the hash function performs
* (1.0 is approx as good as random distribution).
+ *
+ * Smaller is better!
*/
double BLI_ghash_calc_quality(GHash *gh)
{
diff --git a/source/blender/blenlib/intern/edgehash.c b/source/blender/blenlib/intern/edgehash.c
index f6e4aec..4ed82f8 100644
--- a/source/blender/blenlib/intern/edgehash.c
+++ b/source/blender/blenlib/intern/edgehash.c
@@ -622,6 +622,16 @@ void BLI_edgeset_free(EdgeSet *es)
BLI_edgehash_free((EdgeHash *)es, NULL);
}
+void BLI_edgeset_flag_set(EdgeSet *es, unsigned int flag)
+{
+ ((EdgeHash *)es)->flag |= flag;
+}
+
+void BLI_edgeset_flag_clear(EdgeSet *es, unsigned int flag)
+{
+ ((EdgeHash *)es)->flag &= ~flag;
+}
+
/** \} */
/** \name Debugging & Introspection
More information about the Bf-blender-cvs
mailing list