25 #include "FXElement.h" 37 FXbool resize(FXival num,FXival sz);
43 template<
typename EType>
60 if(
no(n)){ fillElms(
data(),src,n); }
65 if(
no(n)){ copyElms(
data(),src,n); }
69 FXival
no()
const {
return *(((FXival*)ptr)-1); }
75 if(!resize(n,
sizeof(EType)))
return false;
76 constructElms(&
at(m),n-m);
79 destructElms(&
at(n),m-n);
80 if(!resize(n,
sizeof(EType)))
return false;
92 EType*
data(){
return reinterpret_cast<EType*
>(ptr); }
93 const EType*
data()
const {
return reinterpret_cast<const EType*
>(ptr); }
101 const EType&
at(FXival i)
const {
return data()[i]; }
105 const EType&
head()
const {
return data()[0]; }
109 const EType&
tail()
const {
return data()[
no()-1]; }
113 if(ptr!=src.ptr &&
no(0)){ swap(ptr,src.ptr); }
119 if(
no(1)){
head()=src;
return true; }
124 FXbool
assign(
const EType& src,FXival n){
125 if(
no(n)){ fillElms(
data(),src,n);
return true; }
130 FXbool
assign(
const EType* src,FXival n){
131 if(
no(n)){ copyElms(
data(),src,n);
return true; }
141 FXbool
insert(FXival pos,
const EType& src){
142 if(
no(
no()+1)){ moveElms(
data()+pos+1,
data()+pos,
no()-pos-1);
at(pos)=src;
return true; }
147 FXbool
insert(FXival pos,
const EType& src,FXival n){
148 if(
no(
no()+n)){ moveElms(
data()+pos+n,
data()+pos,
no()-pos-n); fillElms(
data()+pos,src,n);
return true; }
153 FXbool
insert(FXival pos,
const EType* src,FXival n){
154 if(
no(
no()+n)){ moveElms(
data()+pos+n,
data()+pos,
no()-pos-n); copyElms(
data()+pos,src,n);
return true; }
171 if(
no(
no()+n)){ moveElms(
data()+n,
data(),
no()-n); fillElms(
data(),src,n);
return true; }
177 if(
no(
no()+n)){ moveElms(
data()+n,
data(),
no()-n); copyElms(
data(),src,n);
return true; }
188 if(
no(
no()+1)){
tail()=src;
return true; }
193 FXbool
append(
const EType& src,FXival n){
194 if(
no(
no()+n)){ fillElms(
data()+
no()-n,src,n);
return true; }
199 FXbool
append(
const EType* src,FXival n){
200 if(
no(
no()+n)){ copyElms(
data()+
no()-n,src,n);
return true; }
216 FXbool
replace(FXival pos,FXival m,
const EType& src,FXival n){
218 if(!
no(
no()-m+n))
return false;
219 moveElms(
data()+pos+n,
data()+pos+m,
no()-pos-n);
222 moveElms(
data()+pos+n,
data()+pos+m,
no()-pos-m);
223 if(!
no(
no()-m+n))
return false;
225 fillElms(
data()+pos,src,n);
230 FXbool
replace(FXival pos,FXival m,
const EType* src,FXival n){
232 if(!
no(
no()-m+n))
return false;
233 moveElms(
data()+pos+n,
data()+pos+m,
no()-pos-n);
236 moveElms(
data()+pos+n,
data()+pos+m,
no()-pos-m);
237 if(!
no(
no()-m+n))
return false;
239 copyElms(
data()+pos,src,n);
262 if(
no(
no()+1)){
tail()=src;
return true; }
FXbool assign(const EType &src)
Assign object p to array.
Definition: FXArray.h:118
EType & operator[](FXival i)
Index into array.
Definition: FXArray.h:96
FXbool prepend(const FXArray< EType > &src)
Prepend n objects.
Definition: FXArray.h:182
FXArray< EType > & operator=(const FXArray< EType > &src)
Assign from another array.
Definition: FXArray.h:86
FXbool prepend(const EType &src)
Prepend object.
Definition: FXArray.h:164
FXbool replace(FXival pos, const EType &src)
Replace an object by other object.
Definition: FXArray.h:210
FXbool append(const FXArray< EType > &src)
Append n objects.
Definition: FXArray.h:205
FXbool append(const EType &src, FXival n)
Append n copies of object.
Definition: FXArray.h:193
FXbool pop()
Pop object from end.
Definition: FXArray.h:267
FXbool prepend(const EType *src, FXival n)
Prepend n objects.
Definition: FXArray.h:176
FXArray< EType > & adopt(FXArray< EType > &src)
Adopt array from another one; the other array becomes empty.
Definition: FXArray.h:112
FXbool insert(FXival pos, const EType *src, FXival n)
Insert n objects at specified position.
Definition: FXArray.h:153
Array of some generic type.
Definition: FXArray.h:44
FXArray(FXival n)
Allocate array of n elements.
Definition: FXArray.h:51
FXArray(const FXArray< EType > &src)
Allocate array copied from another.
Definition: FXArray.h:54
FXArray()
Allocate initially empty array.
Definition: FXArray.h:48
FXbool assign(const EType *src, FXival n)
Assign n objects to list.
Definition: FXArray.h:130
FXbool clear()
Remove all objects.
Definition: FXArray.h:272
FXbool no(FXival n)
Change number of elements in array to n.
Definition: FXArray.h:72
FXbool erase(FXival pos, FXival n)
Remove n objects starting at pos.
Definition: FXArray.h:255
FXbool insert(FXival pos, const EType &src)
Insert an object.
Definition: FXArray.h:141
FXbool push(const EType &src)
Push object to end.
Definition: FXArray.h:261
Definition: FX4Splitter.h:28
EType & at(FXival i)
Index into array.
Definition: FXArray.h:100
FXbool replace(FXival pos, FXival m, const FXArray< EType > &src)
Replace m objects at pos by other objects.
Definition: FXArray.h:244
FXbool replace(FXival pos, FXival m, const EType &src, FXival n)
Replace the m objects at pos with n copies of other object.
Definition: FXArray.h:216
FXbool insert(FXival pos, const EType &src, FXival n)
Insert n copies of object at specified position.
Definition: FXArray.h:147
FXbool replace(FXival pos, FXival m, const EType *src, FXival n)
Replace m objects at pos by n other objects.
Definition: FXArray.h:230
FXbool assign(const FXArray< EType > &src)
Assign n objects to list.
Definition: FXArray.h:136
FXbool append(const EType *src, FXival n)
Append n objects.
Definition: FXArray.h:199
EType & tail()
Last element in array.
Definition: FXArray.h:108
EType & head()
First element in array.
Definition: FXArray.h:104
FXbool assign(const EType &src, FXival n)
Assign n copies of object to array.
Definition: FXArray.h:124
FXArray(const EType *src, FXival n)
Allocate initialized with array of n objects.
Definition: FXArray.h:64
FXbool insert(FXival pos, const FXArray< EType > &src)
Insert n objects at specified position.
Definition: FXArray.h:159
FXArray(const EType &src, FXival n)
Allocate initialized with n copies of object.
Definition: FXArray.h:59
ArrayBase manages a memory buffer.
Definition: FXArray.h:32
FXbool append(const EType &src)
Append object.
Definition: FXArray.h:187
FXbool prepend(const EType &src, FXival n)
Prepend n copies of object.
Definition: FXArray.h:170
FXbool erase(FXival pos)
Remove object at pos.
Definition: FXArray.h:249
~FXArray()
Delete data.
Definition: FXArray.h:277
FXival no() const
Return number of items.
Definition: FXArray.h:69
EType * data()
Return pointer to array.
Definition: FXArray.h:92