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

template one dimensional Arrays. More...

#include <STK_SArray1D.h>

Inheritance diagram for STK::SArray1D< Type_, Size_, NzMax_ >:
Inheritance graph

Public Types

enum  {
  structure_ = hidden::Traits< SArray1D<Type_, Size_, NzMax_> >::structure_ , orient_ = hidden::Traits< SArray1D<Type_, Size_, NzMax_> >::orient_ , sizeCols_ = hidden::Traits< SArray1D<Type_, Size_, NzMax_> >::sizeCols_ , sizeRows_ = hidden::Traits< SArray1D<Type_, Size_, NzMax_> >::sizeRows_ ,
  size_ = hidden::Traits< SArray1D<Type_, Size_, NzMax_> >::size_ , storage_ = hidden::Traits< SArray1D<Type_, Size_, NzMax_> >::storage_
}
 
typedef IArray1D< SArray1D< Type_, Size_, NzMax_ > > Base
 
typedef hidden::Traits< SArray1D< Type_, Size_, NzMax_ > >::Row Row
 
typedef hidden::Traits< SArray1D< Type_, Size_, NzMax_ > >::Col Col
 
typedef hidden::Traits< SArray1D< Type_, Size_, NzMax_ > >::SubVector SubVector
 
typedef hidden::Traits< SArray1D< Type_, Size_ > >::Type Type
 
typedef hidden::Traits< SArray1D< Type_, Size_ > >::TypeConst TypeConst
 
typedef hidden::Traits< SArray1D< Type_, Size_ > >::Allocator Allocator
 
typedef TRange< size_RowRange
 
typedef TRange< 1 > ColRange
 
- Public Types inherited from STK::IArray1D< SArray1D< Type_, Size_, NzMax_ > >
enum  
 
typedef ITContainer1D< SArray1D< Type_, Size_, NzMax_ > > Base
 
typedef hidden::Traits< SArray1D< Type_, Size_, NzMax_ > >::Allocator Allocator
 
typedef hidden::Traits< SArray1D< Type_, Size_, NzMax_ > >::Type Type
 
typedef hidden::Traits< SArray1D< Type_, Size_, NzMax_ > >::TypeConst TypeConst
 
typedef hidden::Traits< SArray1D< Type_, Size_, NzMax_ > >::RowRange RowRange
 
typedef hidden::Traits< SArray1D< Type_, Size_, NzMax_ > >::ColRange ColRange
 
typedef hidden::Traits< SArray1D< Type_, Size_, NzMax_ > >::Iterator Iterator
 
typedef hidden::Traits< SArray1D< Type_, Size_, NzMax_ > >::ConstIterator ConstIterator
 
typedef hidden::Traits< SArray1D< Type_, Size_, NzMax_ > >::ReverseIterator ReverseIterator
 
typedef hidden::Traits< SArray1D< Type_, Size_, NzMax_ > >::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

 SArray1D ()
 Default constructor.
 
 SArray1D (Range const &I)
 constructor with a specified Range
 
 SArray1D (Range const &I, Type const &v)
 Misc constructor with beg and end, initialization with a constant.
 
 SArray1D (SArray1D const &T, bool ref=false)
 Copy constructor.
 
template<int OtherSize_, int OtherNzMax_>
 SArray1D (SArray1D< Type, OtherSize_, OtherNzMax_ > const &T, bool ref=false)
 Copy constructor.
 
template<int OtherSize_, int OtherNzMax_>
 SArray1D (SArray1D< Type, OtherSize_, OtherNzMax_ > const &T, RowRange const &I, bool ref=true)
 constructor by reference, ref_=1.
 
 SArray1D (Type *q, Range const &I)
 Wrapper constructor: the container is a reference of a C-Array.
 
 ~SArray1D ()
 destructor: allocated memory is liberated by MemAllocator base class.
 
SArray1Doperator= (SArray1D const &T)
 operator = : overwrite the SArray1D with T.
 
template<class OtherArray >
SArray1Doperator= (ITContainer1D< OtherArray > const &T)
 Copy an other type of 1D array in an SArray1D.
 
