00001
00007 #ifndef ARRAY_H
00008 #define ARRAY_H
00009
00010 template <class Elem, int Size> class Array {
00011
00012 public:
00013 Elem data[Size];
00014
00015
00016 Array(void) { ; }
00017
00018
00019 virtual ~Array(void) { ; }
00020
00021
00022 Array(const Array<Elem,Size> &a2) {
00023 for ( int i = 0; i < Size; ++i ) { data[i] = a2.data[i]; }
00024 }
00025
00026
00027 Array<Elem,Size> & operator= (const Array<Elem,Size> &a2) {
00028 for ( int i = 0; i < Size; ++i ) { data[i] = a2.data[i]; }
00029 return (*this);
00030 }
00031
00032
00033 Array(const Elem &v) {
00034 for ( int i = 0; i < Size; ++i ) { data[i] = v; }
00035 }
00036 Array<Elem,Size> & operator= (const Elem &v) {
00037 for ( int i = 0; i < Size; ++i ) { data[i] = v; }
00038 return (*this);
00039 }
00040
00041
00042 inline Elem & operator[](int index) { return data[index]; }
00043 inline const Elem & operator[](int index) const { return data[index]; }
00044
00045
00046 typedef Elem* iterator;
00047 iterator begin(void) { return &data[0]; }
00048 iterator end(void) { return &data[0] + Size; }
00049 typedef const Elem* const_iterator;
00050 const_iterator const_begin(void) const { return &data[0]; }
00051 const_iterator const_end(void) const { return &data[0] + Size; }
00052
00053 };
00054
00055 #endif
00056