HEFaceList< T > Class Template Reference

#include <TAPsHEFaceList.hpp>

List of all members.

Public Member Functions

void Append (HEFace< T > *const n)
void Current (HEFace< T > *const n)
HEFace< T > * Current () const
void Delete (HEFace< T > *pFace)
HEFace< T > * Head ()
 HEFaceList ()
void InsertAfter (HEFace< T > *const n)
void InsertBefore (HEFace< T > *const n)
bool IsEmpty () const
bool IsHead () const
bool IsTail () const
int Length () const
HEFace< T > * NextCurrent ()
void Prepend (HEFace< T > *const n)
HEFace< T > * PrevCurrent ()
HEFace< T > * Remove (HEFace< T > *pFace)
HEFace< T > * Remove ()
int Size () const
HEFace< T > * Tail ()
virtual ~HEFaceList ()

Protected Attributes

int m_iLength
HEFace< T > * pCurrent
HEFace< T > * pHead
HEFace< T > * pTail


Detailed Description

template<typename T>
class HEFaceList< T >

Definition at line 18 of file TAPsHEFaceList.hpp.


Constructor & Destructor Documentation

template<typename T>
BEGIN_NAMESPACE_TAPs HEFaceList< T >::HEFaceList (  )  [inline]

Definition at line 20 of file TAPsHEFaceList.cpp.

00021     : m_iLength( 0 ),
00022     pHead( NULL ), pTail( NULL ), pCurrent( NULL )
00023 {}

template<typename T>
HEFaceList< T >::~HEFaceList (  )  [inline, virtual]

Definition at line 28 of file TAPsHEFaceList.cpp.

00029 {
00030     HEFace<T> *tmp;
00031     pCurrent = pHead;
00032     while ( pHead != NULL ) {
00033         tmp = Remove();
00034         if ( tmp != NULL ) delete tmp;
00035     }
00036     m_iLength = 0;
00037 }


Member Function Documentation

template<typename T>
void HEFaceList< T >::Append ( HEFace< T > *const   n  )  [inline]

Definition at line 115 of file TAPsHEFaceList.cpp.

00116 {
00117     // case empty list
00118     if ( pHead == NULL ) {
00119         pCurrent = pHead = pTail = n;
00120         n->Next( NULL );
00121         n->Prev( NULL );
00122         ++m_iLength;
00123     }
00124     // case non-empty list
00125     else {
00126         n->Prev( pTail );
00127         n->Next( NULL );
00128         pTail = n;
00129         n->Prev()->Next( n );
00130         ++m_iLength;
00131     }
00132 }

template<typename T>
void HEFaceList< T >::Current ( HEFace< T > *const   n  )  [inline]

Definition at line 43 of file TAPsHEFaceList.hpp.

00043 { pCurrent = n; }

template<typename T>
HEFace<T>* HEFaceList< T >::Current (  )  const [inline]

Definition at line 42 of file TAPsHEFaceList.hpp.

00042 { return pCurrent; }

template<typename T>
void HEFaceList< T >::Delete ( HEFace< T > *  pFace  )  [inline]

Definition at line 247 of file TAPsHEFaceList.cpp.

00248 {
00249     HEFace<T> * removeItem = Remove( pFace );
00250     if ( removeItem )   delete removeItem;
00251 }

template<typename T>
HEFace<T>* HEFaceList< T >::Head (  )  [inline]

Definition at line 44 of file TAPsHEFaceList.hpp.

00044 { pCurrent = pHead; return pCurrent; }

template<typename T>
void HEFaceList< T >::InsertAfter ( HEFace< T > *const   n  )  [inline]

Definition at line 64 of file TAPsHEFaceList.cpp.

