STK++ 1.0

STK::Array1D< TYPE > Class Template Reference

Templated one dimensional Array. More...

#include <STK_Array1D.h>

Inheritance diagram for STK::Array1D< TYPE >:

List of all members.

Public Member Functions

 Array1D (Range const &I=Range())
 Default constructor : beg_ =1 and end_ =0.
 Array1D (Range const &I, TYPE const &v)
 Misc constructor with beg and end, initialization with a constant.
 Array1D (const Array1D &T, bool ref=false)
 Copy constructor.
 Array1D (Array1D const &T, Range const &I)
 constructor by reference, ref_=1.
 Array1D (TYPE *q, Range const &I, Integer const &index=0)
 Wrapper constructor : the container is a reference.
 Array1D (_IArrayBaseType const &T, Range const &I, Integer const &index)
 constructor by reference, ref_=1.
virtual ~Array1D ()
 Virtual destructor: allocated memory is liberated by IArrayBase base class.
TYPE & elt (Integer const &pos)
 access to one element.
TYPE const & elt (Integer const &pos) const
 access to one element const.
Array1D elt (Range const &J) const
 access to many elements.
Array1D< TYPE > & operator= (const Array1D< TYPE > &T)
 operator = : overwrite the Array1D with t.
Array1Doperator= (TYPE const &v)
 operator= : set the container to a constant value.
template<class LEAF >
Array1Doperator= (const ITContainer1D< TYPE, LEAF > &T)
 operator = : overwrite the ArrayHo with the ITContainer1D T.

Private Types

typedef IArrayBase< TYPE * > _IArrayBaseType
 Type for the Base reference Class.
typedef RecursiveArray1D< TYPE,
Array1D< TYPE > > 
_IArray1DType
 Type for the IArray1DBase Class.

Detailed Description

template<class TYPE>
class STK::Array1D< TYPE >

Templated one dimensional Array.

An Array1D is a templated non-oriented container implementing the interface base class RecursiveArray1D. It contains objects of the type TYPE. It is a final class for the curious recursive paradigm.

Definition at line 54 of file STK_Array1D.h.


Member Typedef Documentation

template<class TYPE>
typedef IArrayBase<TYPE*> STK::Array1D< TYPE >::_IArrayBaseType [private]

Type for the Base reference Class.

Reimplemented from STK::RecursiveArray1D< TYPE, Array1D< TYPE > >.

Definition at line 57 of file STK_Array1D.h.

template<class TYPE>
typedef RecursiveArray1D<TYPE, Array1D<TYPE> > STK::Array1D< TYPE >::_IArray1DType [private]

Type for the IArray1DBase Class.

Reimplemented from STK::RecursiveArray1D< TYPE, Array1D< TYPE > >.

Definition at line 59 of file STK_Array1D.h.


Constructor & Destructor Documentation

template<class TYPE>
STK::Array1D< TYPE >::Array1D ( Range const &  I = Range()) [inline]

Default constructor : beg_ =1 and end_ =0.

Parameters:
Irange of the container

Definition at line 65 of file STK_Array1D.h.

Referenced by STK::Array1D< Real >::elt(), and STK::Array1D< Variable< String > >::elt().

           : _IArray1DType(I)
    { ;}
template<class TYPE>
STK::Array1D< TYPE >::Array1D ( Range const &  I,
TYPE const &  v 
) [inline]

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

Parameters:
Irange of the container
vinitial value of the container

Definition at line 73 of file STK_Array1D.h.

           : _IArray1DType(I, v)
    { }
template<class TYPE>
STK::Array1D< TYPE >::Array1D ( const Array1D< TYPE > &  T,
bool  ref = false 
) [inline]

Copy constructor.

Parameters:
Tthe container to copy
reftrue if T is wrapped

Definition at line 81 of file STK_Array1D.h.

           : _IArray1DType(T, ref)
    { }
template<class TYPE>
STK::Array1D< TYPE >::Array1D ( Array1D< TYPE > const &  T,
Range const &  I 
) [inline]

constructor by reference, ref_=1.

Parameters:
Tthe container to wrap
Irange of the data to wrap

Definition at line 89 of file STK_Array1D.h.

           : _IArray1DType(T, I)
    { ;}
template<class TYPE>
STK::Array1D< TYPE >::Array1D ( TYPE *  q,
Range const &  I,
Integer const &  index = 0 
) [inline]

Wrapper constructor : the container is a reference.

Parameters:
qpointer on data
Irange of the data
indexindex (row or column) of the data

