Array.cxx
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "Array.hxx"
00023
00024 namespace CLAM
00025 {
00026 #define CLAM_NUMERIC_ARRAY_INITIALIZATION(Type) \
00027 template<> \
00028 inline void Array<Type>::InitializeElement(int i) \
00029 { \
00030 mpData[i]=0; \
00031 } \
00032
00033
00034 CLAM_NUMERIC_ARRAY_INITIALIZATION(unsigned long)
00035 CLAM_NUMERIC_ARRAY_INITIALIZATION(unsigned int)
00036 CLAM_NUMERIC_ARRAY_INITIALIZATION(unsigned short)
00037 CLAM_NUMERIC_ARRAY_INITIALIZATION(unsigned char)
00038 CLAM_NUMERIC_ARRAY_INITIALIZATION(signed long)
00039 CLAM_NUMERIC_ARRAY_INITIALIZATION(signed int)
00040 CLAM_NUMERIC_ARRAY_INITIALIZATION(signed short)
00041 CLAM_NUMERIC_ARRAY_INITIALIZATION(signed char)
00042 CLAM_NUMERIC_ARRAY_INITIALIZATION(double)
00043 CLAM_NUMERIC_ARRAY_INITIALIZATION(float)
00044
00045
00046
00048 #define CLAM_FAST_ARRAY_SPECIALIZATIONS(TYPE) \
00049 template<> \
00050 inline void Array<TYPE >::CopyDataBlock(int first, int last, \
00051 const TYPE *src) \
00052 { \
00053 if (last>first) \
00054 memcpy(&mpData[first],&src[first], \
00055 sizeof(TYPE)*(last-first)); \
00056 } \
00057 template<> \
00058 inline void Array<TYPE >::InitializeCopyDataBlock(int first, int last, \
00059 const TYPE *src) \
00060 { \
00061 if (last>first) \
00062 memcpy(&mpData[first],&src[first], \
00063 sizeof(TYPE)*(last-first)); \
00064 } \
00065 template<> \
00066 inline void Array<TYPE >::InitializeCopyDataBlock(int first, int last, \
00067 int src_first, \
00068 const TYPE *src) \
00069 { \
00070 if (last>first) \
00071 memcpy(&mpData[first],&src[src_first], \
00072 sizeof(TYPE)*(last-first)); \
00073 } \
00074 template<> \
00075 inline void Array<TYPE >::ResizeDataBuffer(int new_size) \
00076 { \
00077 mpData = (TYPE*) realloc(mpData,new_size*sizeof(TYPE)); \
00078 } \
00079 template<> \
00080 inline void Array<TYPE >::InsertElemInDataBuffer(int where) \
00081 { \
00082 memmove(&mpData[where+1],&mpData[where], \
00083 (mSize-where)*sizeof(TYPE)); \
00084 } \
00085 template<> \
00086 inline void Array<TYPE >::DeleteElemInDataBuffer(int where) \
00087 { \
00088 memmove(&mpData[where],&mpData[where+1], \
00089 (mSize-where-1)*sizeof(TYPE)); \
00090 } \
00091
00092 CLAM_FAST_ARRAY_SPECIALIZATIONS(unsigned long)
00093 CLAM_FAST_ARRAY_SPECIALIZATIONS(unsigned int)
00094 CLAM_FAST_ARRAY_SPECIALIZATIONS(unsigned short)
00095 CLAM_FAST_ARRAY_SPECIALIZATIONS(unsigned char)
00096 CLAM_FAST_ARRAY_SPECIALIZATIONS(signed long)
00097 CLAM_FAST_ARRAY_SPECIALIZATIONS(signed int)
00098 CLAM_FAST_ARRAY_SPECIALIZATIONS(signed short)
00099 CLAM_FAST_ARRAY_SPECIALIZATIONS(signed char)
00100 CLAM_FAST_ARRAY_SPECIALIZATIONS(double)
00101 CLAM_FAST_ARRAY_SPECIALIZATIONS(float)
00102
00103
00104 }
00105