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

Specialization for row-oriented Allocators. More...

#include <STK_CAllocator.h>

Inheritance diagram for STK::OrientedCAllocator< Derived, Arrays::by_row_ >:
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 container.
 
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)
 constructor with specified ranges
 
 OrientedCAllocator (OrientedCAllocator const &A, bool ref)
 copy constructor
 
template<class OtherDerived >
 OrientedCAllocator (OrientedCAllocator< OtherDerived, Arrays::by_row_ > 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 exchange (OrientedCAllocator &T)
 exchange T with this.
 
int shiftInc (int beginRows, int beginCols)
 return the increment corresponding to the actual first row an column.
 
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 I indexes in the first dimension and J indexes in the second dimension.
 

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_row_ >

Specialization for row-oriented Allocators.

Definition at line 376 of file STK_CAllocator.h.

Member Typedef Documentation

◆ Allocator

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

Definition at line 394 of file STK_CAllocator.h.

◆ AllocatorRange

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

Type of the Range for the allocator.

Definition at line 401 of file STK_CAllocator.h.

◆ Base

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

Definition at line 393 of file STK_CAllocator.h.

◆ Col

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

Definition at line 380 of file STK_CAllocator.h.

◆ ColRange

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

Type of the Range for the columns.

Definition at line 399 of file STK_CAllocator.h.

◆ Row

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

Definition at line 379 of file STK_CAllocator.h.

◆ RowRange

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

Type of the Range for the rows.

Definition at line 397 of file STK_CAllocator.h.

◆ Type

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

Definition at line 381 of file STK_CAllocator.h.

◆ TypeConst

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

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

385 {
386 structure_ = hidden::Traits<Derived>::structure_,
387 orient_ = hidden::Traits<Derived>::orient_,
388 sizeRows_ = hidden::Traits<Derived>::sizeRows_,
389 sizeCols_ = hidden::Traits<Derived>::sizeCols_,
390 sizeProd_ = hidden::Traits<Derived>::sizeProd_,
391 storage_ = hidden::Traits<Derived>::storage_
392 };

Constructor & Destructor Documentation

◆ OrientedCAllocator() [1/4]

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

constructor with specified ranges

Definition at line 408 of file STK_CAllocator.h.

409 : Base(I, J), ldx_(J.size()), allocator_(prod(I, J))
410 {}
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 I indexes in the first...
int ldx_
leading dimension of the data set

◆ OrientedCAllocator() [2/4]

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

copy constructor

Definition at line 412 of file STK_CAllocator.h.

413 : Base(A), ldx_(A.ldx_), allocator_(A.allocator_, ref)
414 { if (!ref) allocator_.assign(A.allocator_);}

◆ OrientedCAllocator() [3/4]

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

Reference constructor.

Definition at line 417 of file STK_CAllocator.h.

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

◆ OrientedCAllocator() [4/4]

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

wrapper constructor for 0 based C-Array

Definition at line 422 of file STK_CAllocator.h.

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

◆ ~OrientedCAllocator()

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

destructor

Definition at line 427 of file STK_CAllocator.h.

427{}

Member Function Documentation

◆ allocator()

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

Definition at line 444 of file STK_CAllocator.h.

444{ return allocator_;}

◆ begin()

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

Definition at line 433 of file STK_CAllocator.h.

433{ return allocator_.begin();}

◆ elt2Impl() [1/2]

template<class Derived >
Type & STK::OrientedCAllocator< Derived, Arrays::by_row_ >::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 454 of file STK_CAllocator.h.

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

◆ elt2Impl() [2/2]

template<class Derived >
TypeConst STK::OrientedCAllocator< Derived, Arrays::by_row_ >::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 450 of file STK_CAllocator.h.

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

◆ end()

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

Definition at line 435 of file STK_CAllocator.h.

435{ return allocator_.end();}

◆ exchange()

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

exchange T with this.

Parameters
Tthe container to move

Definition at line 480 of file STK_CAllocator.h.

481 {
482 allocator_.exchange(T.allocator_);
484 std::swap(ldx_, T.ldx_);
485 }

◆ isRef()

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

Definition at line 440 of file STK_CAllocator.h.

440{ return allocator_.isRef();}

◆ ldx()

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

Definition at line 446 of file STK_CAllocator.h.

446{ return ldx_;}

◆ move()

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

move T to this without copying data

Definition at line 460 of file STK_CAllocator.h.

461 {
462 if (this->asPtrDerived() != T.asPtrDerived())
463 {
464 allocator_.move(T.allocator_);
465 this->asDerived().moveImpl(T.asDerived()); // move any other data fields
466 this->setRanges(T.rows(), T.cols());
467 ldx_ = T.ldx_;
468 }
469 return this->asDerived();
470 }
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.

◆ p_data()

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

Definition at line 442 of file STK_CAllocator.h.

442{ return allocator_.p_data();}

◆ prod()

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

Compute the range of the 1D Allocator when we want to allocate a 2D array with I indexes in the first dimension and J indexes in the second dimension.

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

Definition at line 492 of file STK_CAllocator.h.

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

◆ range()

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

Definition at line 431 of file STK_CAllocator.h.

431{ return allocator_.range();}

◆ setSizedIdx()

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

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

Definition at line 498 of file STK_CAllocator.h.

◆ setValue()

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

set a value to this container.

Parameters
vthe value to set

Definition at line 458 of file STK_CAllocator.h.

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

◆ shiftInc()

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

◆ size()

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

Definition at line 437 of file STK_CAllocator.h.

437{ return allocator_.size();}

Member Data Documentation

◆ allocator_

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

manager of the memory

Definition at line 476 of file STK_CAllocator.h.

◆ ldx_

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

leading dimension of the data set

Definition at line 474 of file STK_CAllocator.h.


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