47 #define DEFAULT_TABLE_SIZE 16
55 #define HASH_1(k,size,idxOut) \
56 { *idxOut = k % size; }
58 #define HASH_2(k,size,idxOut) \
60 int r = k % (size-13); \
61 r = (r % 2) ? r : r+1; \
93 #define __FUNC__ "Hash_i_dhCreate"
119 while (size < sizeIN)
122 if ((size - sizeIN) < (.1 *
size))
133 for (i = 0; i <
size; ++i)
144 #define __FUNC__ "Hash_i_dhDestroy"
158 #define __FUNC__ "Hash_i_dhReset"
168 #define __FUNC__ "Hash_i_dhLookup"
181 for (i = 0; i <
size; ++i)
183 idx = (start + i * inc) % size;
187 if (data[idx].mark != curMark)
193 if (data[idx].key == key)
195 retval = data[idx].
data;
204 #define __FUNC__ "Hash_i_dhInsert"
211 bool success =
false;
215 sprintf (
msgBuf_dh,
"data = %i must be >= 0", dataIN);
233 for (i = 0; i <
size; ++i)
235 idx = (start + i * inc) % size;
241 if (data[idx].mark == curMark && data[idx].key == key)
243 sprintf (
msgBuf_dh,
"key,data= <%i, %i> already inserted", key,
248 if (data[idx].mark < curMark)
252 data[idx].
data = dataIN;
260 sprintf (
msgBuf_dh,
"Failed to insert key= %i, data= %i", key, dataIN);
266 #define __FUNC__ "rehash_private"
272 old_size = h->
size, new_size = old_size * 2, oldCurMark = h->
curMark;
275 sprintf (
msgBuf_dh,
"rehashing; old_size= %i, new_size= %i", old_size,
284 for (i = 0; i < new_size; ++i)
287 newData[i].mark = -1;
294 for (i = h->
count; i < new_size; ++i)
297 newData[i].mark = -1;
304 for (i = 0; i < old_size; ++i)
306 if (oldData[i].mark == oldCurMark)
#define HASH_2(k, size, idxOut)
void Hash_i_dhReset(Hash_i_dh h)
void Hash_i_dhInsert(Hash_i_dh h, int key, int dataIN)
#define DEFAULT_TABLE_SIZE
#define END_FUNC_VAL(retval)
static void rehash_private(Hash_i_dh h)
void Hash_i_dhCreate(Hash_i_dh *h, int sizeIN)
#define HASH_1(k, size, idxOut)
void Hash_i_dhDestroy(Hash_i_dh h)
int Hash_i_dhLookup(Hash_i_dh h, int key)
char msgBuf_dh[MSG_BUF_SIZE_DH]