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