kget
array.h
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 #ifndef BTARRAY_H
00021 #define BTARRAY_H
00022
00023 #include <btcore_export.h>
00024 #include "constants.h"
00025
00026 namespace bt
00027 {
00028
00035 template<class T>
00036 class BTCORE_EXPORT Array
00037 {
00038 Uint32 num;
00039 T* data;
00040 public:
00041 Array(Uint32 num = 0) : num(num),data(0)
00042 {
00043 if (num > 0)
00044 data = new T[num];
00045 }
00046
00047 ~Array()
00048 {
00049 delete [] data;
00050 }
00051
00052 T & operator [] (Uint32 i) {return data[i];}
00053 const T & operator [] (Uint32 i) const {return data[i];}
00054
00055 operator const T* () const {return data;}
00056 operator T* () {return data;}
00057
00059 Uint32 size() const {return num;}
00060
00065 void fill(T val)
00066 {
00067 for (Uint32 i = 0;i < num;i++)
00068 data[i] = val;
00069 }
00070 };
00071
00072 }
00073
00074 #endif