// (c) 1995-2014 by Artsoft Entertainment
// Holger Schemel
// info@artsoft.org
-// http://www.artsoft.org/
+// https://www.artsoft.org/
// ----------------------------------------------------------------------------
// hash.c
// ============================================================================
struct hashtable *
create_hashtable(unsigned int minsize, float maxloadfactor,
unsigned int (*hashf) (void*),
- int (*eqf) (void*,void*))
+ int (*eqf) (void*, void*))
{
struct hashtable *h;
unsigned int i, size = 1u;
return NULL;
}
- for (i=0; i < size; i++)
+ for (i = 0; i < size; i++)
h->table[i] = NULL;
h->tablelength = size;
while ((e = h->table[i]) != NULL)
{
h->table[i] = e->next;
- index = indexFor(newsize,e->h);
+ index = indexFor(newsize, e->h);
e->next = newtable[index];
newtable[index] = e;
}
{
for (pE = &(newtable[i]), e = *pE; e != NULL; e = *pE)
{
- index = indexFor(newsize,e->h);
+ index = indexFor(newsize, e->h);
if (index == i)
{
return 0;
}
- e->h = hash(h,k);
- index = indexFor(h->tablelength,e->h);
+ e->h = hash(h, k);
+ index = indexFor(h->tablelength, e->h);
e->k = k;
e->v = v;
e->next = h->table[index];
struct entry *e;
unsigned int hashvalue, index;
- hashvalue = hash(h,k);
- index = indexFor(h->tablelength,hashvalue);
+ hashvalue = hash(h, k);
+ index = indexFor(h->tablelength, hashvalue);
e = h->table[index];
while (e != NULL)
struct entry *e;
unsigned int hashvalue, index;
- hashvalue = hash(h,k);
- index = indexFor(h->tablelength,hashvalue);
+ hashvalue = hash(h, k);
+ index = indexFor(h->tablelength, hashvalue);
e = h->table[index];
while (e != NULL)
struct entry *e;
struct entry **pE;
void *v;
- unsigned int index = indexFor(h->tablelength,hash(h,k));
+ unsigned int index = indexFor(h->tablelength, hash(h, k));
pE = &(h->table[index]);
e = *pE;
}
/*****************************************************************************/
-/* key - return the key of the (key,value) pair at the current position */
+/* key - return the key of the (key, value) pair at the current position */
void *
hashtable_iterator_key(struct hashtable_itr *i)
}
/*****************************************************************************/
-/* value - return the value of the (key,value) pair at the current position */
+/* value - return the value of the (key, value) pair at the current position */
void *
hashtable_iterator_value(struct hashtable_itr *i)
int
hashtable_iterator_advance(struct hashtable_itr *itr)
{
- unsigned int j,tablelength;
+ unsigned int j, tablelength;
struct entry **table;
struct entry *next;