STK++ 0.9.13
STK::Array1D< Type_, Size_ > Class Template Reference

template one dimensional Arrays. More...

#include <STK_Array1D.h>

Inheritance diagram for STK::Array1D< Type_, Size_ >:
Inheritance graph

Classes

class  InnerOperator
 

Public Types

enum  {
  structure_ = hidden::Traits< Array1D<Type_, Size_> >::structure_ , orient_ = hidden::Traits< Array1D<Type_, Size_> >::orient_ , sizeCols_ = hidden::Traits< Array1D<Type_, Size_> >::sizeCols_ , sizeRows_ = hidden::Traits< Array1D<Type_, Size_> >::sizeRows_ ,
  size_ = hidden::Traits< Array1D<Type_, Size_> >::size_ , storage_ = hidden::Traits< Array1D<Type_, Size_> >::storage_
}
 
typedef IArray1D< Array1D< Type_, Size_ > > Base
 
typedef hidden::Traits< Array1D< Type_, Size_ > >::Allocator Allocator
 
typedef hidden::Traits< Array1D< Type_, Size_ > >::Type Type
 
typedef hidden::Traits< Array1D< Type_, Size_ > >::TypeConst TypeConst
 
typedef hidden::Traits< Array1D< Type_, Size_ > >::RowRange RowRange
 
typedef hidden::Traits< Array1D< Type_, Size_ > >::ColRange ColRange
 
typedef hidden::Traits< Array1D< Type_, Size_ > >::Iterator Iterator
 
typedef hidden::Traits< Array1D< Type_, Size_ > >::ConstIterator ConstIterator
 
typedef hidden::Traits< Array1D< Type_, Size_ > >::ReverseIterator ReverseIterator
 
typedef hidden::Traits< Array1D< Type_, Size_ > >::ConstReverseIterator ConstReverseIterator
 
typedef Iterator iterator
 
typedef ConstIterator const_iterator
 
typedef ReverseIterator reverse_iterator
 
typedef ConstReverseIterator const_reverse_iterator
 
- Public Types inherited from STK::IArray1D< Array1D< Type_, Size_ > >
enum  
 
typedef ITContainer1D< Array1D< Type_, Size_ > > Base
 
typedef hidden::Traits< Array1D< Type_, Size_ > >::Allocator Allocator
 
typedef hidden::Traits< Array1D< Type_, Size_ > >::Type Type
 
typedef hidden::Traits< Array1D< Type_, Size_ > >::TypeConst TypeConst
 
typedef hidden::Traits< Array1D< Type_, Size_ > >::RowRange RowRange
 
typedef hidden::Traits< Array1D< Type_, Size_ > >::ColRange ColRange
 
typedef hidden::Traits< Array1D< Type_, Size_ > >::Iterator Iterator
 
typedef hidden::Traits< Array1D< Type_, Size_ > >::ConstIterator ConstIterator
 
typedef hidden::Traits< Array1D< Type_, Size_ > >::ReverseIterator ReverseIterator
 
typedef hidden::Traits< Array1D< Type_, Size_ > >::ConstReverseIterator ConstReverseIterator
 
- Public Types inherited from STK::ITContainer1D< Derived >
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

 Array1D ()
 Default constructor.
 
 Array1D (Range const &I)
 constructor with a specified Range
 
 Array1D (Range const &I, Type const &v)
 Misc constructor with beg and end, initialization with a constant.
 
 Array1D (Array1D const &T, bool ref=false)
 Copy constructor.
 
template<int OtherSize>
 Array1D (Array1D< Type, OtherSize > const &T, bool ref=false)
 Copy constructor.
 
template<int OtherSize>
 Array1D (Array1D< Type, OtherSize > const &T, RowRange const &I, bool ref=true)
 constructor by reference, ref_=1.
 
 Array1D (Allocator const &A, Range const &I, bool ref)
 Wrapper constructor.
 
 Array1D (Type *q, Range const &I)
 Wrapper constructor: the container is a reference of a C-Array.
 
 ~Array1D ()
 destructor: allocated memory is liberated by MemAllocator base class.
 
Array1Doperator= (Array1D const &T)
 operator = : overwrite the Array1D with T.
 
template<class OtherArray >
Array1Doperator= (ITContainer1D< OtherArray > const &T)
 Copy an other type of 1D array in an Array1D.
 
