STK++ 0.9.13
STK_DataFrame.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------*/
2/* Copyright (C) 2004-2016 Serge Iovleff, Université Lille 1, Inria
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with this program; if not, write to the
16 Free Software Foundation, Inc.,
17 59 Temple Place,
18 Suite 330,
19 Boston, MA 02111-1307
20 USA
21
22 Contact : S..._Dot_I..._At_stkpp_Dot_org (see copyright for ...)
23*/
24
25/*
26 * Project: stkpp::DManager
27 * Purpose: Define the DataFrame class.
28 * Author: Serge Iovleff, S..._Dot_I..._At_stkpp_Dot_org (see copyright for ...)
29 *
30 **/
31
36#ifndef STK_DATAFRAME_H
37#define STK_DATAFRAME_H
38
39
40#include "STK_List1D.h"
41#include "STK_IVariable.h"
43
44
45namespace STK
46{
47
58class DataFrame : protected List1D<IVariable* >, public IContainer2D<UnknownSize,UnknownSize>
59{
60 public:
69
70 public:
72 DataFrame();
78 DataFrame( DataFrame const& T, bool ref = false);
80 virtual ~DataFrame();
81
83 inline RowRange const& rows() const { return Base2D::rows();}
85 inline int beginRows() const { return Base2D::beginRows();}
87 inline int endRows() const { return Base2D::endRows();}
89 inline int sizeRows() const { return Base2D::sizeRows();}
90
92 inline ColRange cols() const { return ColRange(1);}
94 inline int beginCols() const { return Base2D::beginCols();}
96 inline int endCols() const { return Base2D::endCols();}
98 inline int sizeCols() const { return Base2D::sizeCols();};
99
101 inline int lastIdxRows() const { return this->lastIdx();}
103 inline int lastIdxCols() const { return baseIdx;}
104
105
107 inline bool empty() const { return Base::empty();}
108
110 void clear();
112 inline IVariable*& elt(int const& i) { return Base::elt(i);}
114 inline IVariable* const elt(int const& i) const { return Base::elt(i);}
115
117 DataFrame& operator=(DataFrame const& T);
118
128 void resize( Range const& I, Range const& J);
132 void shift(int const& cbeg =1);
137 void shift(int const& rbeg, int const& cbeg);
139 void popBackCols(int const& n);
141 void eraseCols( int pos, int const& n=1);
146 inline void swapCols(int j1, int j2)
147 { Base::swap(j1, j2);}
148
152 void popBackRows(int const& n);
157 void eraseRows( int pos, int const& n=1);
162 void insertVariable( int pos, IVariable* const & V);
166 void pushBackVariable( IVariable* const & V);
168 inline void pushFrontVariable( IVariable* const & V)
169 { insertVariable(beginCols(), V);}
171 void merge( DataFrame const& D);
173 void insertDataFrame( int pos, DataFrame const& D);
175 void pushBackDataFrame( DataFrame const &D);
177 inline void pushFrontDataFrame( DataFrame const &D)
178 { insertDataFrame(beginCols(), D);}
180 void writeDataFrame( ostream &os, int const& left, int const& right) const;
181
182 protected:
184 void freeMem();
186 void freeCols();
188 void pushBackCols(int const& n=1);
190 void insertCols( int pos, int const& n=1);
192 void pushBackRows(int const& n=1);
194 void insertRows( int pos, int const& n =1);
195};
196
201ostream& operator<< (ostream& s, DataFrame const& V);
202
203} // namespace STK
204
205#endif
206//STK_DATAFRAME_H
In this file we define the IContainer2D interface classes.
Define the Interface base class of all types of Variables.
This is an implementation of the Interface ITContainer1D.
DataFrame is a List of Variable with the same number of rows.
void eraseRows(int pos, int const &n=1)
Delete n rows at the position pos to the container.
int endRows() const
void pushFrontVariable(IVariable *const &V)
Append a DataFrame front.
bool empty() const
int beginRows() const
void popBackCols(int const &n)
Delete n columns of the container.
int sizeCols() const
void insertRows(int pos, int const &n=1)
Insert n rows at the ith position of the container.
TRange< UnknownSize > RowRange
Type of the Range for the rows.
int beginCols() const
IVariable *& elt(int const &i)
access to an element.
void clear()
Clear the object.
void swapCols(int j1, int j2)
Swapping the j1th column and the j2th column.
void shift(int const &cbeg=1)
New beginning index for the object.
void merge(DataFrame const &D)
merge this DataFrame with D.
void pushBackCols(int const &n=1)
Add columns to the container.
virtual ~DataFrame()
Destructor.
void pushBackVariable(IVariable *const &V)
Append a DataFrame back.
RowRange const & rows() const
void insertDataFrame(int pos, DataFrame const &D)
Insert a DataFrame at the specified position to the container.
void pushFrontDataFrame(DataFrame const &D)
Append a DataFrame front.
List1D< IVariable * > Base
Type for the list container.
TRange< UnknownSize > ColRange
Type of the Range for the columns.
void insertCols(int pos, int const &n=1)
Insert columns at the specified position to the container.
DataFrame & operator=(DataFrame const &T)
Operator = : overwrite the DataFrame with T.
int lastIdxRows() const
void popBackRows(int const &n)
Dell last rows of the container.
void freeCols()
function for row memory deallocation.
void eraseCols(int pos, int const &n=1)
Delete n columns at the position of the container.
int lastIdxCols() const
int sizeRows() const
IVariable *const elt(int const &i) const
access to a constant element.
int endCols() const
void freeMem()
function for memory deallocation.
void insertVariable(int pos, IVariable *const &V)
Insert a Vartiable at the specified position to the container.
void pushBackRows(int const &n=1)
Add n rows to the container.
void resize(Range const &I, Range const &J)
resize the container:
DataFrame()
Default Constructor, empty table.
IContainer2D< UnknownSize, UnknownSize > Base2D
Type of the Base container.
void writeDataFrame(ostream &os, int const &left, int const &right) const
write a DataFrame to the output stream os.
ColRange cols() const
void pushBackDataFrame(DataFrame const &D)
Append a DataFrame back.
Interface base class for 2D containers.
bool empty() const
Is there some data ?
IVariable is an Interface class for all Variables classes.
template One dimensional Horizontal List.
Definition STK_List1D.h:113
void swap(int const &j1, int const &j2)
Swapping the j1th column and the j2th column.
Definition STK_List1D.h:521
The MultidimRegression class allows to regress a multidimensional output variable among a multivariat...
Index sub-vector region: Specialization when the size is unknown.
Definition STK_Range.h:265
ostream & operator<<(ostream &s, const CAllocator< Type, SizeRows_, SizeCols_, Orient_ > &V)
output stream for CAllocator.
Definition STK_CArray.h:221
const int baseIdx
base index of the containers created in STK++.
std::basic_ostream< Char > ostream
ostream for Char
Definition STK_Stream.h:57
The namespace STK is the main domain space of the Statistical ToolKit project.