STK++ 1.0

STK::ITContainer1D< TYPE, TContainer1D > Class Template Reference

Interface base class for homogeneous 1D containers. More...

#include <STK_ITContainer1D.h>

Inheritance diagram for STK::ITContainer1D< TYPE, TContainer1D >:

List of all members.

Public Member Functions

virtual ~ITContainer1D ()
 Virtual destructor.
Integer const & first () const
 Index of the first element.
Integer const & last () const
 Index of the last element.
Integer const & size () const
 Number of elements.
Range const & range () const
 range of the container
TYPE & elt (Integer const &pos)
 Access to one element.
TYPE const & elt (Integer const &pos) const
 Access to one element.
TContainer1D elt (Range const &I) const
 Access to many elements.
TYPE & operator[] (Integer const &pos)
 Operator [] : access to one element.
TYPE const & operator[] (Integer const &pos) const
 Operator [] : access to one element const.
TContainer1D operator[] (Range const &I) const
 Operator [] : access to many elements.
void swap (Integer const &pos1, Integer const &pos2)
 Swap two elements of the container using default constructor of the class TYPE.
TYPE & at (Integer const &pos)
 STL compatibility : return the element number pos.
TYPE const & at (Integer const &pos) const
 STL compatibility : return the element number pos (const).
TYPE & front ()
 STL compatibility : return the first element.
TYPE const & front () const
 STL compatibility : return the first element (const).
TYPE & back ()
 STL compatibility : return the last element.
TYPE const & back () const
 STL compatibility : return the last element (const).
void push_back (TYPE const &v)
 STL compatibility : append an element v.
void push_front (TYPE const &v)
 STL compatibility : push front an element.
void insert (Range const &I, TYPE const &v)
 STL compatibility : insert n elements v in the range I.

Protected Member Functions

 ITContainer1D (Range const &I=Range())
 Default constructor.
 ITContainer1D (const ITContainer1D &T)
 Copy constructor.
void setRange (Range const &I=Range())
 Set range of the rows of the container.
void incRange (Integer const &inc=1)
 increment the range of the container (can be negative).
void incFirst (Integer const &inc=1)
 increment the beginning of the container (can be negative).
void decFirst (Integer const &inc=1)
 decrement the beginning of the container.
void incLast (Integer const &inc=1)
 increment the end of the container (can be negative).
void decLast (Integer const &inc=1)
 decrement the end of the container.

Protected Attributes

Range range_
 Range of the container.

Detailed Description

template<class TYPE, class TContainer1D>
class STK::ITContainer1D< TYPE, TContainer1D >

Interface base class for homogeneous 1D containers.

The ITContainer1D class is the templated base class for all homogeneous one-dimensional containers containing element of type TYPE.

Implement the curious recursive template paradigm : the template parameter TContainer1D is the name of the class that implements ITContainer1D. For example template<class TYPE> class TContainer1D : public ITContainer1D<TYPE, TContainer1D<TYPE> > {...}

The pseudo virtual function defined in this interface have the following definition:

   TYPE& elt(Integer const& pos);
   TYPE const& elt(Integer const& pos) const;
   TContainer1D elt(Range const& I) const;

All these methods have to be implemented in the TContainer1D class.

Definition at line 77 of file STK_ITContainer1D.h.


Constructor & Destructor Documentation

template<class TYPE, class TContainer1D>
STK::ITContainer1D< TYPE, TContainer1D >::ITContainer1D ( Range const &  I = Range()) [inline, protected]

Default constructor.

Parameters:
I: the range of the container

Definition at line 84 of file STK_ITContainer1D.h.

                 : IContainerBase<TContainer1D>(IContainerBase<TContainer1D>::_1D_)
                 , range_(I)
    { this->ranges_.push_back(&range_);}
template<class TYPE, class TContainer1D>
STK::ITContainer1D< TYPE, TContainer1D >::ITContainer1D ( const ITContainer1D< TYPE, TContainer1D > &  T) [inline, protected]

Copy constructor.

Parameters:
Tthe container to copy

Definition at line 92 of file STK_ITContainer1D.h.

                 : IContainerBase<TContainer1D>(IContainerBase<TContainer1D>::_1D_)
                 , range_(T.range_)
    { this->ranges_.push_back(&range_);}
