STK++ 0.9.13
STK::ITContainer2D< Derived > Class Template Reference

Interface base class for homogeneous 2D containers like allocators. More...

#include <STK_ITContainer2D.h>

Inheritance diagram for STK::ITContainer2D< Derived >:
Inheritance graph

Public Types

enum  {
  structure_ = hidden::Traits<Derived>::structure_ , orient_ = hidden::Traits<Derived>::orient_ , sizeRows_ = hidden::Traits<Derived>::sizeRows_ , sizeCols_ = hidden::Traits<Derived>::sizeCols_ ,
  storage_ = hidden::Traits<Derived>::storage_
}
 
typedef hidden::Traits< Derived >::Type Type
 
typedef hidden::Traits< Derived >::TypeConst TypeConst
 
typedef hidden::Traits< Derived >::Row Row
 
typedef hidden::Traits< Derived >::Col Col
 
typedef TRange< sizeRows_RowRange
 Type of the Range for the rows.
 
typedef TRange< sizeCols_ColRange
 Type of the Range for the columns.
 
typedef IContainer2D< sizeRows_, sizeCols_Base2D
 Type of the Base container.
 
typedef IRecursiveTemplate< Derived > Base
 Type of the Base container.
 
- Public Types inherited from STK::IContainer2D< hidden::Traits< Derived >::sizeRows_, hidden::Traits< Derived >::sizeCols_ >
typedef TRange< SizeRows_RowRange
 Type of the Range for the rows.
 
typedef TRange< SizeCols_ColRange
 Type of the Range for the columns.
 

Public Member Functions

Typeelt (int i, int j)
 
TypeConst elt (int i, int j) const
 
Typeelt (int i)
 
TypeConst elt (int i) const
 
Typeelt ()
 
TypeConst elt () const
 
Derived & resize (int sizeRows, int sizeCols)
 resize the container
 
Derived & resize (int size)
 Resize 1D container.
 
void shift (int firstRow, int firstCol)
 shift the first indexes of the container
 
void shift (int beg)
 shift the first indexes of the 1D container
 
- Public Member Functions inherited from STK::IContainer2D< hidden::Traits< Derived >::sizeRows_, hidden::Traits< Derived >::sizeCols_ >
 IContainer2D ()
 Default constructor.
 
 IContainer2D (RowRange const &I, ColRange const &J)
 Constructor with specified ranges.
 
 IContainer2D (IContainer2D const &T)
 Copy constructor.
 
 ~IContainer2D ()
 destructor.
 
ColRange constcols () const
 
int beginCols () const
 
int endCols () const
 
int sizeCols () const
 
RowRange constrows () const
 
int beginRows () const
 
int endRows () const
 
int sizeRows () const
 
int lastIdxCols () const
 
int lastIdxRows () const
 
bool empty () const
 
- Public Member Functions inherited from STK::IRecursiveTemplate< Derived >
Derived & asDerived ()
 static cast : return a reference of this with a cast to the derived class.
 
Derived constasDerived () const
 static cast : return a const reference of this with a cast to the derived class.
 
Derived * asPtrDerived ()
 static cast : return a ptr on a Derived of this with a cast to the derived class.
 
Derived constasPtrDerived () const
 static cast : return a ptr on a constant Derived of this with a cast to the derived class.
 
Derived * clone () const
 create a leaf using the copy constructor of the Derived class.
 
Derived * clone (bool isRef) const
 create a leaf using the copy constructor of the Derived class and a flag determining if the clone is a reference or not.
 

Protected Member Functions

 ITContainer2D ()
 Default constructor.
 
 ITContainer2D (RowRange const &I, ColRange const &J)
 constructor with specified Range.
 
 ITContainer2D (ITContainer2D const &T)
 Copy constructor.
 
 ~ITContainer2D ()
 destructor.
 
- Protected Member Functions inherited from STK::IContainer2D< hidden::Traits< Derived >::sizeRows_, hidden::Traits< Derived >::sizeCols_ >
void shift (int rbeg, int cbeg)
 Set the first index of the rows and columns.
 