Array1Doperator= (Type const &v)
 operator= : set the container to a constant value.
 
- Public Member Functions inherited from STK::IArray1D< Array1D< Type_, Size_ > >
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 constallocator () const
 
RowRange constrows () 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
 
Typeelt1Impl (int pos)
 access to an element
 
TypeConst elt1Impl (int pos) const
 access to a constant element
 
Array1D< Type_, Size_ > & 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.
 
Array1D< Type_, Size_ > & 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 (Array1D< Type_, Size_ > const &T)
 move T to this.
 
Array1D< Type_, Size_ > & pushBack (int n=1)
 Add n Elements to the end of the container.
 
Array1D< Type_, Size_ > & popBack (int n=1)
 Delete last elts of the container.
 
Array1D< Type_, Size_ > & erase (int pos, int n=1)
 Delete n elements at the pos index to the container.
 
Array1D< Type_, Size_ > & insertElt (int pos, int n=1)
 Insert n elements at the position pos of the container.
 
Array1D< Type_, Size_ > & insert (int pos, Type const &v)
 STL compatibility: Insert element v at position pos of the Array.
 
Array1D< Type_, Size_ > & insert (Range const &I, Type const &v)
 STL compatibility: Insert element v in the range I of the Array.
 
Array1D< Type_, Size_ > & push_front (Type const &v)
 STL compatibility: push front an element.
 
Array1D< Type_, Size_ > & 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.
 
Array1D< Type_, Size_ > & 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 constrange () 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.
 
Typeelt (int i)
 
TypeConst elt (int i) const
 
- Public Member Functions inherited from STK::ITContainer1D< Derived >
RowRange constrange () 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 ?
 
Typeelt (int i)
 
TypeConst elt (int i) const
 
Typeoperator[] (int i)
 
TypeConst operator[] (int i) const
 
Typeat (int i)
 
TypeConst at (int i) const
 
SubVector sub (Range const &I) const
 Access to many elements.
 
Typefront ()
 
TypeConst front () const
 
Typeback ()
 
TypeConst back () const
 
void shift (int beg)
 
Derived & resize (Range const &I=RowRange())
 
- 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.
 

Additional Inherited Members

- Protected Member Functions inherited from STK::IArray1D< Array1D< Type_, Size_ > >
 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.
 
 IArray1D (IArray1D< OtherDerived > const &T, bool ref)
 Copy constructor.
 
 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.
 
Allocatorallocator ()
 
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.
 
- Protected Member Functions inherited from STK::ITContainer1D< Derived >
 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.
 
- Protected Member Functions inherited from STK::IRecursiveTemplate< Derived >
 IRecursiveTemplate ()
 constructor.
 
 ~IRecursiveTemplate ()
 destructor.
 

Detailed Description

template<class Type_, int Size_>
class STK::Array1D< Type_, Size_ >

template one dimensional Arrays.

An Array1D is a template non-oriented container (even if the Traits struct define it as column oriented) implementing the interface class IArray1D.

Note
It is a final class for the curious recursive paradigm.
Template Parameters
Typeof the objects stored in the Array1D
Size_size of the vector if it known. Default is UnknownSize

Definition at line 102 of file STK_Array1D.h.

Member Typedef Documentation

◆ Allocator

template<class Type_ , int Size_>
typedef hidden::Traits<Array1D<Type_,Size_>>::Allocator STK::Array1D< Type_, Size_ >::Allocator

Definition at line 106 of file STK_Array1D.h.

◆ Base

template<class Type_ , int Size_>
typedef IArray1D< Array1D<Type_, Size_> > STK::Array1D< Type_, Size_ >::Base

Definition at line 105 of file STK_Array1D.h.

◆ ColRange

template<class Type_ , int Size_>
typedef hidden::Traits<Array1D<Type_,Size_>>::ColRange STK::Array1D< Type_, Size_ >::ColRange

Definition at line 122 of file STK_Array1D.h.

◆ const_iterator

template<class Type_ , int Size_>
typedef ConstIterator STK::Array1D< Type_, Size_ >::const_iterator

Definition at line 131 of file STK_Array1D.h.

◆ const_reverse_iterator

