STK::DataFrame Class Reference
[project DManager (Data Management)]

DataFrame is a List and a 2D container containing Variables. More...

#include <STK_DataFrame.h>

Inherits List1D< IVariable * >, and IContainer2D< DataFrame >.

List of all members.

Public Member Functions

 DataFrame ()
 DataFrame (const DataFrame &T, const bool &ref=false)
virtual ~DataFrame ()
void clear ()
IVariable *& getElt (const Integer &i)
IVariable *const & getElt (const Integer &i) const
DataFrameoperator= (const DataFrame &T)
void shift (const Integer &cbeg=1)
void shift (Integer rbeg, Integer cbeg)
void popBackCols (const Integer &n)
void eraseCols (Integer pos, Integer n=1)
void swapCols (Integer j1, Integer j2)
void popBackRows (const Integer &n)
void eraseRows (Integer pos, Integer n=1)
void insertVariable (const Integer &pos, IVariable *const &V)
void pushBackVariable (IVariable *const &V)
void pushFrontVariable (IVariable *const &V)
void insertDataFrame (Integer pos, const DataFrame &D)
void pushBackDataFrame (DataFrame const &D)
void pushFrontDataFrame (DataFrame const &D)
void writeDataFrame (ostream &os, const Integer &left, const Integer &right) const

Protected Types

typedef List1D< IVariable * > _BaseList

Protected Member Functions

void freeMem ()
void freeRows ()
void pushBackCols (Integer n=1)
void insertCols (Integer pos, Integer n=1)
void pushBackRows (Integer n=1)
void insertRows (Integer pos, Integer n=1)


Detailed Description

A DataFrame inherit from List1D and IContainer2D. It is essentially a List, except that each col (the variables) possess the same dimension. Each Cell of the List1D contain a pointer on a Variable.

Definition at line 55 of file STK_DataFrame.h.


Member Typedef Documentation

Type for the list container.

Definition at line 60 of file STK_DataFrame.h.


Constructor & Destructor Documentation

STK::DataFrame::DataFrame (  ) 

Default Ctor, empty table.

Definition at line 48 of file STK_DataFrame.cpp.

00048                      : _BaseList()
00049                        , IContainer2D<DataFrame>(Inx(), Inx())
00050 { ;}

STK::DataFrame::DataFrame ( const DataFrame T,
const bool &  ref = false 
)

Copy Ctor. If ref is true, only references of the variables are copied into the DataFrame.

Parameters:
T the DataFrame to copy
ref true if we want to wrap the variables of T

Definition at line 53 of file STK_DataFrame.cpp.

References STK::ITContainer1D< IVariable *, List1D< IVariable * > >::at(), STK::ITContainer1D< IVariable *, List1D< IVariable * > >::first(), and STK::ITContainer1D< IVariable *, List1D< IVariable * > >::last().

00054                     : _BaseList(T)
00055                     , IContainer2D<DataFrame>(T)
00056 {
00057   // the adress of the variables are copied in List1D
00058   // but we need to copy explicitly the data
00059   for (Integer j=first(); j<=last(); j++) // for all cols
00060     if (T[j])                // if there is data
00061       at(j) = T[j]->clone(ref); // set the adress of a clone
00062 }

STK::DataFrame::~DataFrame (  )  [virtual]

Dtor.

Definition at line 65 of file STK_DataFrame.cpp.

References freeRows().

00066 {
00067   // free the rows as the destructor of _BaseList will not free the mem
00068   freeRows();
00069 }


Member Function Documentation

void STK::DataFrame::clear (  ) 

clear the object.

Reimplemented from STK::List1D< IVariable * >.

Definition at line 72 of file STK_DataFrame.cpp.

References freeMem(), STK::IContainer2D< DataFrame >::setRange(), and STK::ITContainer1D< IVariable *, List1D< IVariable * > >::setRange().

00073 {
00074   freeMem();
00075   // set default range for list
00076   _BaseList::setRange();
00077   // set default range for container2D
00078   IContainer2D<DataFrame>::setRange();
00079 }

IVariable* & STK::DataFrame::getElt ( const Integer i  )  [inline]

access to one element.

Reimplemented from STK::List1D< IVariable * >.