void setRanges (RowRange const &I=RowRange(), ColRange const &J=ColRange())
 Set the ranges of the container.
 
void setRows (RowRange const &I=RowRange())
 Set the range of the number of rows.
 
void shiftRows (int beg)
 Set the first index of the rows.
 
void incRangeRows (int inc)
 Increment the range of the number of rows.
 
void incBeginRows (int inc)
 Increment the first index of the number of rows.
 
void decBeginRows (int dec)
 Decrement the first index of the number of rows.
 
void incEndRows (int inc)
 Increment the end of the number of rows.
 
void decEndRows (int dec)
 Decrement the end of the number of rows.
 
void setCols (ColRange const &J=ColRange())
 Set the columns range.
 
void shiftCols (int beg)
 Shift the columns first index to beg.
 
void incRangeCols (int inc)
 Increment the columns range.
 
void incBeginCols (int inc)
 increment the first index of the columns.
 
void decBeginCols (int dec)
 Decrement the columns first index.
 
void incEndCols (int inc)
 Increment the last index of the columns.
 
void decEndCols (int dec)
 Decrement the last index of the columns.
 
void exchange (IContainer2D &T)
 exchange this container with T
 
void incLastIdxRows (int inc)
 Increment the end of the number of rows.
 
void decLastIdxRows (int dec)
 Decrement the end of the number of rows.
 
void incLastIdxCols (int inc)
 Increment the last index of the columns.
 
void decLastIdxCols (int dec)
 Decrement the last index of the columns.
 
- Protected Member Functions inherited from STK::IRecursiveTemplate< Derived >
 IRecursiveTemplate ()
 constructor.
 
 ~IRecursiveTemplate ()
 destructor.
 

Detailed Description

template<class Derived>
class STK::ITContainer2D< Derived >

Interface base class for homogeneous 2D containers like allocators.

The ITContainer2D class is the template base class for all homogeneous two-dimensional containers containing element of type Type where Type is note necessarily a scalar. Some methods assume that derived class is not part of an expression and is not constant, so that it can be #- shifted, #- resized #- accessed in modification.

Implement the curious recursive template paradigm : the template parameter Derived is the name of the class that implements ITContainer2D. For example template<class Type> class Derived: public ITContainer2D< Derived<Type> > {...}

Functions used in this interface and to implement in derived class if necessary have the following definitions:

Type& elt2Impl(int i, int j);
TypeConst elt2Impl(int i, int j) const;
Type& elt1Impl(int pos);
TypeConst elt1Impl(int pos) const;
Type& elt0Impl()
TypeConst elt0Impl(int pos) const;
void shift1Impl(int beg);
void shift2Impl(int beginRows, int beginCols);
Derived& resize1Impl(int size);
resize2Impl(sizeRows, sizeCols);
hidden::Traits< Derived >::TypeConst TypeConst
hidden::Traits< Derived >::Type Type
The MultidimRegression class allows to regress a multidimensional output variable among a multivariat...
See also
IContainer2D, ICArray
Note
The constant getter elt1Impl(pos) have to return a reference as we are using derived classes for storing any kind of data.

Definition at line 84 of file STK_ITContainer2D.h.

Member Typedef Documentation

◆ Base

template<class Derived >
typedef IRecursiveTemplate<Derived> STK::ITContainer2D< Derived >::Base

Type of the Base container.

Definition at line 113 of file STK_ITContainer2D.h.

◆ Base2D

template<class Derived >
typedef IContainer2D<sizeRows_, sizeCols_ > STK::ITContainer2D< Derived >::Base2D

Type of the Base container.

Definition at line 111 of file STK_ITContainer2D.h.

◆ Col

template<class Derived >
typedef hidden::Traits<Derived>::Col STK::ITContainer2D< Derived >::Col

Definition at line 94 of file STK_ITContainer2D.h.

◆ ColRange

template<class Derived >
typedef TRange<sizeCols_> STK::ITContainer2D< Derived >::ColRange

Type of the Range for the columns.

Definition at line 108 of file STK_ITContainer2D.h.

◆ Row

template<class Derived >
typedef hidden::Traits<Derived>::Row STK::ITContainer2D< Derived >::Row

