OpenBarnyard
 
Loading...
Searching...
No Matches
TNodeList< T > Class Template Reference

#include <TNodeList.h>

Classes

class  Iterator
 
class  TNode
 

Public Member Functions

 TNodeList ()
 
 ~TNodeList ()
 
void InsertAfter (T *insertAfter, T *newNode)
 
void InsertBefore (T *insertBefore, T *newNode)
 
T * Remove (T *pNode)
 
void RemoveAll ()
 
Iterator RemoveHead ()
 
Iterator RemoveTail ()
 
void DeleteHead ()
 
void DeleteTail ()
 
void DeleteAll ()
 
void Delete (T *pNode)
 
void InsertHead (T *a_pNode)
 
void InsertTail (T *a_pNode)
 
TBOOL IsEmpty () const
 
TBOOL IsValid (const T *a_pNode) const
 
TSIZE Count () const
 
Iterator Head () const
 
Iterator Tail () const
 
Iterator Begin () const
 
Iterator End () const
 
Iterator RBegin () const
 
Iterator REnd () const
 

Protected Attributes

TNode m_oRoot
 
TINT m_iCount
 

Detailed Description

template<class T>
class TNodeList< T >

Definition at line 6 of file TNodeList.h.

Constructor & Destructor Documentation

◆ TNodeList()

template<class T>
TNodeList< T >::TNodeList ( )
inline

Definition at line 129 of file TNodeList.h.

130 {
131 m_iCount = 0;
132 }
TINT m_iCount
Definition TNodeList.h:238

◆ ~TNodeList()

template<class T>
TNodeList< T >::~TNodeList ( )
inline

Definition at line 134 of file TNodeList.h.

135 {
136 DeleteAll();
137 }
void DeleteAll()
Definition TNodeList.h:205

Member Function Documentation

◆ Begin()

template<class T>
Iterator TNodeList< T >::Begin ( ) const
inline

Definition at line 230 of file TNodeList.h.

230{ return m_oRoot.m_pNext; }
TNode m_oRoot
Definition TNodeList.h:237

◆ Count()

template<class T>
TSIZE TNodeList< T >::Count ( ) const
inline

Definition at line 225 of file TNodeList.h.

225{ return m_iCount; }

◆ Delete()

template<class T>
void TNodeList< T >::Delete ( T * pNode)
inline

Definition at line 213 of file TNodeList.h.

214 {
215 Remove( pNode );
216 delete pNode;
217 }
T * Remove(T *pNode)
Definition TNodeList.h:161

◆ DeleteAll()

template<class T>
void TNodeList< T >::DeleteAll ( )
inline

Definition at line 205 of file TNodeList.h.

206 {
207 while ( !IsEmpty() )
208 {
209 DeleteHead();
210 }
211 }
TBOOL IsEmpty() const
Definition TNodeList.h:222
void DeleteHead()
Definition TNodeList.h:202

◆ DeleteHead()

template<class T>
void TNodeList< T >::DeleteHead ( )
inline

Definition at line 202 of file TNodeList.h.

202{ Delete( Head() ); }
void Delete(T *pNode)
Definition TNodeList.h:213
Iterator Head() const
Definition TNodeList.h:227

◆ DeleteTail()

template<class T>
void TNodeList< T >::DeleteTail ( )
inline

Definition at line 203 of file TNodeList.h.

203{ Delete( Tail() ); }
Iterator Tail() const
Definition TNodeList.h:228

◆ End()

template<class T>
Iterator TNodeList< T >::End ( ) const
inline

Definition at line 231 of file TNodeList.h.

231{ return TSTATICCAST( T, &m_oRoot ); }
#define TSTATICCAST(POINTERTYPE, VALUE)
Definition Defines.h:69

◆ Head()

template<class T>
Iterator TNodeList< T >::Head ( ) const
inline

Definition at line 227 of file TNodeList.h.

227{ return m_oRoot.m_pNext; }

◆ InsertAfter()

template<class T>
void TNodeList< T >::InsertAfter ( T * insertAfter,
T * newNode )
inline

Definition at line 139 of file TNodeList.h.

140 {
141 TASSERT( !newNode->IsLinked() );
142 newNode->SetList( this );
143 newNode->m_pNext = insertAfter->m_pNext;
144 newNode->m_pPrev = insertAfter;
145 insertAfter->m_pNext->m_pPrev = newNode;
146 insertAfter->m_pNext = newNode;
147 m_iCount++;
148 }
#define TASSERT(X,...)
Definition Defines.h:138

