| Rev | Line |   | 
|---|
| [658] | 1 | #ifndef PDATAARRAY_H
 | 
|---|
 | 2 | #define PDATAARRAY_H
 | 
|---|
 | 3 | #include "prefcount.h"
 | 
|---|
 | 4 | 
 | 
|---|
 | 5 | template <class T>
 | 
|---|
 | 6 | class PDataArray : public PRefCounted {
 | 
|---|
 | 7 | public:
 | 
|---|
 | 8 |                             PDataArray(long n, 
 | 
|---|
 | 9 |                                        bool isTmp=false)
 | 
|---|
 | 10 |                                                     :PRefCounted(isTmp) 
 | 
|---|
 | 11 |                                                     {data = new T[n]; sz=n;}
 | 
|---|
 | 12 |                             ~PDataArray()           {delete[] data;}
 | 
|---|
 | 13 |   
 | 
|---|
 | 14 |   T*                        Data()                  {return data;}
 | 
|---|
 | 15 |   T const*                  Data() const            {return data;}
 | 
|---|
 | 16 |   long                      Size() const            {return sz;}
 | 
|---|
 | 17 |   
 | 
|---|
 | 18 |   // Pointeurs/iterateurs
 | 
|---|
 | 19 |   T*                        begin()                 {return data;}
 | 
|---|
 | 20 |   T const*                  begin() const           {return data;}
 | 
|---|
 | 21 |   T*                        end()                   {return data+sz;}
 | 
|---|
 | 22 |   T const*                  end() const             {return data+sz;}
 | 
|---|
 | 23 | 
 | 
|---|
 | 24 |   
 | 
|---|
 | 25 |   PDataArray<T>*            Clone(bool isTmp=false) const;
 | 
|---|
 | 26 |   
 | 
|---|
 | 27 | private:
 | 
|---|
 | 28 |   T*                        data;
 | 
|---|
 | 29 |   int                       sz;
 | 
|---|
 | 30 | };
 | 
|---|
 | 31 | 
 | 
|---|
 | 32 | 
 | 
|---|
 | 33 | template <class T>
 | 
|---|
 | 34 | PDataArray<T>* PDataArray<T>::Clone(bool isTmp) const
 | 
|---|
 | 35 | {
 | 
|---|
 | 36 | #ifdef TRACE_COPY
 | 
|---|
 | 37 |   cerr << "PDataArray::Clone" << endl;
 | 
|---|
 | 38 | #endif
 | 
|---|
 | 39 |    PDataArray<T>* p = new PDataArray<T>(sz, isTmp);
 | 
|---|
 | 40 |    memcpy(p->data, data, sz*sizeof(T));
 | 
|---|
 | 41 |    return p;
 | 
|---|
 | 42 | }
 | 
|---|
 | 43 | 
 | 
|---|
 | 44 | 
 | 
|---|
 | 45 | #endif
 | 
|---|
 | 46 | 
 | 
|---|
       
      
  Note:
 See   
TracBrowser
 for help on using the repository browser.