Definition at line 93 of file STK_ITContainer2D.h.

◆ RowRange

template<class Derived >
typedef TRange<sizeRows_> STK::ITContainer2D< Derived >::RowRange

Type of the Range for the rows.

Definition at line 106 of file STK_ITContainer2D.h.

◆ Type

template<class Derived >
typedef hidden::Traits<Derived>::Type STK::ITContainer2D< Derived >::Type

Definition at line 90 of file STK_ITContainer2D.h.

◆ TypeConst

template<class Derived >
typedef hidden::Traits<Derived>::TypeConst STK::ITContainer2D< Derived >::TypeConst

Definition at line 91 of file STK_ITContainer2D.h.

Member Enumeration Documentation

◆ anonymous enum

template<class Derived >
anonymous enum
Enumerator
structure_ 
orient_ 
sizeRows_ 
sizeCols_ 
storage_ 

Definition at line 96 of file STK_ITContainer2D.h.

97 {
98 structure_ = hidden::Traits<Derived>::structure_,
99 orient_ = hidden::Traits<Derived>::orient_,
100 sizeRows_ = hidden::Traits<Derived>::sizeRows_,
101 sizeCols_ = hidden::Traits<Derived>::sizeCols_,
102 storage_ = hidden::Traits<Derived>::storage_
103 };

Constructor & Destructor Documentation

◆ ITContainer2D() [1/3]

template<class Derived >
STK::ITContainer2D< Derived >::ITContainer2D ( )
inlineprotected

Default constructor.

Definition at line 117 of file STK_ITContainer2D.h.

117: Base2D(), Base() {}
IContainer2D< sizeRows_, sizeCols_ > Base2D
Type of the Base container.
IRecursiveTemplate< Derived > Base
Type of the Base container.

◆ ITContainer2D() [2/3]

template<class Derived >
STK::ITContainer2D< Derived >::ITContainer2D ( RowRange const I,
ColRange const J 
)
inlineprotected

constructor with specified Range.

Parameters
I,Jrange of the rows and columns

Definition at line 121 of file STK_ITContainer2D.h.

121: Base2D(I, J), Base() {}

◆ ITContainer2D() [3/3]

template<class Derived >
STK::ITContainer2D< Derived >::ITContainer2D ( ITContainer2D< Derived > const T)
inlineprotected

Copy constructor.

Parameters
Tthe container to copy

Definition at line 125 of file STK_ITContainer2D.h.

125: Base2D(T), Base() {}

◆ ~ITContainer2D()

template<class Derived >
STK::ITContainer2D< Derived >::~ITContainer2D ( )
inlineprotected

destructor.

Definition at line 127 of file STK_ITContainer2D.h.

127{}

Member Function Documentation

◆ elt() [1/6]

template<class Derived >
Type & STK::ITContainer2D< Derived >::elt ( )
inline
Returns
a reference on the number

Definition at line 167 of file STK_ITContainer2D.h.

167{ return this->asDerived().elt0Impl();}
Derived & asDerived()
static cast : return a reference of this with a cast to the derived class.

References STK::IRecursiveTemplate< Derived >::asDerived().

Referenced by STK::ITContainer2D< Derived >::elt(), and STK::ITContainer2D< Derived >::elt().

◆ elt() [2/6]

template<class Derived >
TypeConst STK::ITContainer2D< Derived >::elt ( ) const
inline
Returns
a constant reference on the number

Definition at line 169 of file STK_ITContainer2D.h.

169{ return this->asDerived().elt0Impl();}

References STK::IRecursiveTemplate< Derived >::asDerived().

◆ elt() [3/6]

template<class Derived >
Type & STK::ITContainer2D< Derived >::elt ( int  i)
inline
Returns
a reference on the ith element
Parameters
iindex of the element to get

Definition at line 159 of file STK_ITContainer2D.h.

159{ return this->asDerived().elt1Impl(i);}

References STK::IRecursiveTemplate< Derived >::asDerived().

◆ elt() [4/6]

