tArray< T, MALLOC > Class Template Reference

#include <tArray.h>

Inheritance diagram for tArray< T, MALLOC >:

Inheritance graph
[legend]
Collaboration diagram for tArray< T, MALLOC >:

Collaboration graph
[legend]

List of all members.

Public Member Functions

void SetLen (int i)
 ~tArray ()
 tArray (int firstsize=0)
 tArray (const tArray &A)
T & operator[] (int i)
T const & operator[] (int i) const
T & operator() (int i) const
T * operator+ (int i) const
const tArray< T > & operator= (const tArray< T > &A)
void RemoveAt (int index)
bool Remove (const T &t)
void Insert (const T &t)

Protected Member Functions

void Init ()
void resize (int i)
void Clear ()
void CopyFrom (const tArray &A)


Detailed Description

template<class T, bool MALLOC = false>
class tArray< T, MALLOC >

Definition at line 69 of file tArray.h.


Constructor & Destructor Documentation

template<class T, bool MALLOC = false>
tArray< T, MALLOC >::~tArray (  )  [inline]

Definition at line 110 of file tArray.h.

00110              {
00111         tERR_FLOW_LOW();
00112         Clear();
00113         Delete(MALLOC);
00114     }

template<class T, bool MALLOC = false>
tArray< T, MALLOC >::tArray ( int  firstsize = 0  )  [inline]

Definition at line 117 of file tArray.h.

00118             :GrowingArrayBase(firstsize,sizeof(T),MALLOC) {
00119         // dump(low,flow,"con:size " << firstsize);
00120         Init();
00121     };

template<class T, bool MALLOC = false>
tArray< T, MALLOC >::tArray ( const tArray< T, MALLOC > &  A  )  [inline]

Definition at line 124 of file tArray.h.

00125             :GrowingArrayBase(A.Len(),sizeof(T),MALLOC){
00126         CopyFrom(A);
00127     };


Member Function Documentation

template<class T, bool MALLOC = false>
void tArray< T, MALLOC >::Init ( void   )  [inline, protected]

Definition at line 71 of file tArray.h.

Referenced by tArray< uSelectItem< tString > *, false >::tArray().

00071                {
00072         int i;
00073         for(i=Size()-1;i>=0;i--)
00074             new(reinterpret_cast<T *>(Base())+i) T();
00075     }

Here is the caller graph for this function:

template<class T, bool MALLOC = false>
void tArray< T, MALLOC >::resize ( int  i  )  [inline, protected]

Definition at line 77 of file tArray.h.

Referenced by tArray< uSelectItem< tString > *, false >::SetLen().

00077                       {
00078         int oldsize=Size();
00079         ResizeBase(i,sizeof(T),MALLOC);
00080         // dump(low,flow,"Array resize from " << oldsize << " to " << Size());
00081         for(i=Size()-1;i>=oldsize;i--)
00082             new(reinterpret_cast<T *>(Base())+i) T();
00083     }

Here is the caller graph for this function:

template<class T, bool MALLOC = false>
void tArray< T, MALLOC >::Clear ( void   )  [inline, protected]

Definition at line 86 of file tArray.h.

Referenced by tArray< uSelectItem< tString > *, false >::operator=(), gArena::PrepareGrid(), and tArray< uSelectItem< tString > *, false >::~tArray().

00086                 {
00087         int i;
00088         for(i=Size()-1;i>=0;i--){
00089             // dump(low,flow,"i=" << i);
00090             ((reinterpret_cast<T *>(Base()))+i)->~T();
00091         }
00092         Delete(MALLOC);
00093     }

Here is the caller graph for this function:

template<class T, bool MALLOC = false>
void tArray< T, MALLOC >::CopyFrom ( const tArray< T, MALLOC > &  A  )  [inline, protected]

Definition at line 96 of file tArray.h.

Referenced by tArray< uSelectItem< tString > *, false >::operator=(), and tArray< uSelectItem< tString > *, false >::tArray().

00096                                   {
00097         int i;
00098         for(i=Len()-1;i>=0;i--)
00099             new(reinterpret_cast<T *>(Base())+i) T(A(i));
00100         for(i=Len();i<Size();i++)
00101             new(reinterpret_cast<T *>(Base())+i) T();
00102     }

Here is the caller graph for this function:

template<class T, bool MALLOC = false>
void tArray< T, MALLOC >::SetLen ( int  i  )  [inline]

Reimplemented from GrowingArrayBase.

Definition at line 105 of file tArray.h.

