BOSS 7.0.4
BESIII Offline Software System
Loading...
Searching...
No Matches
FTList< T > Class Template Reference

#include <FTList.h>

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
 
 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
 

Detailed Description

template<class T>
class FTList< T >

Definition at line 16 of file InstallArea/include/MdcFastTrkAlg/MdcFastTrkAlg/FTList.h.

Constructor & Destructor Documentation

◆ FTList() [1/4]

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

default constructor

Definition at line 98 of file InstallArea/include/MdcFastTrkAlg/MdcFastTrkAlg/FTList.h.

99 : _length(0),
100 _remain(length_to_alloc),
101 _length_to_alloc(length_to_alloc),
102 _obj((T *) malloc(length_to_alloc * sizeof(T))){
103}

◆ FTList() [2/4]

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

copy constructor

Definition at line 106 of file InstallArea/include/MdcFastTrkAlg/MdcFastTrkAlg/FTList.h.

107 : _length(src._length),
108 _remain(src._remain),
109 _length_to_alloc(src._length_to_alloc)
110{
111 _obj = (T *) malloc((_length + _remain) * sizeof(T));
112 T * srcObj = src._obj;
113 for (int i = 0; i < _length; i++){
114 *(_obj+i) = *(srcObj+i);
115 }
116}

◆ ~FTList() [1/2]

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

destructor

Definition at line 120 of file InstallArea/include/MdcFastTrkAlg/MdcFastTrkAlg/FTList.h.

120 {
121 free(_obj);
122}

◆ FTList() [3/4]

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

default constructor

◆ FTList() [4/4]

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

copy constructor

◆ ~FTList() [2/2]

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

destructor

Member Function Documentation

◆ append() [1/4]

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

append objects into the end of the list

Definition at line 250 of file InstallArea/include/MdcFastTrkAlg/MdcFastTrkAlg/FTList.h.

251{
252 int srcLength = src._length;
253 T * srcObj = src._obj;
254 int i = 0;
255 if (_remain < srcLength){
256 _obj = (T *) realloc(_obj,(_length + _remain + srcLength) * sizeof(T));
257 while(i^srcLength) *(_obj+(_length++)) = *(srcObj+(i++));
258 }else{
259 while(i^srcLength) *(_obj+(_length++)) = *(srcObj+(i++));
260 _remain -= srcLength;
261 }
262 return _length;
263}

◆ append() [2/4]

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

append objects into the end of the list

◆ append() [3/4]

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 InstallArea/include/MdcFastTrkAlg/MdcFastTrkAlg/FTList.h.

127 {
128 if (!_remain){
129 _obj = (T *) realloc(_obj,(_length+_length_to_alloc) * sizeof(T));
130 _remain = _length_to_alloc;
131 }
132 *(_obj+(_length++)) = src;
133 _remain--;
134 return _length;
135}

Referenced by FTTrack::append_stereo(), FTTrack::append_stereo_cache(), FTSuperLayer::appendHit(), FTSegment::connect_inner(), FTSegment::connect_outer(), FTSegment::examine(), FTTrack::linkStereoSegments(), FTSuperLayer::mkSegmentList(), FTTrack::r_phiFit(), FTSuperLayer::reAppendSalvage(), FTSuperLayer::reduce_noise(), FTTrack::s_zFit(), FTSegment::update3D(), and FTTrack::updateSZ().

◆ append() [4/4]

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

append an object into the end of the list

◆ clear() [1/2]

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

clear lists but the allocated memory remains same

Definition at line 182 of file InstallArea/include/MdcFastTrkAlg/MdcFastTrkAlg/FTList.h.

182 {
183 _remain += _length;
184 _length = 0;
185}

Referenced by FTSuperLayer::clear(), FTSegment::connect_inner(), FTSegment::connect_outer(), and FTTrack::updateSZ().

◆ clear() [2/2]

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

clear lists but the allocated memory remains same

◆ deleteAll() [1/2]

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

delete all object and clear(allocated memory remains same)

Definition at line 266 of file InstallArea/include/MdcFastTrkAlg/MdcFastTrkAlg/FTList.h.

267{
268 int i = _length;
269 while (i) delete *(_obj + (--i));
270 clear();
271}
void clear(void)
clear lists but the allocated memory remains same

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

◆ deleteAll() [2/2]

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

delete all object and clear(allocated memory remains same)

