21 #ifndef ABC__misc__hash__hashGen_h
22 #define ABC__misc__hash__hashGen_h
72 #define Hash_GenForEachEntry( pHash, pEntry, bin ) \
73 for(bin=-1, pEntry=NULL; bin < pHash->nBins; (!pEntry)?(pEntry=pHash->pArray[++bin]):(pEntry=pEntry->pNext)) \
93 const char*
p = (
const char*)key;
99 return (
unsigned)h % nBins;
104 return strcmp((
const char*)key1, (
const char*) key2);
120 return (
long)key % nBins;
136 return (
long)key1 - (long)key2;
152 int (*Hash_FuncHash)(
void *,
int),
153 int (*Hash_FuncComp)(
void *,
void *),
162 p->fFreeKey = fFreeKey;
185 bin = (*(p->fHash))(
key, p->nBins);
188 pEntry = p->pArray[bin];
190 if ( !p->fComp(pEntry->
key,key) ) {
193 pEntry = pEntry->
pNext;
216 bin = (*(p->fHash))(
key, p->nBins);
219 pLast = &(p->pArray[bin]);
220 pEntry = p->pArray[bin];
222 if ( !p->fComp(pEntry->
key,key) ) {
226 pLast = &(pEntry->
pNext);
227 pEntry = pEntry->
pNext;
234 pEntry->
pNext = NULL;
235 pEntry->
key = (
char *)key;
259 bin = (*(p->fHash))(
key, p->nBins);
262 pLast = &(p->pArray[bin]);
263 pEntry = p->pArray[bin];
265 if ( !p->fComp(pEntry->
key,key) )
267 pLast = &(pEntry->
pNext);
268 pEntry = pEntry->
pNext;
276 pEntry->
pNext = NULL;
277 pEntry->
key = (
char *)key;
303 bin = (*(p->fHash))(
key, p->nBins);
306 pLast = &(p->pArray[bin]);
307 pEntry = p->pArray[bin];
309 if ( !p->fComp(pEntry->
key,key) ) {
312 *pLast = pEntry->
pNext;
318 pLast = &(pEntry->
pNext);
319 pEntry = pEntry->
pNext;
343 for(bin = 0; bin < p->nBins; bin++) {
344 pEntry = p->pArray[bin];
349 pEntry = pEntry->
pNext;
static void * Hash_GenRemove(Hash_Gen_t *p, void *key)
static int Hash_DefaultHashFuncStr(void *key, int nBins)
FUNCTION DEFINITIONS ///.
Hash_GenHashFunction_t fHash
static Hash_Gen_Entry_t * Hash_GenEntry(Hash_Gen_t *p, void *key, int fCreate)
#define ABC_ALLOC(type, num)
static int Hash_DefaultHashFuncInt(void *key, int nBins)
Hash_Gen_Entry_t ** pArray
static Hash_Gen_t * Hash_GenAlloc(int nBins, int(*Hash_FuncHash)(void *, int), int(*Hash_FuncComp)(void *, void *), int fFreeKey)
static void Hash_GenFree(Hash_Gen_t *p)
int(* Hash_GenCompFunction_t)(void *key, void *data)
static int Hash_DefaultCmpFuncStr(void *key1, void *key2)
int(* Hash_GenHashFunction_t)(void *key, int nBins)
#define ABC_NAMESPACE_HEADER_START
NAMESPACES ///.
typedefABC_NAMESPACE_HEADER_START struct Hash_Gen_t_ Hash_Gen_t
INCLUDES ///.
#define ABC_NAMESPACE_HEADER_END
Hash_GenCompFunction_t fComp
static int Hash_DefaultCmpFuncInt(void *key1, void *key2)
#define ABC_CALLOC(type, num)
static int Hash_GenExists(Hash_Gen_t *p, void *key)
static void Hash_GenWriteEntry(Hash_Gen_t *p, void *key, void *data)
struct Hash_Gen_Entry_t_ * pNext