Definition at line 85 of file STK_DataFrame.h.

References STK::List1D< IVariable * >::getElt().

Referenced by STK::ExportToCsv::ExportToCsv().

00086     { return _BaseList::getElt(i);}

IVariable* const& STK::DataFrame::getElt ( const Integer i  )  const [inline]

access to one element for const.

Reimplemented from STK::List1D< IVariable * >.

Definition at line 89 of file STK_DataFrame.h.

References STK::List1D< IVariable * >::getElt().

00090     { return _BaseList::getElt(i);}

DataFrame & STK::DataFrame::operator= ( const DataFrame T  ) 

Operator = : overwrite the DataFrame with T.

Definition at line 82 of file STK_DataFrame.cpp.

References STK::ITContainer1D< IVariable *, List1D< IVariable * > >::at(), STK::ITContainer1D< IVariable *, List1D< IVariable * > >::first(), STK::ITContainer1D< TYPE, TContainer1D >::first(), STK::IContainer2D< Container2D >::getRangeHo(), STK::ITContainer1D< IVariable *, List1D< IVariable * > >::last(), STK::ITContainer1D< TYPE, TContainer1D >::last(), STK::ITContainer1D< IVariable *, List1D< IVariable * > >::resize(), STK::IContainer2D< Container2D >::sizeHo(), and STK::IContainer2D< DataFrame >::sizeHo().

00083 {
00084   // Resize if necessary.
00085   if (sizeHo() != T.sizeHo()) _BaseList::resize(T.getRangeHo());
00086 
00087   // Copy without overlapping.
00088   if ((T.first()>=first()))
00089   {
00090     for (Integer jt=T.first(), j=first(); jt<=T.last(); j++, jt++)
00091     {
00092       // clear old mem if any
00093       if (at(j)) delete at(j);
00094       // if there is a variable, create a copy
00095       if (T[jt]) at(j) = T[jt]->clone();
00096       else       at(j) = (IVariable*)NULL;
00097     }
00098   }
00099   else
00100   {
00101     for (Integer jt=T.last(), j=last(); jt>=T.first(); j--, jt--)
00102     {
00103       // clear old mem if any
00104       if (at(j)) delete at(j);
00105       // if there is a variable, create a copy
00106       if (T[jt]) at(j) = T[jt]->clone();
00107       else       at(j) = (IVariable*)NULL;
00108     }
00109   }
00110   return *this;
00111 }

void STK::DataFrame::shift ( const Integer cbeg = 1  ) 

New beginning index for the object.

Reimplemented from STK::List1D< IVariable * >.

Definition at line 114 of file STK_DataFrame.cpp.

References STK::IContainer2D< DataFrame >::setFirstHo(), and STK::List1D< IVariable * >::shift().

Referenced by shift().

00115 {
00116   // list1D shift
00117   _BaseList::shift(cbeg);
00118   // IContainer2D shift for Col
00119   setFirstHo(cbeg);
00120 }

void STK::DataFrame::shift ( Integer  rbeg,
Integer  cbeg 
)

New beginning index for the object.

Definition at line 173 of file STK_DataFrame.cpp.

References STK::ITContainer1D< IVariable *, List1D< IVariable * > >::at(), STK::ITContainer1D< IVariable *, List1D< IVariable * > >::first(), STK::IContainer2D< DataFrame >::firstCol(), STK::IContainer2D< DataFrame >::firstRow(), STK::ITContainer1D< IVariable *, List1D< IVariable * > >::last(), STK::IContainer2D< DataFrame >::setFirstVe(), STK::IVariable::shift(), and shift().

00174 {
00175   // if there is something to do
00176   if ((rbeg - firstRow() != 0)||(cbeg - firstCol() != 0))
00177   {
00178     // list1D shift
00179     shift(cbeg);
00180     // For each col update Variable
00181     for (Integer j=first(); j<=last(); j++)
00182       if (at(j)) { at(j)->shift(rbeg);}
00183     // update range of the rows
00184     setFirstVe(rbeg);
00185   }
00186 }

void STK::DataFrame::popBackCols ( const Integer n  ) 

Del n col of the container.

Definition at line 123 of file STK_DataFrame.cpp.