template<class Type_ , int Size_>
typedef ConstReverseIterator STK::Array1D< Type_, Size_ >::const_reverse_iterator

Definition at line 133 of file STK_Array1D.h.

◆ ConstIterator

template<class Type_ , int Size_>
typedef hidden::Traits<Array1D<Type_,Size_>>::ConstIterator STK::Array1D< Type_, Size_ >::ConstIterator

Definition at line 125 of file STK_Array1D.h.

◆ ConstReverseIterator

template<class Type_ , int Size_>
typedef hidden::Traits<Array1D<Type_,Size_>>::ConstReverseIterator STK::Array1D< Type_, Size_ >::ConstReverseIterator

Definition at line 127 of file STK_Array1D.h.

◆ Iterator

template<class Type_ , int Size_>
typedef hidden::Traits<Array1D<Type_,Size_>>::Iterator STK::Array1D< Type_, Size_ >::Iterator

Definition at line 124 of file STK_Array1D.h.

◆ iterator

template<class Type_ , int Size_>
typedef Iterator STK::Array1D< Type_, Size_ >::iterator

Definition at line 130 of file STK_Array1D.h.

◆ reverse_iterator

template<class Type_ , int Size_>
typedef ReverseIterator STK::Array1D< Type_, Size_ >::reverse_iterator

Definition at line 132 of file STK_Array1D.h.

◆ ReverseIterator

template<class Type_ , int Size_>
typedef hidden::Traits<Array1D<Type_,Size_>>::ReverseIterator STK::Array1D< Type_, Size_ >::ReverseIterator

Definition at line 126 of file STK_Array1D.h.

◆ RowRange

template<class Type_ , int Size_>
typedef hidden::Traits<Array1D<Type_,Size_>>::RowRange STK::Array1D< Type_, Size_ >::RowRange

Definition at line 121 of file STK_Array1D.h.

◆ Type

template<class Type_ , int Size_>
typedef hidden::Traits<Array1D<Type_,Size_>>::Type STK::Array1D< Type_, Size_ >::Type

Definition at line 118 of file STK_Array1D.h.

◆ TypeConst

template<class Type_ , int Size_>
typedef hidden::Traits<Array1D<Type_,Size_>>::TypeConst STK::Array1D< Type_, Size_ >::TypeConst

Definition at line 119 of file STK_Array1D.h.

Member Enumeration Documentation

◆ anonymous enum

template<class Type_ , int Size_>
anonymous enum
Enumerator
structure_ 
orient_ 
sizeCols_ 
sizeRows_ 
size_ 
storage_ 

Definition at line 108 of file STK_Array1D.h.

109 {
110 structure_ = hidden::Traits< Array1D<Type_, Size_> >::structure_,
111 orient_ = hidden::Traits< Array1D<Type_, Size_> >::orient_,
112 sizeCols_ = hidden::Traits< Array1D<Type_, Size_> >::sizeCols_,
113 sizeRows_ = hidden::Traits< Array1D<Type_, Size_> >::sizeRows_,
114 size_ = hidden::Traits< Array1D<Type_, Size_> >::size_,
115 storage_ = hidden::Traits< Array1D<Type_, Size_> >::storage_
116 };

Constructor & Destructor Documentation

◆ Array1D() [1/8]

template<class Type_ , int Size_>
STK::Array1D< Type_, Size_ >::Array1D ( )
inline

Default constructor.

Definition at line 138 of file STK_Array1D.h.

138: Base(){}
IArray1D< Array1D< Type_, Size_ > > Base

◆ Array1D() [2/8]

template<class Type_ , int Size_>
STK::Array1D< Type_, Size_ >::Array1D ( Range const I)
inline

constructor with a specified Range

Parameters
Irange of the container

Definition at line 142 of file STK_Array1D.h.

142: Base(I) {}

◆ Array1D() [3/8]

template<class Type_ , int Size_>
STK::Array1D< Type_, Size_ >::Array1D ( Range const I,
Type const v 
)
inline

Misc constructor with beg and end, initialization with a constant.

Parameters
I,vrange and initial value of the container

Definition at line 146 of file STK_Array1D.h.

146: Base(I, v) {}

◆ Array1D() [4/8]

template<class Type_ , int Size_>
STK::Array1D< Type_, Size_ >::Array1D ( Array1D< Type_, Size_ > const T,
bool  ref = false 
)
inline

