mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-02-24 05:47:36 +00:00
Replacing splaynode with tree generally.
Copied from Perforce Change: 184426 ServerID: perforce.ravenbrook.com
This commit is contained in:
parent
85b11f7b55
commit
2e5ca2df04
4 changed files with 110 additions and 113 deletions
|
|
@ -89,7 +89,7 @@ static Bool CBSBlockCheck(CBSBlock block)
|
|||
/* See .enter-leave.simple. */
|
||||
UNUSED(block); /* Required because there is no signature */
|
||||
CHECKL(block != NULL);
|
||||
CHECKL(SplayNodeCheck(nodeOfCBSBlock(block)));
|
||||
CHECKL(TreeCheck(nodeOfCBSBlock(block)));
|
||||
|
||||
/* If the block is in the middle of being deleted, */
|
||||
/* the pointers will be equal. */
|
||||
|
|
@ -104,7 +104,7 @@ static Bool CBSBlockCheck(CBSBlock block)
|
|||
* See <design/splay/#type.splay.compare.method>
|
||||
*/
|
||||
|
||||
static Compare cbsCompare(void *key, SplayNode node)
|
||||
static Compare cbsCompare(void *key, Tree node)
|
||||
{
|
||||
Addr base1, base2, limit2;
|
||||
CBSBlock cbsBlock;
|
||||
|
|
@ -131,13 +131,13 @@ static Compare cbsCompare(void *key, SplayNode node)
|
|||
|
||||
/* cbsTestNode, cbsTestTree -- test for nodes larger than the S parameter */
|
||||
|
||||
static Bool cbsTestNode(SplayTree tree, SplayNode node,
|
||||
static Bool cbsTestNode(SplayTree tree, Tree node,
|
||||
void *closureP, Size size)
|
||||
{
|
||||
CBSBlock block;
|
||||
|
||||
AVERT(SplayTree, tree);
|
||||
AVERT(SplayNode, node);
|
||||
AVERT(Tree, node);
|
||||
AVER(closureP == NULL);
|
||||
AVER(size > 0);
|
||||
AVER(cbsOfTree(tree)->fastFind);
|
||||
|
|
@ -147,13 +147,13 @@ static Bool cbsTestNode(SplayTree tree, SplayNode node,
|
|||
return CBSBlockSize(block) >= size;
|
||||
}
|
||||
|
||||
static Bool cbsTestTree(SplayTree tree, SplayNode node,
|
||||
static Bool cbsTestTree(SplayTree tree, Tree node,
|
||||
void *closureP, Size size)
|
||||
{
|
||||
CBSBlock block;
|
||||
|
||||
AVERT(SplayTree, tree);
|
||||
AVERT(SplayNode, node);
|
||||
AVERT(Tree, node);
|
||||
AVER(closureP == NULL);
|
||||
AVER(size > 0);
|
||||
AVER(cbsOfTree(tree)->fastFind);
|
||||
|
|
@ -166,18 +166,18 @@ static Bool cbsTestTree(SplayTree tree, SplayNode node,
|
|||
|
||||
/* cbsUpdateNode -- update size info after restructuring */
|
||||
|
||||
static void cbsUpdateNode(SplayTree tree, SplayNode node,
|
||||
SplayNode leftChild, SplayNode rightChild)
|
||||
static void cbsUpdateNode(SplayTree tree, Tree node,
|
||||
Tree leftChild, Tree rightChild)
|
||||
{
|
||||
Size maxSize;
|
||||
CBSBlock block;
|
||||
|
||||
AVERT(SplayTree, tree);
|
||||
AVERT(SplayNode, node);
|
||||
AVERT(Tree, node);
|
||||
if (leftChild != NULL)
|
||||
AVERT(SplayNode, leftChild);
|
||||
AVERT(Tree, leftChild);
|
||||
if (rightChild != NULL)
|
||||
AVERT(SplayNode, rightChild);
|
||||
AVERT(Tree, rightChild);
|
||||
AVER(cbsOfTree(tree)->fastFind);
|
||||
|
||||
block = cbsBlockOfNode(node);
|
||||
|
|
@ -382,7 +382,7 @@ static Res cbsInsertIntoTree(Range rangeReturn, CBS cbs, Range range)
|
|||
{
|
||||
Res res;
|
||||
Addr base, limit, newBase, newLimit;
|
||||
SplayNode leftSplay, rightSplay;
|
||||
Tree leftSplay, rightSplay;
|
||||
CBSBlock leftCBS, rightCBS;
|
||||
Bool leftMerge, rightMerge;
|
||||
Size oldSize;
|
||||
|
|
@ -500,7 +500,7 @@ static Res cbsDeleteFromTree(Range rangeReturn, CBS cbs, Range range)
|
|||
{
|
||||
Res res;
|
||||
CBSBlock cbsBlock;
|
||||
SplayNode node;
|
||||
Tree node;
|
||||
Addr base, limit, oldBase, oldLimit;
|
||||
Size oldSize;
|
||||
|
||||
|
|
@ -609,7 +609,7 @@ static Res cbsBlockDescribe(CBSBlock block, mps_lib_FILE *stream)
|
|||
return res;
|
||||
}
|
||||
|
||||
static Res cbsSplayNodeDescribe(SplayNode node, mps_lib_FILE *stream)
|
||||
static Res cbsSplayNodeDescribe(Tree node, mps_lib_FILE *stream)
|
||||
{
|
||||
Res res;
|
||||
|
||||
|
|
@ -630,7 +630,7 @@ static Res cbsSplayNodeDescribe(SplayNode node, mps_lib_FILE *stream)
|
|||
void CBSIterate(CBS cbs, CBSIterateMethod iterate,
|
||||
void *closureP, Size closureS)
|
||||
{
|
||||
SplayNode node;
|
||||
Tree node;
|
||||
SplayTree tree;
|
||||
CBSBlock cbsBlock;
|
||||
|
||||
|
|
@ -737,7 +737,7 @@ Bool CBSFindFirst(Range rangeReturn, Range oldRangeReturn,
|
|||
CBS cbs, Size size, FindDelete findDelete)
|
||||
{
|
||||
Bool found;
|
||||
SplayNode node;
|
||||
Tree node;
|
||||
|
||||
AVERT(CBS, cbs);
|
||||
cbsEnter(cbs);
|
||||
|
|
@ -774,7 +774,7 @@ Bool CBSFindLast(Range rangeReturn, Range oldRangeReturn,
|
|||
CBS cbs, Size size, FindDelete findDelete)
|
||||
{
|
||||
Bool found;
|
||||
SplayNode node;
|
||||
Tree node;
|
||||
|
||||
AVERT(CBS, cbs);
|
||||
cbsEnter(cbs);
|
||||
|
|
@ -811,7 +811,7 @@ Bool CBSFindLargest(Range rangeReturn, Range oldRangeReturn,
|
|||
CBS cbs, Size size, FindDelete findDelete)
|
||||
{
|
||||
Bool found = FALSE;
|
||||
SplayNode root;
|
||||
Tree root;
|
||||
Bool notEmpty;
|
||||
|
||||
AVERT(CBS, cbs);
|
||||
|
|
@ -826,7 +826,7 @@ Bool CBSFindLargest(Range rangeReturn, Range oldRangeReturn,
|
|||
if (notEmpty) {
|
||||
RangeStruct range;
|
||||
CBSBlock block;
|
||||
SplayNode node = NULL; /* suppress "may be used uninitialized" */
|
||||
Tree node = NULL; /* suppress "may be used uninitialized" */
|
||||
Size maxSize;
|
||||
|
||||
maxSize = cbsBlockOfNode(root)->maxSize;
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ static void TagTrivInit(void* tag, va_list args)
|
|||
|
||||
/* TagComp -- splay comparison function for address ordering of tags */
|
||||
|
||||
static Compare TagComp(void *key, SplayNode node)
|
||||
static Compare TagComp(void *key, Tree node)
|
||||
{
|
||||
Addr addr1, addr2;
|
||||
|
||||
|
|
@ -457,7 +457,7 @@ static Res tagAlloc(PoolDebugMixin debug,
|
|||
|
||||
static void tagFree(PoolDebugMixin debug, Pool pool, Addr old, Size size)
|
||||
{
|
||||
SplayNode node;
|
||||
Tree node;
|
||||
Tag tag;
|
||||
Res res;
|
||||
|
||||
|
|
@ -556,7 +556,7 @@ typedef void (*ObjectsStepMethod)(Addr addr, Size size, Format fmt,
|
|||
|
||||
static void TagWalk(Pool pool, ObjectsStepMethod step, void *p)
|
||||
{
|
||||
SplayNode node;
|
||||
Tree node;
|
||||
PoolDebugMixin debug;
|
||||
Addr dummy = NULL; /* Breaks <design/type/#addr.use>, but it's */
|
||||
/* only temporary until SplayTreeFirst is fixed. */
|
||||
|
|
|
|||
136
mps/code/splay.c
136
mps/code/splay.c
|
|
@ -54,7 +54,7 @@ void SplayTreeInit(SplayTree tree, SplayCompareMethod compare,
|
|||
}
|
||||
|
||||
|
||||
void SplayNodeInit(SplayNode node)
|
||||
void SplayNodeInit(Tree node)
|
||||
{
|
||||
AVER(node != NULL);
|
||||
|
||||
|
|
@ -62,13 +62,13 @@ void SplayNodeInit(SplayNode node)
|
|||
TreeSetLeft(node, NULL);
|
||||
TreeSetRight(node, NULL);
|
||||
|
||||
AVERT(SplayNode, node);
|
||||
AVERT(Tree, node);
|
||||
}
|
||||
|
||||
|
||||
void SplayNodeFinish(SplayNode node)
|
||||
void SplayNodeFinish(Tree node)
|
||||
{
|
||||
AVERT(SplayNode, node);
|
||||
AVERT(Tree, node);
|
||||
|
||||
/* we don't try to do a recursive finish. See .note.stack. */
|
||||
TreeSetLeft(node, NULL);
|
||||
|
|
@ -84,10 +84,10 @@ void SplayTreeFinish(SplayTree tree)
|
|||
}
|
||||
|
||||
|
||||
static void SplayNodeUpdate(SplayTree tree, SplayNode node)
|
||||
static void SplayNodeUpdate(SplayTree tree, Tree node)
|
||||
{
|
||||
AVERT(SplayTree, tree);
|
||||
AVERT(SplayNode, node);
|
||||
AVERT(Tree, node);
|
||||
AVER(tree->updateNode != NULL);
|
||||
|
||||
(*tree->updateNode)(tree, node, TreeLeft(node),
|
||||
|
|
@ -104,10 +104,10 @@ static void SplayNodeUpdate(SplayTree tree, SplayNode node)
|
|||
* See <design/splay/#impl.link.right>.
|
||||
*/
|
||||
|
||||
static void SplayLinkRight(SplayNode *topIO, SplayNode *rightIO)
|
||||
static void SplayLinkRight(Tree *topIO, Tree *rightIO)
|
||||
{
|
||||
AVERT(SplayNode, *topIO);
|
||||
AVERT(SplayNode, *rightIO);
|
||||
AVERT(Tree, *topIO);
|
||||
AVERT(Tree, *rightIO);
|
||||
|
||||
/* Don't fix client properties yet. */
|
||||
|
||||
|
|
@ -132,9 +132,9 @@ static void SplayLinkRight(SplayNode *topIO, SplayNode *rightIO)
|
|||
* See <design/splay/#impl.link.left>.
|
||||
*/
|
||||
|
||||
static void SplayLinkLeft(SplayNode *topIO, SplayNode *leftIO) {
|
||||
AVERT(SplayNode, *topIO);
|
||||
AVERT(SplayNode, *leftIO);
|
||||
static void SplayLinkLeft(Tree *topIO, Tree *leftIO) {
|
||||
AVERT(Tree, *topIO);
|
||||
AVERT(Tree, *leftIO);
|
||||
|
||||
/* Don't fix client properties yet. */
|
||||
|
||||
|
|
@ -159,12 +159,12 @@ static void SplayLinkLeft(SplayNode *topIO, SplayNode *leftIO) {
|
|||
* See <design/splay/#impl.rotate.left>.
|
||||
*/
|
||||
|
||||
static void SplayRotateLeft(SplayNode *nodeIO, SplayTree tree) {
|
||||
SplayNode nodeRight;
|
||||
static void SplayRotateLeft(Tree *nodeIO, SplayTree tree) {
|
||||
Tree nodeRight;
|
||||
|
||||
AVER(nodeIO != NULL);
|
||||
AVERT(SplayNode, *nodeIO);
|
||||
AVERT(SplayNode, TreeRight(*nodeIO));
|
||||
AVERT(Tree, *nodeIO);
|
||||
AVERT(Tree, TreeRight(*nodeIO));
|
||||
AVERT(SplayTree, tree);
|
||||
|
||||
nodeRight = TreeRight(*nodeIO);
|
||||
|
|
@ -191,12 +191,12 @@ static void SplayRotateLeft(SplayNode *nodeIO, SplayTree tree) {
|
|||
* See <design/splay/#impl.rotate.right>.
|
||||
*/
|
||||
|
||||
static void SplayRotateRight(SplayNode *nodeIO, SplayTree tree) {
|
||||
SplayNode nodeLeft;
|
||||
static void SplayRotateRight(Tree *nodeIO, SplayTree tree) {
|
||||
Tree nodeLeft;
|
||||
|
||||
AVER(nodeIO != NULL);
|
||||
AVERT(SplayNode, *nodeIO);
|
||||
AVERT(SplayNode, TreeLeft(*nodeIO));
|
||||
AVERT(Tree, *nodeIO);
|
||||
AVERT(Tree, TreeLeft(*nodeIO));
|
||||
AVERT(SplayTree, tree);
|
||||
|
||||
nodeLeft = TreeLeft(*nodeIO);
|
||||
|
|
@ -228,15 +228,15 @@ static void SplayRotateRight(SplayNode *nodeIO, SplayTree tree) {
|
|||
* See <design/splay/#impl.assemble>.
|
||||
*/
|
||||
|
||||
static void SplayAssemble(SplayTree tree, SplayNode top,
|
||||
SplayNode leftTop, SplayNode leftLast,
|
||||
SplayNode rightTop, SplayNode rightFirst) {
|
||||
static void SplayAssemble(SplayTree tree, Tree top,
|
||||
Tree leftTop, Tree leftLast,
|
||||
Tree rightTop, Tree rightFirst) {
|
||||
AVERT(SplayTree, tree);
|
||||
AVERT(SplayNode, top);
|
||||
AVERT(Tree, top);
|
||||
AVER(leftTop == TreeEMPTY ||
|
||||
(SplayNodeCheck(leftTop) && SplayNodeCheck(leftLast)));
|
||||
(TreeCheck(leftTop) && TreeCheck(leftLast)));
|
||||
AVER(rightTop == TreeEMPTY ||
|
||||
(SplayNodeCheck(rightTop) && SplayNodeCheck(rightFirst)));
|
||||
(TreeCheck(rightTop) && TreeCheck(rightFirst)));
|
||||
|
||||
if (leftTop != NULL) {
|
||||
TreeSetRight(leftLast, TreeLeft(top));
|
||||
|
|
@ -244,7 +244,7 @@ static void SplayAssemble(SplayTree tree, SplayNode top,
|
|||
|
||||
if (tree->updateNode != NULL) {
|
||||
/* Update client property using pointer reversal (Ugh!). */
|
||||
SplayNode node, parent, rightChild;
|
||||
Tree node, parent, rightChild;
|
||||
|
||||
/* Reverse the pointers between leftTop and leftLast */
|
||||
/* leftLast is not reversed. */
|
||||
|
|
@ -277,7 +277,7 @@ static void SplayAssemble(SplayTree tree, SplayNode top,
|
|||
|
||||
if (tree->updateNode != NULL) {
|
||||
/* Update client property using pointer reversal (Ugh!). */
|
||||
SplayNode node, parent, leftChild;
|
||||
Tree node, parent, leftChild;
|
||||
|
||||
/* Reverse the pointers between rightTop and rightFirst */
|
||||
/* ightFirst is not reversed. */
|
||||
|
|
@ -318,11 +318,11 @@ static void SplayAssemble(SplayTree tree, SplayNode top,
|
|||
* See <design/splay/#impl.splay>.
|
||||
*/
|
||||
|
||||
static Bool SplaySplay(SplayNode *nodeReturn, SplayTree tree,
|
||||
static Bool SplaySplay(Tree *nodeReturn, SplayTree tree,
|
||||
void *key, SplayCompareMethod compareMethod) {
|
||||
/* The sides structure avoids a boundary case in SplayLink* */
|
||||
TreeStruct sides; /* rightTop and leftTop */
|
||||
SplayNode top, leftLast, rightFirst;
|
||||
Tree top, leftLast, rightFirst;
|
||||
Bool found;
|
||||
Compare compareTop;
|
||||
|
||||
|
|
@ -353,7 +353,7 @@ static Bool SplaySplay(SplayNode *nodeReturn, SplayTree tree,
|
|||
switch(compareTop) {
|
||||
|
||||
case CompareLESS: {
|
||||
SplayNode topLeft = TreeLeft(top);
|
||||
Tree topLeft = TreeLeft(top);
|
||||
if (topLeft == TreeEMPTY) {
|
||||
found = FALSE;
|
||||
goto assemble;
|
||||
|
|
@ -390,7 +390,7 @@ static Bool SplaySplay(SplayNode *nodeReturn, SplayTree tree,
|
|||
} break;
|
||||
|
||||
case CompareGREATER: {
|
||||
SplayNode topRight = TreeRight(top);
|
||||
Tree topRight = TreeRight(top);
|
||||
if (topRight == TreeEMPTY) {
|
||||
found = FALSE;
|
||||
goto assemble;
|
||||
|
|
@ -466,11 +466,11 @@ static Bool SplaySplay(SplayNode *nodeReturn, SplayTree tree,
|
|||
* <design/splay/#impl.insert>.
|
||||
*/
|
||||
|
||||
Res SplayTreeInsert(SplayTree tree, SplayNode node, void *key) {
|
||||
SplayNode neighbour;
|
||||
Res SplayTreeInsert(SplayTree tree, Tree node, void *key) {
|
||||
Tree neighbour;
|
||||
|
||||
AVERT(SplayTree, tree);
|
||||
AVERT(SplayNode, node);
|
||||
AVERT(Tree, node);
|
||||
AVER(TreeLeft(node) == TreeEMPTY);
|
||||
AVER(TreeRight(node) == TreeEMPTY);
|
||||
|
||||
|
|
@ -518,12 +518,12 @@ Res SplayTreeInsert(SplayTree tree, SplayNode node, void *key) {
|
|||
* <design/splay/#impl.delete>.
|
||||
*/
|
||||
|
||||
Res SplayTreeDelete(SplayTree tree, SplayNode node, void *key) {
|
||||
SplayNode rightHalf, del, leftLast;
|
||||
Res SplayTreeDelete(SplayTree tree, Tree node, void *key) {
|
||||
Tree rightHalf, del, leftLast;
|
||||
Bool found;
|
||||
|
||||
AVERT(SplayTree, tree);
|
||||
AVERT(SplayNode, node);
|
||||
AVERT(Tree, node);
|
||||
|
||||
found = SplaySplay(&del, tree, key, tree->compare);
|
||||
AVER(!found || del == node);
|
||||
|
|
@ -560,8 +560,8 @@ Res SplayTreeDelete(SplayTree tree, SplayNode node, void *key) {
|
|||
* <design/splay/#impl.search>.
|
||||
*/
|
||||
|
||||
Res SplayTreeSearch(SplayNode *nodeReturn, SplayTree tree, void *key) {
|
||||
SplayNode node;
|
||||
Res SplayTreeSearch(Tree *nodeReturn, SplayTree tree, void *key) {
|
||||
Tree node;
|
||||
|
||||
AVERT(SplayTree, tree);
|
||||
AVER(nodeReturn != NULL);
|
||||
|
|
@ -582,13 +582,13 @@ Res SplayTreeSearch(SplayNode *nodeReturn, SplayTree tree, void *key) {
|
|||
* in which case NULL is returned, and the tree is unchanged.
|
||||
*/
|
||||
|
||||
static SplayNode SplayTreePredecessor(SplayTree tree, void *key) {
|
||||
SplayNode oldRoot, newRoot;
|
||||
static Tree SplayTreePredecessor(SplayTree tree, void *key) {
|
||||
Tree oldRoot, newRoot;
|
||||
|
||||
AVERT(SplayTree, tree);
|
||||
|
||||
oldRoot = SplayTreeRoot(tree);
|
||||
AVERT(SplayNode, oldRoot);
|
||||
AVERT(Tree, oldRoot);
|
||||
|
||||
if (TreeLeft(oldRoot) == TreeEMPTY) {
|
||||
newRoot = NULL; /* No predecessor */
|
||||
|
|
@ -619,13 +619,13 @@ static SplayNode SplayTreePredecessor(SplayTree tree, void *key) {
|
|||
* in which case NULL is returned, and the tree is unchanged.
|
||||
*/
|
||||
|
||||
static SplayNode SplayTreeSuccessor(SplayTree tree, void *key) {
|
||||
SplayNode oldRoot, newRoot;
|
||||
static Tree SplayTreeSuccessor(SplayTree tree, void *key) {
|
||||
Tree oldRoot, newRoot;
|
||||
|
||||
AVERT(SplayTree, tree);
|
||||
|
||||
oldRoot = SplayTreeRoot(tree);
|
||||
AVERT(SplayNode, oldRoot);
|
||||
AVERT(Tree, oldRoot);
|
||||
|
||||
if (TreeRight(oldRoot) == TreeEMPTY) {
|
||||
newRoot = NULL; /* No successor */
|
||||
|
|
@ -659,9 +659,9 @@ static SplayNode SplayTreeSuccessor(SplayTree tree, void *key) {
|
|||
*/
|
||||
|
||||
|
||||
Res SplayTreeNeighbours(SplayNode *leftReturn, SplayNode *rightReturn,
|
||||
Res SplayTreeNeighbours(Tree *leftReturn, Tree *rightReturn,
|
||||
SplayTree tree, void *key) {
|
||||
SplayNode neighbour;
|
||||
Tree neighbour;
|
||||
|
||||
AVERT(SplayTree, tree);
|
||||
AVER(leftReturn != NULL);
|
||||
|
|
@ -707,8 +707,8 @@ Res SplayTreeNeighbours(SplayNode *leftReturn, SplayNode *rightReturn,
|
|||
* <design/splay/#function.splay.tree.next>.
|
||||
*/
|
||||
|
||||
SplayNode SplayTreeFirst(SplayTree tree, void *zeroKey) {
|
||||
SplayNode node;
|
||||
Tree SplayTreeFirst(SplayTree tree, void *zeroKey) {
|
||||
Tree node;
|
||||
AVERT(SplayTree, tree);
|
||||
|
||||
if (SplayTreeRoot(tree) == TreeEMPTY) {
|
||||
|
|
@ -722,12 +722,12 @@ SplayNode SplayTreeFirst(SplayTree tree, void *zeroKey) {
|
|||
return node;
|
||||
}
|
||||
|
||||
SplayNode SplayTreeNext(SplayTree tree, SplayNode oldNode, void *oldKey) {
|
||||
Tree SplayTreeNext(SplayTree tree, Tree oldNode, void *oldKey) {
|
||||
Bool b;
|
||||
SplayNode node;
|
||||
Tree node;
|
||||
|
||||
AVERT(SplayTree, tree);
|
||||
AVERT(SplayNode, oldNode);
|
||||
AVERT(Tree, oldNode);
|
||||
|
||||
/* Make old node the root. Probably already is. */
|
||||
b = SplaySplay(&node, tree, oldKey, tree->compare);
|
||||
|
|
@ -744,12 +744,12 @@ SplayNode SplayTreeNext(SplayTree tree, SplayNode oldNode, void *oldKey) {
|
|||
* This is alright as the function is debug only.
|
||||
*/
|
||||
|
||||
static Res SplayNodeDescribe(SplayNode node, mps_lib_FILE *stream,
|
||||
static Res SplayNodeDescribe(Tree node, mps_lib_FILE *stream,
|
||||
SplayNodeDescribeMethod nodeDescribe) {
|
||||
Res res;
|
||||
|
||||
#if defined(AVER_AND_CHECK)
|
||||
if (!SplayNodeCheck(node)) return ResFAIL;
|
||||
if (!TreeCheck(node)) return ResFAIL;
|
||||
/* stream and nodeDescribe checked by SplayTreeDescribe */
|
||||
#endif
|
||||
|
||||
|
|
@ -790,7 +790,7 @@ typedef struct {
|
|||
SplayTree tree;
|
||||
} SplayFindClosureStruct, *SplayFindClosure;
|
||||
|
||||
static Compare SplayFindFirstCompare(void *key, SplayNode node)
|
||||
static Compare SplayFindFirstCompare(void *key, Tree node)
|
||||
{
|
||||
SplayFindClosure closure;
|
||||
void *closureP;
|
||||
|
|
@ -799,7 +799,7 @@ static Compare SplayFindFirstCompare(void *key, SplayNode node)
|
|||
SplayTestTreeMethod testTree;
|
||||
SplayTree tree;
|
||||
|
||||
AVERT(SplayNode, node);
|
||||
AVERT(Tree, node);
|
||||
AVER(key != NULL);
|
||||
|
||||
closure = (SplayFindClosure)key;
|
||||
|
|
@ -821,7 +821,7 @@ static Compare SplayFindFirstCompare(void *key, SplayNode node)
|
|||
}
|
||||
}
|
||||
|
||||
static Compare SplayFindLastCompare(void *key, SplayNode node)
|
||||
static Compare SplayFindLastCompare(void *key, Tree node)
|
||||
{
|
||||
SplayFindClosure closure;
|
||||
void *closureP;
|
||||
|
|
@ -830,7 +830,7 @@ static Compare SplayFindLastCompare(void *key, SplayNode node)
|
|||
SplayTestTreeMethod testTree;
|
||||
SplayTree tree;
|
||||
|
||||
AVERT(SplayNode, node);
|
||||
AVERT(Tree, node);
|
||||
AVER(key != NULL);
|
||||
|
||||
closure = (SplayFindClosure)key;
|
||||
|
|
@ -865,12 +865,12 @@ static Compare SplayFindLastCompare(void *key, SplayNode node)
|
|||
* arbitrary closures closureP and closureS.
|
||||
*/
|
||||
|
||||
Bool SplayFindFirst(SplayNode *nodeReturn, SplayTree tree,
|
||||
Bool SplayFindFirst(Tree *nodeReturn, SplayTree tree,
|
||||
SplayTestNodeMethod testNode,
|
||||
SplayTestTreeMethod testTree,
|
||||
void *closureP, Size closureS)
|
||||
{
|
||||
SplayNode node;
|
||||
Tree node;
|
||||
SplayFindClosureStruct closureStruct;
|
||||
|
||||
AVER(nodeReturn != NULL);
|
||||
|
|
@ -901,12 +901,12 @@ Bool SplayFindFirst(SplayNode *nodeReturn, SplayTree tree,
|
|||
|
||||
/* SplayFindLast -- As SplayFindFirst but in reverse address order */
|
||||
|
||||
Bool SplayFindLast(SplayNode *nodeReturn, SplayTree tree,
|
||||
Bool SplayFindLast(Tree *nodeReturn, SplayTree tree,
|
||||
SplayTestNodeMethod testNode,
|
||||
SplayTestTreeMethod testTree,
|
||||
void *closureP, Size closureS)
|
||||
{
|
||||
SplayNode node;
|
||||
Tree node;
|
||||
SplayFindClosureStruct closureStruct;
|
||||
|
||||
AVER(nodeReturn != NULL);
|
||||
|
|
@ -937,9 +937,9 @@ Bool SplayFindLast(SplayNode *nodeReturn, SplayTree tree,
|
|||
|
||||
/* SplayRoot -- return the root node of the tree */
|
||||
|
||||
Bool SplayRoot(SplayNode *nodeReturn, SplayTree tree)
|
||||
Bool SplayRoot(Tree *nodeReturn, SplayTree tree)
|
||||
{
|
||||
SplayNode node;
|
||||
Tree node;
|
||||
|
||||
AVER(nodeReturn != NULL);
|
||||
AVERT(SplayTree, tree);
|
||||
|
|
@ -964,13 +964,13 @@ Bool SplayRoot(SplayNode *nodeReturn, SplayTree tree)
|
|||
* updating the single node. This may change.
|
||||
*/
|
||||
|
||||
void SplayNodeRefresh(SplayTree tree, SplayNode node, void *key)
|
||||
void SplayNodeRefresh(SplayTree tree, Tree node, void *key)
|
||||
{
|
||||
Bool b;
|
||||
SplayNode node2;
|
||||
Tree node2;
|
||||
|
||||
AVERT(SplayTree, tree);
|
||||
AVERT(SplayNode, node);
|
||||
AVERT(Tree, node);
|
||||
|
||||
b = SplaySplay(&node2, tree, key, tree->compare);
|
||||
AVER(b);
|
||||
|
|
|
|||
|
|
@ -15,18 +15,15 @@
|
|||
|
||||
typedef struct SplayTreeStruct *SplayTree;
|
||||
|
||||
typedef struct TreeStruct *SplayNode;
|
||||
#define SplayNodeCheck TreeCheck
|
||||
|
||||
typedef Compare (*SplayCompareMethod)(void *key, SplayNode node);
|
||||
typedef Bool (*SplayTestNodeMethod)(SplayTree tree, SplayNode node,
|
||||
typedef Compare (*SplayCompareMethod)(void *key, Tree node);
|
||||
typedef Bool (*SplayTestNodeMethod)(SplayTree tree, Tree node,
|
||||
void *closureP, Size closureS);
|
||||
typedef Bool (*SplayTestTreeMethod)(SplayTree tree, SplayNode node,
|
||||
typedef Bool (*SplayTestTreeMethod)(SplayTree tree, Tree node,
|
||||
void *closureP, Size closureS);
|
||||
typedef void (*SplayUpdateNodeMethod)(SplayTree tree, SplayNode node,
|
||||
SplayNode leftChild,
|
||||
SplayNode rightChild);
|
||||
typedef Res (*SplayNodeDescribeMethod)(SplayNode node, mps_lib_FILE *stream);
|
||||
typedef void (*SplayUpdateNodeMethod)(SplayTree tree, Tree node,
|
||||
Tree leftChild,
|
||||
Tree rightChild);
|
||||
typedef Res (*SplayNodeDescribeMethod)(Tree node, mps_lib_FILE *stream);
|
||||
|
||||
|
||||
typedef struct SplayTreeStruct {
|
||||
|
|
@ -39,38 +36,38 @@ typedef struct SplayTreeStruct {
|
|||
extern Bool SplayTreeCheck(SplayTree tree);
|
||||
extern void SplayTreeInit(SplayTree tree, SplayCompareMethod compare,
|
||||
SplayUpdateNodeMethod updateNode);
|
||||
extern void SplayNodeInit(SplayNode node);
|
||||
extern void SplayNodeFinish(SplayNode node);
|
||||
extern void SplayNodeInit(Tree node);
|
||||
extern void SplayNodeFinish(Tree node);
|
||||
extern void SplayTreeFinish(SplayTree tree);
|
||||
|
||||
extern Res SplayTreeInsert(SplayTree tree, SplayNode node, void *key);
|
||||
extern Res SplayTreeDelete(SplayTree tree, SplayNode node, void *key);
|
||||
extern Res SplayTreeInsert(SplayTree tree, Tree node, void *key);
|
||||
extern Res SplayTreeDelete(SplayTree tree, Tree node, void *key);
|
||||
|
||||
extern Res SplayTreeSearch(SplayNode *nodeReturn,
|
||||
extern Res SplayTreeSearch(Tree *nodeReturn,
|
||||
SplayTree tree, void *key );
|
||||
extern Res SplayTreeNeighbours(SplayNode *leftReturn,
|
||||
SplayNode *rightReturn,
|
||||
extern Res SplayTreeNeighbours(Tree *leftReturn,
|
||||
Tree *rightReturn,
|
||||
SplayTree tree, void *key);
|
||||
|
||||
extern SplayNode SplayTreeFirst(SplayTree tree, void *zeroKey);
|
||||
extern SplayNode SplayTreeNext(SplayTree tree, SplayNode oldNode,
|
||||
extern Tree SplayTreeFirst(SplayTree tree, void *zeroKey);
|
||||
extern Tree SplayTreeNext(SplayTree tree, Tree oldNode,
|
||||
void *oldKey);
|
||||
|
||||
extern Bool SplayFindFirst(SplayNode *nodeReturn, SplayTree tree,
|
||||
extern Bool SplayFindFirst(Tree *nodeReturn, SplayTree tree,
|
||||
SplayTestNodeMethod testNode,
|
||||
SplayTestTreeMethod testTree,
|
||||
void *closureP, Size closureS);
|
||||
extern Bool SplayFindLast(SplayNode *nodeReturn, SplayTree tree,
|
||||
extern Bool SplayFindLast(Tree *nodeReturn, SplayTree tree,
|
||||
SplayTestNodeMethod testNode,
|
||||
SplayTestTreeMethod testTree,
|
||||
void *closureP, Size closureS);
|
||||
|
||||
extern void SplayNodeRefresh(SplayTree tree, SplayNode node, void *key);
|
||||
extern void SplayNodeRefresh(SplayTree tree, Tree node, void *key);
|
||||
|
||||
extern Res SplayTreeDescribe(SplayTree tree, mps_lib_FILE *stream,
|
||||
SplayNodeDescribeMethod nodeDescribe);
|
||||
|
||||
extern Bool SplayRoot(SplayNode *nodeReturn, SplayTree tree);
|
||||
extern Bool SplayRoot(Tree *nodeReturn, SplayTree tree);
|
||||
|
||||
|
||||
#endif /* splay_h */
|
||||
|
|
|
|||
Loading…
Reference in a new issue