References STK::ITContainer1D< IVariable *, List1D< IVariable * > >::at(), STK::IContainer2D< DataFrame >::decLastHo(), freeMem(), STK::IContainer2D< DataFrame >::getSizeHo(), STK::IContainer2D< DataFrame >::lastCol(), STK::List1D< IVariable * >::popBackElts(), and STK::IContainer2D< DataFrame >::sizeHo().

00124 {
00125   // if n<=0 nothing to do
00126   if (n<=0) return;
00127   // if there is cols to erase
00128   if (getSizeHo()<n)
00129   { throw std::out_of_range("DataFrame::popBackCols(n) "
00130                        "getSizeHo() < n");
00131   }
00132   // for all cols, delete variables
00133   for (Integer j=lastCol() - n +1; j<=lastCol(); j++)
00134     if (at(j)) delete at(j);
00135   // popBackElts() of List1D
00136   _BaseList::popBackElts(n);
00137   // update IContainer2D
00138   decLastHo(n);
00139   // if it was the last elt, free mem
00140   if (this->sizeHo() == 0) freeMem();
00141 }

void STK::DataFrame::eraseCols ( Integer  pos,
Integer  n = 1 
)

Del n cols at the position of the container.

Definition at line 144 of file STK_DataFrame.cpp.

References STK::ITContainer1D< IVariable *, List1D< IVariable * > >::at(), STK::IContainer2D< DataFrame >::decLastHo(), STK::List1D< IVariable * >::eraseElts(), STK::ITContainer1D< IVariable *, List1D< IVariable * > >::first(), freeMem(), STK::ITContainer1D< IVariable *, List1D< IVariable * > >::last(), and STK::IContainer2D< DataFrame >::sizeHo().

00145 {
00146   // if n<=0 nothing to do
00147   if (n<=0) return;
00148   // check conditions
00149   if (pos<first())
00150   { throw std::out_of_range("DataFrame::eraseCols(pos, n) "
00151                        "pos < first()");
00152   }
00153   if (pos>last())
00154   { throw std::out_of_range("DataFrame::eraseCols(pos, n) "
00155                        "pos > last()");
00156   }
00157   if (last() < pos+n-1)
00158   { throw std::out_of_range("DataFrame::eraseCols(pos, n) "
00159                        "last() < pos+n-1");
00160   }
00161   // for all cols, delete variables
00162   for (Integer j=pos+n-1; j>=pos; j--)
00163     if (at(j)) { delete at(j);}
00164   // delete elements of the List1D
00165   eraseElts(pos, n);
00166   // update rangeHo_
00167   decLastHo(n);
00168   // if it was the last col, free mem
00169   if (this->sizeHo() == 0) freeMem();
00170 }

void STK::DataFrame::swapCols ( Integer  j1,
Integer  j2 
) [inline]

Swapping the j1th col and the j2th col.

Definition at line 114 of file STK_DataFrame.h.

References STK::List1D< IVariable * >::swapElts().

00115     { swapElts(j1, j2);}

void STK::DataFrame::popBackRows ( const Integer n  ) 

Dell last row of the container.

Definition at line 189 of file STK_DataFrame.cpp.

References STK::ITContainer1D< IVariable *, List1D< IVariable * > >::at(), STK::IContainer2D< DataFrame >::decLastVe(), STK::ITContainer1D< IVariable *, List1D< IVariable * > >::first(), STK::ITContainer1D< IVariable *, List1D< IVariable * > >::last(), STK::IVariable::popBackElts(), and STK::IContainer2D< DataFrame >::sizeVe().

00190 {
00191   if (sizeVe() < n)
00192   { throw std::out_of_range("DataFrame::popBackRows(n) "
00193                        "sizeVe() < n");
00194   }
00195   // del last row to each variable
00196   for (Integer j=first(); j<=last(); j++)
00197     if (at(j)) { at(j)->popBackElts(n);}
00198   // update rangeVe_
00199   decLastVe(n);
00200 }

void STK::DataFrame::eraseRows ( Integer  pos,
Integer  n = 1 
)

Dell n rows at the position to the container.

Definition at line 203 of file STK_DataFrame.cpp.