00065 {
00066     // case empty list
00067     if ( pHead == NULL ) {
00068         pCurrent = pHead = pTail = n;
00069         n->Next( NULL );
00070         n->Prev( NULL );
00071         ++m_iLength;
00072     }
00073     // case pCurrent == pTail
00074     else if ( pCurrent == pTail ) {
00075         Append( n );
00076         //n->Prev( pCurrent );
00077         //n->Next( NULL );
00078         //pCurrent->Next( n );
00079         //pCurrent = pTail = n;
00080     }
00081     // case pCurrent != pTail
00082     else {
00083         n->Prev( pCurrent );
00084         n->Next( pCurrent->Next() );
00085         n->Next()->Prev( n );
00086         pCurrent->Next( n );
00087         pCurrent = n;
00088         ++m_iLength;
00089     }
00090 }

template<typename T>
void HEFaceList< T >::InsertBefore ( HEFace< T > *const   n  )  [inline]

Definition at line 43 of file TAPsHEFaceList.cpp.

00043                                                        {
00044     // case empty list
00045     if ( pHead == NULL ) {
00046         pCurrent = pHead = pTail = n;
00047         n->Next( NULL );
00048         n->Prev( NULL );
00049         ++m_iLength;
00050     }
00051     // case pCurrent == pHead
00052     else if ( pCurrent == pHead ) {
00053         Prepend( n );
00054     }
00055     // case non-empty list
00056     else {
00057         pCurrent = pCurrent->Prev();
00058         InsertAfter( n );
00059     }
00060 }

template<typename T>
bool HEFaceList< T >::IsEmpty (  )  const [inline]

Definition at line 39 of file TAPsHEFaceList.hpp.

00039 { return pHead == NULL ? true : false; }

template<typename T>
bool HEFaceList< T >::IsHead (  )  const [inline]

Definition at line 48 of file TAPsHEFaceList.hpp.

00048 { return pHead == pCurrent ? true : false; }

template<typename T>
bool HEFaceList< T >::IsTail (  )  const [inline]

Definition at line 49 of file TAPsHEFaceList.hpp.

00049 { return pTail == pCurrent ? true : false; }

template<typename T>
int HEFaceList< T >::Length (  )  const [inline]

Definition at line 37 of file TAPsHEFaceList.hpp.

00037 { return m_iLength; }

template<typename T>
HEFace<T>* HEFaceList< T >::NextCurrent (  )  [inline]

Definition at line 46 of file TAPsHEFaceList.hpp.

00046 { pCurrent = pCurrent->Next(); return pCurrent; }

template<typename T>
void HEFaceList< T >::Prepend ( HEFace< T > *const   n  )  [inline]

Definition at line 94 of file TAPsHEFaceList.cpp.

00095 {
00096     // case empty list
00097     if ( pHead == NULL ) {
00098         pCurrent = pHead = pTail = n;
00099         n->Next( NULL );
00100         n->Prev( NULL );
00101         ++m_iLength;
00102     }
00103     // case non-empty list
00104     else {
00105         n->Prev( NULL );
00106         n->Next( pHead );
00107         pHead->Prev( n );
00108         pHead = n;
00109         ++m_iLength;
00110     }
00111 }

template<typename T>
HEFace<T>* HEFaceList< T >::PrevCurrent (  )  [inline]

Definition at line 47 of file TAPsHEFaceList.hpp.

00047 { pCurrent = pCurrent->Prev(); return pCurrent; }

template<typename T>
HEFace< T > * HEFaceList< T >::Remove ( HEFace< T > *  pFace  )  [inline]

Definition at line 198 of file TAPsHEFaceList.cpp.

