From: robertc <> Date: Mon, 9 Jun 2003 09:39:08 +0000 (+0000) Subject: Summary: Cleanup splay template methods. X-Git-Tag: SQUID_3_0_PRE1~143 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=626e1f9767f98ebe16c0f6fec1fe292aa7f88601;p=thirdparty%2Fsquid.git Summary: Cleanup splay template methods. Keywords: include/splay.h used the same name in parameters as the nodes do - which potentially could lead to confusion on the programmers part. --- diff --git a/include/splay.h b/include/splay.h index f606e8121e..72c716585b 100644 --- a/include/splay.h +++ b/include/splay.h @@ -1,5 +1,5 @@ /* - * $Id: splay.h,v 1.18 2003/03/06 11:51:55 robertc Exp $ + * $Id: splay.h,v 1.19 2003/06/09 03:39:08 robertc Exp $ */ #ifndef SQUID_SPLAY_H @@ -98,17 +98,17 @@ SplayNode::destroy(SPLAYFREE * free_func) template SplayNode * -SplayNode::remove(Value const data, SPLAYCMP * compare) +SplayNode::remove(Value const dataToRemove, SPLAYCMP * compare) { if (this == NULL) return NULL; - SplayNode *result = splay(data, compare); + SplayNode *result = splay(dataToRemove, compare); if (splayLastResult == 0) { /* found it */ SplayNode *newTop; if (result->left == NULL) { newTop = result->right; } else { - newTop = result->left->splay(data, compare); + newTop = result->left->splay(dataToRemove, compare); /* temporary */ newTop->right = result->right; result->right = NULL; @@ -121,18 +121,18 @@ SplayNode::remove(Value const data, SPLAYCMP * compare) template SplayNode * -SplayNode::insert(Value data, SPLAYCMP * compare) +SplayNode::insert(Value dataToInsert, SPLAYCMP * compare) { /* create node to insert */ SplayNode *newNode = new SplayNode; - newNode->data = data; + newNode->data = dataToInsert; if (this == NULL) { splayLastResult = -1; newNode->left = newNode->right = NULL; return newNode; } - SplayNode *newTop = splay(data, compare); + SplayNode *newTop = splay(dataToInsert, compare); if (splayLastResult < 0) { newNode->left = newTop->left; newNode->right = newTop; @@ -152,7 +152,7 @@ SplayNode::insert(Value data, SPLAYCMP * compare) template SplayNode * -SplayNode::splay(Value const &data, SPLAYCMP * compare) const +SplayNode::splay(Value const &dataToFind, SPLAYCMP * compare) const { if (this == NULL) { /* can't have compared successfully :} */ @@ -168,11 +168,11 @@ SplayNode::splay(Value const &data, SPLAYCMP * compare) const SplayNode *top = const_cast *>(this); for (;;) { - splayLastResult = compare(data, top->data); + splayLastResult = compare(dataToFind, top->data); if (splayLastResult < 0) { if (top->left == NULL) break; - if ((splayLastResult = compare(data, top->left->data)) < 0) { + if ((splayLastResult = compare(dataToFind, top->left->data)) < 0) { y = top->left; /* rotate right */ top->left = y->right; y->right = top; @@ -186,7 +186,7 @@ SplayNode::splay(Value const &data, SPLAYCMP * compare) const } else if (splayLastResult > 0) { if (top->right == NULL) break; - if ((splayLastResult = compare(data, top->right->data)) > 0) { + if ((splayLastResult = compare(dataToFind, top->right->data)) > 0) { y = top->right; /* rotate left */ top->right = y->left; y->left = top;