template<class Derived >
TypeConst STK::ITContainer2D< Derived >::elt ( int  i) const
inline
Returns
the constant ith element
Parameters
iindex of the element to get
Note
bounds check cannot be done there as number_ does not have begin() and end() implemented

Definition at line 165 of file STK_ITContainer2D.h.

165{ return this->asDerived().elt1Impl(i);}

References STK::IRecursiveTemplate< Derived >::asDerived().

◆ elt() [5/6]

template<class Derived >
Type & STK::ITContainer2D< Derived >::elt ( int  i,
int  j 
)
inline
Returns
the element (i,j) of the 2D container.
Parameters
i,jindexes of the element to get

Definition at line 133 of file STK_ITContainer2D.h.

134 {
135#ifdef STK_BOUNDS_CHECK
136 if (this->beginRows() > i) { STKOUT_OF_RANGE_2ARG(ITContainer2D::elt, i, j, beginRows() > i);}
137 if (this->endRows() <= i) { STKOUT_OF_RANGE_2ARG(ITContainer2D::elt, i, j, endRows() <= i);}
138 if (this->beginCols() > j) { STKOUT_OF_RANGE_2ARG(ITContainer2D::elt, i, j, beginCols() > j);}
139 if (this->endCols() <= j) { STKOUT_OF_RANGE_2ARG(ITContainer2D::elt, i, j, endCols() <= j);}
140#endif
141 return this->asDerived().elt2Impl(i,j);
142 }
#define STKOUT_OF_RANGE_2ARG(Where, Arg1, Arg2, Error)
Definition STK_Macros.h:102

References STK::IRecursiveTemplate< Derived >::asDerived(), STK::IContainer2D< hidden::Traits< Derived >::sizeRows_, hidden::Traits< Derived >::sizeCols_ >::beginCols(), STK::IContainer2D< hidden::Traits< Derived >::sizeRows_, hidden::Traits< Derived >::sizeCols_ >::beginRows(), STK::ITContainer2D< Derived >::elt(), STK::IContainer2D< hidden::Traits< Derived >::sizeRows_, hidden::Traits< Derived >::sizeCols_ >::endCols(), STK::IContainer2D< hidden::Traits< Derived >::sizeRows_, hidden::Traits< Derived >::sizeCols_ >::endRows(), and STKOUT_OF_RANGE_2ARG.

◆ elt() [6/6]

◆ resize() [1/2]

template<class Derived >
Derived & STK::ITContainer2D< Derived >::resize ( int  size)
inline

Resize 1D container.

Parameters
sizethe size to set to the vector

Definition at line 179 of file STK_ITContainer2D.h.

179{ return this->asDerived().resize1Impl(size);}

References STK::IRecursiveTemplate< Derived >::asDerived().

◆ resize() [2/2]

template<class Derived >
Derived & STK::ITContainer2D< Derived >::resize ( int  sizeRows,
int  sizeCols 
)
inline

resize the container

Parameters
sizeRows,sizeColssize of the rows and columns

Definition at line 174 of file STK_ITContainer2D.h.

175 { return this->asDerived().resize2Impl(sizeRows, sizeCols);}

References STK::IRecursiveTemplate< Derived >::asDerived(), and STK::IContainer2D< hidden::Traits< Derived >::sizeRows_, hidden::Traits< Derived >::sizeCols_ >::sizeCols().

◆ shift() [1/2]

template<class Derived >
void STK::ITContainer2D< Derived >::shift ( int  beg)
inline

shift the first indexes of the 1D container

Parameters
begthe index of the first row or column

Definition at line 188 of file STK_ITContainer2D.h.

188{ this->asDerived().shift1Impl(beg);}

References STK::IRecursiveTemplate< Derived >::asDerived().

◆ shift() [2/2]

template<class Derived >
void STK::ITContainer2D< Derived >::shift ( int  firstRow,
int  firstCol 
)
inline

shift the first indexes of the container

Parameters
firstRow,firstColindexes of the first row and first column

Definition at line 184 of file STK_ITContainer2D.h.

184{ this->asDerived().shift2Impl(firstRow, firstCol);}

References STK::IRecursiveTemplate< Derived >::asDerived().


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