|
STK++
0.4
|
Variable is an implementation of the Base class IVariable using The Array1D class for storing the data. More...
#include <STK_Variable.h>

Public Types | |
| typedef IArray1D< Variable < Type > > | Base |
| Type for the Array1DBase Class. | |
Public Member Functions | |
| Variable () | |
| Default constructor. | |
| Variable (String const &name) | |
| constructor | |
| Variable (Range const &I) | |
| constructor | |
| Variable (Range const &I, String const &name) | |
| constructor | |
| Variable (Range const &I, Type const &v, String const &name) | |
| Misc constructor. | |
| Variable (Variable const &V, bool ref=false) | |
| Copy ctor. | |
| Variable (Variable const &V, Range const &I) | |
| Reference constructor. | |
| virtual | ~Variable () |
| Virtual destructor. | |
| Variable & | operator= (Variable const &var) |
| Operator = : overwrite the Variable with V. | |
| Variable & | operator= (Type const &v) |
| Operator = : overwrite the Variable with the value v. | |
| void | move (Variable const &V) |
| move the variable in this | |
| void | encode () |
| encode values as ints. | |
| int | maxLength (bool with_name) const |
| int | nbMiss () const |
| virtual int const & | size () const |
| virtual void | insertElt (int pos, int const &n=1) |
| Insert n elements at the position pos of the container. | |
| virtual void | clear () |
| clear Container from all elements and memory allocated. | |
| virtual void | erase (int pos, int const &n=1) |
Delete n elements at the pos index from the container. | |
| virtual void | shift (int const &beg) |
| New first index for the object. | |
| virtual void | pushBack (int const &n=1) |
| Add n elements at the end of the container. | |
| virtual void | popBack (int const &n=1) |
| Delete n last elements of the container. | |
| virtual Variable * | clone (bool ref=false) const |
| clone return a ptr on a copy of the Object. | |
| virtual void | pushBackNAValues (int const &n=1) |
| push back n NA values. | |
| virtual void | exportAsString (Variable< String > &V) const |
| Overwrite the variable V by converting the data into strings. | |
| virtual Variable & | operator<< (Variable< String > const &V) |
| Operator << : overwrite the Variable by converting the Strings contained in V into the Type. | |
| virtual Variable< Type > const & | operator>> (Variable< String > &V) const |
| Operator >> : convert the Variable V into strings. | |
| int | importFromString (Variable< String > const &V, std::ios_base &(*f)(std::ios_base &)=std::dec) |
| overwrite the Variable by converting the strings contained in V into the Type. | |
| template<> | |
| void | pushBackNAValues (int const &n) |
| template<> | |
| int | importFromString (Variable< String > const &V, std::ios_base &(*f)(std::ios_base &)) |
| template<> | |
| void | exportAsString (Variable< String > &V) const |
| template<> | |
| Variable< String > & | operator<< (Variable< String > const &V) |
| template<> | |
| Variable< String > const & | operator>> (Variable< String > &V) const |
Protected Attributes | |
| std::map< Type, int > | coding_ |
| store the map String <-> int | |
Variable is an implementation of the Base class IVariable using The Array1D class for storing the data.
It implement all purely virtual methods defined in the IVariable base class.
Definition at line 82 of file STK_Variable.h.
Type for the Array1DBase Class.
Reimplemented from STK::IArray1D< Variable< Type > >.
Definition at line 87 of file STK_Variable.h.
| STK::Variable< Type >::Variable | ( | ) | [inline] |
Default constructor.
Definition at line 90 of file STK_Variable.h.
Referenced by STK::Variable< Type >::clone().
| STK::Variable< Type >::Variable | ( | String const & | name | ) | [inline] |
| STK::Variable< Type >::Variable | ( | Range const & | I | ) | [inline] |
| STK::Variable< Type >::Variable | ( | Range const & | I, |
| String const & | name | ||
| ) | [inline] |
constructor
| I | : range of the data |
| name | : name of the variable |
Definition at line 111 of file STK_Variable.h.
| STK::Variable< Type >::Variable | ( | Range const & | I, |
| Type const & | v, | ||
| String const & | name | ||
| ) | [inline] |
Misc constructor.
| I | : range of the data |
| name | : name of the variable |
| v | : initial value |
Definition at line 120 of file STK_Variable.h.
| STK::Variable< Type >::Variable | ( | Variable< Type > const & | V, |
| bool | ref = false |
||
| ) | [inline] |
Copy ctor.
| V | the Variable to copy |
| ref | true if we want to wrap V |
Definition at line 128 of file STK_Variable.h.
| STK::Variable< Type >::Variable | ( | Variable< Type > const & | V, |
| Range const & | I | ||
| ) | [inline] |
Reference constructor.
| V | the Variable to wrap |
| I | range of the data |
Definition at line 136 of file STK_Variable.h.
| virtual STK::Variable< Type >::~Variable | ( | ) | [inline, virtual] |
| Variable& STK::Variable< Type >::operator= | ( | Variable< Type > const & | var | ) | [inline] |
Operator = : overwrite the Variable with V.
| var | the variable to copy |
Definition at line 144 of file STK_Variable.h.
References STK::IVariable::name_, and STK::IArray1D< Variable< Type > >::resize().
| Variable& STK::Variable< Type >::operator= | ( | Type const & | v | ) | [inline] |
Operator = : overwrite the Variable with the value v.
| v | the value to set to the variable |
Definition at line 157 of file STK_Variable.h.
{
for (int i=this->firstIdx(); i<=this->lastIdx(); i++) this->elt(i)= v;
return *this;
}
| void STK::Variable< Type >::move | ( | Variable< Type > const & | V | ) | [inline] |
move the variable in this
| V | variable to move in this |
Definition at line 165 of file STK_Variable.h.
References STK::IArray1D< Variable< Type > >::move(), and STK::IVariable::name_.
{ Base::move(V);
name_ = V.name_;
}
| void STK::Variable< Type >::encode | ( | ) | [inline] |
encode values as ints.
Not used yet.
Definition at line 170 of file STK_Variable.h.
References STK::Variable< Type >::coding_.
{ int code = STKBASEARRAYS;
std::pair< typename std::map<Type, int>::iterator, bool> ret;
for (int i=this->firstIdx(); i<= this->lastIdx(); i++)
{ ret=coding_.insert(std::pair<Type, int>(this->elt(i), i));
if (ret.second==true) { code++;}
}
}
| int STK::Variable< Type >::maxLength | ( | bool | with_name | ) | const [inline] |
Definition at line 179 of file STK_Variable.h.
References STK::Stat::max(), STK::IVariable::name(), and STK::Variable< Type >::size().
| int STK::Variable< Type >::nbMiss | ( | ) | const [inline] |
Definition at line 188 of file STK_Variable.h.
| virtual int const& STK::Variable< Type >::size | ( | ) | const [inline, virtual] |
Implements STK::IVariable.
Definition at line 198 of file STK_Variable.h.
Referenced by STK::Variable< Type >::importFromString(), and STK::Variable< Type >::maxLength().
{ return Base::size();}
| virtual void STK::Variable< Type >::insertElt | ( | int | pos, |
| int const & | n = 1 |
||
| ) | [inline, virtual] |
Insert n elements at the position pos of the container.
| pos | index where to insert elements |
| n | number of elements to insert (default 1) |
Implements STK::IVariable.
Definition at line 203 of file STK_Variable.h.
References STK::IArray1D< Variable< Type > >::insertElt().
{ Base::insertElt(pos, n);}
| virtual void STK::Variable< Type >::clear | ( | ) | [inline, virtual] |
clear Container from all elements and memory allocated.
Implements STK::IVariable.
Definition at line 205 of file STK_Variable.h.
References STK::IArray1D< Variable< Type > >::clear().
{ Base::clear();}
| virtual void STK::Variable< Type >::erase | ( | int | pos, |
| int const & | n = 1 |
||
| ) | [inline, virtual] |
Delete n elements at the pos index from the container.
| pos | index where to delete elements |
| n | number of elements to delete (default 1) |
Implements STK::IVariable.
Definition at line 210 of file STK_Variable.h.
References STK::IArray1D< Variable< Type > >::erase().
{ Base::erase(pos,n);}
| virtual void STK::Variable< Type >::shift | ( | int const & | beg | ) | [inline, virtual] |
New first index for the object.
| beg | the index of the first column to set |
Implements STK::IVariable.
Definition at line 214 of file STK_Variable.h.
References STK::IArray1D< Variable< Type > >::shift().
{ Base::shift(beg);}
| virtual void STK::Variable< Type >::pushBack | ( | int const & | n = 1 | ) | [inline, virtual] |
Add n elements at the end of the container.
| n | number of elements to add |
Implements STK::IVariable.
Definition at line 218 of file STK_Variable.h.
References STK::IArray1D< Variable< Type > >::pushBack().
{ Base::pushBack(n);}
| virtual void STK::Variable< Type >::popBack | ( | int const & | n = 1 | ) | [inline, virtual] |
Delete n last elements of the container.
| n | number of elements to delete |
Implements STK::IVariable.
Definition at line 222 of file STK_Variable.h.
References STK::IArray1D< Variable< Type > >::popBack().
{ Base::popBack(n);}
| virtual Variable* STK::Variable< Type >::clone | ( | bool | ref = false | ) | const [inline, virtual] |
clone return a ptr on a copy of the Object.
| ref | true if we want just a reference |
Implements STK::IVariable.
Definition at line 226 of file STK_Variable.h.
References STK::Variable< Type >::Variable().
{ return new Variable(*this, ref);}
| void STK::Variable< Type >::pushBackNAValues | ( | int const & | n = 1 | ) | [inline, virtual] |
push back n NA values.
| n | number of NA values to add |
Implements STK::IVariable.
Definition at line 270 of file STK_Variable.h.
| void STK::Variable< Type >::exportAsString | ( | Variable< String > & | V | ) | const [inline, virtual] |
Overwrite the variable V by converting the data into strings.
| V | Variable of String |
Definition at line 314 of file STK_Variable.h.
References STK::IArray1D< Variable< Type > >::resize(), and STK::IVariable::setName().
{
V.resize(this->range());
V.setName(this->name());
for (int i=this->firstIdx(); i<=this->lastIdx(); i++)
{ V[i] = this->eltAsString<Type>(i);}
}
| Variable< Type > & STK::Variable< Type >::operator<< | ( | Variable< String > const & | V | ) | [inline, virtual] |
Operator << : overwrite the Variable by converting the Strings contained in V into the Type.
| V | the Variable of string to import |
Definition at line 338 of file STK_Variable.h.
References STK::IVariable::name().
| Variable< Type > const & STK::Variable< Type >::operator>> | ( | Variable< String > & | V | ) | const [inline, virtual] |
Operator >> : convert the Variable V into strings.
| V | Variable of String |
Definition at line 360 of file STK_Variable.h.
References STK::IArray1D< Variable< Type > >::resize(), and STK::IVariable::setName().
{
V.resize(this->range());
V.setName(this->name());
for (int i=this->firstIdx(); i<=this->lastIdx(); i++) V[i] = typeToString<Type>(this->elt(i));
return *this;
}
| int STK::Variable< Type >::importFromString | ( | Variable< String > const & | V, |
| std::ios_base &(*)(std::ios_base &) | f = std::dec |
||
| ) | [inline] |
overwrite the Variable by converting the strings contained in V into the Type.
| V | Variable of String |
| f | io flags |
Definition at line 290 of file STK_Variable.h.
References STK::Arithmetic< TYPE >::NA(), STK::IVariable::name(), and STK::Variable< Type >::size().
{
this->resize(V.range());
this->setName(V.name());
int nSuccess = V.size();
for (int i=V.firstIdx(); i<=V.lastIdx(); i++)
if ( (Arithmetic<String>::isNA(V[i])) || (V[i]==STRING_NA) ) // not Available
this->elt(i) = Arithmetic<Type>::NA();
else
if (!stringToType<Type>(this->elt(i), V[i], f)) nSuccess--;
return nSuccess;
}
| void STK::Variable< String >::pushBackNAValues | ( | int const & | n | ) | [inline, virtual] |
Specialization for Type = String.
| n | number of NA values to add |
Implements STK::IVariable.
Definition at line 264 of file STK_Variable.h.
| int STK::Variable< String >::importFromString | ( | Variable< String > const & | V, |
| std::ios_base &(*)(std::ios_base &) | f | ||
| ) | [inline] |
Give the number of success.
| V | Variable of String |
| f | io flags |
Definition at line 279 of file STK_Variable.h.
References STK::Variable< Type >::size().
{ *this = V; return V.size();}
| void STK::Variable< String >::exportAsString | ( | Variable< String > & | V | ) | const [inline] |
| Variable< String > & STK::Variable< String >::operator<< | ( | Variable< String > const & | V | ) | [inline] |
| V | the Variable of string to import |
Definition at line 326 of file STK_Variable.h.
References STK::IVariable::name().
| Variable< String > const & STK::Variable< String >::operator>> | ( | Variable< String > & | V | ) | const [inline] |
| V | Variable of String |
Definition at line 349 of file STK_Variable.h.
References STK::IArray1D< Variable< Type > >::resize(), and STK::IVariable::setName().
{
V.resize(this->range());
V.setName(this->name());
for (int i=this->firstIdx(); i<=this->lastIdx(); i++) V[i] = this->elt(i);
return *this;
}
std::map<Type, int> STK::Variable< Type >::coding_ [protected] |
store the map String <-> int
Definition at line 257 of file STK_Variable.h.
Referenced by STK::Variable< Type >::encode().
1.7.6.1