STK::Array2D< TYPE > Class Template Reference
[Subproject STKernel::Tcontainer]

Templated Two dimensionnal Column Array. More...

#include <STK_Array2D.h>

Inherits IArray2D< TYPE, Array2D< TYPE > >.

List of all members.

Public Types

typedef Array1D< TYPE > _Cont1DType
typedef ArrayHo< TYPE > _ContHoType
typedef IArray2D< TYPE,
Array2D< TYPE > > 
_IArray2DType

Public Member Functions

 Array2D (const Inx &I=Inx(), const Inx &J=Inx())
 Array2D (const Inx &I, const Inx &J, const TYPE &v)
 Array2D (const _IArray2DType &T, bool ref=false)
 Array2D (const Array2D &T, const Inx &I, const Inx &J)
 Array2D (TYPE **q, const Inx &I, const Inx &J)
virtual ~Array2D ()
TYPE & getElt (const Integer &i, const Integer &j)
const TYPE & getElt (const Integer &i, const Integer &j) const
Array2D get2D (const Inx &I, const Inx &J) const
_Cont1DType getCol (const Inx &I, const Integer &j) const
_ContHoType getRow (Integer i, const Inx &J) const
Inx compRangeVe (const Integer &icol) const
Array2Doperator= (const Array2D &T)
Array2Doperator= (const TYPE &v)


Detailed Description

template<class TYPE>
class STK::Array2D< TYPE >

A Array2D is a col oriented 2D container. All the element are of a single type TYPE.

The elements of the Array2D can be acceded with the operators () and [].

Definition at line 86 of file STK_Array2D.h.


Member Typedef Documentation

template<class TYPE >
typedef Array1D<TYPE> STK::Array2D< TYPE >::_Cont1DType

Column type.

Definition at line 92 of file STK_Array2D.h.

template<class TYPE >
typedef ArrayHo<TYPE> STK::Array2D< TYPE >::_ContHoType

Row type.

Definition at line 95 of file STK_Array2D.h.

template<class TYPE >
typedef IArray2D<TYPE, Array2D<TYPE> > STK::Array2D< TYPE >::_IArray2DType

Type for the Interface base Class.

Definition at line 98 of file STK_Array2D.h.


Constructor & Destructor Documentation

template<class TYPE >
STK::Array2D< TYPE >::Array2D ( const Inx I = Inx(),
const Inx J = Inx() 
) [inline]

Default Ctor.

Parameters:
I range of the Rows
J range of the Cols

Definition at line 106 of file STK_Array2D.h.

References STK::IArray2D< TYPE, Array2D< TYPE > >::initializeCols().

Referenced by STK::Array2D< Real >::get2D(), and STK::Array2D< TYPE >::get2D().

00107            : _IArray2DType(I, J)
00108     {
00109       // initialize vertically the container
00110       this->initializeCols(J);
00111     }

template<class TYPE >
STK::Array2D< TYPE >::Array2D ( const Inx I,
const Inx J,
const TYPE &  v 
) [inline]

Ctor with rbeg, rend, cbeg and cend specified, initialization with a constant.

Parameters:
I range of the Rows
J range of the Cols
v initial value of the container

Definition at line 119 of file STK_Array2D.h.

References STK::Inx::first(), STK::IArrayBase< TYPE * >::getData(), STK::IArray2D< TYPE, Array2D< TYPE > >::initializeCols(), and STK::Inx::last().

00120            : _IArray2DType(I, J)
00121     {
00122       // initialize vertically the container
00123       this->initializeCols(J);
00124       // initialize with v
00125       for (Integer j=J.first(); j<=J.last(); j++)
00126       {
00127         TYPE* p(this->getData(j));
00128         for (Integer i=I.first(); i<=I.last(); i++) p[i]= v;
00129       }
00130     }

template<class TYPE >
STK::Array2D< TYPE >::Array2D ( const _IArray2DType T,
bool  ref = false 
) [inline]

Copy Ctor.

Parameters:
T the container to copy
ref true if T is wrapped

Definition at line 136 of file STK_Array2D.h.

References STK::ITContainer2D< TYPE, TContainerHo, TContainerVe, TContainer2D >::firstCol(), STK::ITContainer2D< TYPE, TContainerHo, TContainerVe, TContainer2D >::firstRow(), STK::IArrayBase< DATA >::getData(), STK::IArrayBase< TYPE * >::getData(), STK::ITContainer2D< TYPE, TContainerHo, TContainerVe, TContainer2D >::getRangeHo(), STK::IArray2D< TYPE, Array2D< TYPE > >::initializeCols(), STK::ITContainer2D< TYPE, TContainerHo, TContainerVe, TContainer2D >::lastCol(), STK::ITContainer2D< TYPE, TContainerHo, TContainerVe, TContainer2D >::lastRow(), and pt().

