#include <FTList.h>
Public Member Functions | |
int | append (const FTList< T > &) |
append objects into the end of the list | |
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 | append (const 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 | |
FTList (const FTList< T > &) | |
copy constructor | |
FTList (int length_to_alloc=100) | |
default constructor | |
FTList (const FTList< T > &) | |
copy constructor | |
FTList (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 | |
~FTList () | |
destructor | |
~FTList () | |
destructor | |
Private Attributes | |
int | _length |
int | _length_to_alloc |
T * | _obj |
T * | _obj |
int | _remain |
|
default constructor
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 }
|
|
copy constructor
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 }
|
|
destructor
00120 { 00121 free(_obj); 00122 }
|
|
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
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 }
|
|
append an object into the end of the list
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 }
|
|
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
00164 { 00165 delete *(_obj+iterator); 00166 *(_obj+(iterator--)) = *(_obj+(--_length)); 00167 _remain++; 00168 return _length; 00169 }
|
|
returns the first object in the list
|
|
returns the first object in the list
00224 {
00225 return *_obj;
00226 }
|
|
returns the pointer of first object
|
|
returns the pointer of first object
00231 {
00232 return _obj;
00233 }
|
|
returns the pointer of last object
|
|
returns the pointer of last object
|
|
returns the length of the list
|
|
returns the length of the list
00245 {
00246 return _length;
00247 }
|
|
returns the reference of a object by index
|
|
returns the reference of a object by index
00217 { 00218 return *(_obj+i); 00219 }
|
|
returns a object by index
|
|
returns a object by index
00210 { 00211 return *(_obj+i); 00212 }
|
|
remove objects by index and returns decremented index and length
|
|
remove objects by index and returns decremented index and length
00140 { 00141 *(_obj+(iterator--)) = *(_obj+(--_length)); 00142 _remain++; 00143 return _length; 00144 }
|
|
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
00157 { 00158 *(_obj+i) = src; 00159 }
|
|
re-allocate memory to reduce size
|
|
re-allocate memory to reduce size
00201 { 00202 _obj = (T *) realloc(_obj,_length * sizeof(T)); 00203 _remain = 0; 00204 _length_to_alloc = _length; 00205 }
|
|
|
|
|
|
|
|
|
|
|