template<class TYPE, class TContainer1D>
virtual STK::ITContainer1D< TYPE, TContainer1D >::~ITContainer1D ( ) [inline, virtual]

Virtual destructor.

Definition at line 99 of file STK_ITContainer1D.h.

{ ;}

Member Function Documentation

template<class TYPE, class TContainer1D>
Integer const& STK::ITContainer1D< TYPE, TContainer1D >::first ( ) const [inline, virtual]

Index of the first element.

Returns:
the index of the first element

Implements STK::IContainer1D.

Definition at line 104 of file STK_ITContainer1D.h.

Referenced by STK::applySort(), STK::ITContainer1D< TYPE, List1D< TYPE > >::at(), STK::ReadWriteCsv::colIndex(), STK::BSplineCoefficients::computeCoefficients(), STK::BSplineCoefficients::computeKnots(), STK::dist(), STK::dot(), STK::dotHouse(), STK::ExportToCsv::ExportToCsv(), STK::ReadWriteCsv::first(), STK::ReadWriteCsv::firstVe(), STK::IArray2D< Integer, Array2D< Integer > >::freeCol(), STK::ITContainer1D< TYPE, List1D< TYPE > >::front(), STK::heapSort(), STK::house(), STK::IArray1DBase< Range, Range, Array1D< Range > >::IArray1DBase(), STK::ReadWriteCsv::largestNumberOfRows(), STK::ReadWriteCsv::lastVe(), STK::ReadWriteCsv::lookupVariableIndex(), STK::Stat::mean(), STK::normInf(), STK::normTwo(), STK::normTwo2(), STK::ReadWriteCsv::operator+=(), STK::operator<<(), STK::Array1D< Real >::operator=(), STK::ArrayHo< Real >::operator=(), STK::MatrixUpperTriangular::operator=(), STK::MatrixLowerTriangular::operator=(), STK::DataFrame::operator=(), STK::ArrayHo< TYPE >::operator=(), STK::Array1D< Variable< String > >::operator=(), STK::ITContainer1D< TYPE, List1D< TYPE > >::push_front(), STK::ITContainer2D< Real, ArrayHo< Real >, Array1D< Real >, MatrixUpperTriangular >::pushBackCol(), STK::DataFrame::pushBackDataFrame(), STK::Law::ITUnivariate< Real >::rand1D(), STK::RandBase::RandBase(), STK::RandBase::randDiscreteUnif(), STK::RandBase::randExp(), STK::RandBase::randGauss(), STK::RandBase::randUnif(), STK::IArray2D< Integer, Array2D< Integer > >::shiftCol(), STK::Funct::stirlingCoefficients(), STK::sum(), STK::ITContainer1D< TYPE, List1D< TYPE > >::swap(), STK::Stat::Univariate< YTYPE, TContainer1D >::Univariate(), STK::Stat::variance(), STK::Stat::varianceWithFixedMean(), STK::weightedDist(), STK::weightedDot(), STK::weightedNormInf(), STK::weightedNormTwo(), STK::weightedNormTwo2(), STK::weightedSum(), and STK::ReadWriteCsv::write().

{ return range_.first();}
template<class TYPE, class TContainer1D>
Integer const& STK::ITContainer1D< TYPE, TContainer1D >::last ( ) const [inline, virtual]

Index of the last element.

Returns:
the index of the last element

Implements STK::IContainer1D.

Definition at line 109 of file STK_ITContainer1D.h.

