Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

FTList< T > Class Template Reference

#include <FTList.h>

List of all members.

Public Member Functions

int append (const FTList< T > &)
 append objects into the end of the list
int append (const T &x)
 append an object into the end of the list
int append (const FTList< T > &)
 append objects into the end of the list
int append (const T &x)
 append an object into the end of the list
void clear (void)
 clear lists but the allocated memory remains same
void clear (void)
 clear lists but the allocated memory remains same
void deleteAll (void)
 delete all object and clear(allocated memory remains same)
void deleteAll (void)
 delete all object and clear(allocated memory remains same)
int deleteObj (int &)
 delete objects by index and returns decremented index and length
int deleteObj (int &)
 delete objects by index and returns decremented index and length
T & first (void) const
 returns the first object in the list
T & first (void) const
 returns the first object in the list
T * firstPtr (void) const
 returns the pointer of first object
T * firstPtr (void) const
 returns the pointer of first object
 FTList (const FTList< T > &)
 copy constructor
 FTList (int length_to_alloc=100)
 default constructor
 FTList (const FTList< T > &)
 copy constructor
 FTList (int length_to_alloc=100)
 default constructor
T * lastPtr (void) const
 returns the pointer of last object
T * lastPtr (void) const
 returns the pointer of last object
int length (void) const
 returns the length of the list
int length (void) const
 returns the length of the list
T & operator() (unsigned i) const
 returns the reference of a object by index
T & operator() (unsigned i) const
 returns the reference of a object by index
T & operator[] (unsigned i) const
 returns a object by index
T & operator[] (unsigned i) const
 returns a object by index
int remove (int &)
 remove objects by index and returns decremented index and length
int remove (int &)
 remove objects by index and returns decremented index and length
void remove2 (int)
 remove objects by index
void remove2 (int)
 remove objects by index
void removeAll (void)
 clear lists and free memory
void removeAll (void)
 clear lists and free memory
void removeLast (void)
 remove just last objects of the list
void removeLast (void)
 remove just last objects of the list
void replace (int i, T src)
 replace index-th object by the object src
void replace (int i, T src)
 replace index-th object by the object src
void resize (void)
 re-allocate memory to reduce size
void resize (void)
 re-allocate memory to reduce size
 ~FTList ()
 destructor
 ~FTList ()
 destructor

Private Attributes

int _length
int _length_to_alloc
T * _obj
T * _obj
int _remain

template<class T>
class FTList< T >


Constructor & Destructor Documentation

template<class T>
FTList< T >::FTList int  length_to_alloc = 100  )  [inline]
 

default constructor

00099   : _length(0),
00100     _remain(length_to_alloc),
00101     _length_to_alloc(length_to_alloc),
00102     _obj((T *) malloc(length_to_alloc * sizeof(T))){
00103 }

template<class T>
FTList< T >::FTList const FTList< T > &   ) 
 

copy constructor

00107   : _length(src._length),
00108     _remain(src._remain),
00109     _length_to_alloc(src._length_to_alloc)
00110 {
00111   _obj = (T *) malloc((_length + _remain) * sizeof(T));
00112   T * srcObj = src._obj;
00113   for (int i = 0; i < _length; i++){
00114     *(_obj+i) = *(srcObj+i);
00115   }
00116 }

template<class T>
FTList< T >::~FTList  )  [inline]
 

destructor

00120                   {
00121   free(_obj);
00122 }

template<class T>
FTList< T >::FTList int  length_to_alloc = 100  ) 
 

default constructor

template<class T>
FTList< T >::FTList const FTList< T > &   ) 
 

copy constructor

template<class T>
FTList< T >::~FTList  ) 
 

destructor


Member Function Documentation

template<class T>
int FTList< T >::append const FTList< T > &   ) 
 

append objects into the end of the list

template<class T>
int FTList< T >::append const T &  x  ) 
 

append an object into the end of the list

template<class T>
int FTList< T >::append const FTList< T > &   ) 
 

append objects into the end of the list

00251 {
00252   int srcLength = src._length;
00253   T * srcObj = src._obj;
00254   int i = 0;
00255   if (_remain < srcLength){
00256     _obj = (T *) realloc(_obj,(_length + _remain + srcLength) * sizeof(T));
00257     while(i^srcLength) *(_obj+(_length++)) = *(srcObj+(i++));
00258   }else{
00259     while(i^srcLength) *(_obj+(_length++)) = *(srcObj+(i++));
00260     _remain -= srcLength;
00261   }
00262   return _length;
00263 }

template<class T>
int FTList< T >::append const T &  x  )  [inline]
 

append an object into the end of the list

00127                              {
00128   if (!_remain){
00129     _obj = (T *) realloc(_obj,(_length+_length_to_alloc) * sizeof(T));
00130     _remain = _length_to_alloc;
00131   }
00132   *(_obj+(_length++)) = src;
00133   _remain--;
00134   return _length;
00135 }