00199 {
00200     //---------------------------------------------------------------
00201     // case empty list
00202     if ( pFace == NULL ) return NULL;
00203     //---------------------------------------------------------------
00204     HEFace<T> *tmp = pFace;
00205     //---------------------------------------------------------------
00206     // case one element list
00207     if ( pHead == pTail && pFace == pHead ) {
00208         std::cout << "// case one element list" << std::endl;
00209         pFace = pHead = pTail = NULL;   // make list empty
00210         m_iLength = 0;                  // size is zero
00211         return tmp;
00212     }
00213     //---------------------------------------------------------------
00214     // case pFace == pHead
00215     else if ( pHead == pFace ) {
00216         std::cout << "// case pFace == pHead" << std::endl;
00217         pFace = pHead = pHead->Next();
00218         pHead->Prev( NULL );
00219     }
00220     //---------------------------------------------------------------
00221     // case pFace == pTail
00222     else if ( pTail == pFace ) {
00223         std::cout << "// case pFace == pTail" << std::endl;
00224         pFace = pTail = pTail->Prev();
00225         pTail->Next( NULL );
00226     }
00227     //---------------------------------------------------------------
00228     // case between pHead and pTail
00229     else {
00230         std::cout << "// case between pHead and pTail" << std::endl;
00231         pFace = pFace->Next();
00232         tmp->Prev()->Next( pFace );
00233         pFace->Prev( tmp->Prev() );
00234     }
00235     //---------------------------------------------------------------
00236     tmp->Prev( NULL );
00237     tmp->Next( NULL );
00238     --m_iLength;
00239 
00240     std::cout << "Size: " << m_iLength << std::endl;
00241 
00242     return tmp;
00243 }

template<typename T>
HEFace< T > * HEFaceList< T >::Remove (  )  [inline]

Definition at line 136 of file TAPsHEFaceList.cpp.

00137 {
00138     return Remove( pCurrent );
00139 
00140     /*
00141     // case empty list
00142     if ( pCurrent == NULL ) return NULL;
00143     // case one element list
00144     else if ( pHead == pTail && pCurrent == pHead ) {
00145         HEFace<T> *tmp = pCurrent;
00146         pCurrent = pHead = pTail = NULL;
00147         --m_iLength;
00148         return tmp;
00149     }
00150     // case pCurrent == pHead
00151     else if ( pHead == pCurrent ) {
00152         HEFace<T> *tmp = pCurrent;
00153         pCurrent = pHead = pHead->Next();
00154         pHead->Prev( NULL );
00155         tmp->Prev( NULL );
00156         tmp->Next( NULL );
00157         --m_iLength;
00158         return tmp;
00159     }
00160     // case pCurrent == pTail
00161     else if ( pTail == pCurrent ) {
00162         HEFace<T> *tmp = pCurrent;
00163         pCurrent = pTail = pTail->Prev();
00164         pTail->Next( NULL );
00165         tmp->Prev( NULL );
00166         tmp->Next( NULL );
00167         --m_iLength;
00168         return tmp;
00169     }
00170     else {
00171         HEFace<T> *tmp = pCurrent;
00172         pCurrent = pCurrent->Next();
00173         tmp->Prev()->Next( pCurrent );
00174         pCurrent->Prev( tmp->Prev() );
00175         tmp->Prev( NULL );
00176         tmp->Next( NULL );
00177         --m_iLength;
00178         return tmp;
00179     }
00180     //*/
00181 }

template<typename T>
int HEFaceList< T >::Size (  )  const [inline]

Definition at line 38 of file TAPsHEFaceList.hpp.

00038 { return m_iLength; }

template<typename T>
HEFace<T>* HEFaceList< T >::Tail (  )  [inline]

Definition at line 45 of file TAPsHEFaceList.hpp.

00045 { pCurrent = pTail; return pCurrent; }


Member Data Documentation

template<typename T>
int HEFaceList< T >::m_iLength [protected]

Definition at line 23 of file TAPsHEFaceList.hpp.

template<typename T>
HEFace<T>* HEFaceList< T >::pCurrent [protected]

Definition at line 26 of file TAPsHEFaceList.hpp.

template<typename T>
HEFace<T>* HEFaceList< T >::pHead [protected]

Definition at line 24 of file TAPsHEFaceList.hpp.

template<typename T>
HEFace<T>* HEFaceList< T >::pTail [protected]

Definition at line 25 of file TAPsHEFaceList.hpp.


The documentation for this class was generated from the following files:

Generated on Mon Oct 13 11:45:00 2008 for TAPs by  doxygen 1.5.6