Blender V5.3
BLI_ghash.hh File Reference

Go to the source code of this file.

Classes

struct  blender::GHashIterator
struct  blender::GHashIterState
struct  blender::_gh_Entry
struct  blender::GSetIterator
struct  blender::GHashPair

Namespaces

namespace  blender
 BMesh Iterators.

Macros

#define _GHASH_INTERNAL_ATTR
GHash/GSet Macros
#define GHASH_FOREACH_BEGIN(type, var, what)
#define GHASH_FOREACH_END()
#define GSET_FOREACH_BEGIN(type, var, what)
#define GSET_FOREACH_END()

Typedefs

GSet Types

A "set" implementation (unordered collection of unique elements).

Internally this is a 'GHash' without any keys, which is why this API's are in the same header & source file.

typedef GHashHashFP blender::GSetHashFP
typedef GHashCmpFP blender::GSetCmpFP
typedef GHashKeyFreeFP blender::GSetKeyFreeFP
typedef GHashKeyCopyFP blender::GSetKeyCopyFP
typedef GHashIterState blender::GSetIterState

Functions

GHash API

Defined in BLI_ghash.c

GHash * blender::BLI_ghash_new_ex (GHashHashFP hashfp, GHashCmpFP cmpfp, const char *info, unsigned int nentries_reserve) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
GHash * blender::BLI_ghash_new (GHashHashFP hashfp, GHashCmpFP cmpfp, const char *info) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
GHash * blender::BLI_ghash_copy (const GHash *gh, GHashKeyCopyFP keycopyfp, GHashValCopyFP valcopyfp) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
void blender::BLI_ghash_free (GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
void blender::BLI_ghash_reserve (GHash *gh, unsigned int nentries_reserve)
void blender::BLI_ghash_insert (GHash *gh, void *key, void *val)
bool blender::BLI_ghash_reinsert (GHash *gh, void *key, void *val, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
void * blender::BLI_ghash_replace_key (GHash *gh, void *key)
void * blender::BLI_ghash_lookup (const GHash *gh, const void *key) ATTR_WARN_UNUSED_RESULT
void * blender::BLI_ghash_lookup_default (const GHash *gh, const void *key, void *val_default) ATTR_WARN_UNUSED_RESULT
void ** blender::BLI_ghash_lookup_p (GHash *gh, const void *key) ATTR_WARN_UNUSED_RESULT
bool blender::BLI_ghash_ensure_p (GHash *gh, void *key, void ***r_val) ATTR_WARN_UNUSED_RESULT
bool blender::BLI_ghash_ensure_p_ex (GHash *gh, const void *key, void ***r_key, void ***r_val) ATTR_WARN_UNUSED_RESULT
bool blender::BLI_ghash_remove (GHash *gh, const void *key, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
void blender::BLI_ghash_clear (GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
void blender::BLI_ghash_clear_ex (GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp, unsigned int nentries_reserve)
void * blender::BLI_ghash_popkey (GHash *gh, const void *key, GHashKeyFreeFP keyfreefp) ATTR_WARN_UNUSED_RESULT
bool blender::BLI_ghash_haskey (const GHash *gh, const void *key) ATTR_WARN_UNUSED_RESULT
bool blender::BLI_ghash_pop (GHash *gh, GHashIterState *state, void **r_key, void **r_val) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
unsigned int blender::BLI_ghash_len (const GHash *gh) ATTR_WARN_UNUSED_RESULT
void blender::BLI_ghash_flag_set (GHash *gh, unsigned int flag)
void blender::BLI_ghash_flag_clear (GHash *gh, unsigned int flag)
GSet Public API
GSet * blender::BLI_gset_new_ex (GSetHashFP hashfp, GSetCmpFP cmpfp, const char *info, unsigned int nentries_reserve) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
GSet * blender::BLI_gset_new (GSetHashFP hashfp, GSetCmpFP cmpfp, const char *info) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
GSet * blender::BLI_gset_copy (const GSet *gs, GSetKeyCopyFP keycopyfp) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
unsigned int blender::BLI_gset_len (const GSet *gs) ATTR_WARN_UNUSED_RESULT
void blender::BLI_gset_flag_set (GSet *gs, unsigned int flag)
void blender::BLI_gset_flag_clear (GSet *gs, unsigned int flag)
void blender::BLI_gset_free (GSet *gs, GSetKeyFreeFP keyfreefp)
void blender::BLI_gset_insert (GSet *gs, void *key)
bool blender::BLI_gset_add (GSet *gs, void *key)
bool blender::BLI_gset_ensure_p_ex (GSet *gs, const void *key, void ***r_key)
bool blender::BLI_gset_reinsert (GSet *gs, void *key, GSetKeyFreeFP keyfreefp)
void * blender::BLI_gset_replace_key (GSet *gs, void *key)
bool blender::BLI_gset_haskey (const GSet *gs, const void *key) ATTR_WARN_UNUSED_RESULT
bool blender::BLI_gset_pop (GSet *gs, GSetIterState *state, void **r_key) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
bool blender::BLI_gset_remove (GSet *gs, const void *key, GSetKeyFreeFP keyfreefp)
void blender::BLI_gset_clear_ex (GSet *gs, GSetKeyFreeFP keyfreefp, unsigned int nentries_reserve)
void blender::BLI_gset_clear (GSet *gs, GSetKeyFreeFP keyfreefp)
void * blender::BLI_gset_lookup (const GSet *gs, const void *key) ATTR_WARN_UNUSED_RESULT
void * blender::BLI_gset_pop_key (GSet *gs, const void *key) ATTR_WARN_UNUSED_RESULT

GHash Iterator

#define _gh_Entry   void
#define GHASH_ITER(gh_iter_, ghash_)
#define GHASH_ITER_INDEX(gh_iter_, ghash_, i_)
GHashIterator * blender::BLI_ghashIterator_new (GHash *gh) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
void blender::BLI_ghashIterator_init (GHashIterator *ghi, GHash *gh)
void blender::BLI_ghashIterator_free (GHashIterator *ghi)
void blender::BLI_ghashIterator_step (GHashIterator *ghi)
BLI_INLINE void * blender::BLI_ghashIterator_getKey (GHashIterator *ghi) ATTR_WARN_UNUSED_RESULT
BLI_INLINE void * blender::BLI_ghashIterator_getValue (GHashIterator *ghi) ATTR_WARN_UNUSED_RESULT
BLI_INLINE void ** blender::BLI_ghashIterator_getValue_p (GHashIterator *ghi) ATTR_WARN_UNUSED_RESULT
BLI_INLINE bool blender::BLI_ghashIterator_done (const GHashIterator *ghi) ATTR_WARN_UNUSED_RESULT

GSet Iterator

#define GSET_ITER(gs_iter_, gset_)
#define GSET_ITER_INDEX(gs_iter_, gset_, i_)
BLI_INLINE GSetIterator * blender::BLI_gsetIterator_new (GSet *gs)
BLI_INLINE void blender::BLI_gsetIterator_init (GSetIterator *gsi, GSet *gs)
BLI_INLINE void blender::BLI_gsetIterator_free (GSetIterator *gsi)
BLI_INLINE void * blender::BLI_gsetIterator_getKey (GSetIterator *gsi)
BLI_INLINE void blender::BLI_gsetIterator_step (GSetIterator *gsi)
BLI_INLINE bool blender::BLI_gsetIterator_done (const GSetIterator *gsi)

GHash/GSet Utils

Defined in BLI_ghash_utils.cc

#define BLI_ghashutil_strhash(key)
#define BLI_ghashutil_inthash(key)
#define BLI_ghashutil_inthash_v4(key)
#define BLI_ghashutil_inthash_v4_p   ((GSetHashFP)BLI_ghashutil_uinthash_v4)
#define BLI_ghashutil_uinthash_v4_p   ((GSetHashFP)BLI_ghashutil_uinthash_v4)
#define BLI_ghashutil_inthash_v4_murmur(key)
#define BLI_ghashutil_inthash_v4_p_murmur   ((GSetHashFP)BLI_ghashutil_uinthash_v4_murmur)
#define BLI_ghashutil_uinthash_v4_p_murmur   ((GSetHashFP)BLI_ghashutil_uinthash_v4_murmur)
#define BLI_ghashutil_inthash_v4_cmp   BLI_ghashutil_uinthash_v4_cmp
unsigned int blender::BLI_ghashutil_ptrhash (const void *key)
bool blender::BLI_ghashutil_ptrcmp (const void *a, const void *b)
unsigned int blender::BLI_ghashutil_strhash_n (const char *key, size_t n)
unsigned int blender::BLI_ghashutil_strhash_p (const void *ptr)
unsigned int blender::BLI_ghashutil_strhash_p_murmur (const void *ptr)
bool blender::BLI_ghashutil_strcmp (const void *a, const void *b)
unsigned int blender::BLI_ghashutil_uinthash (unsigned int key)
unsigned int blender::BLI_ghashutil_inthash_p (const void *ptr)
unsigned int blender::BLI_ghashutil_inthash_p_murmur (const void *ptr)
unsigned int blender::BLI_ghashutil_inthash_p_simple (const void *ptr)
bool blender::BLI_ghashutil_intcmp (const void *a, const void *b)
size_t blender::BLI_ghashutil_combine_hash (size_t hash_a, size_t hash_b)
unsigned int blender::BLI_ghashutil_uinthash_v4 (const unsigned int key[4])
unsigned int blender::BLI_ghashutil_uinthash_v4_murmur (const unsigned int key[4])
bool blender::BLI_ghashutil_uinthash_v4_cmp (const void *a, const void *b)
GHashPair * blender::BLI_ghashutil_pairalloc (const void *first, const void *second)
unsigned int blender::BLI_ghashutil_pairhash (const void *ptr)
bool blender::BLI_ghashutil_paircmp (const void *a, const void *b)
void blender::BLI_ghashutil_pairfree (void *ptr)
GHash * blender::BLI_ghash_ptr_new_ex (const char *info, unsigned int nentries_reserve) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
GHash * blender::BLI_ghash_ptr_new (const char *info) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
GHash * blender::BLI_ghash_str_new_ex (const char *info, unsigned int nentries_reserve) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
GHash * blender::BLI_ghash_str_new (const char *info) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
GHash * blender::BLI_ghash_int_new_ex (const char *info, unsigned int nentries_reserve) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
GHash * blender::BLI_ghash_int_new (const char *info) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
GHash * blender::BLI_ghash_pair_new_ex (const char *info, unsigned int nentries_reserve) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
GHash * blender::BLI_ghash_pair_new (const char *info) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
GSet * blender::BLI_gset_ptr_new_ex (const char *info, unsigned int nentries_reserve) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
GSet * blender::BLI_gset_ptr_new (const char *info)
GSet * blender::BLI_gset_str_new_ex (const char *info, unsigned int nentries_reserve) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
GSet * blender::BLI_gset_str_new (const char *info)
GSet * blender::BLI_gset_pair_new_ex (const char *info, unsigned int nentries_reserve) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
GSet * blender::BLI_gset_pair_new (const char *info) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
GSet * blender::BLI_gset_int_new_ex (const char *info, unsigned int nentries_reserve) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
GSet * blender::BLI_gset_int_new (const char *info) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT

GHash Types

enum  { blender::GHASH_FLAG_ALLOW_DUPES = (1 << 0) , blender::GHASH_FLAG_ALLOW_SHRINK = (1 << 1) }
typedef unsigned int(*) blender::GHashHashFP(const void *key)
typedef bool(*) blender::GHashCmpFP(const void *a, const void *b)
typedef void(*) blender::GHashKeyFreeFP(void *key)
typedef void(*) blender::GHashValFreeFP(void *val)
typedef void *(*) blender::GHashKeyCopyFP(const void *key)
typedef void *(*) blender::GHashValCopyFP(const void *val)

Detailed Description

GHash is a hash-map implementation (unordered key, value pairs).

This is also used to implement a 'set' (see #GSet below).

Definition in file BLI_ghash.hh.

Macro Definition Documentation

◆ _gh_Entry

#define _gh_Entry   void

Definition at line 317 of file BLI_ghash.hh.

◆ _GHASH_INTERNAL_ATTR

#define _GHASH_INTERNAL_ATTR

Definition at line 21 of file BLI_ghash.hh.

◆ BLI_ghashutil_inthash

#define BLI_ghashutil_inthash ( key)
Value:
(CHECK_TYPE_ANY(&(key), int *, const int *), BLI_ghashutil_uinthash((unsigned int)key))
#define CHECK_TYPE_ANY(...)

Definition at line 579 of file BLI_ghash.hh.

Referenced by blender::ed::object::DupliObjectInstancerHash::operator()().

◆ BLI_ghashutil_inthash_v4

#define BLI_ghashutil_inthash_v4 ( key)
Value:
(CHECK_TYPE_ANY(key, int *, const int *), BLI_ghashutil_uinthash_v4((const unsigned int *)key))

Definition at line 590 of file BLI_ghash.hh.

◆ BLI_ghashutil_inthash_v4_cmp

#define BLI_ghashutil_inthash_v4_cmp   BLI_ghashutil_uinthash_v4_cmp

Definition at line 601 of file BLI_ghash.hh.

Referenced by blender::BM_mesh_intersect().

◆ BLI_ghashutil_inthash_v4_murmur

#define BLI_ghashutil_inthash_v4_murmur ( key)
Value:
(CHECK_TYPE_ANY(key, int *, const int *), \
BLI_ghashutil_uinthash_v4_murmur((const unsigned int *)key))

Definition at line 595 of file BLI_ghash.hh.

◆ BLI_ghashutil_inthash_v4_p

#define BLI_ghashutil_inthash_v4_p   ((GSetHashFP)BLI_ghashutil_uinthash_v4)

Definition at line 592 of file BLI_ghash.hh.

Referenced by blender::BM_mesh_intersect().

◆ BLI_ghashutil_inthash_v4_p_murmur

#define BLI_ghashutil_inthash_v4_p_murmur   ((GSetHashFP)BLI_ghashutil_uinthash_v4_murmur)

Definition at line 598 of file BLI_ghash.hh.

◆ BLI_ghashutil_strhash

#define BLI_ghashutil_strhash ( key)
Value:
(CHECK_TYPE_ANY(key, char *, const char *), BLI_ghashutil_strhash_p(key))

Definition at line 573 of file BLI_ghash.hh.

Referenced by blender::do_map(), blender::idkey_hash(), and blender::modify_mesh().

◆ BLI_ghashutil_uinthash_v4_p

#define BLI_ghashutil_uinthash_v4_p   ((GSetHashFP)BLI_ghashutil_uinthash_v4)

Definition at line 593 of file BLI_ghash.hh.

Referenced by blender::TEST().

◆ BLI_ghashutil_uinthash_v4_p_murmur

#define BLI_ghashutil_uinthash_v4_p_murmur   ((GSetHashFP)BLI_ghashutil_uinthash_v4_murmur)

Definition at line 599 of file BLI_ghash.hh.

Referenced by blender::TEST().

◆ GHASH_FOREACH_BEGIN

#define GHASH_FOREACH_BEGIN ( type,
var,
what )
Value:
do { \
GHashIterator gh_iter##var; \
GHASH_ITER (gh_iter##var, what) { \
type var = (type)(BLI_ghashIterator_getValue(&gh_iter##var));

Definition at line 523 of file BLI_ghash.hh.

◆ GHASH_FOREACH_END

#define GHASH_FOREACH_END ( )
Value:
} \
} \
while (0)

Definition at line 529 of file BLI_ghash.hh.

◆ GHASH_ITER

◆ GHASH_ITER_INDEX

#define GHASH_ITER_INDEX ( gh_iter_,
ghash_,
i_ )
Value:
for (BLI_ghashIterator_init(&gh_iter_, ghash_), i_ = 0; \
BLI_ghashIterator_done(&gh_iter_) == false; \
BLI_ghashIterator_step(&gh_iter_), i_++)

Definition at line 324 of file BLI_ghash.hh.

Referenced by blender::bm_mesh_region_match_pair().

◆ GSET_FOREACH_BEGIN

#define GSET_FOREACH_BEGIN ( type,
var,
what )
Value:
do { \
GSetIterator gh_iter##var; \
GSET_ITER (gh_iter##var, what) { \
type var = (type)(BLI_gsetIterator_getKey(&gh_iter##var));

Definition at line 534 of file BLI_ghash.hh.

◆ GSET_FOREACH_END

#define GSET_FOREACH_END ( )
Value:
} \
} \
while (0)

Definition at line 540 of file BLI_ghash.hh.

◆ GSET_ITER

#define GSET_ITER ( gs_iter_,
gset_ )
Value:
for (BLI_gsetIterator_init(&gs_iter_, gset_); BLI_gsetIterator_done(&gs_iter_) == false; \
BLI_gsetIterator_step(&gs_iter_))

Definition at line 471 of file BLI_ghash.hh.

◆ GSET_ITER_INDEX

#define GSET_ITER_INDEX ( gs_iter_,
gset_,
i_ )
Value:
for (BLI_gsetIterator_init(&gs_iter_, gset_), i_ = 0; \
BLI_gsetIterator_done(&gs_iter_) == false; \
BLI_gsetIterator_step(&gs_iter_), i_++)

Definition at line 475 of file BLI_ghash.hh.