/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1985-2010 AT&T Intellectual Property *
* and is licensed under the *
* Common Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* Glenn Fowler <gsf@research.att.com> *
* David Korn <dgk@research.att.com> *
* Phong Vo <kpv@research.att.com> *
* *
***********************************************************************/
#include "dthdr.h"
/* Hash table.
** dt: dictionary
** obj: what to look for
** type: type of search
**
** Written by Kiem-Phong Vo (05/25/96)
*/
/* resize the hash table */
#if __STD_C
#else
#endif
{
int n, k;
return;
{ if(n < 0) /* fix table size */
return;
}
else /* set a particular size */
{ for(k = 2; k < n; k *= 2)
;
n = k;
}
}
else n = 0;
/* compute new table size */
if(n <= 0)
n = HSLOT;
n = HRESIZE(n);
}
return;
/* allocate new table */
return;
/* rehash elements */
{ r = t->right;
p = t;
else /* move to a new chain */
{ if(p)
p->right = r;
else *hs = r;
}
}
}
}
#if __STD_C
#else
int type;
#endif
{
/* initialize discipline data */
if(!obj)
goto end_walk;
{ /* clean out all objects */
for(; s < ends; ++s)
{ t = *s;
continue;
while(t)
{ r = t->right;
t = r;
}
}
}
while(s < ends && !t )
;
}
}
/* allow apps to delete an object "actually" in the dictionary */
goto do_delete;
r = p;
}
/* delete some matching object */
goto do_delete;
}
goto do_search;
}
goto do_search;
}
else /*if(type&(DT_DELETE|DT_DETACH|DT_NEXT|DT_PREV))*/
}
else
break;
}
}
}
}
if(t) /* found matching object */
{ if(!t)
{ /* move-to-front heuristic */
t->right = *s;
*s = t;
}
}
}
if(lk >= 0)
else
if(r)
else
}
}
/* insert object */
}
if(t)
t->right = r;
}
else
{ r->right = *s;
*s = r;
}
return obj;
}
{ if(t && !(p = t->right) )
if((p = *s) )
break;
}
goto done_adj;
}
{ if(t && !p)
{ if((p = *s) != t)
{ while(p->right != t)
p = p->right;
}
else
{ if((p = *s) )
{ while(p->right)
p = p->right;
break;
}
}
}
}
{ end_walk:
}
else
}
}
goto do_insert;
else
}
}
else /*if(type&(DT_DELETE|DT_DETACH))*/
{ /* take an element out of the dictionary */
if(!t)
else if(p)
else if((p = *s) == t)
p = *s = t->right;
else
{ while(p->right != t)
p = p->right;
}
return obj;
}
}
#ifndef KPVDEL /* for backward compatibility - remove next time */
#endif
#ifdef NoF
#endif