References STK::ITContainer1D< IVariable *, List1D< IVariable * > >::at(), STK::IContainer2D< DataFrame >::decLastVe(), STK::IVariable::eraseElts(), STK::ITContainer1D< IVariable *, List1D< IVariable * > >::first(), STK::IContainer2D< DataFrame >::firstRow(), STK::ITContainer1D< IVariable *, List1D< IVariable * > >::last(), and STK::IContainer2D< DataFrame >::lastRow().

00204 {
00205   // if n<=0 nothing to do
00206   if (n<=0) return;
00207   // check conditions
00208   if (firstRow() > pos)
00209   { throw std::out_of_range("DataFrame::eraseRows(pos, n) "
00210                        "firstRow() > pos");
00211   }
00212   if (lastRow() < pos)
00213   { throw std::out_of_range("DataFrame::eraseRows(pos, n) "
00214                        "lastRow() < pos");
00215   }
00216   if (lastRow() < pos+n-1)
00217   { throw std::out_of_range("DataFrame::eraseRows(pos, n) "
00218                        "lastRow() < pos+n-1");
00219   }
00220   // for each variable erase elts
00221   for (Integer j=first(); j<=last(); j++)
00222     if (at(j)) { at(j)->eraseElts(pos, n);}
00223   // update rangeVe_
00224   decLastVe(n);
00225 }

void STK::DataFrame::insertVariable ( const Integer pos,
IVariable *const &  V 
)

Insert a Vartiable at the specified position to the container.

Parameters:
pos pos

Definition at line 228 of file STK_DataFrame.cpp.

References STK::ITContainer1D< IVariable *, List1D< IVariable * > >::at(), STK::IContainer2D< DataFrame >::firstCol(), STK::IContainer2D< DataFrame >::firstRow(), STK::IContainer2D< DataFrame >::incLastHo(), STK::IContainer2D< DataFrame >::incLastVe(), STK::ITContainer1D< IVariable *, List1D< IVariable * > >::insert(), STK::IContainer2D< DataFrame >::lastCol(), STK::IVariable::pushBackNA(), STK::IVariable::shift(), STK::IVariable::size(), and STK::IContainer2D< DataFrame >::sizeVe().

Referenced by pushFrontVariable().

00229 {
00230   // List1D
00231   insert(pos, V);
00232   at(pos)->shift(firstRow());
00233 
00234   // update rows with NA values
00235   Integer inc = sizeVe() - V->size();
00236   // update LastHo
00237   incLastHo();
00238   if (inc == 0) return; // same size
00239   if (inc > 0) // V has less rows
00240   { // put NA values to the inserted cols
00241     at(pos)->pushBackNA(inc);
00242   }
00243   else
00244   { // put NA values to the oter cols
00245     for (Integer i=this->firstCol(); i <pos; i++)
00246       if (at(i)) { at(i)->pushBackNA(-inc);}
00247     for (Integer i=pos+1; i <=this->lastCol(); i++)
00248       if (at(i)) { at(i)->pushBackNA(-inc);}
00249     // update LastVe
00250     incLastVe(-inc);
00251   }
00252 }

void STK::DataFrame::pushBackVariable ( IVariable *const &  V  ) 

Append a DataFrame back.

Definition at line 256 of file STK_DataFrame.cpp.

References STK::ITContainer1D< IVariable *, List1D< IVariable * > >::at(), STK::ITContainer1D< IVariable *, List1D< IVariable * > >::first(), STK::IContainer2D< DataFrame >::firstRow(), STK::IContainer2D< DataFrame >::incLastHo(), STK::IContainer2D< DataFrame >::incLastVe(), STK::IContainer2D< DataFrame >::lastCol(), STK::ITContainer1D< IVariable *, List1D< IVariable * > >::push_back(), STK::IVariable::pushBackNA(), STK::IVariable::shift(), STK::IVariable::size(), and STK::IContainer2D< DataFrame >::sizeVe().

Referenced by STK::ImportFromCsv::ImportFromCsv().