Referenced by STK::applySort(), STK::ITContainer1D< TYPE, List1D< TYPE > >::at(), STK::ITContainer1D< TYPE, List1D< TYPE > >::back(), STK::ReadWriteCsv::colIndex(), STK::BSplineCoefficients::computeCoefficients(), STK::BSplineCoefficients::computeKnots(), STK::EigenvaluesSymmetric::diagonalize(), STK::dist(), STK::dot(), STK::dotHouse(), STK::ExportToCsv::ExportToCsv(), STK::ReadWriteCsv::firstVe(), STK::heapSort(), STK::house(), STK::IArray1DBase< Range, Range, Array1D< Range > >::IArray1DBase(), STK::IArray2D< Integer, Array2D< Integer > >::insertRows(), STK::ReadWriteCsv::largestNumberOfRows(), STK::ReadWriteCsv::last(), STK::ReadWriteCsv::lastVe(), STK::ReadWriteCsv::lookupVariableIndex(), STK::Stat::mean(), STK::normInf(), STK::normTwo(), STK::normTwo2(), STK::ReadWriteCsv::operator+=(), STK::operator<<(), STK::Array1D< Real >::operator=(), STK::ArrayHo< Real >::operator=(), STK::DataFrame::operator=(), STK::ArrayHo< TYPE >::operator=(), STK::Array1D< Variable< String > >::operator=(), STK::ITContainer1D< TYPE, List1D< TYPE > >::push_back(), STK::ITContainer2D< Real, ArrayHo< Real >, Array1D< Real >, MatrixUpperTriangular >::pushBackCol(), STK::DataFrame::pushBackDataFrame(), STK::Law::ITUnivariate< Real >::rand1D(), STK::RandBase::RandBase(), STK::RandBase::randDiscreteUnif(), STK::RandBase::randExp(), STK::RandBase::randGauss(), STK::RandBase::randUnif(), STK::sum(), STK::ITContainer1D< TYPE, List1D< TYPE > >::swap(), STK::Stat::Univariate< YTYPE, TContainer1D >::Univariate(), STK::Stat::variance(), STK::Stat::varianceWithFixedMean(), STK::weightedDist(), STK::weightedDot(), STK::weightedNormInf(), STK::weightedNormTwo(), STK::weightedNormTwo2(), STK::weightedSum(), and STK::ReadWriteCsv::write().

{ return range_.last();}
template<class TYPE, class TContainer1D>
Range const& STK::ITContainer1D< TYPE, TContainer1D >::range ( ) const [inline, virtual]

range of the container

Returns:
the range of the container

Implements STK::IContainer1D.

Definition at line 119 of file STK_ITContainer1D.h.

Referenced by STK::applySort(), STK::ArrayHo< Real >::ArrayHo(), STK::ArrayHo< TYPE >::ArrayHo(), STK::Stat::center(), STK::Stat::covariance(), STK::Stat::covarianceWithFixedMean(), STK::heapSort(), STK::IArray1DBase< Range, Range, Array1D< Range > >::IArray1DBase(), STK::Qr::insertCol(), STK::RecursiveArray1D< Integer, Array1D< Integer > >::insertElt(), STK::ArrayHo< Real >::insertElt(), STK::ArrayHo< TYPE >::insertElt(), STK::Law::MultivariateNormal< Container1D >::lpdf(), STK::Stat::mean(), STK::mult(), STK::multLefTranspose(), STK::multLeftTranspose(), STK::Array1D< Real >::operator=(), STK::ArrayHo< Real >::operator=(), STK::ArrayHo< TYPE >::operator=(), STK::Array1D< Variable< String > >::operator=(), STK::Law::MultivariateNormal< Container1D >::pdf(), STK::Qr::pushBackCol(), STK::ITContainer2D< Real, ArrayHo< Real >, Array1D< Real >, MatrixUpperTriangular >::pushBackCol(), STK::Law::MultivariateNormal< Container1D >::rand(), STK::EigenvaluesSymmetric::run(), STK::Stat::Univariate< Real, TContainer1D >::setData(), STK::BSplineCoefficients::setData(), STK::Stat::standardize(), STK::IArray1DBase< Range, Range, Array1D< Range > >::swap(), STK::Stat::variance(), STK::Stat::varianceWithFixedMean(), STK::weightedDist(), STK::weightedDot(), STK::weightedNormInf(), STK::weightedNormTwo(), STK::weightedNormTwo2(), and STK::weightedSum().

{ return range_;}
template<class TYPE, class TContainer1D>
TYPE& STK::ITContainer1D< TYPE, TContainer1D >::elt ( Integer const &  pos) [inline]
template<class TYPE, class TContainer1D>
TYPE const& STK::ITContainer1D< TYPE, TContainer1D >::elt ( Integer const &  pos) const [inline]
template<class TYPE, class TContainer1D>
TContainer1D STK::ITContainer1D< TYPE, TContainer1D >::elt ( Range const &  I) const [inline]