00137            : _IArray2DType(T, ref)
00138     {
00139       if (!ref)
00140       {
00141         // initialize the Cols and Rows
00142         this->initializeCols(T.getRangeHo());
00143         for (Integer j=T.firstCol(); j<=T.lastCol(); j++)
00144         {
00145           // ptr on the rows
00146           TYPE* p = this->getData(j);
00147           TYPE* pt= T.getData(j);
00148           for (Integer i=T.firstRow(); i<=T.lastRow(); i++) p[i]=pt[i];
00149         }
00150       }
00151     }

template<class TYPE >
STK::Array2D< TYPE >::Array2D ( const Array2D< TYPE > &  T,
const Inx I,
const Inx J 
) [inline]

Ctor by reference, ref_=1.

Parameters:
T the container to wrap
I range of the Rows to wrap
J range of the Cols to wrap

Definition at line 158 of file STK_Array2D.h.

00159            : _IArray2DType(T, I, J)
00160     { ;}

template<class TYPE >
STK::Array2D< TYPE >::Array2D ( TYPE **  q,
const Inx I,
const Inx J 
) [inline]

Wrapper Ctor. Contruct a reference container.

Parameters:
q pointer on the datas
I range of the Rows to wrap
J range of the Cols to wrap

Definition at line 167 of file STK_Array2D.h.

00168            : _IArray2DType(q, I, J)
00169     { ;}

template<class TYPE >
virtual STK::Array2D< TYPE >::~Array2D (  )  [inline, virtual]

virtual Dtor.

Definition at line 173 of file STK_Array2D.h.

00174     { ;}


Member Function Documentation

template<class TYPE >
TYPE& STK::Array2D< TYPE >::getElt ( const Integer i,
const Integer j 
) [inline]

access to one element.

Parameters:
i index of the row
j index of the col

Definition at line 182 of file STK_Array2D.h.

References STK::IArrayBase< TYPE * >::getData().

Referenced by STK::Array2D< Real >::operator=().

00183     { return this->getData(j)[i];}

template<class TYPE >
const TYPE& STK::Array2D< TYPE >::getElt ( const Integer i,
const Integer j 
) const [inline]

access to one element const.

Parameters:
i index of the row
j index of the col

Definition at line 189 of file STK_Array2D.h.

References STK::IArrayBase< TYPE * >::getData().

00190     { return this->getData(j)[i];}

template<class TYPE >
Array2D STK::Array2D< TYPE >::get2D ( const Inx I,
const Inx J 
) const [inline]

access to a sub-array.

Parameters:
I range of the rows
J range of the cols

Definition at line 196 of file STK_Array2D.h.

References STK::Array2D< TYPE >::Array2D().

00197     { return Array2D(*this, I, J);}

template<class TYPE >
_Cont1DType STK::Array2D< TYPE >::getCol ( const Inx I,
const Integer j 
) const [inline]

access to a sub-col.

Parameters:
I range of the rows
j index of the col

Definition at line 203 of file STK_Array2D.h.

References STK::IArrayBase< TYPE * >::getData().

Referenced by STK::Array2D< Real >::operator*=(), STK::Array2D< Real >::operator+=(), STK::Array2D< Real >::operator-=(), and STK::Array2D< Real >::operator/=().

00204     { return _Cont1DType(this->getData(j), I, j);}

template<class TYPE >
_ContHoType STK::Array2D< TYPE >::getRow ( Integer  i,
const Inx J 
) const [inline]

access to a sub-row.

Parameters:
i index of the row
J range of the cols

Definition at line 210 of file STK_Array2D.h.

00211     { return _ContHoType(*this, J, i);}

template<class TYPE >
Inx STK::Array2D< TYPE >::compRangeVe ( const Integer icol  )  const [inline]

pseudo virtual method required by IArray2D. compute the range of the effectively stored elements in the col icol.

Parameters:
icol the index of the column to compute the range

Definition at line 219 of file STK_Array2D.h.

References STK::ITContainer2D< TYPE, ArrayHo< TYPE >, Array1D< TYPE >, Array2D< TYPE > >::getRangeVe().

00220     {
00221       return this->getRangeVe();
00222     }

template<class TYPE >
Array2D& STK::Array2D< TYPE >::operator= ( const Array2D< TYPE > &  T  )  [inline]

operator = : overwrite the Array2D with T. We resize the object if this and T does not have the same size but if they have the same size, we don't modify the range of the object.

Parameters:
T the container to copy

Definition at line 232 of file STK_Array2D.h.