SArray1Doperator= (Type const &v)
 operator= : set the container to a constant value.
 
- Public Member Functions inherited from STK::IArray1D< SArray1D< Type_, Size_, NzMax_ > >
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
 
SArray1D< Type_, Size_, NzMax_ > & 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.
 
SArray1D< Type_, Size_, NzMax_ > & 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 (SArray1D< Type_, Size_, NzMax_ > const &T)
 move T to this.
 
SArray1D< Type_, Size_, NzMax_ > & pushBack (int n=1)
 Add n Elements to the end of the container.
 
SArray1D< Type_, Size_, NzMax_ > & popBack (int n=1)
 Delete last elts of the container.
 
SArray1D< Type_, Size_, NzMax_ > & erase (int pos, int n=1)
 Delete n elements at the pos index to the container.
 
SArray1D< Type_, Size_, NzMax_ > & insertElt (int pos, int n=1)
 Insert n elements at the position pos of the container.
 
SArray1D< Type_, Size_, NzMax_ > & insert (int pos, Type const &v)
 STL compatibility: Insert element v at position pos of the Array.
 
SArray1D< Type_, Size_, NzMax_ > & insert (Range const &I, Type const &v)
 STL compatibility: Insert element v in the range I of the Array.
 
SArray1D< Type_, Size_, NzMax_ > & push_front (Type const &v)
 STL compatibility: push front an element.
 
SArray1D< Type_, Size_, NzMax_ > & 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.
 
SArray1D< Type_, Size_, NzMax_ > & 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< SArray1D< Type_, Size_, NzMax_ > >
 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_, int NzMax_>
class STK::SArray1D< Type_, Size_, NzMax_ >

template one dimensional Arrays.

An SArray1D 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 SArray1D
Size_size of the vector if it known. Default is UnknownSize

Definition at line 103 of file STK_SArray1D.h.

Member Typedef Documentation

◆ Allocator

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

Definition at line 125 of file STK_SArray1D.h.

◆ Base

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

Definition at line 106 of file STK_SArray1D.h.

◆ Col

template<class Type_ , int Size_, int NzMax_>
typedef hidden::Traits<SArray1D<Type_,Size_,NzMax_>>::Col STK::SArray1D< Type_, Size_, NzMax_ >::Col

Definition at line 109 of file STK_SArray1D.h.

◆ ColRange

template<class Type_ , int Size_, int NzMax_>
typedef TRange<1> STK::SArray1D< Type_, Size_, NzMax_ >::ColRange

Definition at line 128 of file STK_SArray1D.h.

◆ Row

template<class Type_ , int Size_, int NzMax_>
typedef hidden::Traits<SArray1D<Type_,Size_,NzMax_>>::Row STK::SArray1D< Type_, Size_, NzMax_ >::Row

Definition at line 108 of file STK_SArray1D.h.

◆ RowRange

template<class Type_ , int Size_, int NzMax_>
typedef TRange<size_> STK::SArray1D< Type_, Size_, NzMax_ >::RowRange

Definition at line 127 of file STK_SArray1D.h.

◆ SubVector

template<class Type_ , int Size_, int NzMax_>
typedef hidden::Traits<SArray1D<Type_,Size_,NzMax_>>::SubVector STK::SArray1D< Type_, Size_, NzMax_ >::SubVector

Definition at line 110 of file STK_SArray1D.h.

◆ Type

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

Definition at line 122 of file STK_SArray1D.h.

◆ TypeConst

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

Definition at line 123 of file STK_SArray1D.h.

Member Enumeration Documentation

◆ anonymous enum

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

Definition at line 112 of file STK_SArray1D.h.

113 {
114 structure_ = hidden::Traits< SArray1D<Type_, Size_, NzMax_> >::structure_,
115 orient_ = hidden::Traits< SArray1D<Type_, Size_, NzMax_> >::orient_,
116 sizeCols_ = hidden::Traits< SArray1D<Type_, Size_, NzMax_> >::sizeCols_,
117 sizeRows_ = hidden::Traits< SArray1D<Type_, Size_, NzMax_> >::sizeRows_,
118 size_ = hidden::Traits< SArray1D<Type_, Size_, NzMax_> >::size_,
119 storage_ = hidden::Traits< SArray1D<Type_, Size_, NzMax_> >::storage_
120 };

