STK++ 0.9.13
|
template one dimensional Array. More...
#include <STK_IArray1D.h>
Public Types | |
enum | { structure_ = hidden::Traits< Derived >::structure_ , orient_ = hidden::Traits< Derived >::orient_ , sizeCols_ = hidden::Traits< Derived >::sizeCols_ , sizeRows_ = hidden::Traits< Derived >::sizeRows_ , size_ = hidden::Traits< Derived >::size_ , storage_ = hidden::Traits< Derived >::storage_ , isFixedSize_ = (size_ != UnknownSize) } |
typedef ITContainer1D< Derived > | Base |
typedef hidden::Traits< Derived >::Allocator | Allocator |
typedef hidden::Traits< Derived >::Type | Type |
typedef hidden::Traits< Derived >::TypeConst | TypeConst |
typedef hidden::Traits< Derived >::RowRange | RowRange |
typedef hidden::Traits< Derived >::ColRange | ColRange |
typedef hidden::Traits< Derived >::Iterator | Iterator |
typedef hidden::Traits< Derived >::ConstIterator | ConstIterator |
typedef hidden::Traits< Derived >::ReverseIterator | ReverseIterator |
typedef hidden::Traits< Derived >::ConstReverseIterator | ConstReverseIterator |
![]() | |
enum | { size_ = hidden::Traits<Derived>::size_ } |
typedef hidden::Traits< Derived >::Type | Type |
typedef hidden::Traits< Derived >::TypeConst | TypeConst |
typedef hidden::Traits< Derived >::RowRange | RowRange |
typedef hidden::Traits< Derived >::ColRange | ColRange |
typedef hidden::Traits< Derived >::Row | Row |
typedef hidden::Traits< Derived >::Col | Col |
typedef hidden::Traits< Derived >::SubVector | SubVector |
typedef hidden::Traits< Derived >::Iterator | Iterator |
typedef hidden::Traits< Derived >::ConstIterator | ConstIterator |
typedef hidden::Traits< Derived >::ReverseIterator | ReverseIterator |
typedef hidden::Traits< Derived >::ConstReverseIterator | ConstReverseIterator |
Public Member Functions | |
bool | isRef () const |
void | setRef (bool ref) const |
Modify the state of the container: this become a reference (if ref is true ) or the owner of the data (if ref is false ). | |
Allocator const & | allocator () const |
RowRange const & | rows () const |
int | beginRows () const |
int | endRows () const |
int | sizeRows () const |
ColRange | cols () const |
int | beginCols () const |
int | endCols () const |
int | sizeCols () const |
int | lastIdxRows () const |
int | lastIdxCols () const |
int | capacity () const |
Type & | elt1Impl (int pos) |
access to an element | |
TypeConst | elt1Impl (int pos) const |
access to a constant element | |
Derived & | setValue (Type const &value) |
set a value to this container. | |
void | setValue (int pos, TypeConst value) |
Write a value at a given position. | |
void | shiftImpl (int beg=baseIdx) |
New beginning index for the object. | |
Derived & | resizeImpl (Range const &I) |
Resize the container. | |
void | reserve (int size) |
reserve internal memory for at least size elements. | |
void | clear () |
Clear the object. | |
void | move (Derived const &T) |
move T to this. | |
Derived & | pushBack (int n=1) |
Add n Elements to the end of the container. | |
Derived & | popBack (int n=1) |
Delete last elts of the container. | |
Derived & | erase (int pos, int n=1) |
Delete n elements at the pos index to the container. | |
Derived & | insertElt (int pos, int n=1) |
Insert n elements at the position pos of the container. | |
Derived & | insert (int pos, Type const &v) |
STL compatibility: Insert element v at position pos of the Array. | |
Derived & | insert (Range const &I, Type const &v) |
STL compatibility: Insert element v in the range I of the Array. | |
Derived & | push_front (Type const &v) |
STL compatibility: push front an element. | |
Derived & | push_back (Type const &v) |
STL compatibility: append an element v. | |
void | swap (int pos1, int pos2) |
Swapping the pos1 elt and the pos2 elt. | |
void | exchange (IArray1D &T) |
exchange this Container with T. | |
Derived & | assign (IArray1D const &src) |
overwrite this with src . | |
void | memmove (int pos1, int pos2, int n) |
Copy n elements from pos2 to pos1, guaranteeing correct behavior for overlapping. | |
RowRange const & | range () const |
int | begin () const |
int | end () const |
int | size () const |
int | lastIdx () const |
void | decLast (int n=1) |
decrement the end of the container. | |
void | incLast (int n=1) |
increment the end of the container (can be negative). | |
void | incRange (int n=1) |
increment the range of the container (can be negative). | |
void | setRange (RowRange const &I=RowRange()) |
Set range of the rows of the container. | |
Type & | elt (int i) |
TypeConst | elt (int i) const |
![]() | |
RowRange const & | range () const |
int | begin () const |
int | end () const |
int | size () const |
int | lastIdx () const |
Iterator | beginIterator () |
Iterator | endIterator () |
ConstIterator | beginConstIterator () const |
ConstIterator | endConstIterator () const |
ReverseIterator | rbeginIterator () |
ReverseIterator | rendIterator () |
ConstReverseIterator | rbeginConstIterator () const |
ConstReverseIterator | rendConstIterator () const |
bool | empty () const |
Is there some data ? | |
Type & | elt (int i) |
TypeConst | elt (int i) const |
Type & | operator[] (int i) |
TypeConst | operator[] (int i) const |
Type & | at (int i) |
TypeConst | at (int i) const |
SubVector | sub (Range const &I) const |
Access to many elements. | |
Type & | front () |
TypeConst | front () const |
Type & | back () |
TypeConst | back () const |
void | shift (int beg) |
Derived & | resize (Range const &I=RowRange()) |
![]() | |
Derived & | asDerived () |
static cast : return a reference of this with a cast to the derived class. | |
Derived const & | asDerived () 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 const * | asPtrDerived () 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 | |
IArray1D () | |
Default constructor. | |
IArray1D (Range const &I) | |
constructor with a specified Range. | |
IArray1D (Range const &I, Type const &v) | |
Misc constructor with first and last, initialization with a constant. | |
IArray1D (IArray1D const &T, bool ref) | |
Copy constructor. | |
template<class OtherDerived > | |
IArray1D (IArray1D< OtherDerived > const &T, bool ref) | |
Copy constructor. | |
template<class OtherDerived > | |
IArray1D (IArray1D< OtherDerived > const &T, RowRange const &I, bool ref) | |
copy constructor. | |
IArray1D (Allocator const &A, Range const &I, bool ref) | |
Wrapper constructor. | |
~IArray1D () | |
destructor: allocated memory is liberated by MemAllocator class. | |
Allocator & | allocator () |
void | initialize (RowRange const &I) |
function for memory allocation and initialization. | |
void | allocate (RowRange const &I) |
function for memory allocation. | |
void | freeMem () |
Method for memory deallocation. | |
![]() | |
ITContainer1D () | |
Default constructor. | |
ITContainer1D (RowRange const &I) | |
constructor with a specified range. | |
~ITContainer1D () | |
destructor. | |
void | exchange (ITContainer1D &T) |
exchange this container with T | |
void | setRange (RowRange const &I=RowRange()) |
Set range of the rows of the container. | |
void | incRange (int n=1) |
increment the range of the container (can be negative). | |
void | incFirst (int n=1) |
increment the beginning of the container (can be negative). | |
void | decFirst (int n=1) |
decrement the beginning of the container. | |
void | incLast (int n=1) |
increment the end of the container (can be negative). | |
void | decLast (int n=1) |
decrement the end of the container. | |
![]() | |
IRecursiveTemplate () | |
constructor. | |
~IRecursiveTemplate () | |
destructor. | |
Private Attributes | |
Allocator | allocator_ |
template one dimensional Array.
An IArray1D is a template one column container implementing the interface base class ITContainer1D.
Definition at line 94 of file STK_IArray1D.h.
typedef hidden::Traits<Derived>::Allocator STK::IArray1D< Derived >::Allocator |
Definition at line 99 of file STK_IArray1D.h.
typedef ITContainer1D< Derived > STK::IArray1D< Derived >::Base |
Definition at line 98 of file STK_IArray1D.h.
typedef hidden::Traits<Derived>::ColRange STK::IArray1D< Derived >::ColRange |
Definition at line 116 of file STK_IArray1D.h.
typedef hidden::Traits<Derived>::ConstIterator STK::IArray1D< Derived >::ConstIterator |
Definition at line 119 of file STK_IArray1D.h.
typedef hidden::Traits<Derived>::ConstReverseIterator STK::IArray1D< Derived >::ConstReverseIterator |
Definition at line 121 of file STK_IArray1D.h.
typedef hidden::Traits<Derived>::Iterator STK::IArray1D< Derived >::Iterator |
Definition at line 118 of file STK_IArray1D.h.
typedef hidden::Traits<Derived>::ReverseIterator STK::IArray1D< Derived >::ReverseIterator |
Definition at line 120 of file STK_IArray1D.h.
typedef hidden::Traits<Derived>::RowRange STK::IArray1D< Derived >::RowRange |
Definition at line 115 of file STK_IArray1D.h.
typedef hidden::Traits<Derived>::Type STK::IArray1D< Derived >::Type |
Definition at line 112 of file STK_IArray1D.h.
typedef hidden::Traits<Derived>::TypeConst STK::IArray1D< Derived >::TypeConst |
Definition at line 113 of file STK_IArray1D.h.
Enumerator | |
---|---|
structure_ | |
orient_ | |
sizeCols_ | |
sizeRows_ | |
size_ | |
storage_ | |
isFixedSize_ |
Definition at line 101 of file STK_IArray1D.h.
|
protected |
Default constructor.
Definition at line 339 of file STK_IArray1D.h.
|
protected |
constructor with a specified Range.
I | range of the container |
Definition at line 342 of file STK_IArray1D.h.
|
protected |
Misc constructor with first and last, initialization with a constant.
I | range of the container |
v | initial value of the container |
Definition at line 346 of file STK_IArray1D.h.
References STK::IArray1D< Derived >::allocator_.
|
protected |
Copy constructor.
T | the container to copy |
ref | true if T is wrapped |
Definition at line 356 of file STK_IArray1D.h.
|
protected |
Copy constructor.
T | the container to copy |
ref | true if T is wrapped |
Definition at line 366 of file STK_IArray1D.h.
|
protected |
copy constructor.
T,I | the container and the range of data to wrap |
ref | true if T is wrapped (the default) |
Definition at line 377 of file STK_IArray1D.h.
|
protected |
Wrapper constructor.
A,I | range and allocator to wrap |
ref | true if A is wrapped |
Definition at line 387 of file STK_IArray1D.h.
|
protected |
destructor: allocated memory is liberated by MemAllocator class.
Definition at line 393 of file STK_IArray1D.h.
|
protected |
function for memory allocation.
The range is not set in this method. If a bad_alloc occur, we set the range of the container to default before throwing it.
I | range of the container |
Definition at line 655 of file STK_IArray1D.h.
References STK::IRunnerBase::error(), and STK::Arrays::evalRangeCapacity().
|
inlineprotected |
Definition at line 316 of file STK_IArray1D.h.
References STK::IArray1D< Derived >::allocator_.
|
inline |
Definition at line 184 of file STK_IArray1D.h.
References STK::IArray1D< Derived >::allocator_.
Derived & STK::IArray1D< Derived >::assign | ( | IArray1D< Derived > const & | src | ) |
overwrite this
with src
.
this
is not resized, and in this case, the method take care of the possibility of overlapping. src | the container to assign |
Definition at line 609 of file STK_IArray1D.h.
|
inline |
Definition at line 113 of file STK_ITContainer1D.h.
Referenced by STK::MemSAllocator< Type_, NzMax_, Size_ >::begin(), and STK::IArray1D< Derived >::beginRows().
|
inline |
Definition at line 198 of file STK_IArray1D.h.
References STK::baseIdx.
|
inline |
Definition at line 189 of file STK_IArray1D.h.
References STK::IArray1D< Derived >::begin().
|
inline |
Definition at line 210 of file STK_IArray1D.h.
References STK::IArray1D< Derived >::allocator_.
void STK::IArray1D< Derived >::clear | ( | ) |
Clear the object.
Memory is liberated and the range of the Container is set to 0:-1 or 1:0 (
Definition at line 436 of file STK_IArray1D.h.
|
inline |
|
inline |
decrement the end of the container.
n | decrement to apply to the end of the range |
Definition at line 275 of file STK_ITContainer1D.h.
|
inline |
i | index of the element to get |
Definition at line 150 of file STK_ITContainer1D.h.
|
inline |
i | index of the element to get |
Definition at line 161 of file STK_ITContainer1D.h.
|
inline |
access to an element
pos | index of the element |
Definition at line 216 of file STK_IArray1D.h.
References STK::IArray1D< Derived >::allocator_.
|
inline |
access to a constant element
pos | index of the const element |
Definition at line 221 of file STK_IArray1D.h.
References STK::IArray1D< Derived >::allocator_.
|
inline |
Definition at line 115 of file STK_ITContainer1D.h.
Referenced by STK::MemSAllocator< Type_, NzMax_, Size_ >::end(), STK::IArray1D< Array1D< Type_, Size_ > >::end(), and STK::IArray1D< Derived >::endRows().
|
inline |
Definition at line 200 of file STK_IArray1D.h.
References STK::baseIdx.
|
inline |
Definition at line 191 of file STK_IArray1D.h.
References STK::IArray1D< Derived >::end().
Derived & STK::IArray1D< Derived >::erase | ( | int | pos, |
int | n = 1 |
||
) |
Delete n elements at the pos index to the container.
pos | index where to delete elements |
n | number of elements to delete (default 1) |
Definition at line 479 of file STK_IArray1D.h.
References _R, _T, STK::decLast(), STK::IArray1D< Derived >::erase(), stk_cout, STKOUT_OF_RANGE_2ARG, and STKRUNTIME_ERROR_2ARG.
Referenced by STK::IArray1D< Derived >::erase(), and STK::KernelHandler::removeKernel().
void STK::IArray1D< Derived >::exchange | ( | IArray1D< Derived > & | T | ) |
exchange this Container with T.
T | the Array to exchange with this |
Definition at line 602 of file STK_IArray1D.h.
References STK::IArray1D< Derived >::allocator_.
|
protected |
Method for memory deallocation.
Memory is liberated and the range of the Container is set to begin:begin-1.
Definition at line 669 of file STK_IArray1D.h.
|
inline |
increment the end of the container (can be negative).
n | increment to apply to the end of the range |
Definition at line 271 of file STK_ITContainer1D.h.
|
inline |
increment the range of the container (can be negative).
n | increment to apply to the range |
Definition at line 259 of file STK_ITContainer1D.h.
|
protected |
function for memory allocation and initialization.
This method will free all allocated memory owned by this container before initialization.
I | range of the container |
Definition at line 647 of file STK_IArray1D.h.
Derived & STK::IArray1D< Derived >::insert | ( | int | pos, |
Type const & | v | ||
) |
STL compatibility: Insert element v
at position pos
of the Array.
pos | position to insert elements |
v | value to insert |
Definition at line 559 of file STK_IArray1D.h.
Derived & STK::IArray1D< Derived >::insert | ( | Range const & | I, |
Type const & | v | ||
) |
STL compatibility: Insert element v
in the range I
of the Array.
I | range of the index where to insert elements |
v | value to insert |
Definition at line 567 of file STK_IArray1D.h.
Derived & STK::IArray1D< Derived >::insertElt | ( | int | pos, |
int | n = 1 |
||
) |
Insert n elements at the position pos of the container.
pos,n | index where to insert the n elements (default is 1) |
Definition at line 509 of file STK_IArray1D.h.
References STK::IRunnerBase::error(), STK::incLast(), STK::IArray1D< Derived >::insertElt(), STKOUT_OF_RANGE_2ARG, and STKRUNTIME_ERROR_2ARG.
Referenced by STK::IArray1D< Derived >::insertElt().
|
inline |
true
if *this is reference container, false
otherwise Definition at line 175 of file STK_IArray1D.h.
References STK::IArray1D< Derived >::allocator_.
|
inline |
Definition at line 120 of file STK_ITContainer1D.h.
Referenced by STK::IArray1D< Derived >::lastIdxRows().
|
inline |
Definition at line 207 of file STK_IArray1D.h.
References STK::baseIdx.
|
inline |
Definition at line 205 of file STK_IArray1D.h.
References STK::IArray1D< Derived >::lastIdx().
Copy n elements from pos2 to pos1, guaranteeing correct behavior for overlapping.
pos1,pos2 | positions of the elements to move |
n | number of elements to move |
Definition at line 624 of file STK_IArray1D.h.
References STK::IArray1D< Derived >::memmove(), and STKOUT_OF_RANGE_2ARG.
Referenced by STK::IArray1D< Derived >::memmove().
void STK::IArray1D< Derived >::move | ( | Derived const & | T | ) |
move T to this.
T | the container to move to this. |
Definition at line 443 of file STK_IArray1D.h.
Derived & STK::IArray1D< Derived >::popBack | ( | int | n = 1 | ) |
Delete last elts of the container.
n | number of elts to delete |
Definition at line 467 of file STK_IArray1D.h.
References STK::decLast(), STK::IArray1D< Derived >::popBack(), and STKRUNTIME_ERROR_1ARG.
Referenced by STK::IArray1D< Derived >::popBack().
Derived & STK::IArray1D< Derived >::push_back | ( | Type const & | v | ) |
STL compatibility: append an element v.
v | value to append |
Definition at line 582 of file STK_IArray1D.h.
Referenced by STK::KernelHandler::addKernel(), and STK::KernelHandler::addKernel().
Derived & STK::IArray1D< Derived >::push_front | ( | Type const & | v | ) |
STL compatibility: push front an element.
v | value to append |
Definition at line 575 of file STK_IArray1D.h.
Derived & STK::IArray1D< Derived >::pushBack | ( | int | n = 1 | ) |
Add n Elements to the end of the container.
n | number of elements to add |
Definition at line 452 of file STK_IArray1D.h.
References _T, STK::IArray1D< Derived >::pushBack(), stk_cout, and STKRUNTIME_ERROR_1ARG.
Referenced by STK::IArray1D< Derived >::pushBack().
|
inline |
Definition at line 111 of file STK_ITContainer1D.h.
Referenced by STK::MultiLaw::JointProbability< RowVector, Law >::lpdf(), STK::MultiLaw::JointProbability< RowVector, Law >::rand(), and STK::IArray1D< Derived >::rows().
void STK::IArray1D< Derived >::reserve | ( | int | size | ) |
reserve internal memory for at least size elements.
size | number of elements to reserve |
Definition at line 426 of file STK_IArray1D.h.
References STK::IArray1D< Derived >::reserve(), and STKRUNTIME_ERROR_1ARG.
Referenced by STK::IArray1D< Derived >::reserve().
Derived & STK::IArray1D< Derived >::resizeImpl | ( | Range const & | I | ) |
Resize the container.
shift
pushBack
if there will be more elementspopBack
if three will be less elements I | the range to set to the Array1D |
Definition at line 410 of file STK_IArray1D.h.
References STK::IArray1D< Derived >::resizeImpl(), and STKRUNTIME_ERROR_1ARG.
Referenced by STK::IArray1D< Derived >::resizeImpl().
|
inline |
Definition at line 187 of file STK_IArray1D.h.
References STK::IArray1D< Derived >::range().
|
inline |
Set range of the rows of the container.
I | the range to set (default empty) |
Definition at line 255 of file STK_ITContainer1D.h.
|
inline |
Modify the state of the container: this become a reference (if ref is true
) or the owner of the data (if ref is false
).
ref | : has top be false if this own its own data |
Definition at line 181 of file STK_IArray1D.h.
References STK::IArray1D< Derived >::allocator_.
|
inline |
Write a value at a given position.
pos,value | index of the element |
Definition at line 231 of file STK_IArray1D.h.
References STK::IArray1D< Derived >::allocator_.
Derived & STK::IArray1D< Derived >::setValue | ( | Type const & | value | ) |
set a value to this container.
value | the value to set |
Definition at line 640 of file STK_IArray1D.h.
void STK::IArray1D< Derived >::shiftImpl | ( | int | beg = baseIdx | ) |
New beginning index for the object.
beg | the index of the first column to set |
Definition at line 397 of file STK_IArray1D.h.
References STK::IArray1D< Derived >::shiftImpl(), and STKRUNTIME_ERROR_1ARG.
Referenced by STK::IArray1D< Derived >::shiftImpl().
|
inline |
Definition at line 117 of file STK_ITContainer1D.h.
Referenced by STK::MemSAllocator< Type_, NzMax_, Size_ >::size(), and STK::IArray1D< Derived >::sizeRows().
|
inline |
|
inline |
Definition at line 193 of file STK_IArray1D.h.
References STK::IArray1D< Derived >::size().
void STK::IArray1D< Derived >::swap | ( | int | pos1, |
int | pos2 | ||
) |
Swapping the pos1 elt and the pos2 elt.
pos1,pos2 | positions of the elements to swap |
Definition at line 590 of file STK_IArray1D.h.
References STKOUT_OF_RANGE_2ARG, and STK::IArray1D< Derived >::swap().
Referenced by STK::IArray1D< Derived >::swap().
|
private |
Definition at line 335 of file STK_IArray1D.h.
Referenced by STK::IArray1D< Derived >::allocator(), STK::IArray1D< Derived >::allocator(), STK::IArray1D< Derived >::capacity(), STK::IArray1D< Derived >::elt1Impl(), STK::IArray1D< Derived >::elt1Impl(), STK::IArray1D< Derived >::exchange(), STK::IArray1D< Derived >::IArray1D(), STK::IArray1D< Derived >::isRef(), STK::IArray1D< Derived >::setRef(), and STK::IArray1D< Derived >::setValue().