From 2e8613794571ec11c1334b60addec84e7aa1faa3 Mon Sep 17 00:00:00 2001 From: Jeff Hill Date: Mon, 11 Sep 2000 15:24:18 +0000 Subject: [PATCH] deprecated old iterators --- src/libCom/cxxTemplates/tsDLList.h | 444 ++----------------- src/libCom/cxxTemplates/tsDLListDeprecated.h | 367 +++++++++++++++ 2 files changed, 403 insertions(+), 408 deletions(-) create mode 100644 src/libCom/cxxTemplates/tsDLListDeprecated.h diff --git a/src/libCom/cxxTemplates/tsDLList.h b/src/libCom/cxxTemplates/tsDLList.h index 11fcb7a4a..229c76348 100644 --- a/src/libCom/cxxTemplates/tsDLList.h +++ b/src/libCom/cxxTemplates/tsDLList.h @@ -34,11 +34,11 @@ #define tsDLListH_include template class tsDLList; -template class tsDLIter; -template class tsDLFwdIter; -template class tsDLBwdIter; template class tsDLIterConstBD; template class tsDLIterBD; +template class tsDLIter; // deprecated +template class tsDLFwdIter; // deprecated +template class tsDLBwdIter; // deprecated // // class tsDLNode @@ -53,11 +53,11 @@ template class tsDLIterBD; template class tsDLNode { friend class tsDLList; - friend class tsDLIter; - friend class tsDLFwdIter; - friend class tsDLBwdIter; - friend class tsDLIterConstBD; friend class tsDLIterBD; + friend class tsDLIterConstBD; + friend class tsDLIter; // deprecated + friend class tsDLFwdIter; // deprecated + friend class tsDLBwdIter; // deprecated public: tsDLNode(); void operator = (const tsDLNode &) const; @@ -159,7 +159,6 @@ public: const T & operator * () const; const T * operator -> () const; - //operator const T * () const; tsDLIterConstBD operator ++ (); // prefix ++ tsDLIterConstBD operator ++ (int); // postfix ++ @@ -204,33 +203,14 @@ public: T & operator * () const; T * operator -> () const; - //operator T* () const; - tsDLIterBD operator ++ () // prefix ++ - { - this->tsDLIterConstBD::operator ++ (); - return *this; - } + tsDLIterBD operator ++ (); // prefix ++ - tsDLIterBD operator ++ (int) // postfix ++ - { - tsDLIterBD tmp = *this; - this->tsDLIterConstBD::operator ++ (1); - return tmp; - } + tsDLIterBD operator ++ (int); // postfix ++ - tsDLIterBD operator -- () // prefix -- - { - this->tsDLIterConstBD::operator -- (); - return *this; - } + tsDLIterBD operator -- (); // prefix -- - tsDLIterBD operator -- (int) // postfix -- - { - tsDLIterBD tmp = *this; - this->tsDLIterConstBD::operator -- (1); - return tmp; - } + tsDLIterBD operator -- (int); // postfix -- # if defined(_MSC_VER) && _MSC_VER < 1200 tsDLIterBD (const class tsDLIterBD ©In); @@ -244,121 +224,6 @@ public: static const tsDLIterBD eol (); }; -// -// tsDLIter -// -// doubly linked list iterator -// -// Notes: -// 1) -// This iterator does not allow for removal -// of an item in order to avoid problems -// resulting when we remove an item (and -// then dont know whether to make pCurrent -// point at the item before or after the -// item removed -// -template -class tsDLIter { -public: - tsDLIter (tsDLList & listIn); - void reset (); - void reset (tsDLList &listIn); - void operator = (tsDLList &listIn); - T * next (); - T * prev (); - T * first(); - T * last(); - T * operator () (); - -protected: - T *pCurrent; - tsDLList *pList; - - T * current (); // certain compilers require this -}; - -// -// class tsDLFwdIter -// -// Notes: -// 1) No direct access to pCurrent is provided since -// this might allow for confusion when an item -// is removed (and pCurrent ends up pointing at -// an item that has been seen before) -// -// 2) This iterator only moves forward in order to -// avoid problems resulting when we remove an -// item (and then dont know whether to make -// pCurrent point at the item before or after -// the item removed -// -template -class tsDLFwdIter: private tsDLIter { -public: - tsDLFwdIter (tsDLList &listIn); - void reset (); - void reset (tsDLList &listIn); - void operator = (tsDLList &listIn); - T * operator () (); - T * next (); - T * first(); - - // - // remove () - // (and move current to be the item - // pointed to by pPrev - the item seen - // by the iterator before the current one - - // this guarantee that the list will be - // accessed sequentially even if an item - // is removed) - // - void remove (); -protected: - T *current (); -}; - -// -// tsDLBwdIter -// -// Notes: -// 1) No direct access to pCurrent is provided since -// this might allow for confusion when an item -// is removed (and pCurrent ends up pointing at -// an item that has been seen before) -// -// 2) This iterator only moves backward in order to -// avoid problems resulting when we remove an -// item (and then dont know whether to make -// pCurrent point at the item before or after -// the item removed -// -template -class tsDLBwdIter : private tsDLIter { -public: - tsDLBwdIter (tsDLList &listIn); - void reset (); - void reset (tsDLList &listIn); - void operator = (tsDLList &listIn); - T * operator () () { return this->tsDLIter::prev(); } - T * prev (); - T * last(); - // - // remove () - // remove current item - // (and move current to be the item - // pointed to by pNext - the item seen - // by the iterator before the current one - - // this guarantee that the list will be - // accessed sequentially even if an item - // is removed) - // - void remove (); -protected: - T * current (); -}; - - /////////////////////////////////// // tsDLNode member functions /////////////////////////////////// @@ -447,7 +312,7 @@ inline void tsDLList::clear () // tsDLList::remove () // template -void tsDLList::remove (T &item) +inline void tsDLList::remove (T &item) { tsDLNode &theNode = item; @@ -502,16 +367,16 @@ inline T * tsDLList::pop() // (and removes all items from addList) // template -void tsDLList::add (tsDLList &addList) +inline void tsDLList::add (tsDLList &addList) { // // NOOP if addList is empty // - if (addList.itemCount==0u) { + if ( addList.itemCount == 0u ) { return; } - if (this->itemCount==0u) { + if ( this->itemCount == 0u ) { // // this is empty so just init from // addList @@ -543,7 +408,7 @@ void tsDLList::add (tsDLList &addList) // add an item to the end of the list // template -void tsDLList::add (T &item) +inline void tsDLList::add (T &item) { tsDLNode &theNode = item; @@ -569,7 +434,7 @@ void tsDLList::add (T &item) // place item in the list immediately after itemBefore // template -void tsDLList::insertAfter (T &item, T &itemBefore) +inline void tsDLList::insertAfter (T &item, T &itemBefore) { tsDLNode &nodeItem = item; tsDLNode &nodeBefore = itemBefore; @@ -595,7 +460,7 @@ void tsDLList::insertAfter (T &item, T &itemBefore) // place item in the list immediately before itemAfter // template -void tsDLList::insertBefore (T &item, T &itemAfter) +inline void tsDLList::insertBefore (T &item, T &itemAfter) { tsDLNode &node = item; tsDLNode &nodeAfter = itemAfter; @@ -621,7 +486,7 @@ void tsDLList::insertBefore (T &item, T &itemAfter) // add an item at the beginning of the list // template -void tsDLList::push (T &item) +inline void tsDLList::push (T &item) { tsDLNode &theNode = item; theNode.pPrev = 0; @@ -678,7 +543,7 @@ inline tsDLIterConstBD::tsDLIterConstBD (const T * pInitialEntry) : // # if defined(_MSC_VER) && _MSC_VER < 1200 template - tsDLIterConstBD::tsDLIterConstBD (const class tsDLIterBD ©In) : + inline tsDLIterConstBD::tsDLIterConstBD (const class tsDLIterBD ©In) : pConstEntry (copyIn.pEntry) {} # endif @@ -713,13 +578,6 @@ inline const T * tsDLIterConstBD::operator -> () const return this->pConstEntry; } -//template -//inline tsDLIterConstBD::operator const T * () const -//{ - //return this->pConstEntry; - //return 0; -//} - template inline tsDLIterConstBD tsDLIterConstBD::itemAfter () { @@ -812,7 +670,7 @@ inline tsDLIterBD::tsDLIterBD (T * pInitialEntry) : // # if defined(_MSC_VER) && _MSC_VER < 1200 template - tsDLIterBD::tsDLIterBD (const class tsDLIterBD ©In) : + inline tsDLIterBD::tsDLIterBD (const class tsDLIterBD ©In) : tsDLIterConstBD (copyIn) {} # endif @@ -847,12 +705,6 @@ inline T * tsDLIterBD::operator -> () const return this->pEntry; } -//template -//inline tsDLIterBD::operator T * () const -//{ -// return this->pEntry; -//} - template inline tsDLIterBD tsDLIterBD::itemAfter () { @@ -873,267 +725,43 @@ inline bool tsDLIterBD::valid () const return this->pEntry ? true : false; } -// -// tsDLIterBD::eol -// template inline const tsDLIterBD tsDLIterBD::eol () { return tsDLIterBD(0); } -////////////////////////////////////////// -// tsDLIter member functions -////////////////////////////////////////// - -template -inline tsDLIter::tsDLIter (tsDLList & listIn) : - pCurrent(0), pList(&listIn) {} - -template -inline void tsDLIter::reset () -{ - this->pCurrent = 0; -} - -template -inline void tsDLIter::reset (tsDLList &listIn) -{ - this->reset(); - this->pList = &listIn; -} - -template -inline void tsDLIter::operator = (tsDLList &listIn) -{ - this->reset(listIn); -} - -template -inline T * tsDLIter::first() -{ - this->pCurrent = this->pList->pFirst; - return this->pCurrent; -} - -template -inline T * tsDLIter::last() -{ - this->pCurrent = this->pList->pLast; - return this->pCurrent; -} - -// -// tsDLIter::next () -// -template -inline T * tsDLIter::next () -{ - T *pCur = this->pCurrent; - if (pCur==0) { - pCur = this->pList->pFirst; - } - else { - tsDLNode *pCurNode = pCur; - pCur = pCurNode->pNext; - } - this->pCurrent = pCur; - return pCur; -} - -// -// tsDLIter::prev () -// template -inline T * tsDLIter::prev () +inline tsDLIterBD tsDLIterBD::operator ++ () // prefix ++ { - T *pCur = this->pCurrent; - if (pCur==0) { - pCur = this->pList->pLast; - } - else { - tsDLNode *pCurNode = pCur; - pCur = pCurNode->pPrev; - } - this->pCurrent = pCur; - return pCur; -} - -// -// tsDLIter::operator () () -// -template -inline T * tsDLIter::operator () () -{ - return this->next(); -} - -// -// tsDLIter::current() -// -template -inline T * tsDLIter::current() -{ - return this->pCurrent; -} - -/////////////////////////////////////////// -// tsDLBwdIter member functions -/////////////////////////////////////////// - -template -inline tsDLBwdIter::tsDLBwdIter(tsDLList &listIn) : - tsDLIter(listIn) {} - -template -inline void tsDLBwdIter::reset () -{ - this->tsDLIter::reset(); + this->tsDLIterConstBD::operator ++ (); + return *this; } template -inline void tsDLBwdIter::reset (tsDLList &listIn) +inline tsDLIterBD tsDLIterBD::operator ++ (int) // postfix ++ { - this->tsDLIter::reset(listIn); + tsDLIterBD tmp = *this; + this->tsDLIterConstBD::operator ++ (1); + return tmp; } template -inline void tsDLBwdIter::operator = (tsDLList &listIn) +inline tsDLIterBD tsDLIterBD::operator -- () // prefix -- { - this->tsDLIter::reset(listIn); + this->tsDLIterConstBD::operator -- (); + return *this; } template -inline T * tsDLBwdIter::last() +inline tsDLIterBD tsDLIterBD::operator -- (int) // postfix -- { - return this->tsDLIter::last(); + tsDLIterBD tmp = *this; + this->tsDLIterConstBD::operator -- (1); + return tmp; } -// -// tsDLBwdIter::remove () -// -// remove current item -// (and move current to be the item -// pointed to by pNext - the item seen -// by the iterator before the current one - -// this guarantee that the list will be -// accessed sequentially even if an item -// is removed) -// -template -void tsDLBwdIter::remove () -{ - T *pCur = this->pCurrent; - - if (pCur) { - tsDLNode *pCurNode = pCur; - - // - // strip const (we didnt declare the - // list const in the constructor) - // - tsDLList * pMutableList = - (tsDLList *) this->pList; - - // - // Move this->pCurrent to the item after the - // item being deleted - // - this->pCurrent = pCurNode->pNext; - - // - // delete current item - // - pMutableList->remove(*pCur); - } -} - -////////////////////////////////////////// -// tsDLFwdIter member functions -////////////////////////////////////////// - -template -inline tsDLFwdIter::tsDLFwdIter (tsDLList &listIn) : - tsDLIter(listIn) {} - -template -inline void tsDLFwdIter::reset () -{ - this->tsDLIter::reset(); -} - -template -inline void tsDLFwdIter::reset (tsDLList &listIn) -{ - this->tsDLIter::reset(listIn); -} - -template -inline void tsDLFwdIter::operator = (tsDLList &listIn) -{ - this->tsDLIter::reset(listIn); -} - -template -inline T * tsDLFwdIter::first() -{ - tsDLIter &iterBase = *this; - return iterBase.first(); -} - -template -inline T * tsDLFwdIter::current() -{ - return this->tsDLIter::current (); -} - -// -// tsDLFwdIter::remove () -// (and move current to be the item -// pointed to by pPrev - the item seen -// by the iterator before the current one - -// this guarantee that the list will be -// accessed sequentially even if an item -// is removed) -// -template -void tsDLFwdIter::remove () -{ - T *pCur = this->pCurrent; - - if (pCur) { - tsDLNode *pCurNode = pCur; - - // - // Move this->pCurrent to the previous item - // - this->pCurrent = pCurNode->pPrev; - - // - // delete current item - // - this->pList->remove(*pCur); - } -} - -// -// tsDLFwdIter::next () -// -template -inline T * tsDLFwdIter::next () -{ - tsDLIter &iterBase = *this; - return iterBase.next(); -} - -// -// tsDLFwdIter::operator () () -// -template -inline T * tsDLFwdIter::operator () () -{ - return this->next(); -} +#include #endif // tsDLListH_include diff --git a/src/libCom/cxxTemplates/tsDLListDeprecated.h b/src/libCom/cxxTemplates/tsDLListDeprecated.h new file mode 100644 index 000000000..fa69bf54c --- /dev/null +++ b/src/libCom/cxxTemplates/tsDLListDeprecated.h @@ -0,0 +1,367 @@ + +// +// tsDLIter +// +// doubly linked list iterator +// +// Notes: +// 1) +// This iterator does not allow for removal +// of an item in order to avoid problems +// resulting when we remove an item (and +// then dont know whether to make pCurrent +// point at the item before or after the +// item removed +// +template +class tsDLIter { +public: + tsDLIter (tsDLList & listIn); + void reset (); + void reset (tsDLList &listIn); + void operator = (tsDLList &listIn); + T * next (); + T * prev (); + T * first(); + T * last(); + T * operator () (); + +protected: + T *pCurrent; + tsDLList *pList; + + T * current (); // certain compilers require this +}; + +// +// class tsDLFwdIter +// +// Notes: +// 1) No direct access to pCurrent is provided since +// this might allow for confusion when an item +// is removed (and pCurrent ends up pointing at +// an item that has been seen before) +// +// 2) This iterator only moves forward in order to +// avoid problems resulting when we remove an +// item (and then dont know whether to make +// pCurrent point at the item before or after +// the item removed +// +template +class tsDLFwdIter: private tsDLIter { +public: + tsDLFwdIter (tsDLList &listIn); + void reset (); + void reset (tsDLList &listIn); + void operator = (tsDLList &listIn); + T * operator () (); + T * next (); + T * first(); + + // + // remove () + // (and move current to be the item + // pointed to by pPrev - the item seen + // by the iterator before the current one - + // this guarantee that the list will be + // accessed sequentially even if an item + // is removed) + // + void remove (); +protected: + T *current (); +}; + +// +// tsDLBwdIter +// +// Notes: +// 1) No direct access to pCurrent is provided since +// this might allow for confusion when an item +// is removed (and pCurrent ends up pointing at +// an item that has been seen before) +// +// 2) This iterator only moves backward in order to +// avoid problems resulting when we remove an +// item (and then dont know whether to make +// pCurrent point at the item before or after +// the item removed +// +template +class tsDLBwdIter : private tsDLIter { +public: + tsDLBwdIter (tsDLList &listIn); + void reset (); + void reset (tsDLList &listIn); + void operator = (tsDLList &listIn); + T * operator () () { return this->tsDLIter::prev(); } + T * prev (); + T * last(); + // + // remove () + // remove current item + // (and move current to be the item + // pointed to by pNext - the item seen + // by the iterator before the current one - + // this guarantee that the list will be + // accessed sequentially even if an item + // is removed) + // + void remove (); +protected: + T * current (); +}; + +// +// tsDLFwdIter::remove () +// (and move current to be the item +// pointed to by pPrev - the item seen +// by the iterator before the current one - +// this guarantee that the list will be +// accessed sequentially even if an item +// is removed) +// +template +void tsDLFwdIter::remove () +{ + T *pCur = this->pCurrent; + + if (pCur) { + tsDLNode *pCurNode = pCur; + + // + // Move this->pCurrent to the previous item + // + this->pCurrent = pCurNode->pPrev; + + // + // delete current item + // + this->pList->remove(*pCur); + } +} + +// +// tsDLFwdIter::next () +// +template +inline T * tsDLFwdIter::next () +{ + tsDLIter &iterBase = *this; + return iterBase.next(); +} + +// +// tsDLFwdIter::operator () () +// +template +inline T * tsDLFwdIter::operator () () +{ + return this->next(); +} + +////////////////////////////////////////// +// tsDLIter member functions +////////////////////////////////////////// + +template +inline tsDLIter::tsDLIter (tsDLList & listIn) : + pCurrent(0), pList(&listIn) {} + +template +inline void tsDLIter::reset () +{ + this->pCurrent = 0; +} + +template +inline void tsDLIter::reset (tsDLList &listIn) +{ + this->reset(); + this->pList = &listIn; +} + +template +inline void tsDLIter::operator = (tsDLList &listIn) +{ + this->reset(listIn); +} + +template +inline T * tsDLIter::first() +{ + this->pCurrent = this->pList->pFirst; + return this->pCurrent; +} + +template +inline T * tsDLIter::last() +{ + this->pCurrent = this->pList->pLast; + return this->pCurrent; +} + +// +// tsDLIter::next () +// +template +inline T * tsDLIter::next () +{ + T *pCur = this->pCurrent; + if (pCur==0) { + pCur = this->pList->pFirst; + } + else { + tsDLNode *pCurNode = pCur; + pCur = pCurNode->pNext; + } + this->pCurrent = pCur; + return pCur; +} + +// +// tsDLIter::prev () +// +template +inline T * tsDLIter::prev () +{ + T *pCur = this->pCurrent; + if (pCur==0) { + pCur = this->pList->pLast; + } + else { + tsDLNode *pCurNode = pCur; + pCur = pCurNode->pPrev; + } + this->pCurrent = pCur; + return pCur; +} + +// +// tsDLIter::operator () () +// +template +inline T * tsDLIter::operator () () +{ + return this->next(); +} + +// +// tsDLIter::current() +// +template +inline T * tsDLIter::current() +{ + return this->pCurrent; +} + +/////////////////////////////////////////// +// tsDLBwdIter member functions +/////////////////////////////////////////// + +template +inline tsDLBwdIter::tsDLBwdIter(tsDLList &listIn) : + tsDLIter(listIn) {} + +template +inline void tsDLBwdIter::reset () +{ + this->tsDLIter::reset(); +} + +template +inline void tsDLBwdIter::reset (tsDLList &listIn) +{ + this->tsDLIter::reset(listIn); +} + +template +inline void tsDLBwdIter::operator = (tsDLList &listIn) +{ + this->tsDLIter::reset(listIn); +} + +template +inline T * tsDLBwdIter::last() +{ + return this->tsDLIter::last(); +} + +// +// tsDLBwdIter::remove () +// +// remove current item +// (and move current to be the item +// pointed to by pNext - the item seen +// by the iterator before the current one - +// this guarantee that the list will be +// accessed sequentially even if an item +// is removed) +// +template +void tsDLBwdIter::remove () +{ + T *pCur = this->pCurrent; + + if (pCur) { + tsDLNode *pCurNode = pCur; + + // + // strip const (we didnt declare the + // list const in the constructor) + // + tsDLList * pMutableList = + (tsDLList *) this->pList; + + // + // Move this->pCurrent to the item after the + // item being deleted + // + this->pCurrent = pCurNode->pNext; + + // + // delete current item + // + pMutableList->remove(*pCur); + } +} + +////////////////////////////////////////// +// tsDLFwdIter member functions +////////////////////////////////////////// + +template +inline tsDLFwdIter::tsDLFwdIter (tsDLList &listIn) : + tsDLIter(listIn) {} + +template +inline void tsDLFwdIter::reset () +{ + this->tsDLIter::reset(); +} + +template +inline void tsDLFwdIter::reset (tsDLList &listIn) +{ + this->tsDLIter::reset(listIn); +} + +template +inline void tsDLFwdIter::operator = (tsDLList &listIn) +{ + this->tsDLIter::reset(listIn); +} + +template +inline T * tsDLFwdIter::first() +{ + tsDLIter &iterBase = *this; + return iterBase.first(); +} + +template +inline T * tsDLFwdIter::current() +{ + return this->tsDLIter::current (); +}