49 #define CUR_MARK_INIT -1
61 #define __FUNC__ "Hash_dhCreate"
80 #define __FUNC__ "Hash_dhDestroy"
94 #define __FUNC__ "Hash_dhReset"
103 #define __FUNC__ "Hash_dhInit_private"
115 if ((size - s) < (.1 * size))
129 for (i = 0; i <
size; ++i)
137 #define __FUNC__ "Hash_dhLookup"
147 HASH_1 (key, size, &start)
for (i = 0; i <
size; ++i)
150 HASH_2 (key, size, &tmp) idx = (start + i * tmp) % size;
151 if (data[idx].mark != curMark)
157 if (data[idx].key == key)
159 retval = &(data[idx].
data);
172 #define __FUNC__ "Hash_dhInsert"
186 SET_V_ERROR (
"hash table overflow; rehash need implementing!");
189 HASH_1 (key, size, &start)
for (i = 0; i <
size; ++i)
192 HASH_2 (key, size, &tmp) idx = (start + i * tmp) % size;
193 if (data[idx].mark < curMark)
197 memcpy (&(data[idx].data), dataIN,
sizeof (
HashData));
204 #define __FUNC__ "Hash_dhPrint"
213 fprintf (fp,
"\n--------------------------- hash table \n");
214 for (i = 0; i <
size; ++i)
216 if (data[i].mark == curMark)
218 fprintf (fp,
"key = %2i; iData = %3i; fData = %g\n",
219 data[i].key, data[i].data.iData, data[i].
data.
fData);
HashData * Hash_dhLookup(Hash_dh h, int key)
void Hash_dhDestroy(Hash_dh h)
#define HASH_2(k, size, idxOut)
static void Hash_dhInit_private(Hash_dh h, int s)
#define END_FUNC_VAL(retval)
void Hash_dhPrint(Hash_dh h, FILE *fp)
void Hash_dhReset(Hash_dh h)
void Hash_dhInsert(Hash_dh h, int key, HashData *dataIN)
#define HASH_1(k, size, idxOut)
void Hash_dhCreate(Hash_dh *h, int size)