00257 {
00258   // update LastHo
00259   incLastHo();
00260   // List1D
00261   push_back(V);
00262   at(lastCol())->shift(firstRow());
00263   // update rows with NA values
00264   Integer inc = sizeVe() - V->size();
00265   if (inc == 0) return; // same size
00266   if (inc > 0) //V has less rows
00267   { // put NA values to the inserted cols
00268     at(lastCol())->pushBackNA(inc);
00269   }
00270   else
00271   { // put NA values to the oter cols
00272     for (Integer i=this->first(); i <lastCol(); i++)
00273       if (at(i)) { at(i)->pushBackNA(-inc);}
00274     // update LastVe
00275     incLastVe(-inc);
00276   }
00277 }

void STK::DataFrame::pushFrontVariable ( IVariable *const &  V  )  [inline]

Append a DataFrame front.

Definition at line 135 of file STK_DataFrame.h.

References STK::IContainer2D< DataFrame >::firstCol(), and insertVariable().

00136     { insertVariable(firstCol(), V);}

void STK::DataFrame::insertDataFrame ( Integer  pos,
const DataFrame D 
)

Insert a DataFrame at the specified position to the container.

Definition at line 280 of file STK_DataFrame.cpp.

References STK::ITContainer1D< IVariable *, List1D< IVariable * > >::at(), STK::ITContainer1D< TYPE, TContainer1D >::at(), STK::IVariable::clone(), STK::IContainer2D< DataFrame >::firstCol(), STK::IContainer2D< Container2D >::firstCol(), STK::IContainer2D< DataFrame >::firstRow(), STK::IContainer2D< DataFrame >::incLastHo(), STK::IContainer2D< DataFrame >::incLastVe(), STK::List1D< IVariable * >::insertElts(), STK::ITContainer1D< IVariable *, List1D< IVariable * > >::last(), STK::IContainer2D< Container2D >::lastCol(), STK::IVariable::pushBackNA(), STK::IVariable::shift(), STK::IContainer2D< Container2D >::sizeHo(), STK::IContainer2D< Container2D >::sizeVe(), and STK::IContainer2D< DataFrame >::sizeVe().

Referenced by pushFrontDataFrame().

00281 {
00282   // List1D
00283   insertElts(pos, D.sizeHo());
00284   // insert all cols of D
00285   for (Integer i = D.firstCol(), icol = pos; i <=D.lastCol(); i++, icol++)
00286   {
00287     if (D.at(i))
00288     {
00289       at(icol) = D.at(i)->clone();
00290       at(icol)->shift(firstRow());
00291     }
00292   }
00293   // update LastHo
00294   incLastHo(D.sizeHo());
00295   // update rows with NA values
00296   Integer inc = sizeVe() - D.sizeVe();
00297   if (inc == 0) return; // same size
00298   if (inc > 0) // D has less rows
00299   { // put NA values to the inserted cols
00300     for (Integer i= pos+D.sizeHo()-1; i >=pos; i--)
00301       if (at(i)) { at(i)->pushBackNA(inc);}
00302   }
00303   else
00304   { // put NA values to the oter cols
00305     for (Integer i=this->firstCol(); i <pos; i++)
00306       if (at(i)) { at(i)->pushBackNA(-inc);}
00307     for (Integer i=pos+D.sizeHo(); i <=this->last(); i++)
00308       if (at(i)) { at(i)->pushBackNA(-inc);}
00309     // update LastVe
00310     incLastVe(-inc);
00311   }
00312 }

void STK::DataFrame::pushBackDataFrame ( DataFrame const &  D  ) 

Append a DataFrame back.

Definition at line 316 of file STK_DataFrame.cpp.

References STK::ITContainer1D< IVariable *, List1D< IVariable * > >::at(), STK::ITContainer1D< TYPE, TContainer1D >::at(), STK::IVariable::clone(), STK::ITContainer1D< IVariable *, List1D< IVariable * > >::first(), STK::ITContainer1D< TYPE, TContainer1D >::first(), STK::IContainer2D< DataFrame >::firstRow(), STK::IContainer2D< DataFrame >::incLastHo(), STK::IContainer2D< DataFrame >::incLastVe(), STK::ITContainer1D< TYPE, TContainer1D >::last(), STK::ITContainer1D< IVariable *, List1D< IVariable * > >::last(), STK::List1D< IVariable * >::pushBackElts(), STK::IVariable::pushBackNA(), STK::IVariable::shift(), STK::IContainer2D< Container2D >::sizeHo(), STK::IContainer2D< Container2D >::sizeVe(), and STK::IContainer2D< DataFrame >::sizeVe().

