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

KalFitList< T > Class Template Reference

#include <KalFitList.h>

List of all members.

Public Member Functions

int append (const KalFitList< T > &)
 append objects into the end of the list
int append (T x)
 append an object into the end of the list
int append (const KalFitList< T > &)
 append objects into the end of the list
int append (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
first (void) const
 returns the first object in the list
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
 KalFitList (const KalFitList< T > &)
 copy constructor
 KalFitList (int length_to_alloc=100)
 default constructor
 KalFitList (const KalFitList< T > &)
 copy constructor
 KalFitList (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
operator[] (unsigned i) const
 returns a object by index
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
 ~KalFitList ()
 destructor
 ~KalFitList ()
 destructor

Private Attributes

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

template<class T>
class KalFitList< T >


Constructor & Destructor Documentation

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

default constructor

00094   : _length(0),
00095     _remain(length_to_alloc),
00096     _length_to_alloc(length_to_alloc),
00097     _obj((T *) malloc(length_to_alloc * sizeof(T))){
00098 }

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

copy constructor

00102   : _length(src._length),
00103     _remain(src._remain),
00104     _length_to_alloc(src._length_to_alloc)
00105 {
00106   _obj = (T *) malloc((_length + _remain) * sizeof(T));
00107   T * srcObj = src._obj;
00108   for (int i = 0; i < _length; i++){
00109     *(_obj+i) = *(srcObj+i);
00110   }
00111 }

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

destructor

00115                           {
00116   free(_obj);
00117 }

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

default constructor

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

copy constructor

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

destructor


Member Function Documentation

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

append objects into the end of the list

template<class T>
int KalFitList< T >::append x  ) 
 

append an object into the end of the list

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

append objects into the end of the list

00246 {
00247   int srcLength = src._length;
00248   T * srcObj = src._obj;
00249   int i = 0;
00250   if (_remain < srcLength){
00251     _obj = (T *) realloc(_obj,(_length_to_alloc + srcLength) * sizeof(T));
00252     while(i^srcLength) *(_obj+(_length++)) = *(srcObj+(i++));
00253   }else{
00254     while(i^srcLength) *(_obj+(_length++)) = *(srcObj+(i++));
00255     _remain -= srcLength;
00256   }
00257   return _length;
00258 }

template<class T>
int KalFitList< T >::append x  )  [inline]
 

append an object into the end of the list

00122                           {
00123   if (!_remain){
00124     _obj = (T *) realloc(_obj,(_length+_length_to_alloc) * sizeof(T));
00125     _remain = _length_to_alloc;
00126   }
00127   *(_obj+(_length++)) = src;
00128   _remain--;
00129   return _length;
00130 }

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

clear lists but the allocated memory remains same

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

clear lists but the allocated memory remains same

00177                         {
00178   _remain += _length;
00179   _length = 0;
00180 }

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

delete all object and clear(allocated memory remains same)

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

delete all object and clear(allocated memory remains same)

00262 {
00263   int i = _length;
00264   while (i) delete *(_obj + (--i));
00265   clear();
00266 }

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

delete objects by index and returns decremented index and length

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

delete objects by index and returns decremented index and length

00159                                       {
00160   delete *(_obj+iterator);
00161   *(_obj+(iterator--)) = *(_obj+(--_length));
00162   _remain++;
00163   return _length;
00164 }

template<class T>
T KalFitList< T >::first void   )  const
 

returns the first object in the list

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

returns the first object in the list

00219                               {
00220   return *_obj;
00221 }

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

returns the pointer of first object

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

returns the pointer of first object

00226                                  {
00227   return _obj;
00228 }

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

returns the pointer of last object

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

returns the pointer of last object

00233                                 {
00234   return _obj + (_length - 1);
00235 }

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

returns the length of the list

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

returns the length of the list

00240                                {
00241   return _length;
00242 }

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

returns the reference of a object by index

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

returns the reference of a object by index

00212                                           {
00213   return *(_obj+i);
00214 }

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

returns a object by index

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

returns a object by index

00205                                           {
00206   return *(_obj+i);
00207 }

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

remove objects by index and returns decremented index and length

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

remove objects by index and returns decremented index and length

00135                                    {
00136   *(_obj+(iterator--)) = *(_obj+(--_length));
00137   _remain++;
00138   return _length;
00139 }

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

remove objects by index

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

remove objects by index

00144                                   {
00145   *(_obj+iterator) = *(_obj+(--_length));
00146   _remain++;
00147 }

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

clear lists and free memory

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

clear lists and free memory

00185                             {
00186   free(_obj);
00187   _remain = 0;
00188   _length = 0;
00189   _obj = NULL;
00190 }

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

remove just last objects of the list

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

remove just last objects of the list

00169                              {
00170   _length--;
00171   _remain++;
00172 }

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

replace index-th object by the object src

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

replace index-th object by the object src

00152                                   {
00153   *(_obj+i) = src;
00154 }

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

re-allocate memory to reduce size

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

re-allocate memory to reduce size

00196                          {
00197   _obj = (T *) realloc(_obj,_length * sizeof(T));
00198   _remain = 0;
00199   _length_to_alloc = _length;
00200 }


Member Data Documentation

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

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

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

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

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


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