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

Base class for CAllocators. More...

#include <STK_CAllocator.h>

Inheritance diagram for STK::CAllocatorBase< 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_ ,
  sizeProd_ = hidden::Traits<Derived>::sizeProd_ , storage_ = hidden::Traits<Derived>::storage_
}
 
typedef hidden::Traits< Derived >::Row Row
 
typedef hidden::Traits< Derived >::Col Col
 
typedef hidden::Traits< Derived >::Type Type
 
typedef hidden::Traits< Derived >::TypeConst TypeConst
 
typedef ITContainer2D< Derived > Base
 
typedef hidden::Traits< Derived >::Allocator Allocator
 
typedef TRange< sizeRows_RowRange
 Type of the Range for the rows.
 
typedef TRange< sizeCols_ColRange
 Type of the Range for the columns.
 
typedef TRange< sizeProd_AllocatorRange
 Type of the Range for the allocator.
 
- Public Types inherited from STK::ITContainer2D< Derived >
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

RowRange constrangeRowsInCol (int) const
 
ColRange constrangeColsInRow (int) const
 
Row row (int i) const
 Access to the ith row of the Allocator.
 
template<int Size_>
CAllocator< Type, 1, Size_, orient_row (int i, TRange< Size_ > const &J) const
 Access to the row (i,J) of the Allocator.
 
Col col (int j) const
 Access to the jth column of the Allocator.
 
template<int Size_>
CAllocator< Type, Size_, 1, orient_col (TRange< Size_ > const &I, int j) const
 Access to the column (I,j) of the Allocator.
 
template<int OtherRows_, int OtherCols_>
CAllocator< Type, OtherRows_, OtherCols_, orient_sub (TRange< OtherRows_ > const &I, TRange< OtherCols_ > const &J) const
 Access to the sub-part (I,J) of the Allocator.
 
void swapCols (int pos1, int pos2)
 
void swapRows (int pos1, int pos2)
 
- Public Member Functions inherited from STK::ITContainer2D< Derived >
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

 CAllocatorBase ()
 default constructor
 
 CAllocatorBase (RowRange const &I, ColRange const &J)
 constructor
 
 CAllocatorBase (CAllocatorBase const &A)
 copy constructor
 
- Protected Member Functions inherited from STK::ITContainer2D< Derived >
 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::CAllocatorBase< Derived >

Base class for CAllocators.

Definition at line 89 of file STK_CAllocator.h.

Member Typedef Documentation

◆ Allocator

template<class Derived >
typedef hidden::Traits<Derived>::Allocator STK::CAllocatorBase< Derived >::Allocator

Definition at line 107 of file STK_CAllocator.h.

◆ AllocatorRange

template<class Derived >
typedef TRange<sizeProd_> STK::CAllocatorBase< Derived >::AllocatorRange

Type of the Range for the allocator.

Definition at line 114 of file STK_CAllocator.h.

◆ Base

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

Definition at line 106 of file STK_CAllocator.h.

◆ Col

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

Definition at line 93 of file STK_CAllocator.h.

◆ ColRange

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

Type of the Range for the columns.

Definition at line 112 of file STK_CAllocator.h.

◆ Row

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

Definition at line 92 of file STK_CAllocator.h.

◆ RowRange

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

Type of the Range for the rows.

Definition at line 110 of file STK_CAllocator.h.

◆ Type

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

Definition at line 94 of file STK_CAllocator.h.

◆ TypeConst

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

Definition at line 95 of file STK_CAllocator.h.

Member Enumeration Documentation

◆ anonymous enum

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

Definition at line 97 of file STK_CAllocator.h.

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

Constructor & Destructor Documentation

◆ CAllocatorBase() [1/3]

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

default constructor

Definition at line 118 of file STK_CAllocator.h.

118: Base() {}
ITContainer2D< Derived > Base

◆ CAllocatorBase() [2/3]

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

constructor

Definition at line 120 of file STK_CAllocator.h.

120: Base(I, J) {}

◆ CAllocatorBase() [3/3]

template<class Derived >
STK::CAllocatorBase< Derived >::CAllocatorBase ( CAllocatorBase< Derived > const A)
inlineprotected

copy constructor

Definition at line 122 of file STK_CAllocator.h.

122: Base(A){}

Member Function Documentation

