STK::STK::ITContainer2D< TYPE, TContainerHo, TContainerVe, TContainer2D > Class Template Reference
[Subproject STKernel::TContainer]

Interface class for homogeneous 2D containers. More...

#include <STK_HeapSort.h>

Inherits IContainer2D< TContainer2D >.

List of all members.

Public Member Functions

virtual ~ITContainer2D ()
TYPE & operator() (const Integer &i, const Integer j)
const TYPE & operator() (Integer i, Integer j) const
TContainerVe operator[] (Integer j) const
TContainerVe operator() (const Range &I, Integer j) const
TContainerHo operator() (Integer i) const
TContainerHo operator() (Integer i, const Range &J) const
TContainer2D operator() (const Range &I, const Range &J) const
TContainer2D operator() (const Range &I) const
TContainer2D operator[] (const Range &J) const
TYPE & at (Integer i, Integer j)
const TYPE & at (Integer i, Integer j) const
TContainer2D at (const Range &I, const Range &J)
TContainerVe at (const Range &I, Integer j)
TContainerHo at (Integer i, const Range &J) const
TContainerVe atCol (Integer j)
TContainer2D atCol (const Range &J)
TContainerHo atRow (Integer i) const
TContainer2D atRow (const Range &I) const
void resize (const Range &I=Range(), const Range &J=Range())

Protected Member Functions

 ITContainer2D (const Range &I=Range(), const Range &J=Range())
 ITContainer2D (const ITContainer2D &T)

Detailed Description

template<class TYPE, class TContainerHo, class TContainerVe, class TContainer2D>
class STK::STK::ITContainer2D< TYPE, TContainerHo, TContainerVe, TContainer2D >

Define the curious recursive template paradigm : the template parameter TContainer2D is the name of the class that implements the interface ITContainer2D. For example

 template<class TYPE>
 class TContainer2D : public ITContainer2D< TYPE
                                          , TContainerHo
                                          , TContainerVe
                                          , TContainer2D<TYPE>
                                          >
 {...}

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

   TYPE& getElt( const Integer& i, const Integer& j);
   const TYPE& getElt( const Integer& i, const Integer& j) const;
   TContainerVe getCol( const Range &I, Integer j) const;
   TContainerHo getRow( const Integer& i, const Range &J) const;
   TContainer2D get2D( const Range &I, const Range &J) const;

The classes TContainerHo and TContainerVe are the class of the lines and columns of the two-dimensional container TContainer2D.

Definition at line 85 of file STK_HeapSort.h.


Constructor & Destructor Documentation

template<class TYPE, class TContainerHo, class TContainerVe, class TContainer2D>
STK::STK::ITContainer2D< TYPE, TContainerHo, TContainerVe, TContainer2D >::ITContainer2D ( const Range I = Range(),
const Range J = Range() 
) [inline, protected]

Default constructor : rangeHo=(1:0) and rangeVe=(1:0).

Parameters:
I the vertical range
J the horizontal range

Definition at line 92 of file STK_HeapSort.h.

template<class TYPE, class TContainerHo, class TContainerVe, class TContainer2D>
STK::STK::ITContainer2D< TYPE, TContainerHo, TContainerVe, TContainer2D >::ITContainer2D ( const ITContainer2D< TYPE, TContainerHo, TContainerVe, TContainer2D > &  T  )  [inline, protected]

Copy constructor

Parameters:
T the container to copy

Definition at line 99 of file STK_HeapSort.h.

