STK++ 1.0

STK::ArrayHo< Real > Class Template Reference

Specialization of the templated class ArrayHo for Real. More...

#include <STK_Point.h>

Inheritance diagram for STK::ArrayHo< Real >:

List of all members.

Public Types

typedef IArrayBase< Real * > _IArrayBaseType
 Type for the Base reference Class.
typedef IArray1DBase< Real,
Real *, ArrayHo< Real > > 
_IArrayHoType
 Type for the Implementation Class.

Public Member Functions

 ArrayHo (Range const &I=Range())
 Default constructor : first_ =1 and last_ =0.
 ArrayHo (Range const &I, Real const &v)
 Misc constructor with beg and end, initialization with a constant.
 ArrayHo (const ArrayHo &T, bool ref=false)
 Copy constructor.
 ArrayHo (const ArrayHo< Real > &T, Range const &I)
 constructor by reference, ref_=1.
 ArrayHo (const _IArrayBaseType &T, Range const &I, Integer row)
 constructor by reference, ref_=1.
virtual ~ArrayHo ()
 virtual destructor.
Real const & elt (Integer const &pos) const
 Get one element const.
Realelt (Integer const &pos)
 Get one element.
ArrayHo elt (Range const &J) const
 access to many elements.
void clear ()
 clear the object.
void freeMem ()
 Method for memory deallocation.
void initialize (Range const &I)
 function for memory allocation and initialization.
void pushBack (Integer const &n=1)
 Add n Elts to the container.
void popBack (Integer const &n=1)
 Delete last elts of the container.
void erase (Integer const &pos, Integer const &n=1)
 Delete n elts at the pos index to the container.
ArrayHooperator= (const ArrayHo &T)
 operator = : overwrite the ArrayHo with T.
ArrayHooperator= (Real const &v)
 operator= : set the container to a constant value.
ArrayHooperator+= (Real const &v)
 operator+= Adding a constant.
ArrayHooperator-= (Real const &v)
 operator -= decreasing a constant.
ArrayHooperator/= (Real const &v)
 operator /= Dividing a constant.
ArrayHooperator*= (Real const &v)
 operator *= Multiplying a constant.
template<class LEAF >
ArrayHooperator= (const ITContainer1D< Real, LEAF > &T)
 operator = : overwrite the ArrayHo with the container T.
template<class Exp >
ArrayHooperator= (const Exp &rhs)
 operator = overwriting a ArrayHo with An Expression.
template<class Exp >
ArrayHooperator+= (const Exp &rhs)
 operator += Adding an Expression.
template<class Exp >
ArrayHooperator-= (const Exp &rhs)
 operator -= decreasing an Expression.
template<class Exp >
ArrayHooperator/= (const Exp &rhs)
 operator /= Dividing an Expression.
template<class Exp >
ArrayHooperator*= (const Exp &rhs)
 operator *= Multiplying an Expression.

Protected Member Functions

void initElts (Range const &J)
 Method for elts memory allocation.
void freeElts (Range const &J)
 Method for Elts memory deallocation.
void initElt (Integer const &pos)
 function for the the allocation of memory of element pos.
void freeElt (Integer const &pos)
 protected function for the the deallocation of memory of the element pos.
void insertElt (Integer const &pos, Integer const &n=1)
 Insert n elts at the position pos of the container.

Detailed Description

template<>
class STK::ArrayHo< Real >

Specialization of the templated class ArrayHo for Real.

An ArrayHo<Real> is a Point. It is a horizontal (row) container.

Definition at line 59 of file STK_Point.h.


Member Typedef Documentation

Type for the Base reference Class.

Reimplemented from STK::IArray1DBase< Real, Real *, ArrayHo< Real > >.

Definition at line 63 of file STK_Point.h.

Type for the Implementation Class.

Definition at line 66 of file STK_Point.h.


Constructor & Destructor Documentation

STK::ArrayHo< Real >::ArrayHo ( Range const &  I = Range()) [inline]

Default constructor : first_ =1 and last_ =0.

Parameters:
Irange of the container

Definition at line 71 of file STK_Point.h.

References STK::ArrayHo< TYPE >::initElts().

           : _IArrayHoType(I)
    { this->initElts(I);}
