STK++ 0.9.13
STK::CAllocator< Type_, UnknownSize, SizeCols_, Orient_ > Class Template Reference

Specialized Allocator for the dense Arrays classes. More...

#include <STK_CAllocator.h>

Inheritance diagram for STK::CAllocator< Type_, UnknownSize, SizeCols_, Orient_ >:
Inheritance graph

Public Types

enum  {
  structure_ = hidden::Traits<CAllocator>::structure_ , orient_ = hidden::Traits<CAllocator>::orient_ , sizeRows_ = hidden::Traits<CAllocator>::sizeRows_ , sizeCols_ = hidden::Traits<CAllocator>::sizeCols_ ,
  sizeProd_ = hidden::Traits<CAllocator>::sizeProd_ , storage_ = hidden::Traits<CAllocator>::storage_
}
 
typedef hidden::Traits< CAllocator >::Row Row
 
typedef hidden::Traits< CAllocator >::Col Col
 
typedef hidden::Traits< CAllocator >::Type Type
 
typedef hidden::Traits< CAllocator >::TypeConst TypeConst
 
typedef MemAllocator< Type, UnknownSize > Allocator
 
typedef StructuredCAllocator< CAllocator, UnknownSize, SizeCols_ > Base
 
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 columns.
 
- Public Types inherited from STK::StructuredCAllocator< CAllocator< Type_, UnknownSize, SizeCols_, Orient_ >, UnknownSize, SizeCols_ >
enum  
 
typedef hidden::Traits< CAllocator< Type_, UnknownSize, SizeCols_, Orient_ > >::Row Row
 
typedef hidden::Traits< CAllocator< Type_, UnknownSize, SizeCols_, Orient_ > >::Col Col
 
typedef hidden::Traits< CAllocator< Type_, UnknownSize, SizeCols_, Orient_ > >::Type Type
 
typedef hidden::Traits< CAllocator< Type_, UnknownSize, SizeCols_, Orient_ > >::TypeConst TypeConst
 
typedef OrientedCAllocator< CAllocator< Type_, UnknownSize, SizeCols_, Orient_ >, orient_ > Base
 
typedef IContainer2D< sizeRows_, sizeCols_ > LowBase
 
typedef hidden::Traits< CAllocator< Type_, UnknownSize, SizeCols_, Orient_ > >::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 Member Functions

 CAllocator ()
 
 CAllocator (int sizeRows, int)
 
 CAllocator (int sizeRows, int, Type const &v)
 
 CAllocator (CAllocator const &A, bool ref=true)
 
template<int OtherRows_, int OtherCols_>
 CAllocator (CAllocator< Type, OtherRows_, OtherCols_, Orient_ > const &A, RowRange const &I, ColRange const &J)
 wrap other allocator
 
 CAllocator (Type *const &q, int nbRow, int)
 wrapper constructor for 0 based C-Array
 
 ~CAllocator ()
 destructor
 
void clear ()
 clear allocated memories.
 
CAllocator & resize2Impl (int sizeRows, int)
 resize the rows
 
void realloc (int sizeRows, int)
 
- Public Member Functions inherited from STK::StructuredCAllocator< CAllocator< Type_, UnknownSize, SizeCols_, Orient_ >, UnknownSize, SizeCols_ >
void exchange (StructuredCAllocator &T)
 exchange T with this.
 
TypeConst elt1Impl (int i) const
 
Type & elt1Impl (int i)
 
void shift2Impl (int beginRows, int beginCols)
 shift the first indexes of the allocator
 
void shift1Impl (int begin)
 shift the first indexes of the allocator (for square and diagonal matrices).
 
CAllocator< Type_, UnknownSize, SizeCols_, Orient_ > & resize1Impl (int size)
 resize the allocator (for square and diagonal matrices).
 

Additional Inherited Members

- Protected Member Functions inherited from STK::StructuredCAllocator< CAllocator< Type_, UnknownSize, SizeCols_, Orient_ >, UnknownSize, SizeCols_ >
 StructuredCAllocator (RowRange const &I, ColRange const &J)
 Default constructor.
 
 StructuredCAllocator (StructuredCAllocator const &A, bool ref)
 copy constructor
 
 StructuredCAllocator (StructuredCAllocator< OtherDerived, OtherRows_, OtherCols_ > const &A, RowRange const &I, ColRange const &J)
 Reference constructor.
 
 StructuredCAllocator (Type *const &q, int nbRow, int nbCol)
 wrapper constructor for 0 based C-Array
 

Detailed Description

template<typename Type_, bool Orient_, int SizeCols_>
class STK::CAllocator< Type_, UnknownSize, SizeCols_, Orient_ >