◆ col() [1/2]

template<class Derived >
Col STK::CAllocatorBase< Derived >::col ( int  j) const
inline

Access to the jth column of the Allocator.

Parameters
jindex of the column
Returns
a reference on the jth column

Definition at line 163 of file STK_CAllocator.h.

164 {
165#ifdef STK_BOUNDS_CHECK
166 if (this->beginCols() > j) { STKOUT_OF_RANGE_1ARG(CAllocatorBase::col, j, beginCols() > j);}
167 if (this->endCols() <= j) { STKOUT_OF_RANGE_1ARG(CAllocatorBase::col, j, endCols() <= j);}
168#endif
169 return Col(this->asDerived(), this->rows(), TRange<1>(j,1));
170 }
#define STKOUT_OF_RANGE_1ARG(Where, Arg, Error)
Definition STK_Macros.h:93
hidden::Traits< Derived >::Col Col
Col col(int j) const
Access to the jth column of the Allocator.
Derived & asDerived()
static cast : return a reference of this with a cast to the derived class.

References STKOUT_OF_RANGE_1ARG.

◆ col() [2/2]

template<class Derived >
template<int Size_>
CAllocator< Type, Size_, 1, orient_ > STK::CAllocatorBase< Derived >::col ( TRange< Size_ > const I,
int  j 
) const
inline

Access to the column (I,j) of the Allocator.

Parameters
I,jrange of the rows and index of the column
Returns
a reference on the jth column

Definition at line 176 of file STK_CAllocator.h.

177 {
178#ifdef STK_BOUNDS_CHECK
179 if (this->beginCols() > j) { STKOUT_OF_RANGE_2ARG(CAllocatorBase::col, I, j, beginCols() > j);}
180 if (this->endCols() <= j) { STKOUT_OF_RANGE_2ARG(CAllocatorBase::col, I, j, endCols() <= j);}
181 if (this->beginRows() > I.begin()) { STKOUT_OF_RANGE_2ARG(CAllocatorBase::col, I, j, beginRows() > I.begin());}
182 if (this->endRows() < I.end()) { STKOUT_OF_RANGE_2ARG(CAllocatorBase::col, I, j, endRows() < I.end());}
183#endif
184 return CAllocator<Type, Size_, 1, orient_>(this->asDerived(), I, TRange<1>(j,1));
185 }
#define STKOUT_OF_RANGE_2ARG(Where, Arg1, Arg2, Error)
Definition STK_Macros.h:102

References STKOUT_OF_RANGE_2ARG.

◆ rangeColsInRow()

template<class Derived >
ColRange const & STK::CAllocatorBase< Derived >::rangeColsInRow ( int  ) const
inline
Returns
the range of the effectively stored elements in the row.

Definition at line 129 of file STK_CAllocator.h.

◆ rangeRowsInCol()

template<class Derived >
RowRange const & STK::CAllocatorBase< Derived >::rangeRowsInCol ( int  ) const
inline
Returns
the range of the effectively stored elements in the column.

Definition at line 127 of file STK_CAllocator.h.

127{ return this->rows();}

◆ row() [1/2]

template<class Derived >
Row STK::CAllocatorBase< Derived >::row ( int  i) const
inline

Access to the ith row of the Allocator.

Parameters
iindex of the row
Returns
a reference on the ith row

Definition at line 135 of file STK_CAllocator.h.

136 {
137#ifdef STK_BOUNDS_CHECK
138 if (this->beginRows() > i) { STKOUT_OF_RANGE_1ARG(CAllocatorBase::row, i, beginRows() > i);}
139 if (this->endRows() <= i) { STKOUT_OF_RANGE_1ARG(CAllocatorBase::row, i, endRows() <= i);}
140#endif
141 return Row(this->asDerived(), TRange<1>(i,1), this->cols());
142 }
hidden::Traits< Derived >::Row Row
Row row(int i) const
Access to the ith row of the Allocator.

References STKOUT_OF_RANGE_1ARG.

◆ row() [2/2]

template<class Derived >
template<int Size_>
CAllocator< Type, 1, Size_, orient_ > STK::CAllocatorBase< Derived >::row ( int  i,
TRange< Size_ > const J 
) const
inline

Access to the row (i,J) of the Allocator.

