From 353ec00708cbb7d309e957212dd0b10861dff1e9 Mon Sep 17 00:00:00 2001 From: Jeff Hill Date: Mon, 3 May 1999 15:41:40 +0000 Subject: [PATCH] made compatible with visual C++ 6.0 --- src/cxxTemplates/tsBTree.h | 86 +++++++++++++++--------------- src/cxxTemplates/tsDLList.h | 26 +++++---- src/libCom/cxxTemplates/tsBTree.h | 86 +++++++++++++++--------------- src/libCom/cxxTemplates/tsDLList.h | 26 +++++---- 4 files changed, 118 insertions(+), 106 deletions(-) diff --git a/src/cxxTemplates/tsBTree.h b/src/cxxTemplates/tsBTree.h index 27bad465a..4c45841de 100644 --- a/src/cxxTemplates/tsBTree.h +++ b/src/cxxTemplates/tsBTree.h @@ -22,6 +22,8 @@ public: T * const pNewSeg; }; +template class tsBTree; + // // tsBTreeNode // @@ -53,16 +55,18 @@ private: T *pLeft; T *pRight; - static void traverse(T &self, void (T::*pCB)()) + // + // run callback for evey item in the B-Treee in sort order + // + static void traverse (T &item, void (T::*pCallBack)()) { - if (self.tsBTreeNode::pLeft) { - tsBTreeNode::traverse - (*self.tsBTreeNode::pLeft, pCB); + tsBTreeNode &node = item; + if (node.pLeft) { + tsBTreeNode::traverse (*node.pLeft, pCallBack); } - (self.*pCB)(); - if (self.tsBTreeNode::pRight) { - tsBTreeNode::traverse - (*self.tsBTreeNode::pRight, pCB); + (item.*pCallBack)(); + if (node.pRight) { + tsBTreeNode::traverse (*node.pRight, pCallBack); } } @@ -73,23 +77,22 @@ private: // static void insert(T &self, T &item) { + tsBTreeNode &node = self; btCmp result = item.tsBTreeCompare(self); if (result==btLessOrEqual) { - if (self.tsBTreeNode::pLeft) { - tsBTreeNode::insert - (*self.tsBTreeNode::pLeft, item); + if (node.pLeft) { + tsBTreeNode::insert (*node.pLeft, item); } else { - self.tsBTreeNode::pLeft = &item; + node.pLeft = &item; } } else if(result==btGreater) { - if (self.tsBTreeNode::pRight) { - tsBTreeNode::insert - (*self.tsBTreeNode::pRight, item); + if (node.pRight) { + tsBTreeNode::insert (*node.pRight, item); } else { - self.tsBTreeNode::pRight = &item; + node.pRight = &item; } } else { @@ -104,51 +107,50 @@ private: // static tsBTreeRMRet remove(T &self, T &item) { + tsBTreeNode &node = self; if (&self == &item) { - if (self.tsBTreeNode::pLeft) { - if (self.tsBTreeNode::pRight) { - T *pR = self.tsBTreeNode::pLeft->tsBTreeNode::pRight; + if (node.pLeft) { + if (node.pRight) { + tsBTreeNode *pLeftNode = node.pLeft; + tsBTreeNode *pRightNode = node.pRight; + T *pR = pLeftNode->pRight; if (pR) { - tsBTreeNode::insert - (*pR, *self.tsBTreeNode::pRight); + tsBTreeNode::insert (*pR, *node.pRight); } else { - self.tsBTreeNode::pLeft->tsBTreeNode::pRight = - self.tsBTreeNode::pRight; + pLeftNode->pRight = node.pRight; } } - return tsBTreeRMRet(tsbtrrFound, self.tsBTreeNode::pLeft); // found it + return tsBTreeRMRet(tsbtrrFound, node.pLeft); // found it } else { - return tsBTreeRMRet(tsbtrrFound, self.tsBTreeNode::pRight); // found it + return tsBTreeRMRet(tsbtrrFound, node.pRight); // found it } } btCmp result = item.tsBTreeCompare(self); if (result==btLessOrEqual) { - if (self.tsBTreeNode::pLeft) { - tsBTreeRMRet ret = tsBTreeNode:: - remove(*self.tsBTreeNode::pLeft, item); + if (node.pLeft) { + tsBTreeRMRet ret = tsBTreeNode::remove(*node.pLeft, item); if (ret.foundIt==tsbtrrFound) { - self.tsBTreeNode::pLeft= ret.pNewSeg; - return tsBTreeRMRet(tsbtrrFound,&self); // TRUE - found it + node.pLeft= ret.pNewSeg; + return tsBTreeRMRet (tsbtrrFound, &self); // TRUE - found it } } return tsBTreeRMRet(tsbtrrNotFound, 0u); // not found } else if(result==btGreater) { - if (self.tsBTreeNode::pRight) { - tsBTreeRMRet ret = tsBTreeNode:: - remove(*self.tsBTreeNode::pRight, item); + if (node.pRight) { + tsBTreeRMRet ret = tsBTreeNode::remove(*node.pRight, item); if (ret.foundIt==tsbtrrFound) { - self.tsBTreeNode::pRight = ret.pNewSeg; + node.pRight = ret.pNewSeg; return tsBTreeRMRet(tsbtrrFound,&self); // TRUE - found it } } return tsBTreeRMRet(tsbtrrNotFound, 0u); // not found } else { - assert(0); + return tsBTreeRMRet(tsbtrrNotFound, 0u); // not found } } // @@ -156,30 +158,30 @@ private: // static unsigned verify(const T &self, const T &item) { + const tsBTreeNode &node = self; + if (&self == &item) { return 1u; // TRUE -item is present } btCmp result = item.tsBTreeCompare(self); if (result==btLessOrEqual) { - if (self.tsBTreeNode::pLeft) { - return tsBTreeNode::verify - (*self.tsBTreeNode::pLeft, item); + if (node.pLeft) { + return tsBTreeNode::verify (*node.pLeft, item); } else { return 0u; // FALSE - not found } } else if(result==btGreater) { - if (self.tsBTreeNode::pRight) { - return tsBTreeNode::verify - (*self.tsBTreeNode::pRight, item); + if (node.pRight) { + return tsBTreeNode::verify (*node.pRight, item); } else { return 0u; // FALSE - not found } } else { - assert(0); + return 0u; // FALSE - not found } } }; diff --git a/src/cxxTemplates/tsDLList.h b/src/cxxTemplates/tsDLList.h index b6b3726d3..7e804c243 100644 --- a/src/cxxTemplates/tsDLList.h +++ b/src/cxxTemplates/tsDLList.h @@ -31,6 +31,9 @@ * * History * $Log$ + * Revision 1.15 1999/02/01 21:49:04 jhill + * removed redundant API + * * Revision 1.14 1998/10/23 00:20:41 jhill * attempted to clean up HP-UX warnings * @@ -244,7 +247,17 @@ public: tsDLIterBD (T *pInitialEntry) : pEntry(pInitialEntry) {} - tsDLIterBD (const class tsDLIterBD ©In); + // + // This is apparently required by some compiler, causes + // trouble with MS Visual C 6.0, but should not be + // required by any compiler. I am assuming that the + // other compiler is a past version of MS Visual C. + // +# if defined(_MSC_VER) && _MSC_VER < 1200 + template + tsDLIterBD (const class tsDLIterBD ©In) : + pEntry(copyIn.pEntry) {} +# endif tsDLIterBD & operator = (T *pNewEntry) { @@ -325,7 +338,7 @@ public: private: T *pEntry; }; - + // // tsDLIter // @@ -498,15 +511,6 @@ public: void remove (); }; -// -// MS Visual C 6.0 requires that this code is not provided in -// the class definition because the class isnt fully defined yet -// -template -inline tsDLIterBD::tsDLIterBD(const class tsDLIterBD ©In) : - pEntry(copyIn.pEntry) {} - - // // tsDLList::remove () // diff --git a/src/libCom/cxxTemplates/tsBTree.h b/src/libCom/cxxTemplates/tsBTree.h index 27bad465a..4c45841de 100644 --- a/src/libCom/cxxTemplates/tsBTree.h +++ b/src/libCom/cxxTemplates/tsBTree.h @@ -22,6 +22,8 @@ public: T * const pNewSeg; }; +template class tsBTree; + // // tsBTreeNode // @@ -53,16 +55,18 @@ private: T *pLeft; T *pRight; - static void traverse(T &self, void (T::*pCB)()) + // + // run callback for evey item in the B-Treee in sort order + // + static void traverse (T &item, void (T::*pCallBack)()) { - if (self.tsBTreeNode::pLeft) { - tsBTreeNode::traverse - (*self.tsBTreeNode::pLeft, pCB); + tsBTreeNode &node = item; + if (node.pLeft) { + tsBTreeNode::traverse (*node.pLeft, pCallBack); } - (self.*pCB)(); - if (self.tsBTreeNode::pRight) { - tsBTreeNode::traverse - (*self.tsBTreeNode::pRight, pCB); + (item.*pCallBack)(); + if (node.pRight) { + tsBTreeNode::traverse (*node.pRight, pCallBack); } } @@ -73,23 +77,22 @@ private: // static void insert(T &self, T &item) { + tsBTreeNode &node = self; btCmp result = item.tsBTreeCompare(self); if (result==btLessOrEqual) { - if (self.tsBTreeNode::pLeft) { - tsBTreeNode::insert - (*self.tsBTreeNode::pLeft, item); + if (node.pLeft) { + tsBTreeNode::insert (*node.pLeft, item); } else { - self.tsBTreeNode::pLeft = &item; + node.pLeft = &item; } } else if(result==btGreater) { - if (self.tsBTreeNode::pRight) { - tsBTreeNode::insert - (*self.tsBTreeNode::pRight, item); + if (node.pRight) { + tsBTreeNode::insert (*node.pRight, item); } else { - self.tsBTreeNode::pRight = &item; + node.pRight = &item; } } else { @@ -104,51 +107,50 @@ private: // static tsBTreeRMRet remove(T &self, T &item) { + tsBTreeNode &node = self; if (&self == &item) { - if (self.tsBTreeNode::pLeft) { - if (self.tsBTreeNode::pRight) { - T *pR = self.tsBTreeNode::pLeft->tsBTreeNode::pRight; + if (node.pLeft) { + if (node.pRight) { + tsBTreeNode *pLeftNode = node.pLeft; + tsBTreeNode *pRightNode = node.pRight; + T *pR = pLeftNode->pRight; if (pR) { - tsBTreeNode::insert - (*pR, *self.tsBTreeNode::pRight); + tsBTreeNode::insert (*pR, *node.pRight); } else { - self.tsBTreeNode::pLeft->tsBTreeNode::pRight = - self.tsBTreeNode::pRight; + pLeftNode->pRight = node.pRight; } } - return tsBTreeRMRet(tsbtrrFound, self.tsBTreeNode::pLeft); // found it + return tsBTreeRMRet(tsbtrrFound, node.pLeft); // found it } else { - return tsBTreeRMRet(tsbtrrFound, self.tsBTreeNode::pRight); // found it + return tsBTreeRMRet(tsbtrrFound, node.pRight); // found it } } btCmp result = item.tsBTreeCompare(self); if (result==btLessOrEqual) { - if (self.tsBTreeNode::pLeft) { - tsBTreeRMRet ret = tsBTreeNode:: - remove(*self.tsBTreeNode::pLeft, item); + if (node.pLeft) { + tsBTreeRMRet ret = tsBTreeNode::remove(*node.pLeft, item); if (ret.foundIt==tsbtrrFound) { - self.tsBTreeNode::pLeft= ret.pNewSeg; - return tsBTreeRMRet(tsbtrrFound,&self); // TRUE - found it + node.pLeft= ret.pNewSeg; + return tsBTreeRMRet (tsbtrrFound, &self); // TRUE - found it } } return tsBTreeRMRet(tsbtrrNotFound, 0u); // not found } else if(result==btGreater) { - if (self.tsBTreeNode::pRight) { - tsBTreeRMRet ret = tsBTreeNode:: - remove(*self.tsBTreeNode::pRight, item); + if (node.pRight) { + tsBTreeRMRet ret = tsBTreeNode::remove(*node.pRight, item); if (ret.foundIt==tsbtrrFound) { - self.tsBTreeNode::pRight = ret.pNewSeg; + node.pRight = ret.pNewSeg; return tsBTreeRMRet(tsbtrrFound,&self); // TRUE - found it } } return tsBTreeRMRet(tsbtrrNotFound, 0u); // not found } else { - assert(0); + return tsBTreeRMRet(tsbtrrNotFound, 0u); // not found } } // @@ -156,30 +158,30 @@ private: // static unsigned verify(const T &self, const T &item) { + const tsBTreeNode &node = self; + if (&self == &item) { return 1u; // TRUE -item is present } btCmp result = item.tsBTreeCompare(self); if (result==btLessOrEqual) { - if (self.tsBTreeNode::pLeft) { - return tsBTreeNode::verify - (*self.tsBTreeNode::pLeft, item); + if (node.pLeft) { + return tsBTreeNode::verify (*node.pLeft, item); } else { return 0u; // FALSE - not found } } else if(result==btGreater) { - if (self.tsBTreeNode::pRight) { - return tsBTreeNode::verify - (*self.tsBTreeNode::pRight, item); + if (node.pRight) { + return tsBTreeNode::verify (*node.pRight, item); } else { return 0u; // FALSE - not found } } else { - assert(0); + return 0u; // FALSE - not found } } }; diff --git a/src/libCom/cxxTemplates/tsDLList.h b/src/libCom/cxxTemplates/tsDLList.h index b6b3726d3..7e804c243 100644 --- a/src/libCom/cxxTemplates/tsDLList.h +++ b/src/libCom/cxxTemplates/tsDLList.h @@ -31,6 +31,9 @@ * * History * $Log$ + * Revision 1.15 1999/02/01 21:49:04 jhill + * removed redundant API + * * Revision 1.14 1998/10/23 00:20:41 jhill * attempted to clean up HP-UX warnings * @@ -244,7 +247,17 @@ public: tsDLIterBD (T *pInitialEntry) : pEntry(pInitialEntry) {} - tsDLIterBD (const class tsDLIterBD ©In); + // + // This is apparently required by some compiler, causes + // trouble with MS Visual C 6.0, but should not be + // required by any compiler. I am assuming that the + // other compiler is a past version of MS Visual C. + // +# if defined(_MSC_VER) && _MSC_VER < 1200 + template + tsDLIterBD (const class tsDLIterBD ©In) : + pEntry(copyIn.pEntry) {} +# endif tsDLIterBD & operator = (T *pNewEntry) { @@ -325,7 +338,7 @@ public: private: T *pEntry; }; - + // // tsDLIter // @@ -498,15 +511,6 @@ public: void remove (); }; -// -// MS Visual C 6.0 requires that this code is not provided in -// the class definition because the class isnt fully defined yet -// -template -inline tsDLIterBD::tsDLIterBD(const class tsDLIterBD ©In) : - pEntry(copyIn.pEntry) {} - - // // tsDLList::remove () //