Specialized Allocator for the dense Arrays classes.

The sizes of the columns is known, the number of rows is unknown

Definition at line 1167 of file STK_CAllocator.h.

Member Typedef Documentation

◆ Allocator

template<typename Type_ , bool Orient_, int SizeCols_>
typedef MemAllocator<Type, UnknownSize> STK::CAllocator< Type_, UnknownSize, SizeCols_, Orient_ >::Allocator

Definition at line 1186 of file STK_CAllocator.h.

◆ AllocatorRange

template<typename Type_ , bool Orient_, int SizeCols_>
typedef TRange<sizeProd_> STK::CAllocator< Type_, UnknownSize, SizeCols_, Orient_ >::AllocatorRange

Type of the Range for the columns.

Definition at line 1193 of file STK_CAllocator.h.

◆ Base

Definition at line 1187 of file STK_CAllocator.h.

◆ Col

template<typename Type_ , bool Orient_, int SizeCols_>
typedef hidden::Traits<CAllocator>::Col STK::CAllocator< Type_, UnknownSize, SizeCols_, Orient_ >::Col

Definition at line 1172 of file STK_CAllocator.h.

◆ ColRange

template<typename Type_ , bool Orient_, int SizeCols_>
typedef TRange<sizeCols_> STK::CAllocator< Type_, UnknownSize, SizeCols_, Orient_ >::ColRange

Type of the Range for the columns.

Definition at line 1191 of file STK_CAllocator.h.

◆ Row

template<typename Type_ , bool Orient_, int SizeCols_>
typedef hidden::Traits<CAllocator>::Row STK::CAllocator< Type_, UnknownSize, SizeCols_, Orient_ >::Row

Definition at line 1171 of file STK_CAllocator.h.

◆ RowRange

template<typename Type_ , bool Orient_, int SizeCols_>
typedef TRange<sizeRows_> STK::CAllocator< Type_, UnknownSize, SizeCols_, Orient_ >::RowRange

Type of the Range for the rows.

Definition at line 1189 of file STK_CAllocator.h.

◆ Type

template<typename Type_ , bool Orient_, int SizeCols_>
typedef hidden::Traits<CAllocator>::Type STK::CAllocator< Type_, UnknownSize, SizeCols_, Orient_ >::Type

Definition at line 1173 of file STK_CAllocator.h.

◆ TypeConst

template<typename Type_ , bool Orient_, int SizeCols_>
typedef hidden::Traits<CAllocator>::TypeConst STK::CAllocator< Type_, UnknownSize, SizeCols_, Orient_ >::TypeConst

Definition at line 1174 of file STK_CAllocator.h.

Member Enumeration Documentation

◆ anonymous enum

template<typename Type_ , bool Orient_, int SizeCols_>
anonymous enum
Enumerator
structure_ 
orient_ 
sizeRows_ 
sizeCols_ 
sizeProd_ 
storage_ 

Definition at line 1176 of file STK_CAllocator.h.

1177 {
1178 structure_ = hidden::Traits<CAllocator>::structure_,
1179 orient_ = hidden::Traits<CAllocator>::orient_,
1180 sizeRows_ = hidden::Traits<CAllocator>::sizeRows_,
1181 sizeCols_ = hidden::Traits<CAllocator>::sizeCols_,
1182 sizeProd_ = hidden::Traits<CAllocator>::sizeProd_,
1183 storage_ = hidden::Traits<CAllocator>::storage_
1184 };

Constructor & Destructor Documentation

◆ CAllocator() [1/6]

template<typename Type_ , bool Orient_, int SizeCols_>
STK::CAllocator< Type_, UnknownSize, SizeCols_, Orient_ >::CAllocator ( )
inline

Definition at line 1197 of file STK_CAllocator.h.

1197: Base(0, SizeCols_) {}
StructuredCAllocator< CAllocator, UnknownSize, SizeCols_ > Base

◆ CAllocator() [2/6]

template<typename Type_ , bool Orient_, int SizeCols_>
STK::CAllocator< Type_, UnknownSize, SizeCols_, Orient_ >::CAllocator ( int  sizeRows,
int   
)
inline

Definition at line 1198 of file STK_CAllocator.h.

1198: Base(sizeRows, SizeCols_) {}

◆ CAllocator() [3/6]

template<typename Type_ , bool Orient_, int SizeCols_>
STK::CAllocator< Type_, UnknownSize, SizeCols_, Orient_ >::CAllocator ( int  sizeRows,
int  ,
Type const &  v 
)
inline

Definition at line 1200 of file STK_CAllocator.h.