◆ deleteObj() [1/2]

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

delete objects by index and returns decremented index and length

Definition at line 164 of file InstallArea/include/MdcFastTrkAlg/MdcFastTrkAlg/FTList.h.

164 {
165 delete *(_obj+iterator);
166 *(_obj+(iterator--)) = *(_obj+(--_length));
167 _remain++;
168 return _length;
169}

◆ deleteObj() [2/2]

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

delete objects by index and returns decremented index and length

◆ first() [1/2]

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

returns the first object in the list

Definition at line 224 of file InstallArea/include/MdcFastTrkAlg/MdcFastTrkAlg/FTList.h.

224 {
225 return *_obj;
226}

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

◆ first() [2/2]

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

returns the first object in the list

◆ firstPtr() [1/2]

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

returns the pointer of first object

Definition at line 231 of file InstallArea/include/MdcFastTrkAlg/MdcFastTrkAlg/FTList.h.

231 {
232 return _obj;
233}

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

◆ firstPtr() [2/2]

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

returns the pointer of first object

◆ lastPtr() [1/2]

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

returns the pointer of last object

Definition at line 238 of file InstallArea/include/MdcFastTrkAlg/MdcFastTrkAlg/FTList.h.

238 {
239 return _obj + (_length - 1);
240}

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

◆ lastPtr() [2/2]

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

returns the pointer of last object

◆ length() [1/2]

◆ length() [2/2]

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

returns the length of the list

◆ operator()() [1/2]

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 InstallArea/include/MdcFastTrkAlg/MdcFastTrkAlg/FTList.h.

217 {
218 return *(_obj+i);
219}

◆ operator()() [2/2]

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

returns the reference of a object by index

◆ operator[]() [1/2]

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

returns a object by index

Definition at line 210 of file InstallArea/include/MdcFastTrkAlg/MdcFastTrkAlg/FTList.h.

210 {
211 return *(_obj+i);
212}

◆ operator[]() [2/2]

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

returns a object by index

◆ remove() [1/2]

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

remove objects by index and returns decremented index and length

Definition at line 140 of file InstallArea/include/MdcFastTrkAlg/MdcFastTrkAlg/FTList.h.

140 {
141 *(_obj+(iterator--)) = *(_obj+(--_length));
142 _remain++;
143 return _length;
144}

Referenced by FTFinder::event(), FTSuperLayer::mkSegmentList(), FTTrack::r_phi3Fit(), FTTrack::r_phiFit(), FTSuperLayer::reAppendSalvage(), FTSuperLayer::reduce_noise(), and FTTrack::s_zFit().

◆ remove() [2/2]

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

remove objects by index and returns decremented index and length

◆ remove2() [1/2]

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

remove objects by index

Definition at line 149 of file InstallArea/include/MdcFastTrkAlg/MdcFastTrkAlg/FTList.h.

149 {
150 *(_obj+iterator) = *(_obj+(--_length));
151 _remain++;
152}

Referenced by FTTrack::s_zFit().

◆ remove2() [2/2]

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

remove objects by index

◆ removeAll() [1/2]

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

clear lists and free memory

Definition at line 190 of file InstallArea/include/MdcFastTrkAlg/MdcFastTrkAlg/FTList.h.

190 {
191 free(_obj);
192 _remain = 0;
193 _length = 0;
194 _obj = NULL;
195}

◆ removeAll() [2/2]

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

clear lists and free memory

◆ removeLast() [1/2]

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

remove just last objects of the list

Definition at line 174 of file InstallArea/include/MdcFastTrkAlg/MdcFastTrkAlg/FTList.h.

174 {
175 _length--;
176 _remain++;
177}

◆ removeLast() [2/2]

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

remove just last objects of the list

◆ replace() [1/2]

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 InstallArea/include/MdcFastTrkAlg/MdcFastTrkAlg/FTList.h.

157 {
158 *(_obj+i) = src;
159}

◆ replace() [2/2]

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

replace index-th object by the object src

◆ resize() [1/2]

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

re-allocate memory to reduce size

Definition at line 201 of file InstallArea/include/MdcFastTrkAlg/MdcFastTrkAlg/FTList.h.

201 {
202 _obj = (T *) realloc(_obj,_length * sizeof(T));
203 _remain = 0;
204 _length_to_alloc = _length;
205}

◆ resize() [2/2]

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

re-allocate memory to reduce size


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