00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
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 }
00073
00074 #endif