#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 | |
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 |
Definition at line 11 of file KalFitList.h.
KalFitList< T >::KalFitList | ( | int | length_to_alloc = 100 |
) | [inline] |
default constructor
Definition at line 93 of file KalFitList.h.
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 }
KalFitList< T >::KalFitList | ( | const KalFitList< T > & | ) |
copy constructor
Definition at line 101 of file KalFitList.h.
References KalFitList< T >::_length, KalFitList< T >::_obj, KalFitList< T >::_remain, genRecEmupikp::i, and T.
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 }
KalFitList< T >::~KalFitList | ( | ) | [inline] |
destructor
Definition at line 115 of file KalFitList.h.
References KalFitList< T >::_obj.
00115 { 00116 free(_obj); 00117 }
int KalFitList< T >::append | ( | const KalFitList< T > & | ) |
append objects into the end of the list
Definition at line 245 of file KalFitList.h.
References KalFitList< T >::_length, KalFitList< T >::_length_to_alloc, KalFitList< T >::_obj, KalFitList< T >::_remain, genRecEmupikp::i, and T.
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 }
int KalFitList< T >::append | ( | T | x | ) | [inline] |
append an object into the end of the list
Definition at line 122 of file KalFitList.h.
References KalFitList< T >::_length, KalFitList< T >::_length_to_alloc, KalFitList< T >::_obj, KalFitList< T >::_remain, and T.
Referenced by KalFitSuper_Mdc::appendHit().
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 }
void KalFitList< T >::clear | ( | void | ) | [inline] |
clear lists but the allocated memory remains same
Definition at line 177 of file KalFitList.h.
References KalFitList< T >::_length, and KalFitList< T >::_remain.
Referenced by KalFitSuper_Mdc::clear(), and KalFitList< T >::deleteAll().
void KalFitList< T >::deleteAll | ( | void | ) |
delete all object and clear(allocated memory remains same)
Definition at line 261 of file KalFitList.h.
References KalFitList< T >::_length, KalFitList< T >::_obj, KalFitList< T >::clear(), and genRecEmupikp::i.
int KalFitList< T >::deleteObj | ( | int & | ) | [inline] |
delete objects by index and returns decremented index and length
Definition at line 159 of file KalFitList.h.
References KalFitList< T >::_length, KalFitList< T >::_obj, and KalFitList< T >::_remain.
00159 { 00160 delete *(_obj+iterator); 00161 *(_obj+(iterator--)) = *(_obj+(--_length)); 00162 _remain++; 00163 return _length; 00164 }
T KalFitList< T >::first | ( | void | ) | const [inline] |
returns the first object in the list
Definition at line 219 of file KalFitList.h.
References KalFitList< T >::_obj.
00219 { 00220 return *_obj; 00221 }
T * KalFitList< T >::firstPtr | ( | void | ) | const [inline] |
returns the pointer of first object
Definition at line 226 of file KalFitList.h.
References KalFitList< T >::_obj.
Referenced by KalFitSuper_Mdc::clear().
00226 { 00227 return _obj; 00228 }
T * KalFitList< T >::lastPtr | ( | void | ) | const [inline] |
returns the pointer of last object
Definition at line 233 of file KalFitList.h.
References KalFitList< T >::_length, and KalFitList< T >::_obj.
Referenced by KalFitSuper_Mdc::clear().
int KalFitList< T >::length | ( | void | ) | const [inline] |
returns the length of the list
Definition at line 240 of file KalFitList.h.
References KalFitList< T >::_length.
Referenced by KalFitSuper_Mdc::clear().
00240 { 00241 return _length; 00242 }
T & KalFitList< T >::operator() | ( | unsigned | i | ) | const [inline] |
returns the reference of a object by index
Definition at line 212 of file KalFitList.h.
References KalFitList< T >::_obj.
T KalFitList< T >::operator[] | ( | unsigned | i | ) | const [inline] |
returns a object by index
Definition at line 205 of file KalFitList.h.
References KalFitList< T >::_obj.
int KalFitList< T >::remove | ( | int & | ) | [inline] |
remove objects by index and returns decremented index and length
Definition at line 135 of file KalFitList.h.
References KalFitList< T >::_length, KalFitList< T >::_obj, and KalFitList< T >::_remain.
00135 { 00136 *(_obj+(iterator--)) = *(_obj+(--_length)); 00137 _remain++; 00138 return _length; 00139 }
void KalFitList< T >::remove2 | ( | int | ) | [inline] |
remove objects by index
Definition at line 144 of file KalFitList.h.
References KalFitList< T >::_length, KalFitList< T >::_obj, and KalFitList< T >::_remain.
void KalFitList< T >::removeAll | ( | void | ) | [inline] |
clear lists and free memory
Definition at line 185 of file KalFitList.h.
References KalFitList< T >::_length, KalFitList< T >::_obj, and KalFitList< T >::_remain.
void KalFitList< T >::removeLast | ( | void | ) | [inline] |
remove just last objects of the list
Definition at line 169 of file KalFitList.h.
References KalFitList< T >::_length, and KalFitList< T >::_remain.
void KalFitList< T >::replace | ( | int | i, | |
T | src | |||
) | [inline] |
replace index-th object by the object src
Definition at line 152 of file KalFitList.h.
References KalFitList< T >::_obj.
void KalFitList< T >::resize | ( | void | ) | [inline] |
re-allocate memory to reduce size
Definition at line 196 of file KalFitList.h.
References KalFitList< T >::_length, KalFitList< T >::_length_to_alloc, KalFitList< T >::_obj, KalFitList< T >::_remain, and T.
00196 { 00197 _obj = (T *) realloc(_obj,_length * sizeof(T)); 00198 _remain = 0; 00199 _length_to_alloc = _length; 00200 }
int KalFitList< T >::_length [private] |
Definition at line 75 of file KalFitList.h.
Referenced by KalFitList< T >::append(), KalFitList< T >::clear(), KalFitList< T >::deleteAll(), KalFitList< T >::deleteObj(), KalFitList< T >::KalFitList(), KalFitList< T >::lastPtr(), KalFitList< T >::length(), KalFitList< T >::remove(), KalFitList< T >::remove2(), KalFitList< T >::removeAll(), KalFitList< T >::removeLast(), and KalFitList< T >::resize().
int KalFitList< T >::_length_to_alloc [private] |
Definition at line 77 of file KalFitList.h.
Referenced by KalFitList< T >::append(), and KalFitList< T >::resize().
T* KalFitList< T >::_obj [private] |
Definition at line 78 of file KalFitList.h.
Referenced by KalFitList< T >::append(), KalFitList< T >::deleteAll(), KalFitList< T >::deleteObj(), KalFitList< T >::first(), KalFitList< T >::firstPtr(), KalFitList< T >::KalFitList(), KalFitList< T >::lastPtr(), KalFitList< T >::operator()(), KalFitList< T >::operator[](), KalFitList< T >::remove(), KalFitList< T >::remove2(), KalFitList< T >::removeAll(), KalFitList< T >::replace(), KalFitList< T >::resize(), and KalFitList< T >::~KalFitList().
int KalFitList< T >::_remain [private] |
Definition at line 76 of file KalFitList.h.
Referenced by KalFitList< T >::append(), KalFitList< T >::clear(), KalFitList< T >::deleteObj(), KalFitList< T >::KalFitList(), KalFitList< T >::remove(), KalFitList< T >::remove2(), KalFitList< T >::removeAll(), KalFitList< T >::removeLast(), and KalFitList< T >::resize().