Access to many elements.

Parameters:
Ithe range of the elements
Returns:
A container with the elements in the range I of this

Reimplemented in STK::ArrayHo< Real >, STK::Array1D< Real >, STK::Variable< TYPE >, STK::Array1D< TYPE >, STK::ArrayHo< TYPE >, STK::List1D< TYPE >, STK::Variable< String >, STK::Array1D< std::string >, STK::Array1D< Range >, STK::Array1D< Integer >, STK::Array1D< Variable< String > >, STK::List1D< Tool >, and STK::List1D< IVariable * >.

Definition at line 139 of file STK_ITContainer1D.h.

    { return this->asLeaf().elt(I);}
template<class TYPE, class TContainer1D>
TYPE& STK::ITContainer1D< TYPE, TContainer1D >::operator[] ( Integer const &  pos) [inline]

Operator [] : access to one element.

Parameters:
posposition of the element
Returns:
a reference on the pos-th element

Definition at line 146 of file STK_ITContainer1D.h.

    { return this->asLeaf().elt(pos);}
template<class TYPE, class TContainer1D>
TYPE const& STK::ITContainer1D< TYPE, TContainer1D >::operator[] ( Integer const &  pos) const [inline]

Operator [] : access to one element const.

Parameters:
posposition of the element
Returns:
a constant reference on the pos-th element

Definition at line 153 of file STK_ITContainer1D.h.

    { return this->asLeaf().elt(pos);}
template<class TYPE, class TContainer1D>
TContainer1D STK::ITContainer1D< TYPE, TContainer1D >::operator[] ( Range const &  I) const [inline]

Operator [] : access to many elements.

Parameters:
Ithe range of the elements
Returns:
a container with the elements in the range I of this

Definition at line 160 of file STK_ITContainer1D.h.

    { return this->asLeaf().elt(I);}
template<class TYPE, class TContainer1D>
void STK::ITContainer1D< TYPE, TContainer1D >::swap ( Integer const &  pos1,
Integer const &  pos2 
) [inline]

Swap two elements of the container using default constructor of the class TYPE.

Parameters:
pos1position of the first element
pos2position of the second element

Reimplemented in STK::IArray1DBase< TYPE, PTRELT, TArray1D >, STK::List1D< TYPE >, STK::IArray1DBase< TYPE, TYPE *, ArrayHo< TYPE > >, STK::IArray1DBase< TYPE, TYPE, Array1D< TYPE > >, STK::IArray1DBase< Real, Real *, ArrayHo< Real > >, STK::IArray1DBase< TYPE, TYPE, Container1D >, STK::IArray1DBase< String, String, Variable< String > >, STK::IArray1DBase< Real, Real, Array1D< Real > >, STK::IArray1DBase< std::string, std::string, Array1D< std::string > >, STK::IArray1DBase< TYPE, TYPE, Variable< TYPE > >, STK::IArray1DBase< Variable< String >, Variable< String >, Array1D< Variable< String > > >, STK::IArray1DBase< Integer, Integer, Array1D< Integer > >, STK::IArray1DBase< Range, Range, Array1D< Range > >, STK::List1D< Tool >, and STK::List1D< IVariable * >.

Definition at line 168 of file STK_ITContainer1D.h.

    {
#ifdef STK_BOUNDS_CHECK
      // check indices
      if (pos1<this->first())
      { throw std::out_of_range("ITContainer1D::swap(pos1, pos2) "
                                "pos1<this->first()");
      }
      if (pos1>this->last())
      { throw std::out_of_range("ITContainer1D::swap(pos1, pos2) "
                                "pos1>this->last()");
      }
      if (pos2<this->first())
      { throw std::out_of_range("ITContainer1D::swap(pos1, pos2) "
                                "pos2<this->first()");
      }
      if (pos2>this->last())
      { throw std::out_of_range("ITContainer1D::swap(pos1, pos2) "
                                "pos2>this->last()");
      }
#endif
      // swap
      TYPE aux(this->asLeaf().elt(pos1));
      this->asLeaf().elt(pos1) = this->asLeaf().elt(pos2);
      this->asLeaf().elt(pos2) = aux;
    }