Constructor & Destructor Documentation

◆ SArray1D() [1/7]

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

Default constructor.

Definition at line 137 of file STK_SArray1D.h.

137: Base(){}
IArray1D< SArray1D< Type_, Size_, NzMax_ > > Base

◆ SArray1D() [2/7]

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

constructor with a specified Range

Parameters
Irange of the container

Definition at line 141 of file STK_SArray1D.h.

141: Base(I) {}

◆ SArray1D() [3/7]

template<class Type_ , int Size_, int NzMax_>
STK::SArray1D< Type_, Size_, NzMax_ >::SArray1D ( 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
Note
if v is not zero, you get a dense array !

Definition at line 146 of file STK_SArray1D.h.

146: Base(I, v) {}

◆ SArray1D() [4/7]

template<class Type_ , int Size_, int NzMax_>
STK::SArray1D< Type_, Size_, NzMax_ >::SArray1D ( SArray1D< Type_, Size_, NzMax_ > 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_SArray1D.h.

151: Base(T, ref) {}

◆ SArray1D() [5/7]

template<class Type_ , int Size_, int NzMax_>
template<int OtherSize_, int OtherNzMax_>
STK::SArray1D< Type_, Size_, NzMax_ >::SArray1D ( SArray1D< Type, OtherSize_, OtherNzMax_ > 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_SArray1D.h.

158 : Base(T, ref) {}

◆ SArray1D() [6/7]

template<class Type_ , int Size_, int NzMax_>
template<int OtherSize_, int OtherNzMax_>
STK::SArray1D< Type_, Size_, NzMax_ >::SArray1D ( SArray1D< Type, OtherSize_, OtherNzMax_ > 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 164 of file STK_SArray1D.h.

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

◆ SArray1D() [7/7]

template<class Type_ , int Size_, int NzMax_>
STK::SArray1D< Type_, Size_, NzMax_ >::SArray1D ( 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 169 of file STK_SArray1D.h.

169: Base(q, I) {}

◆ ~SArray1D()

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

destructor: allocated memory is liberated by MemAllocator base class.

Definition at line 171 of file STK_SArray1D.h.

171{}

Member Function Documentation

◆ operator=() [1/3]

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

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

Parameters
Tthe array to copy

Definition at line 181 of file STK_SArray1D.h.

182 {
183 // check size
184 if (range() != T.range()) { resize(T.range());}
185 for (int i=begin(); i<end(); i++)
186 { allocator().setValue(i, T.elt(i));}
187 return *this;
188 }
Derived & resize(Range const &I=RowRange())

References STK::IArray1D< SArray1D< Type_, Size_, NzMax_ > >::allocator(), STK::IArray1D< SArray1D< Type_, Size_, NzMax_ > >::begin(), STK::IArray1D< SArray1D< Type_, Size_, NzMax_ > >::end(), STK::IArray1D< SArray1D< Type_, Size_, NzMax_ > >::range(), and STK::ITContainer1D< Derived >::resize().

◆ operator=() [2/3]

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

operator = : overwrite the SArray1D with T.

Parameters
Tthe container to copy

Definition at line 175 of file STK_SArray1D.h.

176 { return Base::assign(T);}
SArray1D< Type_, Size_, NzMax_ > & assign(IArray1D const &src)
overwrite this with src.

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

◆ operator=() [3/3]

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

operator= : set the container to a constant value.

Parameters
vthe value to set

Definition at line 192 of file STK_SArray1D.h.

193 {
194 allocator().assign(range(), v);
195 return *this;
196 }

References STK::IArray1D< SArray1D< Type_, Size_, NzMax_ > >::allocator(), and STK::IArray1D< SArray1D< Type_, Size_, NzMax_ > >::range().


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