STK::ArrayHo< Real >::ArrayHo ( Range const &  I,
Real 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 79 of file STK_Point.h.

References STK::ArrayHo< TYPE >::elt(), STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::first(), STK::ArrayHo< TYPE >::initElts(), and STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::last().

           : _IArrayHoType(I)
    {
      this->initElts(I);
      // set value v
      for (Integer i=this->first(); i<=this->last(); i++)
        this->elt(i) = v;
    }
STK::ArrayHo< Real >::ArrayHo ( const ArrayHo< Real > &  T,
bool  ref = false 
) [inline]

Copy constructor.

Parameters:
Tthe container to copy
reftrue if this is a wrapper of T

Definition at line 92 of file STK_Point.h.

References STK::IArrayBase< DATA >::data(), STK::IArrayBase< TYPE * >::data(), STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::first(), STK::IArray1DBase< TYPE, PTRELT, TArray1D >::getIndex(), STK::ArrayHo< TYPE >::initElts(), STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::last(), and STK::ITContainer1D< TYPE, TContainer1D >::range().

           : _IArrayHoType(T, ref)
    {
      // check if we want just a reference
      if (!ref)
      {
        // if this is not a reference, initialize the container
        this->initElts(T.range());
        // this and T have the same row : save time
        const Integer row(T.getIndex());
        // and copy the data
        for (Integer j=this->first(); j<=this->last(); j++)
          this->data(j)[row] = T.data(j)[row];
      }
    }
STK::ArrayHo< Real >::ArrayHo ( const ArrayHo< Real > &  T,
Range const &  I 
) [inline]

constructor by reference, ref_=1.

Parameters:
Tthe container to wrap
Ithe range of the data to wrap

Definition at line 112 of file STK_Point.h.

           : _IArrayHoType(T, I)
    { ;}
STK::ArrayHo< Real >::ArrayHo ( const _IArrayBaseType T,
Range const &  I,
Integer  row 
) [inline]

constructor by reference, ref_=1.

Parameters:
Tthe container to wrap
Ithe range of the data to wrap
rowthe index of the row to wrap

Definition at line 121 of file STK_Point.h.

            : _IArrayHoType(T, I, row)
    { ;}
virtual STK::ArrayHo< Real >::~ArrayHo ( ) [inline, virtual]

virtual destructor.

Definition at line 126 of file STK_Point.h.

References STK::ArrayHo< TYPE >::freeElts(), STK::IContainerRef::isRef(), and STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::range().

    { if (!this->isRef())
      { freeElts(this->range());}
    }

Member Function Documentation

Real const& STK::ArrayHo< Real >::elt ( Integer const &  pos) const [inline]

Get one element const.

Parameters:
posindex of the element (const)

Reimplemented from STK::ITContainer1D< Real, ArrayHo< Real > >.

Definition at line 134 of file STK_Point.h.

References STK::IArrayBase< TYPE * >::data(), and STK::IArray1DBase< TYPE, TYPE *, ArrayHo< TYPE > >::getIndex().

    { return this->data(pos)[this->getIndex()];}
Real& STK::ArrayHo< Real >::elt ( Integer const &  pos) [inline]

Get one element.

Parameters:
posindex of the element

Reimplemented from STK::ITContainer1D< Real, ArrayHo< Real > >.

Definition at line 140 of file STK_Point.h.

References STK::IArrayBase< TYPE * >::data(), and STK::IArray1DBase< TYPE, TYPE *, ArrayHo< TYPE > >::getIndex().

    { return this->data(pos)[this->getIndex()];}
ArrayHo STK::ArrayHo< Real >::elt ( Range const &  J) const [inline]

access to many elements.

Parameters:
JRange of the elements

Reimplemented from STK::ITContainer1D< Real, ArrayHo< Real > >.

Definition at line 146 of file STK_Point.h.

References STK::ArrayHo< TYPE >::ArrayHo(), and STK::IArray1DBase< TYPE, TYPE *, ArrayHo< TYPE > >::getIndex().

    { return ArrayHo(*this, J, this->getIndex());}
void STK::ArrayHo< Real >::clear ( ) [inline, virtual]

clear the object.

Implements STK::IContainer1D.

Definition at line 150 of file STK_Point.h.

References STK::ArrayHo< TYPE >::freeMem(), and STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::setRange().

Referenced by STK::Svd::clear().

    {
      this->freeMem();  // Free Mem
      this->setRange(); // Set dimension to default
    }
void STK::ArrayHo< Real >::freeMem ( ) [inline]

Method for memory deallocation.

Memory is liberated but the range of the container is not updated.

Definition at line 159 of file STK_Point.h.

References STK::IArray1DBase< TYPE, TYPE *, ArrayHo< TYPE > >::free1D(), STK::ArrayHo< TYPE >::freeElts(), STK::IContainerRef::isRef(), and STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::range().

    {
      if (this->isRef()) return;        // Nothing to do for ref
      this->freeElts(this->range()); // free the ptr of elts
      this->free1D();                   // free the elts
    }
void STK::ArrayHo< Real >::initialize ( Range const &  I) [inline]

function for memory allocation and initialization.

This method will free all allocated memory owned by this container before initialization.

Parameters:
Irange of the container

Definition at line 171 of file STK_Point.h.

References STK::ArrayHo< TYPE >::clear(), STK::IArray1DBase< TYPE, TYPE *, ArrayHo< TYPE > >::init1D(), STK::ArrayHo< TYPE >::initElts(), STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::setRange(), and STK::IContainerRef::setRef().

    {
      // check if there is memory allocated
      this->clear();
      // if we initialize the memory the container is not a reference
      this->setRef(false);
      // try to allocate memory
      this->init1D(I);
      // initialize Horizontally the container
      this->initElts(I);
      // set the range of the container if init1D is successful
      this->setRange(I);
    }
void STK::ArrayHo< Real >::pushBack ( Integer const &  n = 1) [inline, virtual]

Add n Elts to the container.

Parameters:
nnumber of elements to add

Implements STK::IContainer1D.

Definition at line 188 of file STK_Point.h.

References STK::IContainer1D::empty(), STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::first(), STK::ArrayHo< TYPE >::initialize(), STK::ArrayHo< TYPE >::insertElt(), STK::IContainerRef::isRef(), and STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::last().

    {
      // if n<=0 nothing to do
      if (n <= 0) return;
      // is this structure just a pointer?
      if (this->isRef())
      { throw std::runtime_error("ArrayHo::pushBack(n) "
                            "can't operate on references.");
      }
      // If the container is empty : create it
      if (this->empty())
        this->initialize(Range(this->first(), this->first()+n-1));
      else
        this->insertElt(this->last()+1, n);
    }
void STK::ArrayHo< Real >::popBack ( Integer const &  n = 1) [inline, virtual]

Delete last elts of the container.

Parameters:
nnumber of elts to delete

Implements STK::IContainer1D.

Definition at line 207 of file STK_Point.h.

References STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::decLast(), STK::ArrayHo< TYPE >::freeElts(), STK::ArrayHo< TYPE >::freeMem(), STK::IContainerRef::isRef(), STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::last(), and STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::size().

    {
      // if n<=0 nothing to do
      if (n <= 0) return;
      // is this structure just a pointer?
      if (this->isRef())
      { throw std::runtime_error("ArrayHo::popBack() "
                            "can't operate on references.");
      }
#ifdef STK_BOUNDS_CHECK
      // if there is elts to erase
      if (this->size()<n)
      { throw std::out_of_range("ArrayHo::popBack(n) "
                           "this->size() < n");
      }
#endif
      // delete each elt
      this->freeElts(Range(this->last()-n+1, this->last()));
      // update range
      this->decLast(n);
      // if there is no more Elts
      if (this->size() == 0) this->freeMem();
    }
void STK::ArrayHo< Real >::erase ( Integer const &  pos,
Integer const &  n = 1 
) [inline, virtual]

Delete n elts at the pos index to the container.

Parameters:
posindex where to delete elements
nnumber of elements to delete (default 1)

Implements STK::IContainer1D.

Definition at line 235 of file STK_Point.h.

References STK::IArrayBase< TYPE * >::data(), STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::decLast(), STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::first(), STK::ArrayHo< TYPE >::freeElts(), STK::ArrayHo< TYPE >::freeMem(), STK::IContainerRef::isRef(), STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::last(), STK::IArrayBase< TYPE * >::setData(), and STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::size().

    {
      // if n==0 nothing to do
      if (n<=0) return;
      // is this structure just a pointer?
      if (this->isRef())
      { throw std::runtime_error("ArrayHo::erase(pos, n) "
                            "can't operate on references.");
      }
#ifdef STK_BOUNDS_CHECK
      // check bounds
      if (this->first() > pos)
      { throw std::out_of_range("ArrayHo::erase(pos, n) "
                           "this->first() > pos");
      }
      if (this->last() < pos)
      { throw std::out_of_range("ArrayHo::erase(pos, n)"
                           " this->last() < pos");
      }
      if (this->last() < pos+n-1)
      { throw std::out_of_range("ArrayHo::erase(pos, n)"
                           " this->last() < pos+n-1");
      }
#endif
      // delete each col
      freeElts(Range(pos, pos+n-1));
      // shift Elts
      const Integer last = this->last()-n;
      for (Integer k=pos; k<=last; k++)
        this->setData(k, this->data(k+n));
      // update rangeHo_
      this->decLast(n);
      // if there is no more Elts
      if (this->size() == 0) this->freeMem();
    }
ArrayHo& STK::ArrayHo< Real >::operator= ( const ArrayHo< Real > &  T) [inline]

operator = : overwrite the ArrayHo 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 277 of file STK_Point.h.

References STK::ArrayHo< TYPE >::elt(), STK::ITContainer1D< TYPE, TContainer1D >::first(), STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::first(), STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::last(), STK::ITContainer1D< TYPE, TContainer1D >::last(), STK::ITContainer1D< TYPE, TContainer1D >::range(), STK::IContainer1D::resize(), STK::ITContainer1D< TYPE, TContainer1D >::size(), and STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::size().

    { // 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
      if (this->first() < T.first())
      { for (Integer j=this->first(), i=T.first(); i<=T.last(); j++, i++)
          elt(j) = T.elt(i);
      }
      else
      { for (Integer j=this->last(), i=T.last(); i>=T.first(); j--, i--)
          elt(j) = T.elt(i);
      }
      return *this;
    }
ArrayHo& STK::ArrayHo< Real >::operator= ( Real const &  v) [inline]

operator= : set the container to a constant value.

Parameters:
vthe value to set

Definition at line 297 of file STK_Point.h.

References STK::ArrayHo< TYPE >::elt(), STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::first(), and STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::last().

    {
      for (Integer i=this->first(); i<=this->last(); i++)
        this->elt(i) = v;
      return *this;
    }
ArrayHo& STK::ArrayHo< Real >::operator+= ( Real const &  v) [inline]

operator+= Adding a constant.

Parameters:
vthe value to add

Definition at line 307 of file STK_Point.h.

References STK::ArrayHo< TYPE >::elt(), STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::first(), and STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::last().

    {
      for (Integer i=this->first(); i<=this->last(); i++)
        this->elt(i) += v;
      return *this;
    }
ArrayHo& STK::ArrayHo< Real >::operator-= ( Real const &  v) [inline]

operator -= decreasing a constant.

Parameters:
vthe value to decrease

Definition at line 317 of file STK_Point.h.

References STK::ArrayHo< TYPE >::elt(), STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::first(), and STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::last().

    {
      for (Integer i=this->first(); i<=this->last(); i++)
        this->elt(i) -= v;
      return *this;
    }
ArrayHo& STK::ArrayHo< Real >::operator/= ( Real const &  v) [inline]

operator /= Dividing a constant.

Parameters:
vthe value to divide

Definition at line 327 of file STK_Point.h.

References STK::ArrayHo< TYPE >::elt(), STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::first(), and STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::last().

    {
      for (Integer i=this->first(); i<=this->last(); i++)
        this->elt(i) /= v;
      return *this;
    }
ArrayHo& STK::ArrayHo< Real >::operator*= ( Real const &  v) [inline]

operator *= Multiplying a constant.

Parameters:
vthe value to multiply

Definition at line 337 of file STK_Point.h.

References STK::ArrayHo< TYPE >::elt(), STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::first(), and STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::last().

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

operator = : overwrite the ArrayHo with the container 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 351 of file STK_Point.h.

References STK::ArrayHo< TYPE >::elt(), STK::ITContainer1D< TYPE, TContainer1D >::first(), STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::first(), STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::last(), STK::ITContainer1D< TYPE, TContainer1D >::last(), STK::ITContainer1D< TYPE, TContainer1D >::range(), STK::IContainer1D::resize(), STK::ITContainer1D< TYPE, TContainer1D >::size(), and STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::size().

    { // 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
      if (this->first() < T.first())
      { for (Integer j=this->first(), i=T.first(); i<=T.last(); j++, i++)
          elt(j) = T[i];
      }
      else
      { for (Integer j=this->last(), i=T.last(); i>=T.first(); j--, i--)
          elt(j) = T[i];
      }
      return *this;
    }
template<class Exp >
ArrayHo& STK::ArrayHo< Real >::operator= ( const Exp &  rhs) [inline]

operator = overwriting a ArrayHo with An Expression.

Parameters:
rhsthe right hand side expression

Definition at line 372 of file STK_Point.h.

References STK::ArrayHo< TYPE >::elt(), STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::first(), and STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::last().

    {
      for (Integer i=this->first(); i<=this->last(); i++)
        this->elt(i) = rhs[i];
      return *this;
    }
template<class Exp >
ArrayHo& STK::ArrayHo< Real >::operator+= ( const Exp &  rhs) [inline]

operator += Adding an Expression.

Parameters:
rhsthe right hand side expression

Definition at line 383 of file STK_Point.h.

References STK::ArrayHo< TYPE >::elt(), STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::first(), and STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::last().

    {
      for (Integer i=this->first(); i<=this->last(); i++)
        this->elt(i) += rhs[i];
      return *this;
    }
template<class Exp >
ArrayHo& STK::ArrayHo< Real >::operator-= ( const Exp &  rhs) [inline]

operator -= decreasing an Expression.

Parameters:
rhsthe right hand side expression

Definition at line 394 of file STK_Point.h.

References STK::ArrayHo< TYPE >::elt(), STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::first(), and STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::last().

    {
      for (Integer i=this->first(); i<=this->last(); i++)
        this->elt(i) -= rhs[i];
      return *this;
    }
template<class Exp >
ArrayHo& STK::ArrayHo< Real >::operator/= ( const Exp &  rhs) [inline]

operator /= Dividing an Expression.

Parameters:
rhsthe right hand side expression

Definition at line 405 of file STK_Point.h.

References STK::ArrayHo< TYPE >::elt(), STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::first(), and STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::last().

    {
      for (Integer i=this->first(); i<=this->last(); i++)
        this->elt(i) /= rhs[i];
      return *this;
    }
template<class Exp >
ArrayHo& STK::ArrayHo< Real >::operator*= ( const Exp &  rhs) [inline]

operator *= Multiplying an Expression.

Parameters:
rhsthe right hand side expression

Definition at line 416 of file STK_Point.h.

References STK::ArrayHo< TYPE >::elt(), STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::first(), and STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::last().

    {
      for (Integer i=this->first(); i<=this->last(); i++)
        this->elt(i) *= rhs[i];
      return *this;
    }
void STK::ArrayHo< Real >::initElts ( Range const &  J) [inline, protected]

Method for elts memory allocation.

Parameters:
Jthe range of the Elts to initialize

Definition at line 427 of file STK_Point.h.

References STK::Range::first(), STK::ArrayHo< TYPE >::freeElt(), STK::ArrayHo< TYPE >::initElt(), STK::Range::last(), and STK::IArrayBase< TYPE * >::setData().

    {
      // for each col
      for (Integer j=J.first(); j<=J.last(); j++)
      {
        // try to Allocate mem for the jth elt
        try
        {
          this->initElt(j);
        }
        catch (std::runtime_error & error)   // if an error occur
        {
          // for each column allocated
          for (Integer k=J.first(); k<j; k++)
            this->freeElt(k);
          // put default parameters for the elts j to end
          for (Integer k=j; k<=J.last(); k++)
            this->setData(k);
          // and throw an exception
          throw error;
        }
      }
    }
void STK::ArrayHo< Real >::freeElts ( Range const &  J) [inline, protected]

Method for Elts memory deallocation.

Parameters:
Jthe range of the Elts to liberate

Definition at line 454 of file STK_Point.h.

References STK::Range::first(), STK::ArrayHo< TYPE >::freeElt(), and STK::Range::last().

    { 
      // for all elts
      for (Integer j=J.first(); j<=J.last(); j++)
        this->freeElt(j);
    }
void STK::ArrayHo< Real >::initElt ( Integer const &  pos) [inline, protected]

function for the the allocation of memory of element pos.

Parameters:
posthe number of the elt to initialize

Definition at line 465 of file STK_Point.h.

References STK::IArrayBase< TYPE * >::data(), STK::IArray1DBase< TYPE, TYPE *, ArrayHo< TYPE > >::getIndex(), and STK::IArrayBase< TYPE * >::setData().

    {
      // try to Allocate mem for each col
      try
      {
        this->setData(pos, new Real);
        this->data(pos) -= this->getIndex();
      }
      catch (std::bad_alloc & error)        // if an alloc error occur
      {
        // set default
        this->setData(pos);
        // throw an exception
        throw std::runtime_error("ArrayHo::initElt(pos) "
                            "memory allocation failed.");
      }
    }
void STK::ArrayHo< Real >::freeElt ( Integer const &  pos) [inline, protected]

protected function for the the deallocation of memory of the element pos.

Parameters:
posthe number of the element to liberate

Definition at line 487 of file STK_Point.h.

References STK::IArrayBase< TYPE * >::data(), STK::IArray1DBase< TYPE, TYPE *, ArrayHo< TYPE > >::getIndex(), and STK::IArrayBase< TYPE * >::setData().

    {
      if (this->data(pos))  // if there is an elt
      {
        this->data(pos) += this->getIndex();
        delete this->data(pos);  // erase
        this->setData(pos);         // set default
      }
    }
void STK::ArrayHo< Real >::insertElt ( Integer const &  pos,
Integer const &  n = 1 
) [inline, protected, virtual]

Insert n elts at the position pos of the container.

The bound last_ should be modified at the very end of the insertion as pos can be a reference to it.

Parameters:
posindex where to insert elements
nnumber of elements to insert (default 1)

Implements STK::IContainer1D.

Definition at line 503 of file STK_Point.h.

References STK::IArray1DBase< TYPE, TYPE *, ArrayHo< TYPE > >::capacity(), STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::first(), STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::incLast(), STK::Range::incLast(), STK::IArray1DBase< TYPE, TYPE *, ArrayHo< TYPE > >::init1D(), STK::ArrayHo< TYPE >::initElts(), STK::IContainerRef::isRef(), STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::last(), STK::IArray1DBase< TYPE, TYPE *, ArrayHo< TYPE > >::moveElt(), STK::ITContainer1D< TYPE, TContainer1D >::range(), STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::range(), STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::setRange(), STK::ITContainer1D< TYPE, ArrayHo< TYPE > >::size(), and STK::IArray1DBase< TYPE, TYPE *, ArrayHo< TYPE > >::swap().

    {
      // if n<=0 nothing to do
      if (n <= 0) return;
      // is this structure just a pointer?
      if (this->isRef())
      { throw std::runtime_error("ArrayHo<Real>::insertElt(pos, n) "
                                 "can't operate on references.");
      }
#ifdef STK_BOUNDS_CHECK
      // check indices
      if (this->first() > pos)
      { throw std::out_of_range("ArrayHo<Real>::insertElt(pos, n) "
                                "this->first() > pos");
      }
      if (this->last()+1 < pos)
      { throw std::out_of_range("ArrayHo<Real>::insertElt(pos, n) "
                                "this->last()+1 < pos");
      }
#endif
      // allocate, if necessary, the mem for the elts
      if (this->capacity() < this->size()+n)
      {
        // compute range of the container after insertion
        Range range(this->range());
        range.incLast(n);
        // temporary empty container
        ArrayHo Taux;
        // save Elts in Taux
        this->swap(Taux);
        // initialize Elts of the container
        try
        {
          this->init1D(range);
        }
        catch (std::runtime_error & error)   // if an error occur
        {
          this->swap(Taux);   // restore container
          throw error;        // and send again the exception
        }
        // reset initial stored in range
        this->setRange(Taux.range());
        // move first Elts from Taux to this
        for (Integer k=this->first(); k<pos; k++)
          this->moveElt(k,  Taux, k);
        // translate and copy last Elts from Taux to this
        for (Integer k=this->last(); k>=pos; k--)
          this->moveElt(k+n, Taux, k);
      }
      else // enough space -> initialize and shift the last elts
      {
        // translate data
        for (Integer k=this->last(); k>=pos; k--)
          this->moveElt(k+n, *this, k);
      }
      // initialize the Elts in the range pos:pos+n-1
      initElts(Range(pos, pos+n-1));
      // update range
      this->incLast(n);
    }

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