STK++ 0.9.13
STK::OrientedCAllocator< Derived, Arrays::by_col_ > Class Template Reference

Specialization for column-oriented Allocators. More...

#include <STK_CAllocator.h>

Inheritance diagram for STK::OrientedCAllocator< Derived, Arrays::by_col_ >:
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 CAllocatorBase< 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::CAllocatorBase< Derived >
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

AllocatorRange range () const
 
int begin () const
 
int end () const
 
int size () const
 
bool isRef () const
 
Type *constp_data () const
 
Allocator constallocator () const
 
int ldx () const
 
TypeConst elt2Impl (int i, int j) const
 
Typeelt2Impl (int i, int j)
 
void setValue (TypeConst v)
 set a value to this allocator.
 
Derived & move (OrientedCAllocator const &T)
 move T to this without copying data
 
- Public Member Functions inherited from STK::CAllocatorBase< Derived >
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

 OrientedCAllocator (RowRange const &I, ColRange const &J)
 default constructor
 
 OrientedCAllocator (OrientedCAllocator const &A, bool ref)
 copy constructor
 
template<class OtherDerived >
 OrientedCAllocator (OrientedCAllocator< OtherDerived, Arrays::by_col_ > const &A, RowRange const &I, ColRange const &J)
 Reference constructor.
 
 OrientedCAllocator (Type *const &q, int nbRow, int nbCol)
 wrapper constructor for 0 based C-Array
 
 ~OrientedCAllocator ()
 destructor
 
void moveImpl (OrientedCAllocator const &T)
 do nothing by default
 
void exchange (OrientedCAllocator &T)
 exchange T with this.
 
int shiftInc (int beginRows, int beginCols)
 return the increment to apply to a zero based pointer corresponding to the actual first row and first column indexes.
 
void setSizedIdx ()
 set the index corresponding to the actual size of the allocator.
 
- Protected Member Functions inherited from STK::CAllocatorBase< Derived >
 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.
 

Static Protected Member Functions

static Range prod (Range const &I, Range const &J)
 Compute the range of the 1D Allocator when we want to allocate a 2D array with range I for the rows and range J for the columns.
 

Protected Attributes

int ldx_
 leading dimension of the data set
 
Allocator allocator_
 manager of the memory
 

Detailed Description

template<class Derived>
class STK::OrientedCAllocator< Derived, Arrays::by_col_ >

Specialization for column-oriented Allocators.

Definition at line 244 of file STK_CAllocator.h.

Member Typedef Documentation

◆ Allocator

template<class Derived >
typedef hidden::Traits<Derived>::Allocator STK::OrientedCAllocator< Derived, Arrays::by_col_ >::Allocator

Definition at line 262 of file STK_CAllocator.h.

◆ AllocatorRange

template<class Derived >
typedef TRange<sizeProd_> STK::OrientedCAllocator< Derived, Arrays::by_col_ >::AllocatorRange

Type of the Range for the allocator.

Definition at line 269 of file STK_CAllocator.h.

◆ Base

template<class Derived >
typedef CAllocatorBase<Derived> STK::OrientedCAllocator< Derived, Arrays::by_col_ >::Base

Definition at line 261 of file STK_CAllocator.h.

◆ Col

template<class Derived >
typedef hidden::Traits<Derived>::Col STK::OrientedCAllocator< Derived, Arrays::by_col_ >::Col

Definition at line 248 of file STK_CAllocator.h.

◆ ColRange

template<class Derived >
typedef TRange<sizeCols_> STK::OrientedCAllocator< Derived, Arrays::by_col_ >::ColRange

Type of the Range for the columns.

Definition at line 267 of file STK_CAllocator.h.

◆ Row

template<class Derived >
typedef hidden::Traits<Derived>::Row STK::OrientedCAllocator< Derived, Arrays::by_col_ >::Row

Definition at line 247 of file STK_CAllocator.h.

◆ RowRange

template<class Derived >
typedef TRange<sizeRows_> STK::OrientedCAllocator< Derived, Arrays::by_col_ >::RowRange

Type of the Range for the rows.

Definition at line 265 of file STK_CAllocator.h.

◆ Type

template<class Derived >
typedef hidden::Traits<Derived>::Type STK::OrientedCAllocator< Derived, Arrays::by_col_ >::Type

Definition at line 249 of file STK_CAllocator.h.

◆ TypeConst

template<class Derived >
typedef hidden::Traits<Derived>::TypeConst STK::OrientedCAllocator< Derived, Arrays::by_col_ >::TypeConst

Definition at line 250 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 252 of file STK_CAllocator.h.

