From e9dbe33a14e61e4ae7e7f1d2d7bbaa4099a23c3e Mon Sep 17 00:00:00 2001 From: Jeff Hill Date: Fri, 20 Oct 2000 21:14:46 +0000 Subject: [PATCH] find should use the current version of the iterator --- src/libCom/cxxTemplates/tsDLList.h | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/libCom/cxxTemplates/tsDLList.h b/src/libCom/cxxTemplates/tsDLList.h index 48dbacdc7..54ef2b39e 100644 --- a/src/libCom/cxxTemplates/tsDLList.h +++ b/src/libCom/cxxTemplates/tsDLList.h @@ -75,9 +75,9 @@ private: // template class tsDLList { - friend class tsDLIter; - friend class tsDLFwdIter; - friend class tsDLBwdIter; + friend class tsDLIter; // deprecated + friend class tsDLFwdIter; // deprecated + friend class tsDLBwdIter; // deprecated public: tsDLList (); // create empty list @@ -108,7 +108,7 @@ public: // returns -1 if the item isnt on the list and the node // number (beginning with zero if it is) // - int find (T &item) const; + int find (const T &item) const; T *first (void) const; // ptr to first item on list T *last (void) const; // ptr to last item on list @@ -508,18 +508,19 @@ inline void tsDLList::push (T &item) // and the node number (beginning with zero if // it is) // -template -int tsDLList::find (T &item) const +template < class T > +int tsDLList < T > :: find ( const T &item ) const { - tsDLFwdIter iter (*this); - tsDLNode *pItem; - int itemNo=0; + tsDLIterConstBD < T > thisItem ( &item ); + tsDLIterConstBD < T > iter ( this->first () ); + int itemNo = 0; - while ( ( pItem = iter.next () ) ) { - if ( pItem == &item ) { + while ( iter.valid () ) { + if ( iter == thisItem ) { return itemNo; } itemNo++; + iter++; } return -1; }