Definition at line 98 of file STK_Array1D.h.

           : _IArray1DType(q, I, index)
    { ;}
template<class TYPE>
STK::Array1D< TYPE >::Array1D ( _IArrayBaseType const &  T,
Range const &  I,
Integer const &  index 
) [inline]

constructor by reference, ref_=1.

Parameters:
Tthe container to wrap
Ithe range of the data to wrap
indexthe index of the columnto wrap

Definition at line 107 of file STK_Array1D.h.

            : _IArray1DType(T, I, index)
    { ;}
template<class TYPE>
virtual STK::Array1D< TYPE >::~Array1D ( ) [inline, virtual]

Virtual destructor: allocated memory is liberated by IArrayBase base class.

Definition at line 112 of file STK_Array1D.h.

{ ;}

Member Function Documentation

template<class TYPE>
TYPE& STK::Array1D< TYPE >::elt ( Integer const &  pos) [inline]

access to one element.

Parameters:
posindex of the element

Reimplemented from STK::ITContainer1D< TYPE, Array1D< TYPE > >.

Definition at line 117 of file STK_Array1D.h.

Referenced by STK::Array1D< Real >::operator*=(), STK::Array1D< Real >::operator+=(), STK::Array1D< Real >::operator-=(), and STK::Array1D< Real >::operator/=().

    { return this->data(pos);}
template<class TYPE>
TYPE const& STK::Array1D< TYPE >::elt ( Integer const &  pos) const [inline]

access to one element const.

Parameters:
posindex of the const element

Reimplemented from STK::ITContainer1D< TYPE, Array1D< TYPE > >.

Definition at line 123 of file STK_Array1D.h.

    { return this->data(pos);}
template<class TYPE>
Array1D STK::Array1D< TYPE >::elt ( Range const &  J) const [inline]

access to many elements.

Parameters:
Jthe range of the elements

Reimplemented from STK::ITContainer1D< TYPE, Array1D< TYPE > >.

Definition at line 129 of file STK_Array1D.h.

    {
#ifdef STK_BOUNDS_CHECK
      if ((J.first()<this->first()))
      { throw std::out_of_range("Array1D::elt(J) "
                                "J.first()<this->first()");
      }
      if ((J.last()>this->last()))
      { throw std::out_of_range("Array1D::elt(J) "
                                "J.last()>this->last()");
      }
#endif
      return Array1D(this->asLeaf(), J);
    }
template<class TYPE>
Array1D<TYPE>& STK::Array1D< TYPE >::operator= ( const Array1D< TYPE > &  T) [inline]

operator = : overwrite the Array1D with t.

We resize the object if this and T does not have the same size but if they have the same size, we don't modify the range of the object.

Parameters:
Tthe container to copy

Definition at line 150 of file STK_Array1D.h.

    {
      // check size
      if (this->size()!=T.size()) this->resize(T.range());

      // copy without ovelapping.
      const Integer first = this->first(), last = this->last();
      if (first < T.first())
      { for (Integer i=first, j=T.first(); i<=last; i++, j++)
          this->setData(i, T.data(j));
      }
      else
      { for (Integer i=last, j=T.last(); i>=first; i--, j--)
          this->setData(i, T.data(j));
      }
      return *this;
    }
template<class TYPE>
Array1D& STK::Array1D< TYPE >::operator= ( TYPE const &  v) [inline]

operator= : set the container to a constant value.

Parameters:
vthe value to set

Definition at line 171 of file STK_Array1D.h.

    {
      const Integer first = this->first(), last = this->last();
      for (Integer i=first; i<=last; i++)
        this->setData(i, v);
      return *this;
    }
template<class TYPE>
template<class LEAF >
Array1D& STK::Array1D< TYPE >::operator= ( const ITContainer1D< TYPE, LEAF > &  T) [inline]

operator = : overwrite the ArrayHo with the ITContainer1D T.

We resize this if this and T don't have the same size but if they have the same size, we don't modify the range of the object.

Parameters:
Tthe container to copy

Definition at line 186 of file STK_Array1D.h.

    { // We have to resize if this and T does not have the same size
      // but if they have the same size, we don't scale the index
      if (this->size()!=T.size()) this->resize(T.range());

      // copy without ovelapping
      const Integer first = this->first(), last = this->last();
      if (first < T.first())
      {
        for (Integer j=first, i=T.first(); j<=last; j++, i++)
          this->setData(j, T[i]);
      }
      else
      {
        for (Integer j=last, i=T.last(); j>=first; j--, i--)
          this->setData(j, T[i]);
      }
      return *this;
    }

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