00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef FXELEMENT_H
00022 #define FXELEMENT_H
00023
00024 namespace FX {
00025
00026
00027
00028
00029
00030
00032 template<class EType>
00033 inline void constructElms(EType* ptr,unsigned long n){
00034 while(n--){ ::new ((void*)ptr) EType; ptr++; }
00035 }
00036
00037
00039 template<class EType>
00040 inline void destructElms(EType* ptr,unsigned long n){
00041 while(n--){ ptr->~EType(); ptr++; }
00042 }
00043
00044
00046 template<class EType, class OType>
00047 inline void copyElms(EType* dst,const OType* src,unsigned long n){
00048 while(n--){ *dst++ = *src++; }
00049 }
00050
00051
00053 template<class EType>
00054 inline void moveElms(EType* dst,const EType* src,unsigned long n){
00055 if(src>dst){
00056 while(n--){ *dst++ = *src++; }
00057 }
00058 else if(dst>src){
00059 dst+=n;
00060 src+=n;
00061 while(n--){ *--dst = *--src; }
00062 }
00063 }
00064
00065
00067 template<class EType, class OType>
00068 inline void fillElms(EType* dst,const OType& src,unsigned long n){
00069 while(n--){ *dst++ = src; }
00070 }
00071
00072
00074 template<class EType>
00075 inline void clearElms(EType* dst,unsigned long n){
00076 memset(dst,0,sizeof(EType)*n);
00077 }
00078
00079
00081 template<class EType>
00082 inline FXbool allocElms(EType*& ptr,unsigned long n){
00083 return fxmalloc((void**)&ptr,sizeof(EType)*n);
00084 }
00085
00086
00088 template<class EType>
00089 inline FXbool callocElms(EType*& ptr,unsigned long n){
00090 return fxcalloc((void**)&ptr,sizeof(EType)*n);
00091 }
00092
00093
00095 template<class EType>
00096 inline FXbool dupElms(EType*& ptr,const EType* src,unsigned long n){
00097 return fxmemdup((void**)&ptr,src,sizeof(EType)*n);
00098 }
00099
00100
00102 template<class EType>
00103 inline FXbool resizeElms(EType*& ptr,unsigned long n){
00104 return fxresize((void**)&ptr,sizeof(EType)*n);
00105 }
00106
00107
00109 template<class EType>
00110 inline void freeElms(EType*& ptr){
00111 fxfree((void**)&ptr);
00112 }
00113
00114
00115
00116
00117
00118
00119
00120
00121 inline void constructElms(FXuchar*,unsigned long){ }
00122 inline void constructElms(FXchar*,unsigned long){ }
00123 inline void constructElms(FXushort*,unsigned long){ }
00124 inline void constructElms(FXshort*,unsigned long){ }
00125 inline void constructElms(FXuint*,unsigned long){ }
00126 inline void constructElms(FXint*,unsigned long){ }
00127 inline void constructElms(FXfloat*,unsigned long){ }
00128 inline void constructElms(FXdouble*,unsigned long){ }
00129
00130
00131 inline void destructElms(FXuchar*,unsigned long){ }
00132 inline void destructElms(FXchar*,unsigned long){ }
00133 inline void destructElms(FXushort*,unsigned long){ }
00134 inline void destructElms(FXshort*,unsigned long){ }
00135 inline void destructElms(FXuint*,unsigned long){ }
00136 inline void destructElms(FXint*,unsigned long){ }
00137 inline void destructElms(FXfloat*,unsigned long){ }
00138 inline void destructElms(FXdouble*,unsigned long){ }
00139
00140
00141 inline void copyElms(FXuchar* dst,const FXuchar* src,unsigned long n){ memcpy(dst,src,n); }
00142 inline void copyElms(FXchar* dst,const FXchar* src,unsigned long n){ memcpy(dst,src,n); }
00143 inline void copyElms(FXushort* dst,const FXushort* src,unsigned long n){ memcpy(dst,src,n<<1); }
00144 inline void copyElms(FXshort* dst,const FXshort* src,unsigned long n){ memcpy(dst,src,n<<1); }
00145 inline void copyElms(FXuint* dst,const FXuint* src,unsigned long n){ memcpy(dst,src,n<<2); }
00146 inline void copyElms(FXint* dst,const FXint* src,unsigned long n){ memcpy(dst,src,n<<2); }
00147 inline void copyElms(FXfloat* dst,const FXfloat* src,unsigned long n){ memcpy(dst,src,n<<2); }
00148 inline void copyElms(FXdouble* dst,const FXdouble* src,unsigned long n){ memcpy(dst,src,n<<3); }
00149
00150
00151 template<class EType> inline void copyElms(EType** dst,const EType** src,unsigned long n){ memcpy(dst,src,n*sizeof(void*)); }
00152
00153
00154 inline void moveElms(FXuchar* dst,const FXuchar* src,unsigned long n){ memmove(dst,src,n); }
00155 inline void moveElms(FXchar* dst,const FXchar* src,unsigned long n){ memmove(dst,src,n); }
00156 inline void moveElms(FXushort* dst,const FXushort* src,unsigned long n){ memmove(dst,src,n<<1); }
00157 inline void moveElms(FXshort* dst,const FXshort* src,unsigned long n){ memmove(dst,src,n<<1); }
00158 inline void moveElms(FXuint* dst,const FXuint* src,unsigned long n){ memmove(dst,src,n<<2); }
00159 inline void moveElms(FXint* dst,const FXint* src,unsigned long n){ memmove(dst,src,n<<2); }
00160 inline void moveElms(FXfloat* dst,const FXfloat* src,unsigned long n){ memmove(dst,src,n<<2); }
00161 inline void moveElms(FXdouble* dst,const FXdouble* src,unsigned long n){ memmove(dst,src,n<<3); }
00162
00163
00164 template<class EType> inline void moveElms(EType** dst,const EType** src,unsigned long n){ memmove(dst,src,n*sizeof(void*)); }
00165
00166
00167 inline void fillElms(FXuchar* dst,const FXuchar& src,unsigned long n){ memset(dst,src,n); }
00168 inline void fillElms(FXchar* dst,const FXchar& src,unsigned long n){ memset(dst,src,n); }
00169
00170 }
00171
00172 #endif