lltable.h

Go to the documentation of this file.
00001 
00032 #ifndef LL_LLTABLE_H
00033 #define LL_LLTABLE_H
00034 
00035 template<class T> class LLTable
00036 {
00037 private:
00038         T       *_tab;
00039         U32     _w;
00040         U32 _h;
00041         U32 _size;
00042 public:
00043         LLTable(U32 w, U32 h = 0) : _tab(0), _w(w), _h(h)
00044         {
00045                 if (_w < 0) _w = 0;
00046                 if (_h < 0) _h = 0;
00047                 if (0 == h)
00048                         _h = _w;
00049                 _size = _w * _h;
00050                 if ((_w > 0) && (_h > 0))
00051                         _tab = new T[_size];
00052         }
00053 
00054         ~LLTable()
00055         {
00056                 delete[] _tab;
00057                 _tab = NULL;
00058         }
00059 
00060         void init(const T& t)
00061         {
00062                 for (U32 i = 0; i < _size; ++i)
00063                         _tab[i] = t;
00064         }
00065         const T& at(U32 w, U32 h) const { return _tab[h * _w + w]; }
00066         T& at(U32 w, U32 h) { return _tab[h * _w + w]; }
00067         U32 size() const { return _size; }
00068         U32 w() const { return _w; }
00069         U32 h() const { return _h; }
00070 };
00071 #endif // LL_LLTABLE_H

Generated on Fri May 16 08:34:03 2008 for SecondLife by  doxygen 1.5.5