FTList< T > Class Template Reference

#include <FTList.h>

List of all members.

Public Member Functions

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

Private Attributes

int _length
int _remain
int _length_to_alloc
T * _obj


Detailed Description

template<class T>
class FTList< T >

Definition at line 16 of file FTList.h.


Constructor & Destructor Documentation

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

default constructor

Definition at line 98 of file FTList.h.

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

Definition at line 106 of file FTList.h.

References FTList< T >::_length, FTList< T >::_obj, FTList< T >::_remain, genRecEmupikp::i, and T.

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

Definition at line 120 of file FTList.h.

References FTList< T >::_obj.

00120                   {
00121   free(_obj);
00122 }


Member Function Documentation

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

append objects into the end of the list

Definition at line 250 of file FTList.h.

References FTList< T >::_length, FTList< T >::_obj, FTList< T >::_remain, genRecEmupikp::i, and T.

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

Definition at line 127 of file FTList.h.

References FTList< T >::_length, FTList< T >::_length_to_alloc, FTList< T >::_obj, FTList< T >::_remain, and T.

Referenced by FTTrack::append_stereo(), FTTrack::append_stereo_cache(), FTSuperLayer::appendHit(), FTSuperLayer::clustering(), FTSegment::connect_inner(), FTSegment::connect_outer(), FTSuperLayer::connect_short_segments(), FTSuperLayer::connect_singleHit(), FTSegment::examine(), FTFinder::linkAxialSegments(), FTFinder::linkAxialSegments_step(), FTFinder::linkAxialSuperLayer234(), FTFinder::linkAxialSuperLayer910(), FTTrack::linkStereoSegments(), FTSuperLayer::mkSegmentList(), FTFinder::mkTrack3D(), FTFinder::mkTrackList(), FTTrack::r_phiFit(), FTSuperLayer::reAppendSalvage(), FTSuperLayer::reduce_noise(), FTTrack::s_zFit(), FTSegment::update3D(), FTTrack::updateSZ(), FTFinder::VertexFit(), and FTFinder::VertexFit2D().

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   )  [inline]

clear lists but the allocated memory remains same

Definition at line 182 of file FTList.h.

References FTList< T >::_length, and FTList< T >::_remain.

Referenced by FTSuperLayer::clear(), FTSuperLayer::clustering(), FTSegment::connect_inner(), FTSegment::connect_outer(), FTList< T >::deleteAll(), FTFinder::linkAxialSegments(), FTFinder::linkAxialSuperLayer234(), FTFinder::linkAxialSuperLayer910(), and FTTrack::updateSZ().

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)

Definition at line 266 of file FTList.h.

References FTList< T >::_length, FTList< T >::_obj, FTList< T >::clear(), and genRecEmupikp::i.

Referenced by FTSuperLayer::clear(), FTFinder::clear(), and FTTrack::linkStereoSegments().

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

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

delete objects by index and returns decremented index and length

Definition at line 164 of file FTList.h.

References FTList< T >::_length, FTList< T >::_obj, and FTList< T >::_remain.

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 [inline]

returns the first object in the list

Definition at line 224 of file FTList.h.

References FTList< T >::_obj.

Referenced by FTFinder::linkAxialSegments_step(), FTSegment::s(), FTSegment::update(), FTSegment::update3D(), FTTrack::updateSZ(), and FTSegment::z().

00224                           {
00225   return *_obj;
00226 }

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

returns the pointer of first object

Definition at line 231 of file FTList.h.

References FTList< T >::_obj.

Referenced by FTSuperLayer::clear(), FTSuperLayer::clustering(), and FTSegment::examine().

00231                              {
00232   return _obj;
00233 }

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

returns the pointer of last object

Definition at line 238 of file FTList.h.

References FTList< T >::_length, and FTList< T >::_obj.

Referenced by FTSuperLayer::clear(), FTSuperLayer::clustering(), and FTSegment::examine().

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

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

returns the length of the list

Definition at line 245 of file FTList.h.

References FTList< T >::_length.