template<class TYPE, class TContainer1D>
TYPE& STK::ITContainer1D< TYPE, TContainer1D >::at ( Integer const &  pos) [inline]

STL compatibility : return the element number pos.

Parameters:
posposition of the element
Returns:
a reference on the pos-th element of the container

Definition at line 199 of file STK_ITContainer1D.h.

Referenced by STK::ReadWriteCsv::at(), STK::ReadWriteCsv::back(), STK::ReadWriteCsv::data(), STK::ExportToCsv::ExportToCsv(), STK::ReadWriteCsv::firstVe(), STK::ReadWriteCsv::front(), STK::DataFrame::insertDataFrame(), STK::ReadWriteCsv::lastVe(), STK::ReadWriteCsv::name(), STK::ReadWriteCsv::operator()(), STK::operator>>(), STK::ReadWriteCsv::operator[](), STK::DataFrame::pushBackDataFrame(), STK::ReadWriteCsv::setData(), STK::ReadWriteCsv::setName(), STK::ReadWriteCsv::sizeVe(), and STK::ReadWriteCsv::writeSelection().

    {
      if ((pos<this->first()))
      {
        throw std::out_of_range("ITContainer1D::at(pos) "
                                "pos<this->first()");
      }
      if ((pos>this->last()))
      { throw std::out_of_range("ITContainer1D::at(pos) "
                                "pos>this->last()");
      }
      return this->asLeaf().elt(pos);
    }
template<class TYPE, class TContainer1D>
TYPE const& STK::ITContainer1D< TYPE, TContainer1D >::at ( Integer const &  pos) const [inline]

STL compatibility : return the element number pos (const).

Parameters:
posposition of the element
Returns:
a constant reference on the pos-th element of the container

Definition at line 217 of file STK_ITContainer1D.h.

    {
      if (pos<this->first())
      {
        throw std::out_of_range("ITContainer1D::at(pos) "
                                "pos<this->first()");
      }
      if (pos>this->last())
      { throw std::out_of_range("ITContainer1D::at(pos) "
                                "pos>this->last()");
      }
      return this->asLeaf().elt(pos);
    }
template<class TYPE, class TContainer1D>
TYPE& STK::ITContainer1D< TYPE, TContainer1D >::front ( ) [inline]

STL compatibility : return the first element.

Returns:
a reference on the first element of the container

Definition at line 234 of file STK_ITContainer1D.h.

Referenced by STK::Svd::bidiag(), STK::house(), STK::Qr::qr(), and STK::EigenvaluesSymmetric::tridiagonalize().

    { return this->asLeaf().elt(this->first()); }
template<class TYPE, class TContainer1D>
TYPE const& STK::ITContainer1D< TYPE, TContainer1D >::front ( ) const [inline]

STL compatibility : return the first element (const).

Returns:
a constant reference on the first element of the container

Definition at line 240 of file STK_ITContainer1D.h.

    { return this->asLeaf().elt(this->first()); }
template<class TYPE, class TContainer1D>
TYPE& STK::ITContainer1D< TYPE, TContainer1D >::back ( ) [inline]

STL compatibility : return the last element.

Returns:
a reference on the last element of the container

Definition at line 246 of file STK_ITContainer1D.h.

Referenced by STK::ReadWriteCsv::push_back(), and STK::EigenvaluesSymmetric::tridiagonalize().

    { return this->asLeaf().elt(this->last()); }
template<class TYPE, class TContainer1D>
TYPE const& STK::ITContainer1D< TYPE, TContainer1D >::back ( ) const [inline]

STL compatibility : return the last element (const).

Returns:
a constant reference on the last element of the container

Definition at line 252 of file STK_ITContainer1D.h.

    { return this->asLeaf().elt(this->last()); }
template<class TYPE, class TContainer1D>
void STK::ITContainer1D< TYPE, TContainer1D >::push_back ( TYPE const &  v) [inline]

STL compatibility : append an element v.

Parameters:
vvalue to append

Definition at line 258 of file STK_ITContainer1D.h.