Copy constructor.

Parameters
Tthe container to copy
reftrue if T is wrapped

Definition at line 151 of file STK_Array1D.h.

151: Base(T, ref) {}

◆ Array1D() [5/8]

template<class Type_ , int Size_>
template<int OtherSize>
STK::Array1D< Type_, Size_ >::Array1D ( Array1D< Type, OtherSize > const T,
bool  ref = false 
)
inline

Copy constructor.

Parameters
Tthe container to copy
reftrue if T is wrapped

Definition at line 157 of file STK_Array1D.h.

157: Base(T, ref) {}

◆ Array1D() [6/8]

template<class Type_ , int Size_>
template<int OtherSize>
STK::Array1D< Type_, Size_ >::Array1D ( Array1D< Type, OtherSize > const T,
RowRange const I,
bool  ref = true 
)
inline

constructor by reference, ref_=1.

Parameters
T,Ithe container and the range of data to wrap
reftrue if T is wrapped (the default)

Definition at line 163 of file STK_Array1D.h.

164 : Base(T, I, ref) {}

◆ Array1D() [7/8]

template<class Type_ , int Size_>
STK::Array1D< Type_, Size_ >::Array1D ( Allocator const A,
Range const I,
bool  ref 
)
inline

Wrapper constructor.

Parameters
A,Irange and allocator to wrap
reftrue if A is wrapped

Definition at line 169 of file STK_Array1D.h.

169: Base(A, I, ref) {}

◆ Array1D() [8/8]

template<class Type_ , int Size_>
STK::Array1D< Type_, Size_ >::Array1D ( Type q,
Range const I 
)
inline

Wrapper constructor: the container is a reference of a C-Array.

Parameters
q,Ipointer and range of data

Definition at line 173 of file STK_Array1D.h.

173: Base(q, I) {}

◆ ~Array1D()

template<class Type_ , int Size_>
STK::Array1D< Type_, Size_ >::~Array1D ( )
inline

destructor: allocated memory is liberated by MemAllocator base class.

Definition at line 175 of file STK_Array1D.h.

175{}

Member Function Documentation

◆ operator=() [1/3]

template<class Type_ , int Size_>
Array1D & STK::Array1D< Type_, Size_ >::operator= ( Array1D< Type_, Size_ > const T)
inline

operator = : overwrite the Array1D with T.

Parameters
Tthe container to copy

Definition at line 179 of file STK_Array1D.h.

180 { return this->assign(T);}
Array1D< Type_, Size_ > & assign(IArray1D const &src)
overwrite this with src.

References STK::IArray1D< Array1D< Type_, Size_ > >::assign().

◆ operator=() [2/3]

template<class Type_ , int Size_>
template<class OtherArray >
Array1D & STK::Array1D< Type_, Size_ >::operator= ( ITContainer1D< OtherArray > const T)
inline

Copy an other type of 1D array in an Array1D.

Parameters
Tthe array to copy

Definition at line 185 of file STK_Array1D.h.

186 {
187 // check size
188 if (this->range()!=T.range()) this->resize(T.range());
189 for (int i=this->begin(); i<this->end(); i++) this->elt(i) = T.elt(i);
190 return *this;
191 }
Derived & resize(Range const &I=RowRange())

References STK::IArray1D< Array1D< Type_, Size_ > >::begin(), STK::IArray1D< Array1D< Type_, Size_ > >::elt(), STK::IArray1D< Array1D< Type_, Size_ > >::end(), STK::IArray1D< Array1D< Type_, Size_ > >::range(), and STK::ITContainer1D< Derived >::resize().

◆ operator=() [3/3]

template<class Type_ , int Size_>
Array1D & STK::Array1D< Type_, Size_ >::operator= ( Type const v)
inline

operator= : set the container to a constant value.

Parameters
vthe value to set

Definition at line 195 of file STK_Array1D.h.

196 {
197 for (int i=this->begin(); i<this->end(); i++) this->elt(i)= v;
198 return *this;
199 }

References STK::IArray1D< Array1D< Type_, Size_ > >::begin(), STK::IArray1D< Array1D< Type_, Size_ > >::elt(), and STK::IArray1D< Array1D< Type_, Size_ > >::end().


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