c - Is 'vacated' in open address hash table only capable to store one variable? -
i'm studying master algorithms c , in open address hash table program, author defined: void *vacated;
point vacated position in hash table. if delete 2 values in hash table consecutively. true not possible vacated
point last deleted variable?
if delete 2 variables of same hash value consecutively. think different deleting 2 variables of different hash value.
in function ohtbl_remove
, not find statement null variable deleted. how manages delete variable if delete variables consecutively? thanks.
int ohtbl_remove(ohtbl *htbl, void **data) { int position, i; /***************************************************************************** * * * use double hashing hash key. * * * *****************************************************************************/ (i = 0; < htbl->positions; i++) { position = (htbl->h1(*data) + (i * htbl->h2(*data))) % htbl->positions; if (htbl->table[position] == null) { /*********************************************************************** * * * return data not found. * * * ***********************************************************************/ return -1; } else if (htbl->table[position] == htbl->vacated) { /*********************************************************************** * * * search beyond vacated positions. * * * ***********************************************************************/ continue; } else if (htbl->match(htbl->table[position], *data)) { /*********************************************************************** * * * pass data table. * * * ***********************************************************************/ *data = htbl->table[position]; htbl->table[position] = htbl->vacated; htbl->size--; return 0; } }
several elements in list point @ same vacated
member — no, not true can have 1 vacated slot in table. can have several consecutive vacated slots. links point next entry; data pointer point vacated
know once upon time there element here , should continue searching beyond it.
Comments
Post a Comment