Referenced by STK::Category::addTool(), STK::ReadWriteCsv::appendData(), STK::Funct::coefs_odd_se(), STK::CountCols(), STK::ExportToCsv::ExportToCsv(), STK::ReadWriteCsv::operator+=(), STK::operator>>(), and STK::ReadWriteCsv::push_back().

    {
      this->asLeaf().pushBack();
      this->asLeaf().elt(this->last()) = v;
    }
template<class TYPE, class TContainer1D>
void STK::ITContainer1D< TYPE, TContainer1D >::push_front ( TYPE const &  v) [inline]

STL compatibility : push front an element.

Parameters:
vvalue to append

Definition at line 267 of file STK_ITContainer1D.h.

Referenced by STK::ReadWriteCsv::push_front().

    { insert(Range(this->first(), this->first()), v);}
template<class TYPE, class TContainer1D>
void STK::ITContainer1D< TYPE, TContainer1D >::insert ( Range const &  I,
TYPE const &  v 
) [inline]

STL compatibility : insert n elements v in the range I.

Parameters:
Irange of the element to insert
vvalue to insert

Reimplemented in STK::ArrayHo< TYPE >, STK::List1D< TYPE >, STK::List1D< Tool >, and STK::List1D< IVariable * >.

Definition at line 274 of file STK_ITContainer1D.h.

Referenced by STK::IArray2D< Integer, Array2D< Integer > >::insertCols(), and STK::ITContainer1D< TYPE, List1D< TYPE > >::push_front().

    {
      this->insertElt(I.first(), I.size());
      for (Integer i=I.first(); i<=I.last(); i++)
        this->asLeaf().elt(i) = v;
    }
template<class TYPE, class TContainer1D>
void STK::ITContainer1D< TYPE, TContainer1D >::setRange ( Range const &  I = Range()) [inline, protected]

Set range of the rows of the container.

Parameters:
Ithe range to set (default empty)

Definition at line 288 of file STK_ITContainer1D.h.

Referenced by STK::IArray1DBase< Range, Range, Array1D< Range > >::swap().

    { range_ = I;}
template<class TYPE, class TContainer1D>
void STK::ITContainer1D< TYPE, TContainer1D >::incRange ( Integer const &  inc = 1) [inline, protected]

increment the range of the container (can be negative).

Parameters:
incincrement to apply to the range

Definition at line 294 of file STK_ITContainer1D.h.

    { range_.inc(inc);}
template<class TYPE, class TContainer1D>
void STK::ITContainer1D< TYPE, TContainer1D >::incFirst ( Integer const &  inc = 1) [inline, protected]

increment the beginning of the container (can be negative).

Parameters:
incthe increment to apply to the beginning of the range

Definition at line 300 of file STK_ITContainer1D.h.

    { range_.incFirst(inc);}
template<class TYPE, class TContainer1D>
void STK::ITContainer1D< TYPE, TContainer1D >::decFirst ( Integer const &  inc = 1) [inline, protected]

decrement the beginning of the container.

Parameters:
incthe decrement to apply to the beginning of the range

Definition at line 306 of file STK_ITContainer1D.h.

    { range_.decFirst(inc);}
template<class TYPE, class TContainer1D>
void STK::ITContainer1D< TYPE, TContainer1D >::incLast ( Integer const &  inc = 1) [inline, protected]

increment the end of the container (can be negative).

Parameters:
incthe increment to apply to the end of the range

Definition at line 312 of file STK_ITContainer1D.h.

Referenced by STK::IArray2D< Integer, Array2D< Integer > >::insertRowsToCol(), and STK::IArray2D< Integer, Array2D< Integer > >::pushBackRowsToCol().

    { range_.incLast(inc);}
template<class TYPE, class TContainer1D>
void STK::ITContainer1D< TYPE, TContainer1D >::decLast ( Integer const &  inc = 1) [inline, protected]

decrement the end of the container.

Parameters:
incthe decrement to apply to the end of the range

Definition at line 318 of file STK_ITContainer1D.h.

Referenced by STK::IArray2D< Integer, Array2D< Integer > >::eraseRowsToCol(), and STK::IArray2D< Integer, Array2D< Integer > >::popBackRowsToCol().

    { range_.decLast(inc);}

Member Data Documentation


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