00317 {
00318   // compute pos
00319   Integer pos(last()+1);
00320   // List1D
00321   pushBackElts(D.sizeHo());
00322   // insert all cols of D
00323   for (Integer i = D.first(), icol = pos; i <=D.last(); i++, icol++)
00324   {
00325     if (D.at(i))
00326     {
00327       at(icol) = D.at(i)->clone();
00328       at(icol)->shift(firstRow());
00329     }
00330   }
00331   // update LastHo
00332   incLastHo(D.sizeHo());
00333   // update rows with NA values
00334   Integer inc = sizeVe() - D.sizeVe();
00335   if (inc == 0) return; // same size
00336   if (inc > 0) // D has less rows
00337   { // put NA values to the inserted cols
00338     for (Integer i= last(); i >=pos; i--)
00339       if (at(i)) { at(i)->pushBackNA(inc);}
00340   }
00341   else
00342   { // put NA values to the oter cols
00343     for (Integer i=this->first(); i <pos; i++)
00344       if (at(i)) { at(i)->pushBackNA(-inc);}
00345     // update LastVe
00346     incLastVe(-inc);
00347   }
00348 }

void STK::DataFrame::pushFrontDataFrame ( DataFrame const &  D  )  [inline]

Append a DataFrame front.

Definition at line 147 of file STK_DataFrame.h.

References STK::IContainer2D< DataFrame >::firstCol(), and insertDataFrame().

00148     { insertDataFrame(firstCol(), D);}

void STK::DataFrame::writeDataFrame ( ostream os,
const Integer left,
const Integer right 
) const

write a DataFrame to the output stream os.

Definition at line 460 of file STK_DataFrame.cpp.

References STK::ExportToCsv::eraseReadWriteCsv(), STK::IContainer2D< DataFrame >::firstRow(), STK::ExportToCsv::getReadWriteCsv(), STK::IContainer2D< DataFrame >::lastRow(), STK::ReadWriteCsv::setDelimiters(), and STK::ReadWriteCsv::writeSelection().

Referenced by STK::operator<<().

00464 {
00465   // Export  to csv the DataFrame
00466   ExportToCsv csv(*this);
00467   // get the csv
00468   ReadWriteCsv* pData = csv.getReadWriteCsv();
00469   // set delimiters to blanck
00470   pData->setDelimiters(STRING_BLANCK);
00471   // write the csv
00472   pData->writeSelection(os, firstRow(), lastRow(), left, right);
00473   // delete the csv
00474   csv.eraseReadWriteCsv();
00475 }

void STK::DataFrame::freeMem (  )  [protected]

function for memory desallocation.

Merge two dataframe (vertically) : The concatenation will be done using the names of the variables.

Reimplemented from STK::List1D< IVariable * >.

Definition at line 434 of file STK_DataFrame.cpp.

References STK::List1D< IVariable * >::freeMem(), freeRows(), STK::IContainer2D< DataFrame >::setRangeHo(), and STK::IContainer2D< DataFrame >::setRangeVe().

Referenced by clear(), eraseCols(), and popBackCols().

00435 {
00436   // liberate variables
00437   freeRows();
00438   // call base freeMem
00439   _BaseList::freeMem();
00440   // set range to default
00441   setRangeVe();
00442   setRangeHo();
00443 }

void STK::DataFrame::freeRows (  )  [protected]

function for row memory desallocation.

Definition at line 446 of file STK_DataFrame.cpp.

References STK::ITContainer1D< IVariable *, List1D< IVariable * > >::at(), STK::ITContainer1D< IVariable *, List1D< IVariable * > >::first(), STK::ITContainer1D< IVariable *, List1D< IVariable * > >::last(), and STK::IContainer2D< DataFrame >::setRangeVe().

Referenced by freeMem(), and ~DataFrame().

00447 {
00448   // for all cols
00449   for (Integer j=first(); j<=last(); j++)
00450     if (at(j))                  // if there is mem allocated
00451     {
00452       delete at(j);             // erase
00453       at(j) = (IVariable*)NULL; // set default
00454     }
00455   // set default range
00456   setRangeVe();
00457 }

