/[enigma]/enigma/src/px/array2.hh
ViewVC logotype

Diff of /enigma/src/px/array2.hh

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by dheck, Sun Mar 9 22:17:10 2003 UTC revision 1.3 by dheck, Sun Mar 23 17:17:21 2003 UTC
# Line 62  namespace px Line 62  namespace px
62          typedef const T &   const_reference;          typedef const T &   const_reference;
63          typedef typename A::size_type size_type;          typedef typename A::size_type size_type;
64    
65          explicit Array2(int ww=0, int hh=0, const T& val=T(), const A& a=A())          // Construction / Copying
66          : Array2Base<T,A>(a, ww*hh),          explicit Array2(int ww=0, int hh=0, const T& val=T(), const A& a=A());
67            w(ww), h(hh)          Array2(const Array2<T,A> &a);
         {  
             std::uninitialized_fill(first, last, val);  
         }  
   
         Array2(const Array2<T,A> &a)  
         : Array2Base<T,A>(a.alloc, a.last-a.first)  
         {  
             std::uninitialized_copy(a.begin(), a.end(), first);  
         }  
68          Array2<T,A> &operator=(Array2<T,A> a2); // call by value!          Array2<T,A> &operator=(Array2<T,A> a2); // call by value!
69    
70          // Destructor          // Destructor
# Line 106  namespace px Line 97  namespace px
97          }          }
98    
99          /*! Fill the array with some value or the default value. */          /*! Fill the array with some value or the default value. */
100          void fill (const T& val=T()) {          void fill (const T& val=T());
             destroy_elements();  
             std::uninitialized_fill(first, last, val);  
         }  
101    
102          /*! Resize the array in place, but discard any old array          /*! Resize the array in place, but discard any old array
103            entries */            entries */
104          void resize (int w, int h, const T& val=T())          void resize (int w, int h, const T& val=T());
         {  
             destroy_elements();  
             Array2Base<T,A>::resize(w*h);  
             std::uninitialized_fill(first, last, val);  
             this->w = w;  
             this->h = h;  
         }  
105    
106      private:      private:
107          size_type w, h;          size_type w, h;
# Line 132  namespace px Line 113  namespace px
113      };      };
114    
115      template <class T, class A>      template <class T, class A>
116        Array2<T,A>::Array2(int ww, int hh, const T& val, const A& a)
117        : Array2Base<T,A>(a, ww*hh), w(ww), h(hh)
118        {
119            std::uninitialized_fill(first, last, val);
120        }
121    
122        template <class T, class A>
123        Array2<T,A>::Array2(const Array2<T,A> &a)
124        : Array2Base<T,A>(a.alloc, a.last-a.first)
125        {
126            std::uninitialized_copy(a.begin(), a.end(), first);
127        }
128    
129        template <class T, class A>
130        void Array2<T,A>::fill (const T& val)
131        {
132            destroy_elements();
133            std::uninitialized_fill(first, last, val);
134        }
135    
136        /*! Resize the array in place, but discard any old array
137          entries */
138        template <class T, class A>
139        void Array2<T,A>::resize (int w, int h, const T& val)
140        {
141            destroy_elements();
142            Array2Base<T,A>::resize(w*h);
143            std::uninitialized_fill(first, last, val);
144            this->w = w;
145            this->h = h;
146        }
147    
148        template <class T, class A>
149      void Array2<T,A>::swap(Array2<T,A> &a2)      void Array2<T,A>::swap(Array2<T,A> &a2)
150      {      {
151          std::swap(first, a2.first);          std::swap(first, a2.first);

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26