template<class T>
void FTList< T >::clear void   ) 
 

clear lists but the allocated memory remains same

template<class T>
void FTList< T >::clear void   )  [inline]
 

clear lists but the allocated memory remains same

00182                     {
00183   _remain += _length;
00184   _length = 0;
00185 }

template<class T>
void FTList< T >::deleteAll void   ) 
 

delete all object and clear(allocated memory remains same)

template<class T>
void FTList< T >::deleteAll void   ) 
 

delete all object and clear(allocated memory remains same)

00267 {
00268   int i = _length;
00269   while (i) delete *(_obj + (--i));
00270   clear();
00271 }

template<class T>
int FTList< T >::deleteObj int &   ) 
 

delete objects by index and returns decremented index and length

template<class T>
int FTList< T >::deleteObj int &   )  [inline]
 

delete objects by index and returns decremented index and length

00164                                   {
00165   delete *(_obj+iterator);
00166   *(_obj+(iterator--)) = *(_obj+(--_length));
00167   _remain++;
00168   return _length;
00169 }

template<class T>
T& FTList< T >::first void   )  const
 

returns the first object in the list

template<class T>
T & FTList< T >::first void   )  const [inline]
 

returns the first object in the list

00224                           {
00225   return *_obj;
00226 }

template<class T>
T* FTList< T >::firstPtr void   )  const
 

returns the pointer of first object

template<class T>
T * FTList< T >::firstPtr void   )  const [inline]
 

returns the pointer of first object

00231                              {
00232   return _obj;
00233 }

template<class T>
T* FTList< T >::lastPtr void   )  const
 

returns the pointer of last object

template<class T>
T * FTList< T >::lastPtr void   )  const [inline]
 

returns the pointer of last object

00238                             {
00239   return _obj + (_length - 1);
00240 }

template<class T>
int FTList< T >::length void   )  const
 

returns the length of the list

template<class T>
int FTList< T >::length void   )  const [inline]
 

returns the length of the list

00245                            {
00246   return _length;
00247 }

template<class T>
T& FTList< T >::operator() unsigned  i  )  const
 

returns the reference of a object by index

template<class T>
T & FTList< T >::operator() unsigned  i  )  const [inline]
 

returns the reference of a object by index

00217                                       {
00218   return *(_obj+i);
00219 }

template<class T>
T& FTList< T >::operator[] unsigned  i  )  const
 

returns a object by index

template<class T>
T & FTList< T >::operator[] unsigned  i  )  const [inline]
 

returns a object by index

00210                                       {
00211   return *(_obj+i);
00212 }

template<class T>
int FTList< T >::remove int &   ) 
 

remove objects by index and returns decremented index and length

template<class T>
int FTList< T >::remove int &   )  [inline]
 

remove objects by index and returns decremented index and length

00140                                {
00141   *(_obj+(iterator--)) = *(_obj+(--_length));
00142   _remain++;
00143   return _length;
00144 }

template<class T>
void FTList< T >::remove2 int   ) 
 

remove objects by index

template<class T>
void FTList< T >::remove2 int   )  [inline]
 

remove objects by index

00149                               {
00150   *(_obj+iterator) = *(_obj+(--_length));
00151   _remain++;
00152 }

template<class T>
void FTList< T >::removeAll void   ) 
 

clear lists and free memory

template<class T>
void FTList< T >::removeAll void   )  [inline]
 

clear lists and free memory

00190                         {
00191   free(_obj);
00192   _remain = 0;
00193   _length = 0;
00194   _obj = NULL;
00195 }

template<class T>
void FTList< T >::removeLast void   ) 
 

remove just last objects of the list

template<class T>
void FTList< T >::removeLast void   )  [inline]
 

remove just last objects of the list

00174                          {
00175   _length--;
00176   _remain++;
00177 }

template<class T>
void FTList< T >::replace int  i,
src
 

replace index-th object by the object src

template<class T>
void FTList< T >::replace int  i,
src
[inline]
 

replace index-th object by the object src

00157                               {
00158   *(_obj+i) = src;
00159 }

template<class T>
void FTList< T >::resize void   ) 
 

re-allocate memory to reduce size

template<class T>
void FTList< T >::resize void   )  [inline]
 

re-allocate memory to reduce size

00201                      {
00202   _obj = (T *) realloc(_obj,_length * sizeof(T));
00203   _remain = 0;
00204   _length_to_alloc = _length;
00205 }


Member Data Documentation

template<class T>
int FTList< T >::_length [private]
 

template<class T>
int FTList< T >::_length_to_alloc [private]
 

template<class T>
T* FTList< T >::_obj [private]
 

template<class T>
T* FTList< T >::_obj [private]
 

template<class T>
int FTList< T >::_remain [private]
 


The documentation for this class was generated from the following files:
Generated on Wed Feb 2 16:15:28 2011 for BOSS6.5.5 by  doxygen 1.3.9.1