Referenced by FTSuperLayer::clear(), FTSuperLayer::clustering(), FTSuperLayer::connect_short_segments(), FTSuperLayer::connect_singleHit(), FTFinder::CorrectEvtTiming(), FTTrack::d_z(), FTFinder::event(), FTFinder::findBestVertex(), FTTrack::get_nhits(), FTFinder::getTestime(), FTSegment::incomingPhi(), FTFinder::linkAxialSegments_step(), FTFinder::linkAxialSuperLayer234(), FTTrack::linkStereoSegments(), FTSegment::linkStereoSegments(), FTFinder::makeMdst(), FTFinder::makeTds(), FTSuperLayer::mkSegmentList(), FTFinder::mkTrack3D(), FTFinder::mkTrackList(), FTSegment::outgoingPhi(), FTTrack::printout(), FTSegment::printout(), FTTrack::r_phi2Fit(), FTTrack::r_phi3Fit(), FTTrack::r_phi4Fit(), FTTrack::r_phiFit(), FTTrack::r_phiReFit(), FTSuperLayer::reAppendSalvage(), FTSuperLayer::reduce_noise(), FTTrack::s_zFit(), FTSegment::update(), FTSegment::update3D(), FTTrack::updateSZ(), FTFinder::VertexFit(), and FTFinder::VertexFit2D().

00245                            {
00246   return _length;
00247 }

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

returns the reference of a object by index

Definition at line 217 of file FTList.h.

References FTList< T >::_obj.

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

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

returns a object by index

Definition at line 210 of file FTList.h.

References FTList< T >::_obj.

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

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

remove objects by index and returns decremented index and length

Definition at line 140 of file FTList.h.

References FTList< T >::_length, FTList< T >::_obj, and FTList< T >::_remain.

Referenced by FTSuperLayer::connect_short_segments(), FTSuperLayer::connect_singleHit(), FTFinder::event(), FTFinder::linkAxialSegments_step(), FTFinder::linkAxialSuperLayer234(), FTSuperLayer::mkSegmentList(), FTSuperLayer::reAppendSalvage(), FTSuperLayer::reduce_noise(), and FTTrack::s_zFit().

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

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

remove objects by index

Definition at line 149 of file FTList.h.

References FTList< T >::_length, FTList< T >::_obj, and FTList< T >::_remain.

Referenced by FTTrack::s_zFit().

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

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

clear lists and free memory

Definition at line 190 of file FTList.h.

References FTList< T >::_length, FTList< T >::_obj, and FTList< T >::_remain.

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

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

remove just last objects of the list

Definition at line 174 of file FTList.h.

References FTList< T >::_length, and FTList< T >::_remain.

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

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

replace index-th object by the object src

Definition at line 157 of file FTList.h.

References FTList< T >::_obj.

Referenced by FTFinder::mkTrackList().

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

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

re-allocate memory to reduce size

Definition at line 201 of file FTList.h.

References FTList< T >::_length, FTList< T >::_length_to_alloc, FTList< T >::_obj, FTList< T >::_remain, and T.

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]

Definition at line 80 of file FTList.h.

Referenced by FTList< T >::append(), FTList< T >::clear(), FTList< T >::deleteAll(), FTList< T >::deleteObj(), FTList< T >::FTList(), FTList< T >::lastPtr(), FTList< T >::length(), FTList< T >::remove(), FTList< T >::remove2(), FTList< T >::removeAll(), FTList< T >::removeLast(), and FTList< T >::resize().

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

Definition at line 82 of file FTList.h.

Referenced by FTList< T >::append(), and FTList< T >::resize().

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

Definition at line 83 of file FTList.h.

Referenced by FTList< T >::append(), FTList< T >::deleteAll(), FTList< T >::deleteObj(), FTList< T >::first(), FTList< T >::firstPtr(), FTList< T >::FTList(), FTList< T >::lastPtr(), FTList< T >::operator()(), FTList< T >::operator[](), FTList< T >::remove(), FTList< T >::remove2(), FTList< T >::removeAll(), FTList< T >::replace(), FTList< T >::resize(), and FTList< T >::~FTList().

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

Definition at line 81 of file FTList.h.

Referenced by FTList< T >::append(), FTList< T >::clear(), FTList< T >::deleteObj(), FTList< T >::FTList(), FTList< T >::remove(), FTList< T >::remove2(), FTList< T >::removeAll(), FTList< T >::removeLast(), and FTList< T >::resize().


Generated on Tue Nov 29 23:19:36 2016 for BOSS_7.0.2 by  doxygen 1.4.7