253 {
254 structure_ = hidden::Traits<Derived>::structure_,
255 orient_ = hidden::Traits<Derived>::orient_,
256 sizeRows_ = hidden::Traits<Derived>::sizeRows_,
257 sizeCols_ = hidden::Traits<Derived>::sizeCols_,
258 sizeProd_ = hidden::Traits<Derived>::sizeProd_,
259 storage_ = hidden::Traits<Derived>::storage_
260 };

Constructor & Destructor Documentation

◆ OrientedCAllocator() [1/4]

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

default constructor

Definition at line 276 of file STK_CAllocator.h.

277 : Base(I, J), ldx_(I.size()), allocator_(prod(I, J))
278 {}
static Range prod(Range const &I, Range const &J)
Compute the range of the 1D Allocator when we want to allocate a 2D array with range I for the rows a...
int ldx_
leading dimension of the data set

◆ OrientedCAllocator() [2/4]

template<class Derived >
STK::OrientedCAllocator< Derived, Arrays::by_col_ >::OrientedCAllocator ( OrientedCAllocator< Derived, Arrays::by_col_ > const A,
bool  ref 
)
inlineprotected

copy constructor

Definition at line 280 of file STK_CAllocator.h.

281 : Base(A), ldx_(A.ldx()), allocator_(A.allocator_, ref)
282 { if (!ref) allocator_.assign(A.allocator_);}

◆ OrientedCAllocator() [3/4]

template<class Derived >
template<class OtherDerived >
STK::OrientedCAllocator< Derived, Arrays::by_col_ >::OrientedCAllocator ( OrientedCAllocator< OtherDerived, Arrays::by_col_ > const A,
RowRange const I,
ColRange const J 
)
inlineprotected

Reference constructor.

Definition at line 285 of file STK_CAllocator.h.

287 : Base(I, J), ldx_(A.ldx()), allocator_(A.allocator(), true) {}

◆ OrientedCAllocator() [4/4]

template<class Derived >
STK::OrientedCAllocator< Derived, Arrays::by_col_ >::OrientedCAllocator ( Type *const q,
int  nbRow,
int  nbCol 
)
inlineprotected

wrapper constructor for 0 based C-Array

Definition at line 289 of file STK_CAllocator.h.

290 : Base(Range(0,nbRow), Range(0,nbCol)), ldx_(nbRow)
291 , allocator_(q, nbRow * nbCol, true)
292 {}
TRange< UnknownSize > Range
Definition STK_Range.h:59

◆ ~OrientedCAllocator()

template<class Derived >
STK::OrientedCAllocator< Derived, Arrays::by_col_ >::~OrientedCAllocator ( )
inlineprotected

destructor

Definition at line 294 of file STK_CAllocator.h.

294{}

Member Function Documentation

◆ allocator()

template<class Derived >
Allocator const & STK::OrientedCAllocator< Derived, Arrays::by_col_ >::allocator ( ) const
inline
Returns
a constant reference on the memory manager

Definition at line 311 of file STK_CAllocator.h.

311{ return allocator_;}

◆ begin()

template<class Derived >
int STK::OrientedCAllocator< Derived, Arrays::by_col_ >::begin ( ) const
inline
Returns
the index of the first element in the allocator

Definition at line 300 of file STK_CAllocator.h.

300{ return allocator_.begin();}

◆ elt2Impl() [1/2]

template<class Derived >
Type & STK::OrientedCAllocator< Derived, Arrays::by_col_ >::elt2Impl ( int  i,
int  j 
)
inline
Returns
a reference on the element (i,j) of the Allocator.
Parameters
i,jindexes of the element

Definition at line 322 of file STK_CAllocator.h.

322{ return allocator_[j*ldx_ + i];}

◆ elt2Impl() [2/2]

template<class Derived >
TypeConst STK::OrientedCAllocator< Derived, Arrays::by_col_ >::elt2Impl ( int  i,
int  j 
) const
inline
Returns
a constant reference on the element (i,j) of the Allocator.
Parameters
i,jindexes of the element

Definition at line 318 of file STK_CAllocator.h.

318{ return allocator_[j*ldx_ + i];}

◆ end()

template<class Derived >
int STK::OrientedCAllocator< Derived, Arrays::by_col_ >::end ( ) const
inline
Returns
the ending index of the elements in the allocator

Definition at line 302 of file STK_CAllocator.h.

302{ return allocator_.end();}

◆ exchange()

template<class Derived >
void STK::OrientedCAllocator< Derived, Arrays::by_col_ >::exchange ( OrientedCAllocator< Derived, Arrays::by_col_ > &  T)
inlineprotected

exchange T with this.

Parameters
Tthe container to exchange

Definition at line 351 of file STK_CAllocator.h.

