87#ifdef FTList_NO_INLINE
91#define FTList_INLINE_DEFINE_HERE
94#ifdef FTList_INLINE_DEFINE_HERE
100 _remain(length_to_alloc),
101 _length_to_alloc(length_to_alloc),
102 _obj((T *) malloc(length_to_alloc * sizeof(T))){
107 : _length(src._length),
108 _remain(src._remain),
109 _length_to_alloc(src._length_to_alloc)
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);
129 _obj = (T *) realloc(_obj,(_length+_length_to_alloc) *
sizeof(T));
130 _remain = _length_to_alloc;
132 *(_obj+(_length++)) = src;
141 *(_obj+(iterator--)) = *(_obj+(--_length));
150 *(_obj+iterator) = *(_obj+(--_length));
165 delete *(_obj+iterator);
166 *(_obj+(iterator--)) = *(_obj+(--_length));
202 _obj = (T *) realloc(_obj,_length *
sizeof(T));
204 _length_to_alloc = _length;
239 return _obj + (_length - 1);
252 int srcLength = src._length;
253 T * srcObj = src._obj;
255 if (_remain < srcLength){
256 _obj = (T *) realloc(_obj,(_length + _remain + srcLength) *
sizeof(T));
257 while(i^srcLength) *(_obj+(_length++)) = *(srcObj+(i++));
259 while(i^srcLength) *(_obj+(_length++)) = *(srcObj+(i++));
260 _remain -= srcLength;
269 while (i)
delete *(_obj + (--i));
void resize(void)
re-allocate memory to reduce size
int append(const FTList< T > &)
append objects into the end of the list
T & operator[](unsigned i) const
returns a object by index
T & first(void) const
returns the first object in the list
void deleteAll(void)
delete all object and clear(allocated memory remains same)
FTList(int length_to_alloc=100)
default constructor
void removeLast(void)
remove just last objects of the list
FTList(const FTList< T > &)
copy constructor
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 remove2(int)
remove objects by index
void clear(void)
clear lists but the allocated memory remains same
T & operator()(unsigned i) const
returns the reference of a object by index
int remove(int &)
remove objects by index and returns decremented index and length
T * lastPtr(void) const
returns the pointer of last object
int length(void) const
returns the length of the list
int append(const T &x)
append an object into the end of the list
void removeAll(void)
clear lists and free memory
T * firstPtr(void) const
returns the pointer of first object