/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1985-2011 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"
** dt: dictionary being searched
** obj: the object to look for.
** type: search type.
**
** Written by Kiem-Phong Vo (5/25/96)
*/
#if __STD_C
#else
int type;
#endif
{
if(!obj)
{ do
} while((root = t) );
}
}
}
else /* type&DT_FIRST */
}
}
}
/* note that link.right is LEFT tree and link.left is RIGHT tree */
l = r = &link;
/* allow apps to delete an object "actually" in the dictionary */
break;
if(o == obj)
goto dt_delete;
}
}
}
if(root)
goto do_search;
}
if(root)
goto do_search;
}
{ /* simple search, note that minp should be even */
else
}
}
/* exceed search length, top-down splay now */
for(n = 0; n < minp; n += 2)
{ if(turn[n] < 0)
if(turn[n+1] < 0)
rlink(r,t);
}
else
{ llink(l,t);
}
}
else
if(turn[n+1] > 0)
llink(l,t);
}
else
{ rlink(r,t);
}
}
}
}
while(1)
break;
else if(cmp < 0)
rlink(r,t);
break;
}
else if(cmp == 0)
root = t;
break;
}
else /* if(cmp > 0) */
{ llink(l,t);
break;
}
}
else
break;
}
}
else /* if(cmp > 0) */
llink(l,t);
break;
}
else if(cmp == 0)
root = t;
break;
}
else /* if(cmp < 0) */
{ rlink(r,t);
break;
}
}
else
break;
}
}
}
}
if(root)
{ /* found it, now isolate it */
{ has_root:
{ /* find max of left subtree */
while((r = t->right) )
LROTATE(t,r);
/* now see if it's in the same group */
break;
}
}
}
goto has_root;
}
else goto no_root;
}
goto has_root;
}
else goto no_root;
}
{ /* taking an object out of the dictionary */
goto no_root;
}
goto has_root;
else
goto dt_insert;
}
}
}
else
}
goto has_root;
}
}
else
{ /* not found, finish up LEFT and RIGHT trees */
goto dt_next;
goto dt_prev;
{ no_root:
while((t = r->left) )
r = t;
}
{ dt_insert:
if(obj)
{ if(lk >= 0)
else
if(root)
}
}
if(root)
goto has_root;
}
else goto no_root;
}
goto has_root;
}
else /*if(type&DT_DELETE)*/
goto no_root;
}
}
}
/* make this method available */
#ifndef KPVDEL /* backward compatibility - delete next time around */
#endif
#ifdef NoF
#endif