00105   { // the value to sort

template<class TYPE, class TContainerHo, class TContainerVe, class TContainer2D>
virtual STK::STK::ITContainer2D< TYPE, TContainerHo, TContainerVe, TContainer2D >::~ITContainer2D (  )  [inline, virtual]

virtual Dtor.

Definition at line 106 of file STK_HeapSort.h.

00109 : we end the job


Member Function Documentation

template<class TYPE, class TContainerHo, class TContainerVe, class TContainer2D>
TYPE& STK::STK::ITContainer2D< TYPE, TContainerHo, TContainerVe, TContainer2D >::operator() ( const Integer i,
const Integer  j 
) [inline]

Operator () : access to one element.

Parameters:
i index of the row
j index of the col

Definition at line 112 of file STK_HeapSort.h.

00117     { // j+1 is greatest child

template<class TYPE, class TContainerHo, class TContainerVe, class TContainer2D>
const TYPE& STK::STK::ITContainer2D< TYPE, TContainerHo, TContainerVe, TContainer2D >::operator() ( Integer  i,
Integer  j 
) const [inline]

Operator () : access to one element for const.

Parameters:
i index of the row
j index of the col

Definition at line 119 of file STK_HeapSort.h.

00142 {

template<class TYPE, class TContainerHo, class TContainerVe, class TContainer2D>
TContainerVe STK::STK::ITContainer2D< TYPE, TContainerHo, TContainerVe, TContainer2D >::operator[] ( Integer  j  )  const [inline]

Operator [] : access to one col.

Parameters:
j index of the col

Definition at line 125 of file STK_HeapSort.h.

00142 {

template<class TYPE, class TContainerHo, class TContainerVe, class TContainer2D>
TContainerVe STK::STK::ITContainer2D< TYPE, TContainerHo, TContainerVe, TContainer2D >::operator() ( const Range I,
Integer  j 
) const [inline]

Operator () : access to many elements of a col.

Parameters:
I range of the index of the rows
j index of the col

Definition at line 132 of file STK_HeapSort.h.

00142 {

template<class TYPE, class TContainerHo, class TContainerVe, class TContainer2D>
TContainerHo STK::STK::ITContainer2D< TYPE, TContainerHo, TContainerVe, TContainer2D >::operator() ( Integer  i  )  const [inline]

Operator () : access to one row.

Parameters:
i index of the row

Definition at line 138 of file STK_HeapSort.h.

00142 {

template<class TYPE, class TContainerHo, class TContainerVe, class TContainer2D>
TContainerHo STK::STK::ITContainer2D< TYPE, TContainerHo, TContainerVe, TContainer2D >::operator() ( Integer  i,
const Range J 
) const [inline]

Operator () : access to many elements of a row.

Parameters:
i index of the row
J index of the col

Definition at line 145 of file STK_HeapSort.h.

00154   {

template<class TYPE, class TContainerHo, class TContainerVe, class TContainer2D>
TContainer2D STK::STK::ITContainer2D< TYPE, TContainerHo, TContainerVe, TContainer2D >::operator() ( const Range I,
const Range J 
) const [inline]

Operator () : access to a sub-array.

Parameters:
I range of the index of the rows
J range of the index of the cols

Definition at line 152 of file STK_HeapSort.h.

00154   {

template<class TYPE, class TContainerHo, class TContainerVe, class TContainer2D>
TContainer2D STK::STK::ITContainer2D< TYPE, TContainerHo, TContainerVe, TContainer2D >::operator() ( const Range I  )  const [inline]

Operator () : access to many rows.

Parameters:
I range of the index of the rows

Definition at line 158 of file STK_HeapSort.h.

00160     {

template<class TYPE, class TContainerHo, class TContainerVe, class TContainer2D>
TContainer2D STK::STK::ITContainer2D< TYPE, TContainerHo, TContainerVe, TContainer2D >::operator[] ( const Range J  )  const [inline]

Operator [] : access to many cols.

Parameters:
J range of the index of the cols

Definition at line 164 of file STK_HeapSort.h.

template<class TYPE, class TContainerHo, class TContainerVe, class TContainer2D>
TYPE& STK::STK::ITContainer2D< TYPE, TContainerHo, TContainerVe, TContainer2D >::at ( Integer  i,
Integer  j 
) [inline]

STL compatibility : return the element (i, j).

Parameters:
i index of the row
j index of the col

Definition at line 171 of file STK_HeapSort.h.

00179   { // the value to sort
00180     TYPE value = Tsort[shift0 + last];
00181     // Put the top of the heap at the end
00182     Tsort[shift0 + last] = Tsort[shift1];
00183     // decrease last.  last==1 : we end the job
00184     if (--last == 1)
00185     { Tsort[shift1] = value;
00186       break;
00187     }
00188     // organize the heap
00189     Integer i=1, j=2;
00190     while (j <= last)

template<class TYPE, class TContainerHo, class TContainerVe, class TContainer2D>
const TYPE& STK::STK::ITContainer2D< TYPE, TContainerHo, TContainerVe, TContainer2D >::at ( Integer  i,
Integer  j 
) const [inline]

STL compatibility : return the const element (i, j).

Parameters:
i index of the row
j index of the col

Definition at line 196 of file STK_HeapSort.h.

00217 {

template<class TYPE, class TContainerHo, class TContainerVe, class TContainer2D>
TContainer2D STK::STK::ITContainer2D< TYPE, TContainerHo, TContainerVe, TContainer2D >::at ( const Range I,
const Range J 
) [inline]

STL compatibility : return a sub-Array.

Parameters:
I range of the index of the rows
J range of the index of the cols

Definition at line 221 of file STK_HeapSort.h.

00225   { I[i] = i;}
00226 
00227   if (nb_elt < 2) return;
00228 
00229   // if the container is base one, shift0 = 0 and shift1 = 1
00230   Integer shift1 = T.first(), shift0 = T.first() - 1;
00231 
00232   // create heap
00233   for (first = nb_elt/2; first > 0; --first)
00234   {
00235     // the value value to insert in the heap
00236     TYPE value = T[I[shift0 + first]];
00237     // organize the heap
00238     Integer i=first, j=2*first;
00239     while (j <= nb_elt)
00240     {

template<class TYPE, class TContainerHo, class TContainerVe, class TContainer2D>
TContainerVe STK::STK::ITContainer2D< TYPE, TContainerHo, TContainerVe, TContainer2D >::at ( const Range I,
Integer  j 
) [inline]

STL compatibility : return a part of the column j in the range I.

Parameters:
I range of the index of the rows
j index of the col

Definition at line 246 of file STK_HeapSort.h.

00259   {
00260     // the value to sort
00261     Integer ivalue = I[shift0 + last];
00262     TYPE value = T[ivalue];
00263     // Put the top of the heap at the end
00264     //T[shift0 + last] = T[shift1];
00265     I[shift0 + last] = I[shift1];

template<class TYPE, class TContainerHo, class TContainerVe, class TContainer2D>
TContainerHo STK::STK::ITContainer2D< TYPE, TContainerHo, TContainerVe, TContainer2D >::at ( Integer  i,
const Range J 
) const [inline]

STL compatibility : return a part of the row i in the range J.

Parameters:
i index of the row
J range of the index of the cols

Definition at line 271 of file STK_HeapSort.h.

00275     { // j+1 is greatest child
00276       if ( j < last && T[I[shift0 + j]] < T[I[shift1 + j]] ) j++;
00277       // we have find a child gt value
00278       if (value >= T[I[shift0 + j]]) break;
00279       // else shift the inner value
00280       // T[shift0 + i] = T[shift0 + j];
00281       I[shift0 + i] = I[shift0 + j];
00282       // go down in the tree
00283       i = j;
00284       j*= 2;
00285     }
00286     // plug value in its final location
00287     // T[shift0 + i] = value;
00288     I[shift0 + i] = ivalue;
00289   }
00290 #ifdef STK_HEAPSORT_DEBUG

template<class TYPE, class TContainerHo, class TContainerVe, class TContainer2D>
TContainerVe STK::STK::ITContainer2D< TYPE, TContainerHo, TContainerVe, TContainer2D >::atCol ( Integer  j  )  [inline]

STL compatibility : return the column j.

Parameters:
j index of the col

Definition at line 295 of file STK_HeapSort.h.

00305 {
00306 #ifdef STK_DEBUG

template<class TYPE, class TContainerHo, class TContainerVe, class TContainer2D>
TContainer2D STK::STK::ITContainer2D< TYPE, TContainerHo, TContainerVe, TContainer2D >::atCol ( const Range J  )  [inline]

STL compatibility : return the Container2D in column range J.

Parameters:
J range of the index of the cols

Definition at line 311 of file STK_HeapSort.h.

00315   {
00316     A[i] = T[I[i]];
00317   }
00318   T.asLeaf() = A.asLeaf();
00319 }
00320 

template<class TYPE, class TContainerHo, class TContainerVe, class TContainer2D>
TContainerHo STK::STK::ITContainer2D< TYPE, TContainerHo, TContainerVe, TContainer2D >::atRow ( Integer  i  )  const [inline]

STL compatibility : return the row i.

Parameters:
i the index of the row

Definition at line 327 of file STK_HeapSort.h.

00330 {
00331 #ifdef STK_DEBUG
00332   if (I.range() != T.rangeVe())
00333   { throw std::runtime_error("In applySort(T, I) "
00334                         "incompatible lengths\n");
00335   }
00336 #endif
00337   TContainer2D A(T.rangeVe(), T.rangeHo());
00338   const Integer first = I.first(), last = I.last();

template<class TYPE, class TContainerHo, class TContainerVe, class TContainer2D>
TContainer2D STK::STK::ITContainer2D< TYPE, TContainerHo, TContainerVe, TContainer2D >::atRow ( const Range I  )  const [inline]

STL compatibility : return the Container2D in the row range I.

Parameters:
I range of the index of the rows

Definition at line 343 of file STK_HeapSort.h.

template<class TYPE, class TContainerHo, class TContainerVe, class TContainer2D>
void STK::STK::ITContainer2D< TYPE, TContainerHo, TContainerVe, TContainer2D >::resize ( const Range I = Range(),
const Range J = Range() 
) [inline]

pseudo virtual method. resize the container : the operation assume the container is column oriented.

Parameters:
I the new range of the indexes of the rows
J the new range of the indexes of columns

Reimplemented from STK::IContainer2D< TContainer2D >.

Reimplemented in STK::MatrixSquare.

Definition at line 361 of file STK_HeapSort.h.

Referenced by STK::LocalVariance::computeAxis(), STK::BSplineCoefficients::computeCoefficients(), STK::IAutoAssocMixture::create(), STK::PcaModel::pca(), STK::IAutoAssoc::projection(), STK::Qr::qr(), and STK::LocalVariance::setData().


The documentation for this class was generated from the following file:
Generated on Fri Sep 24 15:13:12 2010 for STK++ by  doxygen 1.6.3