CGEM BOSS 6.6.5.f
BESIII Offline Software System
Loading...
Searching...
No Matches
KalFitList< T > Class Template Reference

#include <KalFitList.h>

Public Member Functions

 KalFitList (int length_to_alloc=100)
 default constructor
 
 KalFitList (const KalFitList< T > &)
 copy constructor
 
 ~KalFitList ()
 destructor
 
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 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
 
operator[] (unsigned i) const
 returns a object by index
 
T & operator() (unsigned i) const
 returns the reference of a object by index
 
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
 
 KalFitList (int length_to_alloc=100)
 default constructor
 
 KalFitList (const KalFitList< T > &)
 copy constructor
 
 ~KalFitList ()
 destructor
 
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 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
 
operator[] (unsigned i) const
 returns a object by index
 
T & operator() (unsigned i) const
 returns the reference of a object by index
 
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 KalFitList< T >

Definition at line 11 of file InstallArea/include/KalFitAlg/KalFitAlg/KalFitList.h.

Constructor & Destructor Documentation

◆ KalFitList() [1/4]

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

default constructor

Definition at line 93 of file InstallArea/include/KalFitAlg/KalFitAlg/KalFitList.h.

94 : _length(0),
95 _remain(length_to_alloc),
96 _length_to_alloc(length_to_alloc),
97 _obj((T *) malloc(length_to_alloc * sizeof(T))){
98}

◆ KalFitList() [2/4]

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

copy constructor

Definition at line 101 of file InstallArea/include/KalFitAlg/KalFitAlg/KalFitList.h.

102 : _length(src._length),
103 _remain(src._remain),
104 _length_to_alloc(src._length_to_alloc)
105{
106 _obj = (T *) malloc((_length + _remain) * sizeof(T));
107 T * srcObj = src._obj;
108 for (int i = 0; i < _length; i++){
109 *(_obj+i) = *(srcObj+i);
110 }
111}

◆ ~KalFitList() [1/2]

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

destructor

Definition at line 115 of file InstallArea/include/KalFitAlg/KalFitAlg/KalFitList.h.

115 {
116 free(_obj);
117}

◆ KalFitList() [3/4]

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

default constructor

◆ KalFitList() [4/4]

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

copy constructor

◆ ~KalFitList() [2/2]

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

destructor

Member Function Documentation

◆ append() [1/4]

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

append objects into the end of the list

Definition at line 245 of file InstallArea/include/KalFitAlg/KalFitAlg/KalFitList.h.

246{
247 int srcLength = src._length;
248 T * srcObj = src._obj;
249 int i = 0;
250 if (_remain < srcLength){
251 _obj = (T *) realloc(_obj,(_length_to_alloc + srcLength) * sizeof(T));
252 while(i^srcLength) *(_obj+(_length++)) = *(srcObj+(i++));
253 }else{
254 while(i^srcLength) *(_obj+(_length++)) = *(srcObj+(i++));
255 _remain -= srcLength;
256 }
257 return _length;
258}

◆ append() [2/4]

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

append objects into the end of the list

◆ append() [3/4]

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

append an object into the end of the list

Definition at line 122 of file InstallArea/include/KalFitAlg/KalFitAlg/KalFitList.h.

122 {
123 if (!_remain){
124 _obj = (T *) realloc(_obj,(_length+_length_to_alloc) * sizeof(T));
125 _remain = _length_to_alloc;
126 }
127 *(_obj+(_length++)) = src;
128 _remain--;
129 return _length;
130}

Referenced by KalFitSuper_Mdc::appendHit().

◆ append() [4/4]

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

append an object into the end of the list

◆ clear() [1/2]

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

clear lists but the allocated memory remains same

Definition at line 177 of file InstallArea/include/KalFitAlg/KalFitAlg/KalFitList.h.

177 {
178 _remain += _length;
179 _length = 0;
180}

Referenced by KalFitSuper_Mdc::clear().

◆ clear() [2/2]

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

clear lists but the allocated memory remains same

◆ deleteAll() [1/2]

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

delete all object and clear(allocated memory remains same)

Definition at line 261 of file InstallArea/include/KalFitAlg/KalFitAlg/KalFitList.h.

262{
263 int i = _length;
264 while (i) delete *(_obj + (--i));
265 clear();
266}
void clear(void)
clear lists but the allocated memory remains same

◆ deleteAll() [2/2]

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

