/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1996-2011 AT&T Intellectual Property *
* and is licensed under the *
* Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* Phong Vo <kpv@research.att.com> *
* Glenn Fowler <gsf@research.att.com> *
* *
***********************************************************************/
/* Splay sort
**
** Written by Kiem-Phong Vo (08/24/96).
*/
#include "rshdr.h"
typedef struct rssplay_s
} Rssplay_t;
#if __STD_C
#else
#endif
{
return 0;
}
if(cmp == 0)
return 0;
}
else if(cmp > 0)
return 0;
}
}
else
return 0;
}
}
for(l = r = &link;; )
{ if(cmp < 0)
if(cmp < 0)
goto no_root;
}
else if(cmp == 0)
goto has_root;
}
else
{ LLINK(l,t);
goto no_root;
}
}
else
goto no_root;
}
}
else /*if(cmp > 0)*/
if(cmp > 0)
goto no_root;
}
else if(cmp == 0)
goto has_root;
}
else
{ RLINK(r,t);
goto no_root;
}
}
else
goto no_root;
}
}
if(cmp == 0)
goto has_root;
}
return 0;
return 0;
}
#if __STD_C
#else
#endif
/* find smallest element and make it head of list */
while((t = r->left) )
RROTATE(r,t);
/* flatten tree */
{ if(!r)
return list;
}
else if((t = r->left) )
{ do RROTATE(r,t);
while((t = r->left) );
p->right = r;
}
}
}
#if __STD_C
#else
#endif
{
return list;
}
/* public method */
{ splayinsert,
sizeof(Rssplay_t),
"splay",
"Splay tree sort."
};
#ifdef NoF
#endif