void STK::DataFrame::pushBackCols ( Integer  n = 1  )  [protected]

Add cols to the container.

Definition at line 353 of file STK_DataFrame.cpp.

References STK::IContainer2D< DataFrame >::incLastHo(), and STK::ITContainer1D< IVariable *, List1D< IVariable * > >::push_back().

00354 {
00355   // if n<=0 nothing to do
00356   if (n <= 0) return;
00357   // add n cols to list1D
00358   _BaseList::push_back(n, (IVariable*)NULL);
00359   // update IContainer2D
00360   incLastHo(n);
00361 }

void STK::DataFrame::insertCols ( Integer  pos,
Integer  n = 1 
) [protected]

Insert cols at the specified position to the container.

Definition at line 364 of file STK_DataFrame.cpp.

References STK::ITContainer1D< IVariable *, List1D< IVariable * > >::first(), STK::IContainer2D< DataFrame >::incLastHo(), STK::ITContainer1D< IVariable *, List1D< IVariable * > >::insert(), and STK::ITContainer1D< IVariable *, List1D< IVariable * > >::last().

00365 {
00366   if (n <= 0) return;        // if n<=0 nothing to do
00367   // check conditions
00368   if (pos<first())
00369   { throw std::out_of_range("DataFrame::insertElts(pos, n) "
00370                        "pos<first()");
00371   }
00372   if (pos>last())
00373   { throw std::out_of_range("Dataframe::insertElts(pos, n) "
00374                        "pos>last()");
00375   }
00376   // insert n elements in list1D
00377   _BaseList::insert(Inx(pos, pos+n-1), (IVariable*)NULL);
00378   // update IContainer2D
00379   incLastHo(n);
00380 }

void STK::DataFrame::pushBackRows ( Integer  n = 1  )  [protected]

Add n rows to the container.

Definition at line 383 of file STK_DataFrame.cpp.

References STK::ITContainer1D< IVariable *, List1D< IVariable * > >::at(), STK::ITContainer1D< IVariable *, List1D< IVariable * > >::first(), STK::IContainer2D< DataFrame >::incRangeVe(), STK::ITContainer1D< IVariable *, List1D< IVariable * > >::last(), and STK::IVariable::pushBackElts().

00384 {
00385   // if n<=0 nothing to do
00386   if (n<=0) return;
00387   // for each col append row
00388   for (Integer j=first(); j<=last(); j++)
00389   {
00390     if (at(j))
00391     { at(j)->pushBackElts(n);}
00392   }
00393   // update range of the container
00394   incRangeVe(n);
00395 }

void STK::DataFrame::insertRows ( Integer  pos,
Integer  n = 1 
) [protected]

Insert n rows at the ith position of the container.

Definition at line 398 of file STK_DataFrame.cpp.

References STK::ITContainer1D< IVariable *, List1D< IVariable * > >::at(), STK::ITContainer1D< IVariable *, List1D< IVariable * > >::first(), STK::IContainer2D< DataFrame >::firstRow(), STK::IContainer2D< DataFrame >::getRangeVe(), STK::IContainer2D< DataFrame >::incLastVe(), STK::IVariable::insertElts(), STK::ITContainer1D< IVariable *, List1D< IVariable * > >::last(), and STK::IContainer2D< DataFrame >::lastRow().

00399 {
00400   // if n<=0 nothing to do
00401   if (n<=0) return;
00402   // update range of the container
00403   getRangeVe();
00404   // check conditions
00405   if (firstRow() > pos)
00406   { throw std::out_of_range("DataFrame::insertRows(pos, n) "
00407                        "firstRow() > pos");
00408   }
00409   if (lastRow()+1 < pos)
00410   { throw std::out_of_range("DataFrame::insertRows(pos, n) "
00411                        "lastRow()+1 < pos");
00412   }
00413   // ins rows to each variables
00414   for (Integer j=first(); j<=last(); j++)
00415   {
00416     // if there is a variable
00417     if (at(j))
00418     { at(j)->insertElts(pos, n);}
00419   }
00420   // update rangeVe_
00421   incLastVe(n);
00422 }


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

Generated on Fri Sep 25 10:31:00 2009 for STK++ by  doxygen 1.5.8