Referenced by gNetPlayerWall::BlowHole(), nSendBuffer::Clear(), ePath::Clear(), nNetObject::ClearAll(), eLineEntry::Delete(), gAISensor::DetectLoop(), ePlayerNetID::ePlayerNetID(), tDirectories::GetFiles(), tDirectories::GetSpecList(), gNetPlayerWall::InitArray(), tArray< uSelectItem< tString > *, false >::Insert(), nServerInfo::Load(), LoadSingleAI(), login_callback(), net_destroy_handler(), tArray< uSelectItem< tString > *, false >::operator=(), nMessage::operator>>(), tArray< uSelectItem< tString > *, false >::operator[](), tPathScripts::Paths(), tPathResource::Paths(), tPathScreenshot::Paths(), tPathVar::Paths(), tPathMusic::Paths(), tPathData::Paths(), tPathConfig::Paths(), gNetPlayerWall::ReadSync(), tSettingRotation::ReadVal(), gNetPlayerWall::real_Update(), tReferenceHolder< T >::ReleaseAll(), tReferenceHolder< T >::Remove(), tArray< uSelectItem< tString > *, false >::RemoveAt(), uMenu::ReverseItems(), se_DeletePasswords(), sn_DoDestroy(), st_DoToDo(), tXmlParserNamespace::st_ErrorFunc(), nBandwidthArbitrator::Timestep(), and tMemManager::tMemManager().

00105                       {
00106         GrowingArrayBase::SetLen(i);
00107         if (i>Size()) resize(i);
00108     }

Here is the caller graph for this function:

template<class T, bool MALLOC = false>
T& tArray< T, MALLOC >::operator[] ( int  i  )  [inline]

Definition at line 130 of file tArray.h.

00130                          {
00131 #ifdef DEBUG
00132         if (i<0) {
00133             tERR_ERROR_INT("Range error;accesed negative element " << i );
00134         }
00135 #endif
00136         if (i>=Len())
00137             SetLen(i+1);
00138 
00139         //    dump(low,flow,"[" << i << "]" << "=" << ((T *)Base())[i] << '\n');
00140 
00141         return((reinterpret_cast<T *>(Base()))[i]);
00142     };

template<class T, bool MALLOC = false>
T const& tArray< T, MALLOC >::operator[] ( int  i  )  const [inline]

Definition at line 145 of file tArray.h.

00145                                      {
00146         tASSERT( i >= 0 && i < Len() );
00147 
00148         return((reinterpret_cast<T *>(Base()))[i]);
00149     };

template<class T, bool MALLOC = false>
T& tArray< T, MALLOC >::operator() ( int  i  )  const [inline]

Reimplemented in tHeapBase, tHeap< T >, tHeap< nBandwidthArbitrator >, and tHeap< tEvent >.

Definition at line 151 of file tArray.h.

00151                               {
00152         tASSERT( i >= 0 && i < Len() );
00153 
00154         return((reinterpret_cast<T *>(Base()))[i]);
00155     };

template<class T, bool MALLOC = false>
T* tArray< T, MALLOC >::operator+ ( int  i  )  const [inline]

Definition at line 157 of file tArray.h.

00157                              {
00158     #ifdef DEBUG
00159         if (i<0) {tERR_ERROR_INT("Range error;accesed negative element " << i )}
00160         if (i>=Len())
00161         {tERR_ERROR_INT("Range error;accesed element "
00162                             << i <<" of maximal " <<Len())}
00163     #endif
00164 
00165         return(reinterpret_cast<T *>(Base())+i);
00166     };

template<class T, bool MALLOC = false>
const tArray<T>& tArray< T, MALLOC >::operator= ( const tArray< T > &  A  )  [inline]

Definition at line 168 of file tArray.h.

00168                                                   {
00169 
00170         Clear();
00171         SetLen(A.Len());
00172         CopyFrom(A);
00173 
00174         return *this;
00175     };

template<class T, bool MALLOC = false>
void tArray< T, MALLOC >::RemoveAt ( int  index  )  [inline]

Definition at line 177 of file tArray.h.

Referenced by tArray< uSelectItem< tString > *, false >::Remove().

00178     {
00179         int newLen = this->Len()-1;
00180         T keep = (*this)[ index ];
00181         if ( index < newLen )
00182             (*this)[ index ] = (*this)[ newLen ];
00183         this->SetLen( newLen );
00184     }

Here is the caller graph for this function:

template<class T, bool MALLOC = false>
bool tArray< T, MALLOC >::Remove ( const T &  t  )  [inline]

Definition at line 186 of file tArray.h.

00187     {
00188         for ( int i = this->Len()-1; i >= 0; --i )
00189         {
00190             if ( (*this)[i] == t )
00191             {
00192                 this->RemoveAt( i );
00193                 return true;
00194             }
00195         }
00196 
00197         return false;
00198     }

template<class T, bool MALLOC = false>
void tArray< T, MALLOC >::Insert ( const T &  t  )  [inline]

Definition at line 200 of file tArray.h.

Referenced by eVoteItem::GetControlMessage(), and tSettingRotation::ReadVal().

00201     {
00202         SetLen( this->Len()+1 );
00203         (*this)[ this->Len() -1 ] = t;
00204     }

Here is the caller graph for this function:


The documentation for this class was generated from the following file:
Generated on Sat Mar 15 23:54:56 2008 for Armagetron Advanced by  doxygen 1.5.4