delete all object and clear(allocated memory remains same)

◆ deleteObj() [1/2]

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

delete objects by index and returns decremented index and length

Definition at line 159 of file InstallArea/include/KalFitAlg/KalFitAlg/KalFitList.h.

159 {
160 delete *(_obj+iterator);
161 *(_obj+(iterator--)) = *(_obj+(--_length));
162 _remain++;
163 return _length;
164}

◆ deleteObj() [2/2]

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

delete objects by index and returns decremented index and length

◆ first() [1/2]

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

returns the first object in the list

Definition at line 219 of file InstallArea/include/KalFitAlg/KalFitAlg/KalFitList.h.

219 {
220 return *_obj;
221}

◆ first() [2/2]

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

returns the first object in the list

◆ firstPtr() [1/2]

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

returns the pointer of first object

Definition at line 226 of file InstallArea/include/KalFitAlg/KalFitAlg/KalFitList.h.

226 {
227 return _obj;
228}

Referenced by KalFitSuper_Mdc::clear().

◆ firstPtr() [2/2]

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

returns the pointer of first object

◆ lastPtr() [1/2]

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

returns the pointer of last object

Definition at line 233 of file InstallArea/include/KalFitAlg/KalFitAlg/KalFitList.h.

233 {
234 return _obj + (_length - 1);
235}

Referenced by KalFitSuper_Mdc::clear().

◆ lastPtr() [2/2]

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

returns the pointer of last object

◆ length() [1/2]

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

returns the length of the list

Definition at line 240 of file InstallArea/include/KalFitAlg/KalFitAlg/KalFitList.h.

240 {
241 return _length;
242}

Referenced by KalFitSuper_Mdc::clear().

◆ length() [2/2]

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

returns the length of the list

◆ operator()() [1/2]

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

returns the reference of a object by index

Definition at line 212 of file InstallArea/include/KalFitAlg/KalFitAlg/KalFitList.h.

212 {
213 return *(_obj+i);
214}

◆ operator()() [2/2]

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

returns the reference of a object by index

◆ operator[]() [1/2]

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

returns a object by index

Definition at line 205 of file InstallArea/include/KalFitAlg/KalFitAlg/KalFitList.h.

205 {
206 return *(_obj+i);
207}

◆ operator[]() [2/2]

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

returns a object by index

◆ remove() [1/2]

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

remove objects by index and returns decremented index and length

Definition at line 135 of file InstallArea/include/KalFitAlg/KalFitAlg/KalFitList.h.

135 {
136 *(_obj+(iterator--)) = *(_obj+(--_length));
137 _remain++;
138 return _length;
139}

◆ remove() [2/2]

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

remove objects by index and returns decremented index and length

◆ remove2() [1/2]

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

remove objects by index

Definition at line 144 of file InstallArea/include/KalFitAlg/KalFitAlg/KalFitList.h.

144 {
145 *(_obj+iterator) = *(_obj+(--_length));
146 _remain++;
147}

◆ remove2() [2/2]

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

remove objects by index

◆ removeAll() [1/2]

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

clear lists and free memory

Definition at line 185 of file InstallArea/include/KalFitAlg/KalFitAlg/KalFitList.h.

185 {
186 free(_obj);
187 _remain = 0;
188 _length = 0;
189 _obj = NULL;
190}

◆ removeAll() [2/2]

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

clear lists and free memory

◆ removeLast() [1/2]

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

remove just last objects of the list

Definition at line 169 of file InstallArea/include/KalFitAlg/KalFitAlg/KalFitList.h.

169 {
170 _length--;
171 _remain++;
172}

◆ removeLast() [2/2]

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

remove just last objects of the list

◆ replace() [1/2]

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

replace index-th object by the object src

Definition at line 152 of file InstallArea/include/KalFitAlg/KalFitAlg/KalFitList.h.

152 {
153 *(_obj+i) = src;
154}

◆ replace() [2/2]

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

replace index-th object by the object src

◆ resize() [1/2]

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

re-allocate memory to reduce size

Definition at line 196 of file InstallArea/include/KalFitAlg/KalFitAlg/KalFitList.h.

196 {
197 _obj = (T *) realloc(_obj,_length * sizeof(T));
198 _remain = 0;
199 _length_to_alloc = _length;
200}

◆ resize() [2/2]

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

re-allocate memory to reduce size


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