◆ InsertBefore()

template<class T>
void TNodeList< T >::InsertBefore ( T * insertBefore,
T * newNode )
inline

Definition at line 150 of file TNodeList.h.

151 {
152 TASSERT( !newNode->IsLinked() );
153 newNode->SetList( this );
154 newNode->m_pNext = insertBefore;
155 newNode->m_pPrev = insertBefore->m_pPrev;
156 insertBefore->m_pPrev->m_pNext = newNode;
157 insertBefore->m_pPrev = newNode;
158 m_iCount++;
159 }

◆ InsertHead()

template<class T>
void TNodeList< T >::InsertHead ( T * a_pNode)
inline

Definition at line 219 of file TNodeList.h.

219{ InsertAfter( End(), a_pNode ); }
Iterator End() const
Definition TNodeList.h:231
void InsertAfter(T *insertAfter, T *newNode)
Definition TNodeList.h:139

◆ InsertTail()

template<class T>
void TNodeList< T >::InsertTail ( T * a_pNode)
inline

Definition at line 220 of file TNodeList.h.

220{ InsertBefore( End(), a_pNode ); }
void InsertBefore(T *insertBefore, T *newNode)
Definition TNodeList.h:150

◆ IsEmpty()

template<class T>
TBOOL TNodeList< T >::IsEmpty ( ) const
inline

Definition at line 222 of file TNodeList.h.

222{ return Begin() == End(); }
Iterator Begin() const
Definition TNodeList.h:230

◆ IsValid()

template<class T>
TBOOL TNodeList< T >::IsValid ( const T * a_pNode) const
inline

Definition at line 223 of file TNodeList.h.

223{ return a_pNode != TNULL && a_pNode->m_pList == this; }

◆ RBegin()

template<class T>
Iterator TNodeList< T >::RBegin ( ) const
inline

Definition at line 233 of file TNodeList.h.

233{ return m_oRoot.m_pPrev; }

◆ Remove()

template<class T>
T * TNodeList< T >::Remove ( T * pNode)
inline

Definition at line 161 of file TNodeList.h.

162 {
163 TASSERT( pNode->GetList() == this );
164 pNode->SetList( TNULL );
165 pNode->m_pPrev->m_pNext = pNode->m_pNext;
166 pNode->m_pNext->m_pPrev = pNode->m_pPrev;
167 pNode->m_pNext = pNode;
168 pNode->m_pPrev = pNode;
169 m_iCount--;
170 TASSERT( pNode->IsLinked() == TFALSE );
171 return pNode;
172 }

◆ RemoveAll()

template<class T>
void TNodeList< T >::RemoveAll ( )
inline

Definition at line 174 of file TNodeList.h.

175 {
176 while ( !IsEmpty() )
177 {
178 Remove( m_oRoot.Next() );
179 }
180 }

◆ RemoveHead()

template<class T>
Iterator TNodeList< T >::RemoveHead ( )
inline

Definition at line 182 of file TNodeList.h.

183 {
184 if ( !IsEmpty() )
185 {
186 return Remove( m_oRoot.Next() );
187 }
188
189 return TNULL;
190 }

◆ RemoveTail()

template<class T>
Iterator TNodeList< T >::RemoveTail ( )
inline

Definition at line 192 of file TNodeList.h.

193 {
194 if ( !IsEmpty() )
195 {
196 return Remove( m_oRoot.Prev() );
197 }
198
199 return TNULL;
200 }

◆ REnd()

template<class T>
Iterator TNodeList< T >::REnd ( ) const
inline

Definition at line 234 of file TNodeList.h.

234{ return TSTATICCAST( T, &m_oRoot ); }

◆ Tail()

template<class T>
Iterator TNodeList< T >::Tail ( ) const
inline

Definition at line 228 of file TNodeList.h.

228{ return m_oRoot.m_pPrev; }

Member Data Documentation

◆ m_iCount

template<class T>
TINT TNodeList< T >::m_iCount
protected

Definition at line 238 of file TNodeList.h.

◆ m_oRoot

template<class T>
TNode TNodeList< T >::m_oRoot
mutableprotected

Definition at line 237 of file TNodeList.h.


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