Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef ValueTypeListHPP
00033 #define ValueTypeListHPP
00034
00035 #include <zeusbase/System/SingleLinkedList.hpp>
00036
00037 BEGIN_NAMESPACE_Zeus
00038
00039
00044
00045 template <class T, class I> class TValueTypeList : public IList<I>
00046 {
00047 public:
00048
00050 inline virtual ~TValueTypeList() { }
00051
00052
00053 inline virtual Int MQUALIFIER add(const I& rItem) { return m_lstData.add(T(rItem)); }
00054 virtual Int MQUALIFIER addAll(const IList<I>& rlstItems);
00055 inline virtual Int MQUALIFIER addEmptyItem() { return m_lstData.addEmptyItem(); }
00056 virtual void MQUALIFIER copyToList(IList<I>& rList) const;
00057 inline virtual void MQUALIFIER clear() { m_lstData.clear(); }
00058 inline virtual Retval MQUALIFIER deleteItem(Int iIndex) { return m_lstData.deleteItem(iIndex); }
00059 inline virtual Retval MQUALIFIER remove(const I& rItem) { return m_lstData.remove(T(rItem)); }
00060 virtual Retval MQUALIFIER removeAll(const IList<I>& rlstItems);
00061 inline virtual Int MQUALIFIER getCount() const { return m_lstData.getCount(); }
00062 inline virtual I& MQUALIFIER getItem(Int iIndex) { return m_lstData.getItem(iIndex); }
00063 inline virtual const I& MQUALIFIER getItemConst(Int iIndex) const { return m_lstData.getItemConst(iIndex); }
00064 inline virtual Int MQUALIFIER indexOf(const I& rItem) const { return m_lstData.indexOf(T(rItem)); }
00065 inline virtual Int MQUALIFIER insert(Int iIndex, const I& rItem) { return m_lstData.insert(iIndex, T(rItem)); }
00066 inline virtual bool MQUALIFIER equalsItem(Int iIndex, const I& rItem) const { return m_lstData.equalsItem(iIndex, T(rItem)); }
00067 virtual bool MQUALIFIER equals(const IList<I>& rList) const;
00068 inline virtual IListIterator<I>* MQUALIFIER getIterator() const { return (IListIterator<I>*)m_lstData.getIterator(); }
00069 inline virtual const IListIterator<I>* MQUALIFIER getConstIterator() const { return (const IListIterator<I>*)m_lstData.getConstIterator(); }
00070 inline virtual void MQUALIFIER releaseIterator(const IListIterator<I>* pIterator) const { m_lstData.releaseIterator((const IListIterator<T>*)pIterator); }
00071 inline virtual bool MQUALIFIER isEmpty() const { return m_lstData.isEmpty(); }
00072 inline virtual I& MQUALIFIER getFirstItem() { return m_lstData.getFirstItem(); }
00073 inline virtual const I& MQUALIFIER getFirstItemConst() const { return m_lstData.getFirstItemConst(); }
00074 inline virtual I& MQUALIFIER getLastItem() { return m_lstData.getLastItem(); }
00075 inline virtual const I& MQUALIFIER getLastItemConst() const { return m_lstData.getLastItemConst(); }
00076 inline virtual bool MQUALIFIER hasItem(const I& rItem) const { return m_lstData.hasItem(T(rItem)); }
00077 virtual bool MQUALIFIER hasAllItems(const IList<I>& rlstItems) const;
00078
00079
00080 inline T& operator[](Int iIndex) { return m_lstData[iIndex]; }
00081 inline const T& operator[](Int iIndex) const { return m_lstData[iIndex]; }
00082
00083 protected:
00085 TSingleLinkedList<T> m_lstData;
00086
00087 private:
00088 };
00089
00090
00093
00094 template <class T, class I> Int MQUALIFIER TValueTypeList<T,I>::addAll(const IList<I>& rlstItems)
00095 {
00096 TConstIterator<I> It = rlstItems.getConstIterator();
00097 while(It.hasNextItem())
00098 {
00099 this->add(T(It.getNextItemConst()));
00100 }
00101
00102 return m_lstData.getCount()-1;
00103 }
00104
00105
00108
00109 template <class T, class I> void MQUALIFIER TValueTypeList<T,I>::copyToList(IList<I>& rList) const
00110 {
00111 rList.clear();
00112 TConstIterator<T> It = m_lstData.getConstIterator();
00113 while(It.hasNextItem())
00114 {
00115 rList.add(It.getNextItemConst());
00116 }
00117 }
00118
00119
00122
00123 template <class T, class I> Retval MQUALIFIER TValueTypeList<T,I>::removeAll(const IList<I>& rlstItems)
00124 {
00125 Retval retValue = RET_REQUEST_FAILED;
00126 bool bOK = false;
00127 TConstIterator<I> It = rlstItems.getConstIterator();
00128 while(It.hasNextItem())
00129 {
00130 bOK |= (this->remove(It.getNextItemConst()) == RET_NOERROR);
00131 }
00132
00133 if (bOK)
00134 {
00135 retValue = RET_NOERROR;
00136 }
00137 return retValue;
00138 }
00139
00140
00143
00144 template <class T, class I> bool MQUALIFIER TValueTypeList<T,I>::equals(const IList<I>& rList) const
00145 {
00146 Int iCount = getCount();
00147 bool bRetval = (iCount == rList.getCount());
00148
00149 if (bRetval)
00150 {
00151 TConstIterator<T> It1 = m_lstData.getConstIterator();
00152 TConstIterator<I> It2 = rList.getConstIterator();
00153 while(It1.hasNextItem() && bRetval)
00154 {
00155 bRetval &= (It1.getNextItemConst() == It2.getNextItemConst());
00156 }
00157 }
00158 return bRetval;
00159 }
00160
00161
00164
00165 template <class T, class I> bool MQUALIFIER TValueTypeList<T,I>::hasAllItems(const IList<I>& rlstItems) const
00166 {
00167 bool bRetval = true;
00168 TConstIterator<I> It = rlstItems.getConstIterator();
00169 while(bRetval && It.hasNextItem())
00170 {
00171 bRetval &= this->hasItem(It.getNextItemConst());
00172 }
00173
00174 return bRetval;
00175 }
00176
00177 END_NAMESPACE_Zeus
00178
00179 #endif