From 6f8e2cd67527b8cb251fd27eb254ce325a03e7a5 Mon Sep 17 00:00:00 2001 From: Jeff Hill Date: Fri, 18 Dec 1998 19:02:47 +0000 Subject: [PATCH] Changed the remove() function in tsSLList class because users were confused by it. The name is now removeNextItem() and it is now a private member of class tsSLNode. --- src/cxxTemplates/test/tsSLListTest.cc | 6 ++-- src/cxxTemplates/tsSLList.h | 34 +++++++++++--------- src/libCom/cxxTemplates/test/tsSLListTest.cc | 6 ++-- src/libCom/cxxTemplates/tsSLList.h | 34 +++++++++++--------- 4 files changed, 44 insertions(+), 36 deletions(-) diff --git a/src/cxxTemplates/test/tsSLListTest.cc b/src/cxxTemplates/test/tsSLListTest.cc index 80186681c..96821bb72 100644 --- a/src/cxxTemplates/test/tsSLListTest.cc +++ b/src/cxxTemplates/test/tsSLListTest.cc @@ -34,11 +34,13 @@ int main () list.add(*pFred); list.add(*pFredII); { - tsSLIter iter(list); + tsSLIterRm iter(list); pFredBack = iter(); assert(pFredBack == pFredII); + pFredBack = iter(); + assert(pFredBack == pFred); + iter.remove(); // removes pFred } - list.remove(*pFredII); // removes *pFred !! list.add(*pFred); pFredBack = list.get(); assert (pFredBack == pFred); diff --git a/src/cxxTemplates/tsSLList.h b/src/cxxTemplates/tsSLList.h index 6d38afeca..5f3db88e3 100644 --- a/src/cxxTemplates/tsSLList.h +++ b/src/cxxTemplates/tsSLList.h @@ -31,6 +31,9 @@ * * History * $Log$ + * Revision 1.14 1998/10/23 16:40:47 jhill + * fixed missing new line at EOF + * * Revision 1.13 1998/10/23 00:20:41 jhill * attempted to clean up HP-UX warnings * @@ -105,6 +108,20 @@ public: private: T *pNext; + + // + // removeNextItem () + // + // removes the item after this node + // + void removeNextItem () + { + T *pItem = this->pNext; + if (pItem) { + tsSLNode *pNode = pItem; + this->pNext = pNode->pNext; + } + } }; @@ -136,21 +153,6 @@ public: this->insert (item, *this); } - // - // remove () - // **** removes item after "itemBefore" **** - // (itemBefore might be the list header object and therefore - // will not always be of type T) - // - void remove (tsSLNode &itemBefore) - { - T *pItem = itemBefore.pNext; - if (pItem) { - tsSLNode *pNode = pItem; - itemBefore.pNext = pNode->pNext; - } - } - // // get () // @@ -158,7 +160,7 @@ public: { tsSLNode *pThisNode = this; T *pItem = pThisNode->pNext; - this->remove(*this); + pThisNode->removeNextItem(); return pItem; } diff --git a/src/libCom/cxxTemplates/test/tsSLListTest.cc b/src/libCom/cxxTemplates/test/tsSLListTest.cc index 80186681c..96821bb72 100644 --- a/src/libCom/cxxTemplates/test/tsSLListTest.cc +++ b/src/libCom/cxxTemplates/test/tsSLListTest.cc @@ -34,11 +34,13 @@ int main () list.add(*pFred); list.add(*pFredII); { - tsSLIter iter(list); + tsSLIterRm iter(list); pFredBack = iter(); assert(pFredBack == pFredII); + pFredBack = iter(); + assert(pFredBack == pFred); + iter.remove(); // removes pFred } - list.remove(*pFredII); // removes *pFred !! list.add(*pFred); pFredBack = list.get(); assert (pFredBack == pFred); diff --git a/src/libCom/cxxTemplates/tsSLList.h b/src/libCom/cxxTemplates/tsSLList.h index 6d38afeca..5f3db88e3 100644 --- a/src/libCom/cxxTemplates/tsSLList.h +++ b/src/libCom/cxxTemplates/tsSLList.h @@ -31,6 +31,9 @@ * * History * $Log$ + * Revision 1.14 1998/10/23 16:40:47 jhill + * fixed missing new line at EOF + * * Revision 1.13 1998/10/23 00:20:41 jhill * attempted to clean up HP-UX warnings * @@ -105,6 +108,20 @@ public: private: T *pNext; + + // + // removeNextItem () + // + // removes the item after this node + // + void removeNextItem () + { + T *pItem = this->pNext; + if (pItem) { + tsSLNode *pNode = pItem; + this->pNext = pNode->pNext; + } + } }; @@ -136,21 +153,6 @@ public: this->insert (item, *this); } - // - // remove () - // **** removes item after "itemBefore" **** - // (itemBefore might be the list header object and therefore - // will not always be of type T) - // - void remove (tsSLNode &itemBefore) - { - T *pItem = itemBefore.pNext; - if (pItem) { - tsSLNode *pNode = pItem; - itemBefore.pNext = pNode->pNext; - } - } - // // get () // @@ -158,7 +160,7 @@ public: { tsSLNode *pThisNode = this; T *pItem = pThisNode->pNext; - this->remove(*this); + pThisNode->removeNextItem(); return pItem; }