Blender  V3.3
Classes | Macros | Typedefs | Functions
BLI_smallhash.h File Reference
#include "BLI_compiler_attrs.h"

Go to the source code of this file.

Classes

struct  SmallHashEntry
 
struct  SmallHash
 
struct  SmallHashIter
 

Macros

#define SMSTACKSIZE   131
 

Typedefs

typedef struct SmallHash SmallHash
 

Functions

void BLI_smallhash_init_ex (SmallHash *sh, unsigned int nentries_reserve) ATTR_NONNULL(1)
 
void BLI_smallhash_init (SmallHash *sh) ATTR_NONNULL(1)
 
void BLI_smallhash_release (SmallHash *sh) ATTR_NONNULL(1)
 
void BLI_smallhash_insert (SmallHash *sh, uintptr_t key, void *item) ATTR_NONNULL(1)
 
bool BLI_smallhash_reinsert (SmallHash *sh, uintptr_t key, void *item) ATTR_NONNULL(1)
 
bool BLI_smallhash_remove (SmallHash *sh, uintptr_t key) ATTR_NONNULL(1)
 
voidBLI_smallhash_lookup (const SmallHash *sh, uintptr_t key) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT
 
void ** BLI_smallhash_lookup_p (const SmallHash *sh, uintptr_t key) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT
 
bool BLI_smallhash_haskey (const SmallHash *sh, uintptr_t key) ATTR_NONNULL(1)
 
int BLI_smallhash_len (const SmallHash *sh) ATTR_NONNULL(1)
 
voidBLI_smallhash_iternext (SmallHashIter *iter, uintptr_t *key) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT
 
void ** BLI_smallhash_iternext_p (SmallHashIter *iter, uintptr_t *key) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT
 
voidBLI_smallhash_iternew (const SmallHash *sh, SmallHashIter *iter, uintptr_t *key) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT
 
void ** BLI_smallhash_iternew_p (const SmallHash *sh, SmallHashIter *iter, uintptr_t *key) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT
 

Macro Definition Documentation

◆ SMSTACKSIZE

#define SMSTACKSIZE   131

How much stack space to use before dynamically allocating memory. set to match one of the values in 'hashsizes' to avoid too many mallocs.

Definition at line 25 of file BLI_smallhash.h.

Typedef Documentation

◆ SmallHash

typedef struct SmallHash SmallHash

Function Documentation

◆ BLI_smallhash_haskey()

bool BLI_smallhash_haskey ( const SmallHash sh,
uintptr_t  key 
)

Definition at line 269 of file smallhash.c.

References e, NULL, sh, and smallhash_lookup().

Referenced by BLI_smallhash_insert(), and knife_find_line_hits().

◆ BLI_smallhash_init()

void BLI_smallhash_init ( SmallHash sh)

Definition at line 196 of file smallhash.c.

References BLI_smallhash_init_ex(), and sh.

Referenced by knife_find_line_hits(), and knife_make_cuts().

◆ BLI_smallhash_init_ex()

void BLI_smallhash_init_ex ( SmallHash sh,
unsigned int  nentries_reserve 
)

◆ BLI_smallhash_insert()

void BLI_smallhash_insert ( SmallHash sh,
uintptr_t  key,
void item 
)

◆ BLI_smallhash_iternew()

void* BLI_smallhash_iternew ( const SmallHash sh,
SmallHashIter iter,
uintptr_t key 
)

Definition at line 312 of file smallhash.c.

References BLI_smallhash_iternext(), SmallHashIter::i, sh, and SmallHashIter::sh.

Referenced by knife_find_line_hits(), and knife_make_cuts().

◆ BLI_smallhash_iternew_p()

void** BLI_smallhash_iternew_p ( const SmallHash sh,
SmallHashIter iter,
uintptr_t key 
)

Definition at line 320 of file smallhash.c.

References BLI_smallhash_iternext_p(), SmallHashIter::i, sh, and SmallHashIter::sh.

Referenced by knife_find_line_hits().

◆ BLI_smallhash_iternext()

void* BLI_smallhash_iternext ( SmallHashIter iter,
uintptr_t key 
)

Definition at line 298 of file smallhash.c.

References e, NULL, and smallhash_iternext().

Referenced by BLI_smallhash_iternew(), knife_find_line_hits(), and knife_make_cuts().

◆ BLI_smallhash_iternext_p()

void** BLI_smallhash_iternext_p ( SmallHashIter iter,
uintptr_t key 
)

Definition at line 305 of file smallhash.c.

References e, NULL, and smallhash_iternext().

Referenced by BLI_smallhash_iternew_p(), and knife_find_line_hits().

◆ BLI_smallhash_len()

int BLI_smallhash_len ( const SmallHash sh)

Definition at line 276 of file smallhash.c.

References sh.

◆ BLI_smallhash_lookup()

void* BLI_smallhash_lookup ( const SmallHash sh,
uintptr_t  key 
)

Definition at line 255 of file smallhash.c.

References e, NULL, sh, and smallhash_lookup().

Referenced by knife_find_line_hits(), and knife_make_cuts().

◆ BLI_smallhash_lookup_p()

void** BLI_smallhash_lookup_p ( const SmallHash sh,
uintptr_t  key 
)

Definition at line 262 of file smallhash.c.

References e, NULL, sh, and smallhash_lookup().

◆ BLI_smallhash_reinsert()

bool BLI_smallhash_reinsert ( SmallHash sh,
uintptr_t  key,
void item 
)

Inserts a new value to a key that may already be in GHash.

Avoids BLI_smallhash_remove, BLI_smallhash_insert calls (double lookups)

Returns
true if a new key has been added.

Definition at line 225 of file smallhash.c.

References BLI_smallhash_insert(), e, sh, and smallhash_lookup().

Referenced by knife_find_line_hits().

◆ BLI_smallhash_release()

void BLI_smallhash_release ( SmallHash sh)
Note
does not free *sh itself! only the direct data!

Definition at line 201 of file smallhash.c.

References MEM_freeN, and sh.

Referenced by knife_find_line_hits(), and knife_make_cuts().

◆ BLI_smallhash_remove()

bool BLI_smallhash_remove ( SmallHash sh,
uintptr_t  key 
)