References STK::ITContainer2D< TYPE, ArrayHo< TYPE >, Array1D< TYPE >, Array2D< TYPE > >::firstCol(), STK::ITContainer2D< TYPE, TContainerHo, TContainerVe, TContainer2D >::firstCol(), STK::ITContainer2D< TYPE, ArrayHo< TYPE >, Array1D< TYPE >, Array2D< TYPE > >::firstRow(), STK::ITContainer2D< TYPE, TContainerHo, TContainerVe, TContainer2D >::firstRow(), STK::IArrayBase< DATA >::getData(), STK::IArrayBase< TYPE * >::getData(), STK::ITContainer2D< TYPE, TContainerHo, TContainerVe, TContainer2D >::getRangeHo(), STK::ITContainer2D< TYPE, TContainerHo, TContainerVe, TContainer2D >::getRangeVe(), STK::ITContainer2D< TYPE, ArrayHo< TYPE >, Array1D< TYPE >, Array2D< TYPE > >::lastCol(), STK::ITContainer2D< TYPE, TContainerHo, TContainerVe, TContainer2D >::lastCol(), STK::ITContainer2D< TYPE, ArrayHo< TYPE >, Array1D< TYPE >, Array2D< TYPE > >::lastRow(), STK::ITContainer2D< TYPE, TContainerHo, TContainerVe, TContainer2D >::lastRow(), pt(), STK::ITContainer2D< TYPE, ArrayHo< TYPE >, Array1D< TYPE >, Array2D< TYPE > >::resize(), STK::ITContainer2D< TYPE, TContainerHo, TContainerVe, TContainer2D >::sizeHo(), STK::ITContainer2D< TYPE, ArrayHo< TYPE >, Array1D< TYPE >, Array2D< TYPE > >::sizeHo(), STK::ITContainer2D< TYPE, TContainerHo, TContainerVe, TContainer2D >::sizeVe(), and STK::ITContainer2D< TYPE, ArrayHo< TYPE >, Array1D< TYPE >, Array2D< TYPE > >::sizeVe().

00233     {
00234       // Resize if necessary.
00235       if ( (this->sizeVe() != T.sizeVe())
00236          ||(this->sizeHo() != T.sizeHo())
00237          )
00238         this->resize(T.getRangeVe(), T.getRangeHo());
00239       // Copy without overlapping
00240       if (T.firstRow()>=this->firstRow())
00241       {
00242         if (T.firstCol()>=this->firstCol())
00243         {
00244           for ( Integer jt=T.firstCol(), j=this->firstCol()
00245               ; jt<=T.lastCol()
00246               ; j++, jt++
00247               )
00248           {
00249             TYPE *p =this->getData(j), *pt =T.getData(jt);
00250             for ( Integer it=T.firstRow(), i=this->firstRow()
00251                 ; it<=T.lastRow()
00252                 ; i++, it++
00253                 )
00254               p[i] = pt[it];
00255           }
00256           return *this;
00257         }
00258         // T.firstCol()<this->firstCol()
00259         for ( Integer jt=T.lastCol(), j=this->lastCol()
00260             ; jt>=T.firstCol()
00261             ; j--, jt--
00262             )
00263         {
00264           TYPE *p =this->getData(j), *pt =T.getData(jt);
00265           for ( Integer it=T.firstRow(), i=this->firstRow()
00266               ; it<=T.lastRow()
00267               ; i++, it++
00268               )
00269             p[i] = pt[it];
00270         }
00271         return *this;
00272       }
00273       // T.firstRow()<this->firstRow()
00274       if (T.firstCol()>=this->firstCol())
00275       {
00276         for ( Integer jt=T.firstCol(), j=this->firstCol()
00277             ; jt<=T.lastCol()
00278             ; j++, jt++
00279             )
00280         {
00281           TYPE *p =this->getData(j), *pt =T.getData(jt);
00282           for ( Integer it=T.lastRow(), i=this->lastRow()
00283               ; it>=T.firstRow()
00284               ; i--, it--
00285               )
00286             p[i] = pt[it] ;
00287         }
00288         return *this;
00289       }
00290       // T.firstCol()<this->firstCol()
00291       for ( Integer jt=T.lastCol(), j=this->lastCol()
00292           ; jt>=T.firstCol()
00293           ; j--, jt--
00294           )
00295       {
00296         TYPE *p =this->getData(j), *pt =T.getData(jt);
00297         for ( Integer it=T.lastRow(), i=this->lastRow()
00298             ; it>=T.firstRow()
00299             ; i--, it--
00300             )
00301           p[i] = pt[it];
00302       }
00303       return *this;
00304     }

template<class TYPE >
Array2D& STK::Array2D< TYPE >::operator= ( const TYPE &  v  )  [inline]

operator= : set the container to a constant value.

Parameters:
v the value to set

Definition at line 309 of file STK_Array2D.h.

References STK::ITContainer2D< TYPE, ArrayHo< TYPE >, Array1D< TYPE >, Array2D< TYPE > >::firstCol(), STK::ITContainer2D< TYPE, ArrayHo< TYPE >, Array1D< TYPE >, Array2D< TYPE > >::firstRow(), STK::IArrayBase< TYPE * >::getData(), STK::ITContainer2D< TYPE, ArrayHo< TYPE >, Array1D< TYPE >, Array2D< TYPE > >::lastCol(), and STK::ITContainer2D< TYPE, ArrayHo< TYPE >, Array1D< TYPE >, Array2D< TYPE > >::lastRow().

00310     {
00311       for (Integer j=this->firstCol(); j<=this->lastCol(); j++)
00312       { TYPE *p =this->getData(j);
00313         for (Integer i=this->firstRow(); i<=this->lastRow(); i++)
00314           p[i] = v;
00315       }
00316       return *this;
00317     }


The documentation for this class was generated from the following file:

Generated on Fri Sep 25 10:31:01 2009 for STK++ by  doxygen 1.5.8