#include <KalFitList.h>
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 | |
T | first (void) const |
returns the first object in the list | |
T | 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 | |
T | operator[] (unsigned i) const |
returns a object by index | |
T | 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 |
|
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 }
|
|
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 }
|
|
destructor
00115 { 00116 free(_obj); 00117 }
|
|
default constructor
|
|
copy constructor
|
|
destructor
|
|
append objects into the end of the list
|
|
append an object into the end of the list
|
|
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 }
|
|
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 }
|
|
clear lists but the allocated memory remains same
|
|
clear lists but the allocated memory remains same
|
|
delete all object and clear(allocated memory remains same)
|
|
delete all object and clear(allocated memory remains same)
|
|
delete objects by index and returns decremented index and length
|
|
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 }
|
|
returns the first object in the list
|
|
returns the first object in the list
00219 {
00220 return *_obj;
00221 }
|
|
returns the pointer of first object
|
|
returns the pointer of first object
00226 {
00227 return _obj;
00228 }
|
|
returns the pointer of last object
|
|
returns the pointer of last object
|
|
returns the length of the list
|
|
returns the length of the list
00240 {
00241 return _length;
00242 }
|
|
returns the reference of a object by index
|
|
returns the reference of a object by index
00212 { 00213 return *(_obj+i); 00214 }
|
|
returns a object by index
|
|
returns a object by index
00205 { 00206 return *(_obj+i); 00207 }
|
|
remove objects by index and returns decremented index and length
|
|
remove objects by index and returns decremented index and length
00135 { 00136 *(_obj+(iterator--)) = *(_obj+(--_length)); 00137 _remain++; 00138 return _length; 00139 }
|
|
remove objects by index
|
|
remove objects by index
|
|
clear lists and free memory
|
|
clear lists and free memory
|
|
remove just last objects of the list
|
|
remove just last objects of the list
|
|
replace index-th object by the object src
|
|
replace index-th object by the object src
00152 { 00153 *(_obj+i) = src; 00154 }
|
|
re-allocate memory to reduce size
|
|
re-allocate memory to reduce size
00196 { 00197 _obj = (T *) realloc(_obj,_length * sizeof(T)); 00198 _remain = 0; 00199 _length_to_alloc = _length; 00200 }
|
|
|
|
|
|
|
|
|
|
|