Parameters
i,Jindex of the row and range of the columns
Returns
a reference on the ith row

Definition at line 148 of file STK_CAllocator.h.

149 {
150#ifdef STK_BOUNDS_CHECK
151 if (this->beginRows() > i) { STKOUT_OF_RANGE_2ARG(CAllocatorBase::row, i, J, beginRows() > i);}
152 if (this->endRows() <= i) { STKOUT_OF_RANGE_2ARG(CAllocatorBase::row, i, J, endRows() <= i);}
153 if (this->beginCols() > J.begin()) { STKOUT_OF_RANGE_2ARG(CAllocatorBase::row, i, J, beginCols() > J.begin());}
154 if (this->endCols() < J.end()) { STKOUT_OF_RANGE_2ARG(CAllocatorBase::row, i, J, endCols() < J.end());}
155#endif
156 return CAllocator<Type, 1, Size_, orient_>(this->asDerived(), TRange<1>(i,1), J);
157 }

References STKOUT_OF_RANGE_2ARG.

◆ sub()

template<class Derived >
template<int OtherRows_, int OtherCols_>
CAllocator< Type, OtherRows_, OtherCols_, orient_ > STK::CAllocatorBase< Derived >::sub ( TRange< OtherRows_ > const I,
TRange< OtherCols_ > const J 
) const
inline

Access to the sub-part (I,J) of the Allocator.

Parameters
I,Jrange of the rows and columns
Returns
a reference on a sub-part of the Allocator

Definition at line 193 of file STK_CAllocator.h.

194 {
195#ifdef STK_BOUNDS_CHECK
196 if (this->beginRows() > I.begin()) { STKOUT_OF_RANGE_2ARG(CAllocatorBase::sub, I, J, beginRows() > I.begin());}
197 if (this->endRows() < I.end()) { STKOUT_OF_RANGE_2ARG(CAllocatorBase::sub, I, J, endRows() < I.end());}
198 if (this->beginCols() > J.begin()) { STKOUT_OF_RANGE_2ARG(CAllocatorBase::sub, I, J, beginCols() > j);}
199 if (this->endCols() < J.end()) { STKOUT_OF_RANGE_2ARG(CAllocatorBase::sub, I, J, endCols() <= j);}
200#endif
201 return CAllocator<Type, OtherRows_, OtherCols_, orient_>(this->asDerived(), I, J);
202 }
CAllocator< Type, OtherRows_, OtherCols_, orient_ > sub(TRange< OtherRows_ > const &I, TRange< OtherCols_ > const &J) const
Access to the sub-part (I,J) of the Allocator.

References STKOUT_OF_RANGE_2ARG.

◆ swapCols()

template<class Derived >
void STK::CAllocatorBase< Derived >::swapCols ( int  pos1,
int  pos2 
)
inline
Parameters
pos1,pos2position of the first and second columns to swap

Definition at line 206 of file STK_CAllocator.h.

207 {
208#ifdef STK_BOUNDS_CHECK
209 if (this->beginCols() > pos1)
211 if (this->endCols() <= pos1)
213 if (this->beginCols() > pos2)
215 if (this->endCols() <= pos2)
217#endif
218 for (int i=this->beginRows(); i< this->endRows(); ++i)
219 { std::swap(this->asDerived().elt2Impl(i, pos1),this->asDerived().elt2Impl(i, pos2));}
220 }
void swapCols(int pos1, int pos2)

References STKOUT_OF_RANGE_2ARG.

◆ swapRows()

template<class Derived >
void STK::CAllocatorBase< Derived >::swapRows ( int  pos1,
int  pos2 
)
inline
Parameters
pos1,pos2position of the first and second rows to swap

Definition at line 222 of file STK_CAllocator.h.

223 {
224#ifdef STK_BOUNDS_CHECK
225 if (this->beginRows() > pos1)
227 if (this->endRows() <= pos1)
229 if (this->beginRows() > pos2)
231 if (this->endRows() <= pos2)
233#endif
234 for (int j=this->beginCols(); j< this->endCols(); ++j)
235 { std::swap(this->asDerived().elt2Impl(pos1, j),this->asDerived().elt2Impl(pos2, j));}
236 }
void swapRows(int pos1, int pos2)

References STKOUT_OF_RANGE_2ARG.


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