freKeyedCollectionBase.txx

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   F.R.E.E. - flexible registration evaluation engine
00004   Version:   v.1.0.0
00005   Date:      $Date: 2006/09/01 12:00:00 $
00006   Module:    $RCSfile: freKeyedCollection.txx,v $
00007   Language:  C++
00008 
00009 
00010 
00011   Copyright (c) 2007 Ralf o Floca (Department of Medical Informatics,
00012   Institute for Medical Biometry and Informatics, University of Heidelberg,
00013   Germany). All rights reserved.
00014   See FREECopyright.txt or http://www.mi.med.uni-hd.de/free/copyright.htm
00015   for details.
00016 
00017      This software is distributed WITHOUT ANY WARRANTY; without even 
00018      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00019      PURPOSE.  See the above copyright notices for more information.
00020 
00021 =========================================================================*/
00022 
00023 #ifndef __freKeyedCollectionBase_txx
00024 #define __freKeyedCollectionBase_txx
00025 
00026 #include "freKeyedCollectionBase.h"
00027 
00028 namespace FREE
00029 {
00030 
00031   template <class TKey, class TElement, class TIdentifierClass>
00032                 KeyedCollectionBase< TKey, TElement, TIdentifierClass >& 
00033                 KeyedCollectionBase< TKey, TElement, TIdentifierClass >::
00034                 operator = (const KeyedCollectionBase& rCollection)
00035         {
00036                 if ( this == &rCollection) return *this;
00037 
00038             this->Reset();
00039         this->AddElements(rCollection);
00040 
00041                 return *this;
00042         };
00043 
00044   template <class TKey, class TElement, class TIdentifierClass>
00045         typename KeyedCollectionBase< TKey, TElement, TIdentifierClass >::ElementType*  
00046                 KeyedCollectionBase< TKey, TElement, TIdentifierClass >::
00047 		GetElement(const KeyType& rKey) const
00048         {
00049         ElementsCountType index = GetElementIndex(rKey); 
00050                 if (index!= Superclass::NULL_Index)
00051                 {
00052                         return (this->m_Elements[index]).GetPointer();
00053                 };
00054                 return NULL;
00055         };
00056 
00057   template <class TKey, class TElement, class TIdentifierClass>
00058         typename KeyedCollectionBase< TKey, TElement, TIdentifierClass >::ElementsCountType  
00059                 KeyedCollectionBase< TKey, TElement, TIdentifierClass >::
00060     GetElementIndex(const KeyType& rKey) const
00061   {
00062     ElementsCountType index = 0; 
00063     for (typename ElementVectorType::const_iterator pos = this->m_Elements.begin(); pos!= this->m_Elements.end(); pos++)
00064     {
00065       if (IdentifierType::KeyMatches(rKey,*(*pos))) return index;
00066       index++;
00067     };
00068     return Superclass::NULL_Index;
00069   };
00070 
00071 
00072 }//end of namespace FREE
00073 
00074 #endif

Generated at Sat Oct 13 16:25:07 2007 for f.r.e.e. - Flexible Registration and Evaluation Engine by doxygen 1.5.3 written by Dimitri van Heesch, © 1997-2000