1200: Base(sizeRows, SizeCols_){ this->asDerived().setValue(v);}

◆ CAllocator() [4/6]

template<typename Type_ , bool Orient_, int SizeCols_>
STK::CAllocator< Type_, UnknownSize, SizeCols_, Orient_ >::CAllocator ( CAllocator< Type_, UnknownSize, SizeCols_, Orient_ > const &  A,
bool  ref = true 
)
inline

Definition at line 1201 of file STK_CAllocator.h.

1201 : Base(A, ref)
1202 { if (!ref) { allocator_.assign(A.allocator_);} }

◆ CAllocator() [5/6]

template<typename Type_ , bool Orient_, int SizeCols_>
template<int OtherRows_, int OtherCols_>
STK::CAllocator< Type_, UnknownSize, SizeCols_, Orient_ >::CAllocator ( CAllocator< Type, OtherRows_, OtherCols_, Orient_ > const &  A,
RowRange const &  I,
ColRange const &  J 
)
inline

wrap other allocator

Definition at line 1206 of file STK_CAllocator.h.

1208 : Base(A, I, J)
1209 {}

◆ CAllocator() [6/6]

template<typename Type_ , bool Orient_, int SizeCols_>
STK::CAllocator< Type_, UnknownSize, SizeCols_, Orient_ >::CAllocator ( Type *const &  q,
int  nbRow,
int   
)
inline

wrapper constructor for 0 based C-Array

Definition at line 1211 of file STK_CAllocator.h.

1211: Base(q, nbRow, SizeCols_) {}

◆ ~CAllocator()

template<typename Type_ , bool Orient_, int SizeCols_>
STK::CAllocator< Type_, UnknownSize, SizeCols_, Orient_ >::~CAllocator ( )
inline

destructor

Definition at line 1213 of file STK_CAllocator.h.

1213{}

Member Function Documentation

◆ clear()

template<typename Type_ , bool Orient_, int SizeCols_>
void STK::CAllocator< Type_, UnknownSize, SizeCols_, Orient_ >::clear ( )
inline

clear allocated memories.

Definition at line 1216 of file STK_CAllocator.h.

1216{ allocator_.free(); this->setRows();}

◆ realloc()

template<typename Type_ , bool Orient_, int SizeCols_>
void STK::CAllocator< Type_, UnknownSize, SizeCols_, Orient_ >::realloc ( int  sizeRows,
int   
)
inline

Definition at line 1235 of file STK_CAllocator.h.

1236 {
1237 // create a copy the original data set
1238 CAllocator copy;
1239 this->exchange(copy);
1240 try
1241 {
1242 // create new container
1243 resize2Impl(sizeRows, SizeCols_);
1244 this->shift2Impl(copy.beginRows(), copy.beginCols());
1245 // copy data
1246 const int endRow = std::min(copy.endRows(), this->endRows());
1247 for (int j= this->beginCols(); j < this->endCols(); ++j)
1248 for (int i = this->beginRows(); i< endRow; ++i)
1249 { this->elt(i, j) = copy.elt(i, j);}
1250 }
1251 catch (std::bad_alloc & error) // if an alloc error occur
1252 {
1253 this->exchange(copy); // restore the original container
1254 STKRUNTIME_ERROR_2ARG(Allocator::realloc, sizeRows, SizeCols_, memory allocation failed);
1255 }
1256 }
#define STKRUNTIME_ERROR_2ARG(Where, Arg1, Arg2, Error)
Definition STK_Macros.h:120
CAllocator & resize2Impl(int sizeRows, int)
resize the rows
void shift2Impl(int beginRows, int beginCols)
shift the first indexes of the allocator

References STKRUNTIME_ERROR_2ARG.

◆ resize2Impl()

template<typename Type_ , bool Orient_, int SizeCols_>
CAllocator & STK::CAllocator< Type_, UnknownSize, SizeCols_, Orient_ >::resize2Impl ( int  sizeRows,
int   
)
inline

resize the rows

Definition at line 1218 of file STK_CAllocator.h.

1219 {
1220 if (this->sizeRows() == sizeRows) return *this;
1221 if (sizeRows <= 0)// check if
1222 {
1223 // free any allocated memory if it is not a reference
1224 allocator_.free();
1225 this->setRanges(sizeRows, SizeCols_);
1226 this->setSizedIdx();
1227 return *this;
1228 }
1229 // allocate
1230 allocator_.malloc(this->prod(sizeRows, SizeCols_));
1231 this->setRanges(sizeRows, SizeCols_);
1232 this->setSizedIdx();
1233 return *this;
1234 }

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