352 {
353 allocator_.exchange(T.allocator_);
355 std::swap(ldx_, T.ldx_);
356 }

◆ isRef()

template<class Derived >
bool STK::OrientedCAllocator< Derived, Arrays::by_col_ >::isRef ( ) const
inline
Returns
is this own its data ?

Definition at line 307 of file STK_CAllocator.h.

307{ return allocator_.isRef();}

◆ ldx()

template<class Derived >
int STK::OrientedCAllocator< Derived, Arrays::by_col_ >::ldx ( ) const
inline
Returns
the leading dimension of the allocator

Definition at line 313 of file STK_CAllocator.h.

313{ return ldx_;}

◆ move()

template<class Derived >
Derived & STK::OrientedCAllocator< Derived, Arrays::by_col_ >::move ( OrientedCAllocator< Derived, Arrays::by_col_ > const T)
inline

move T to this without copying data

Definition at line 329 of file STK_CAllocator.h.

330 {
331 if (this->asPtrDerived() != T.asPtrDerived())
332 {
333 allocator_.move(T.allocator_);
334 this->asDerived().moveImpl(T.asDerived()); // move any other data fields
335 this->setRanges(T.rows(), T.cols());
336 ldx_ = T.ldx_;
337 }
338 return this->asDerived();
339 }
void setRanges(RowRange const &I=RowRange(), ColRange const &J=ColRange())
Set the ranges of the container.
Derived * asPtrDerived()
static cast : return a ptr on a Derived of this with a cast to the derived class.
Derived & asDerived()
static cast : return a reference of this with a cast to the derived class.

◆ moveImpl()

template<class Derived >
void STK::OrientedCAllocator< Derived, Arrays::by_col_ >::moveImpl ( OrientedCAllocator< Derived, Arrays::by_col_ > const T)
inlineprotected

do nothing by default

Definition at line 347 of file STK_CAllocator.h.

347{}

◆ p_data()

template<class Derived >
Type *const & STK::OrientedCAllocator< Derived, Arrays::by_col_ >::p_data ( ) const
inline
Returns
a constant reference on the main pointer

Definition at line 309 of file STK_CAllocator.h.

309{ return allocator_.p_data();}

◆ prod()

template<class Derived >
static Range STK::OrientedCAllocator< Derived, Arrays::by_col_ >::prod ( Range const I,
Range const J 
)
inlinestaticprotected

Compute the range of the 1D Allocator when we want to allocate a 2D array with range I for the rows and range J for the columns.

Parameters
I,Jthe range of the rows and columns
Returns
The range of the 1D allocator

Definition at line 363 of file STK_CAllocator.h.

364 { return Range(I.size()*J.begin()+I.begin(), I.size()*J.size()); }

◆ range()

template<class Derived >
AllocatorRange STK::OrientedCAllocator< Derived, Arrays::by_col_ >::range ( ) const
inline
Returns
the range of the a allocator

Definition at line 298 of file STK_CAllocator.h.

298{ return allocator_.range();}

◆ setSizedIdx()

template<class Derived >
void STK::OrientedCAllocator< Derived, Arrays::by_col_ >::setSizedIdx ( )
inlineprotected

set the index corresponding to the actual size of the allocator.

Definition at line 370 of file STK_CAllocator.h.

◆ setValue()

template<class Derived >
void STK::OrientedCAllocator< Derived, Arrays::by_col_ >::setValue ( TypeConst  v)
inline

set a value to this allocator.

Parameters
vthe value to set

Definition at line 326 of file STK_CAllocator.h.

327 { allocator_.assign(range(), v);}

◆ shiftInc()

template<class Derived >
int STK::OrientedCAllocator< Derived, Arrays::by_col_ >::shiftInc ( int  beginRows,
int  beginCols 
)
inlineprotected

return the increment to apply to a zero based pointer corresponding to the actual first row and first column indexes.

Definition at line 367 of file STK_CAllocator.h.

◆ size()

template<class Derived >
int STK::OrientedCAllocator< Derived, Arrays::by_col_ >::size ( ) const
inline
Returns
the size of the allocator

Definition at line 304 of file STK_CAllocator.h.

304{ return allocator_.size();}

Member Data Documentation

◆ allocator_

template<class Derived >
Allocator STK::OrientedCAllocator< Derived, Arrays::by_col_ >::allocator_
protected

manager of the memory

Definition at line 345 of file STK_CAllocator.h.

◆ ldx_

template<class Derived >
int STK::OrientedCAllocator< Derived, Arrays::by_col_ >::ldx_
protected

leading dimension of the data set

Definition at line 343 of file STK_CAllocator.h.


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