STK++ 0.9.13
STK::Variable< Type_ > Class Template Reference

Variable is an implementation of the Base class IVariable using The Array1D class for storing the data. More...

#include <STK_Variable.h>

Inheritance diagram for STK::Variable< Type_ >:
Inheritance graph

Public Types

enum  {
  structure_ = hidden::Traits< Variable<Type_> >::structure_ , orient_ = hidden::Traits< Variable<Type_> >::orient_ , size_ = hidden::Traits< Variable<Type_> >::size_ , sizeCols_ = hidden::Traits< Variable<Type_> >::sizeCols_ ,
  sizeRows_ = hidden::Traits< Variable<Type_> >::sizeRows_ , storage_ = hidden::Traits< Variable<Type_> >::storage_
}
 
typedef Variable< Type_ > Row
 
typedef Variable< Type_ > Col
 
typedef Variable< Type_ > SubRow
 
typedef Variable< Type_ > SubCol
 
typedef Variable< Type_ > SubArray
 
typedef Variable< Type_ > SubVector
 
typedef hidden::Traits< Variable< Type_ > >::Type Type
 
typedef hidden::Traits< Variable< Type_ > >::TypeConst TypeConst
 
typedef hidden::Traits< Variable< Type_ > >::Allocator Allocator
 
typedef IArray1D< Variable< Type_ > > Base
 
- Public Types inherited from STK::IArray1D< Variable< Type_ > >
enum  
 
typedef ITContainer1D< Variable< Type_ > > Base
 
typedef hidden::Traits< Variable< Type_ > >::Allocator Allocator
 
typedef hidden::Traits< Variable< Type_ > >::Type Type
 
typedef hidden::Traits< Variable< Type_ > >::TypeConst TypeConst
 
typedef hidden::Traits< Variable< Type_ > >::RowRange RowRange
 
typedef hidden::Traits< Variable< Type_ > >::ColRange ColRange
 
typedef hidden::Traits< Variable< Type_ > >::Iterator Iterator
 
typedef hidden::Traits< Variable< Type_ > >::ConstIterator ConstIterator
 
typedef hidden::Traits< Variable< Type_ > >::ReverseIterator ReverseIterator
 
typedef hidden::Traits< Variable< Type_ > >::ConstReverseIterator ConstReverseIterator
 
- Public Types inherited from STK::ITContainer1D< Derived >
enum  { size_ = hidden::Traits<Derived>::size_ }
 
typedef hidden::Traits< Derived >::Type Type
 
typedef hidden::Traits< Derived >::TypeConst TypeConst
 
typedef hidden::Traits< Derived >::RowRange RowRange
 
typedef hidden::Traits< Derived >::ColRange ColRange
 
typedef hidden::Traits< Derived >::Row Row
 
typedef hidden::Traits< Derived >::Col Col
 
typedef hidden::Traits< Derived >::SubVector SubVector
 
typedef hidden::Traits< Derived >::Iterator Iterator
 
typedef hidden::Traits< Derived >::ConstIterator ConstIterator
 
typedef hidden::Traits< Derived >::ReverseIterator ReverseIterator
 
typedef hidden::Traits< Derived >::ConstReverseIterator ConstReverseIterator
 

Public Member Functions

 Variable (String const &name=stringNa)
 default constructor
 
 Variable (int size, String const &name=stringNa)
 constructor
 
 Variable (Range const &I, String const &name=stringNa)
 Default constructor.
 
 Variable (Range const &I, Type_ const &v, String const &name)
 constructor with specified initial value
 
 Variable (Variable const &V, bool ref=false)
 copy/reference constructor.
 
 Variable (Variable const &V, Range const &I, bool ref=true)
 reference constructor
 
template<class OtherArray >
 Variable (IArray1D< OtherArray > const &T)
 constructor by reference, ref_=1.
 
 ~Variable ()
 destructor.
 
virtual Variableclone (bool ref=false) const
 clone return a ptr on a copy of the Object.
 
void shift1D (int rbeg)
 New first index for the object.
 
Variable< Type_ > & resize1D (Range const &I)
 Resize the container.
 
virtual void popBack (int n=1)
 remove n elements to the end of the container
 
void pushBack (int n=1)
 Add n elements to the container.
 
void push_back (Type_ const &v)
 Add an element to the container.
 
void insertElt (int pos, int n=1)
 Insert n elements at the position pos of the container.
 
Variableoperator= (Variable const &V)
 operator = : overwrite the CArray with the Right hand side T.
 
Variableoperator= (Type_ const &v)
 set the container to a constant value.
 
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 size () const
 
virtual void clear ()
 clear Container from all elements and memory allocated.
 
virtual void erase (int pos, int n=1)
 Delete n elements at the pos index from the container.
 
virtual void shift (int beg)
 New first index for the object.
 
virtual void pushBackNAValues (int 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 Variableoperator<< (Variable< String > const &V)
 Operator << : overwrite the Variable by converting the Strings contained in V into the Type_.
 
virtual Variable< Type_ > constoperator>> (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_.
 
void pushBackNAValues (int n)
 push back n NA values.
 
int importFromString (Variable< String > const &V, std::ios_base &(*f)(std::ios_base &))
 overwrite the Variable by converting the strings contained in V into the Type_.
 
void exportAsString (Variable< String > &V) const
 Overwrite the variable V by converting the data into strings.
 
Variable< String > & operator<< (Variable< String > const &V)
 Operator << : overwrite the Variable by converting the strings contained in V into the String.
 
Variable< String > constoperator>> (Variable< String > &V) const
 Operator >> : convert the Variable V into strings.
 
- Public Member Functions inherited from STK::IVariable
virtual ~IVariable ()
 destructor.
 
IVariableoperator= (const IVariable &V)
 Operator = : overwrite the IVariable with T.
 
const Base::IdTypegetType () const
 
String constname () const
 
void setName (int num=0, String const &prefix=STRING_VAR)
 Set a default name for the variable of the form : prefix + num.
 
void setName (String const &name)
 Set the name of the variable.
 
template<class Type >
String eltAsString (int pos) const
 
virtual void exportAsString (VariableString &V) const =0
 Overwrite the variable V by converting the data into strings.
 
virtual IVariableoperator<< (VariableString const &V)=0
 Operator << : overwrite the IVariable by converting the strings contained in V into the Type.
 
virtual const IVariableoperator>> (VariableString &V) const =0
 Operator >> : convert the Variable V into strings.
 
- Public Member Functions inherited from STK::IArray1D< Variable< Type_ > >
bool isRef () const
 
void setRef (bool ref) const
 Modify the state of the container: this become a reference (if ref is true) or the owner of the data (if ref is false).
 
Allocator constallocator () const
 
RowRange constrows () const
 
int beginRows () const
 
int endRows () const
 
int sizeRows () const
 
ColRange cols () const
 
int beginCols () const
 
int endCols () const
 
int sizeCols () const
 
int lastIdxRows () const
 
int lastIdxCols () const
 
int capacity () const
 
Typeelt1Impl (int pos)
 access to an element
 
TypeConst elt1Impl (int pos) const
 access to a constant element
 
Variable< Type_ > & setValue (Type const &value)
 set a value to this container.
 
void setValue (int pos, TypeConst value)
 Write a value at a given position.
 
void shiftImpl (int beg=baseIdx)
 New beginning index for the object.
 
Variable< Type_ > & resizeImpl (Range const &I)
 Resize the container.
 
void reserve (int size)
 reserve internal memory for at least size elements.
 
void clear ()
 Clear the object.
 
void move (Variable< Type_ > const &T)
 move T to this.
 
Variable< Type_ > & pushBack (int n=1)
 Add n Elements to the end of the container.
 
Variable< Type_ > & popBack (int n=1)
 Delete last elts of the container.
 
Variable< Type_ > & erase (int pos, int n=1)
 Delete n elements at the pos index to the container.
 
Variable< Type_ > & insertElt (int pos, int n=1)
 Insert n elements at the position pos of the container.
 
Variable< Type_ > & insert (int pos, Type const &v)
 STL compatibility: Insert element v at position pos of the Array.
 
Variable< Type_ > & insert (Range const &I, Type const &v)
 STL compatibility: Insert element v in the range I of the Array.
 
Variable< Type_ > & push_front (Type const &v)
 STL compatibility: push front an element.
 
Variable< Type_ > & push_back (Type const &v)
 STL compatibility: append an element v.
 
void swap (int pos1, int pos2)
 Swapping the pos1 elt and the pos2 elt.
 
void exchange (IArray1D &T)
 exchange this Container with T.
 
Variable< Type_ > & assign (IArray1D const &src)
 overwrite this with src.
 
void memmove (int pos1, int pos2, int n)
 Copy n elements from pos2 to pos1, guaranteeing correct behavior for overlapping.
 
RowRange constrange () const
 
int begin () const
 
int end () const
 
int size () const
 
int lastIdx () const
 
void decLast (int n=1)
 decrement the end of the container.
 
void incLast (int n=1)
 increment the end of the container (can be negative).
 
void incRange (int n=1)
 increment the range of the container (can be negative).
 
void setRange (RowRange const &I=RowRange())
 Set range of the rows of the container.
 
Typeelt (int i)
 
TypeConst elt (int i) const
 
- Public Member Functions inherited from STK::ITContainer1D< Derived >
RowRange constrange () const
 
int begin () const
 
int end () const
 
int size () const
 
int lastIdx () const
 
Iterator beginIterator ()
 
Iterator endIterator ()
 
ConstIterator beginConstIterator () const
 
ConstIterator endConstIterator () const
 
ReverseIterator rbeginIterator ()
 
ReverseIterator rendIterator ()
 
ConstReverseIterator rbeginConstIterator () const
 
ConstReverseIterator rendConstIterator () const
 
bool empty () const
 Is there some data ?
 
Typeelt (int i)
 
TypeConst elt (int i) const
 
Typeoperator[] (int i)
 
TypeConst operator[] (int i) const
 
Typeat (int i)
 
TypeConst at (int i) const
 
SubVector sub (Range const &I) const
 Access to many elements.
 
Typefront ()
 
TypeConst front () const
 
Typeback ()
 
TypeConst back () const
 
void shift (int beg)
 
Derived & resize (Range const &I=RowRange())
 
- Public Member Functions inherited from STK::IRecursiveTemplate< Derived >
Derived & asDerived ()
 static cast : return a reference of this with a cast to the derived class.
 
Derived constasDerived () const
 static cast : return a const reference of this with a cast to the derived class.
 
Derived * asPtrDerived ()
 static cast : return a ptr on a Derived of this with a cast to the derived class.
 
Derived constasPtrDerived () const
 static cast : return a ptr on a constant Derived of this with a cast to the derived class.
 
Derived * clone () const
 create a leaf using the copy constructor of the Derived class.
 
Derived * clone (bool isRef) const
 create a leaf using the copy constructor of the Derived class and a flag determining if the clone is a reference or not.
 

Protected Attributes

std::map< Type_, intcoding_
 store the map String <-> int
 
- Protected Attributes inherited from STK::IVariable
const Base::IdType type_
 Id Type of the variable.
 
String name_
 Name of the variable.
 

Additional Inherited Members

- Static Public Member Functions inherited from STK::IVariable
static String giveName (int num=0, String const &prefix=STRING_VAR)
 
- Protected Member Functions inherited from STK::IVariable
 IVariable (Base::IdType const &type, String const &name)
 Default constructor.
 
 IVariable (const IVariable &V)
 Copy constructor

 
- Protected Member Functions inherited from STK::IArray1D< Variable< Type_ > >
 IArray1D ()
 Default constructor.
 
 IArray1D (Range const &I)
 constructor with a specified Range.
 
 IArray1D (Range const &I, Type const &v)
 Misc constructor with first and last, initialization with a constant.
 
 IArray1D (IArray1D const &T, bool ref)
 Copy constructor.
 
 IArray1D (IArray1D< OtherDerived > const &T, bool ref)
 Copy constructor.
 
 IArray1D (IArray1D< OtherDerived > const &T, RowRange const &I, bool ref)
 copy constructor.
 
 IArray1D (Allocator const &A, Range const &I, bool ref)
 Wrapper constructor.
 
 ~IArray1D ()
 destructor: allocated memory is liberated by MemAllocator class.
 
Allocatorallocator ()
 
void initialize (RowRange const &I)
 function for memory allocation and initialization.
 
void allocate (RowRange const &I)
 function for memory allocation.
 
void freeMem ()
 Method for memory deallocation.
 
- Protected Member Functions inherited from STK::ITContainer1D< Derived >
 ITContainer1D ()
 Default constructor.
 
 ITContainer1D (RowRange const &I)
 constructor with a specified range.
 
 ~ITContainer1D ()
 destructor.
 
void exchange (ITContainer1D &T)
 exchange this container with T
 
void setRange (RowRange const &I=RowRange())
 Set range of the rows of the container.
 
void incRange (int n=1)
 increment the range of the container (can be negative).
 
void incFirst (int n=1)
 increment the beginning of the container (can be negative).
 
void decFirst (int n=1)
 decrement the beginning of the container.
 
void incLast (int n=1)
 increment the end of the container (can be negative).
 
void decLast (int n=1)
 decrement the end of the container.
 
- Protected Member Functions inherited from STK::IRecursiveTemplate< Derived >
 IRecursiveTemplate ()
 constructor.
 
 ~IRecursiveTemplate ()
 destructor.
 

Detailed Description

template<class Type_>
class STK::Variable< Type_ >

Variable is an implementation of the Base class IVariable using The Array1D class for storing the data.

It implements all purely virtual methods defined in the IVariable base class.

Definition at line 95 of file STK_Variable.h.

Member Typedef Documentation

◆ Allocator

template<class Type_ >
typedef hidden::Traits<Variable<Type_>>::Allocator STK::Variable< Type_ >::Allocator

Definition at line 119 of file STK_Variable.h.

◆ Base

template<class Type_ >
typedef IArray1D< Variable<Type_> > STK::Variable< Type_ >::Base

Definition at line 122 of file STK_Variable.h.

◆ Col

template<class Type_ >
typedef Variable<Type_> STK::Variable< Type_ >::Col

Definition at line 100 of file STK_Variable.h.

◆ Row

template<class Type_ >
typedef Variable<Type_> STK::Variable< Type_ >::Row

Definition at line 99 of file STK_Variable.h.

◆ SubArray

template<class Type_ >
typedef Variable<Type_> STK::Variable< Type_ >::SubArray

Definition at line 103 of file STK_Variable.h.

◆ SubCol

template<class Type_ >
typedef Variable<Type_> STK::Variable< Type_ >::SubCol

Definition at line 102 of file STK_Variable.h.

◆ SubRow

template<class Type_ >
typedef Variable<Type_> STK::Variable< Type_ >::SubRow

Definition at line 101 of file STK_Variable.h.

◆ SubVector

template<class Type_ >
typedef Variable<Type_> STK::Variable< Type_ >::SubVector

Definition at line 104 of file STK_Variable.h.

◆ Type

template<class Type_ >
typedef hidden::Traits<Variable<Type_>>::Type STK::Variable< Type_ >::Type

Definition at line 106 of file STK_Variable.h.

◆ TypeConst

template<class Type_ >
typedef hidden::Traits<Variable<Type_>>::TypeConst STK::Variable< Type_ >::TypeConst

Definition at line 107 of file STK_Variable.h.

Member Enumeration Documentation

◆ anonymous enum

template<class Type_ >
anonymous enum
Enumerator
structure_ 
orient_ 
size_ 
sizeCols_ 
sizeRows_ 
storage_ 

Definition at line 109 of file STK_Variable.h.

110 {
111 structure_ = hidden::Traits< Variable<Type_> >::structure_,
112 orient_ = hidden::Traits< Variable<Type_> >::orient_,
113 size_ = hidden::Traits< Variable<Type_> >::size_,
114 sizeCols_ = hidden::Traits< Variable<Type_> >::sizeCols_,
115 sizeRows_ = hidden::Traits< Variable<Type_> >::sizeRows_,
116 storage_ = hidden::Traits< Variable<Type_> >::storage_
117 };

Constructor & Destructor Documentation

◆ Variable() [1/7]

template<class Type_ >
STK::Variable< Type_ >::Variable ( String const name = stringNa)
inlineexplicit

default constructor

Parameters
namename of the variable

Definition at line 128 of file STK_Variable.h.

130 , Base()
131 {}
IVariable(Base::IdType const &type, String const &name)
Default constructor.
String const & name() const
IArray1D< Variable< Type_ > > Base
static Base::IdType returnType()

◆ Variable() [2/7]

template<class Type_ >
STK::Variable< Type_ >::Variable ( int  size,
String const name = stringNa 
)
inlineexplicit

constructor

Parameters
size,namesize and name of the variable

Definition at line 135 of file STK_Variable.h.

137 , Base(size)
138 {}
virtual int size() const

◆ Variable() [3/7]

template<class Type_ >
STK::Variable< Type_ >::Variable ( Range const I,
String const name = stringNa 
)
inlineexplicit

Default constructor.

Parameters
I,namerange and name of the variable

Definition at line 142 of file STK_Variable.h.

144 , Base(I)
145 {}

◆ Variable() [4/7]

template<class Type_ >
STK::Variable< Type_ >::Variable ( Range const I,
Type_ const v,
String const name 
)
inline

constructor with specified initial value

Parameters
I,vrange of the data and initial value
namename of the variable

Definition at line 150 of file STK_Variable.h.

152 , Base(I)
153 { this->setValue(v);}
Variable< Type_ > & setValue(Type const &value)
set a value to this container.

References STK::IArray1D< Variable< Type_ > >::setValue().

◆ Variable() [5/7]

template<class Type_ >
STK::Variable< Type_ >::Variable ( Variable< Type_ > const V,
bool  ref = false 
)
inlineexplicit

copy/reference constructor.

Parameters
Vthe Variable to copy
reftrue if we want to wrap V

Definition at line 158 of file STK_Variable.h.

159 : IVariable(V)
160 , Base(V, ref)
161 {}

◆ Variable() [6/7]

template<class Type_ >
STK::Variable< Type_ >::Variable ( Variable< Type_ > const V,
Range const I,
bool  ref = true 
)
inlineexplicit

reference constructor

Parameters
V,IVariable and range to wrap
reftrue if we want to wrap V

Definition at line 166 of file STK_Variable.h.

167 : IVariable(V), Base(V, I, true)
168 {}

◆ Variable() [7/7]

template<class Type_ >
template<class OtherArray >
STK::Variable< Type_ >::Variable ( IArray1D< OtherArray > const T)
inline

constructor by reference, ref_=1.

Parameters
Tthe container to wrap

Definition at line 173 of file STK_Variable.h.

175 , Base(T, T.range(), true)
176 {}
String stringNa
Representation of a Not Available value.

◆ ~Variable()

template<class Type_ >
STK::Variable< Type_ >::~Variable ( )
inline

destructor.

Definition at line 178 of file STK_Variable.h.

178{}

Member Function Documentation

◆ clear()

template<class Type_ >
virtual void STK::Variable< Type_ >::clear ( )
inlinevirtual

clear Container from all elements and memory allocated.

Implements STK::IVariable.

Definition at line 260 of file STK_Variable.h.

260{ Base::clear();}
void clear()
Clear the object.

References STK::IArray1D< Variable< Type_ > >::clear().

◆ clone()

template<class Type_ >
virtual Variable * STK::Variable< Type_ >::clone ( bool  ref = false) const
inlinevirtual

clone return a ptr on a copy of the Object.

Parameters
reftrue if we want just a reference

Implements STK::IVariable.

Definition at line 182 of file STK_Variable.h.

183 { return new Variable(*this, ref);}
Variable(String const &name=stringNa)
default constructor

◆ encode()

template<class Type_ >
void STK::Variable< Type_ >::encode ( )
inline

encode values as ints.

Not used yet.

Definition at line 236 of file STK_Variable.h.

237 { int code = baseIdx;
238 std::pair< typename std::map<Type_, int>::iterator, bool> ret;
239 for (int i=this->begin(); i< this->end(); i++)
240 { ret=coding_.insert(std::pair<Type_, int>(this->elt(i), i));
241 if (ret.second==true) { code++;}
242 }
243 }
std::map< Type_, int > coding_
store the map String <-> int
const int baseIdx
base index of the containers created in STK++.

References STK::baseIdx, STK::IArray1D< Variable< Type_ > >::begin(), STK::Variable< Type_ >::coding_, STK::IArray1D< Variable< Type_ > >::elt(), and STK::IArray1D< Variable< Type_ > >::end().

◆ erase()

template<class Type_ >
virtual void STK::Variable< Type_ >::erase ( int  pos,
int  n = 1 
)
inlinevirtual

Delete n elements at the pos index from the container.

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

Implements STK::IVariable.

Definition at line 265 of file STK_Variable.h.

265{ Base::erase(pos,n);}
Variable< Type_ > & erase(int pos, int n=1)
Delete n elements at the pos index to the container.

References STK::IArray1D< Variable< Type_ > >::erase().

◆ exportAsString() [1/2]

template<class Type_ >
void STK::Variable< Type_ >::exportAsString ( Variable< String > &  V) const
inlinevirtual

Overwrite the variable V by converting the data into strings.

Parameters
VVariable of String

Definition at line 375 of file STK_Variable.h.

376{
377 V.resize(this->range());
378 V.setName(this->name());
379 for (int i=this->begin(); i<=this->lastIdx(); i++)
380 { V[i] = this->template eltAsString<Type_>(i);}
381}

◆ exportAsString() [2/2]

void STK::Variable< String >::exportAsString ( Variable< String > &  V) const
inline

Overwrite the variable V by converting the data into strings.

Parameters
VVariable of String

Definition at line 369 of file STK_Variable.h.

370{ V = *this;}

◆ importFromString() [1/2]

int STK::Variable< String >::importFromString ( Variable< String > const V,
std::ios_base &(*)(std::ios_base &)  f 
)
inline

overwrite the Variable by converting the strings contained in V into the Type_.

Give the number of success.

Parameters
VVariable of String
fio flags
Returns
number of successful conversion

Definition at line 340 of file STK_Variable.h.

343{ *this = V; return V.size();}

◆ importFromString() [2/2]

template<class Type_ >
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_.

Parameters
VVariable of String
fio flags
Returns
number of successful conversion

Definition at line 351 of file STK_Variable.h.

354{
355 this->resize(V.range());
356 this->setName(V.name());
357 int nSuccess = V.size();
358 for (int i=V.begin(); i<V.end(); i++)
359 if ( (Arithmetic<String>::isNA(V[i])) || (V[i]==stringNa) ) // not Available
360 this->elt(i) = Arithmetic<Type_>::NA();
361 else
362 if (!stringToType<Type_>(this->elt(i), V[i], f)) nSuccess--;
363 return nSuccess;
364}
Derived & resize(Range const &I=RowRange())
void setName(int num=0, String const &prefix=STRING_VAR)
Set a default name for the variable of the form : prefix + num.
static Type NA()
Adding a Non Available (NA) special number.
static bool isNA(Type const &x)

References STK::Arithmetic< Type >::NA(), and STK::stringNa.

◆ insertElt()

template<class Type_ >
void STK::Variable< Type_ >::insertElt ( int  pos,
int  n = 1 
)
inlinevirtual

Insert n elements at the position pos of the container.

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

Parameters
pos,nindex and number of elements to insert

Implements STK::IVariable.

Definition at line 213 of file STK_Variable.h.

214 { Base::insertElt(pos, n);}
Variable< Type_ > & insertElt(int pos, int n=1)
Insert n elements at the position pos of the container.

References STK::IArray1D< Variable< Type_ > >::insertElt().

◆ maxLength()

template<class Type_ >
int STK::Variable< Type_ >::maxLength ( bool  with_name) const
inline
Returns
the maximal size of all the fields as String in the variable

Definition at line 245 of file STK_Variable.h.

246 {
247 typename String::size_type maxlength = with_name ? this->name().size() : 0;
248 // loop over the values
249 for (int i=this->begin(); i<this->end(); i++)
250 { maxlength = std::max(maxlength, this->template eltAsString<Type_>(i).size() );}
251 return int(maxlength);
252 }

References STK::IArray1D< Variable< Type_ > >::begin(), STK::IArray1D< Variable< Type_ > >::end(), STK::IVariable::name(), and STK::Variable< Type_ >::size().

◆ move()

template<class Type_ >
void STK::Variable< Type_ >::move ( Variable< Type_ > const V)
inline

move the variable in this

Parameters
Vvariable to move in this

Definition at line 231 of file STK_Variable.h.

232 { Base::move(V);
233 name_ = V.name_;
234 }
void move(Variable< Type_ > const &T)
move T to this.
String name_
Name of the variable.

References STK::IArray1D< Variable< Type_ > >::move(), and STK::IVariable::name_.

◆ nbMiss()

template<class Type_ >
int STK::Variable< Type_ >::nbMiss ( ) const
Returns
the number of missing values in the variable

Definition at line 304 of file STK_Variable.h.

305{
306 int nbMiss = 0;
307 // loop over the values
308 for (int i=this->begin(); i<this->end(); i++)
309 { if (Arithmetic<Type_>::isNA(this->elt(i))) nbMiss++;}
310 return nbMiss;
311}
int nbMiss() const

◆ operator<<() [1/2]

template<class Type_ >
Variable< Type_ > & STK::Variable< Type_ >::operator<< ( Variable< String > const V)
inlinevirtual

Operator << : overwrite the Variable by converting the Strings contained in V into the Type_.

Parameters
Vthe Variable of string to import

Definition at line 375 of file STK_Variable.h.

400{
401 this->resize(V.range());
402 this->setName(V.name());
403 for (int i=V.begin(); i<V.end(); i++) this->elt(i) = stringToType<Type_>(V[i]);
404 return *this;
405}

◆ operator<<() [2/2]

Variable< String > & STK::Variable< String >::operator<< ( Variable< String > const V)
inline

Operator << : overwrite the Variable by converting the strings contained in V into the String.

Parameters
Vthe Variable of string to import

Definition at line 375 of file STK_Variable.h.

388{
389 this->resize(V.range());
390 this->setName(V.name());
391 for (int i=V.begin(); i<V.end(); i++) this->elt(i) = V[i];
392 return *this;
393}

◆ operator=() [1/2]

template<class Type_ >
Variable & STK::Variable< Type_ >::operator= ( Type_ const v)
inline

set the container to a constant value.

Parameters
vthe value to set

Definition at line 226 of file STK_Variable.h.

226{ this->setValue(v); return *this;}

References STK::IArray1D< Variable< Type_ > >::setValue().

◆ operator=() [2/2]

template<class Type_ >
Variable & STK::Variable< Type_ >::operator= ( Variable< Type_ > const V)
inline

operator = : overwrite the CArray with the Right hand side T.

Parameters
Vthe container to copy

Definition at line 218 of file STK_Variable.h.

219 { // copy IVariable part
220 this->name_ = V.name_;
221 return Base::assign(V);
222 }
Variable< Type_ > & assign(IArray1D const &src)
overwrite this with src.

References STK::IArray1D< Variable< Type_ > >::assign(), and STK::IVariable::name_.

◆ operator>>() [1/2]

template<class Type_ >
Variable< Type_ > const & STK::Variable< Type_ >::operator>> ( Variable< String > &  V) const
inlinevirtual

Operator >> : convert the Variable V into strings.

Parameters
VVariable of String

Definition at line 421 of file STK_Variable.h.

422{
423 V.resize(this->range());
424 V.setName(this->name());
425 for (int i=this->begin(); i<this->end(); i++) V[i] = typeToString<Type_>(this->elt(i));
426 return *this;
427}

◆ operator>>() [2/2]

Variable< String > const & STK::Variable< String >::operator>> ( Variable< String > &  V) const
inline

Operator >> : convert the Variable V into strings.

Parameters
VVariable of String

Definition at line 410 of file STK_Variable.h.

411{
412 V.resize(this->range());
413 V.setName(this->name());
414 for (int i=this->begin(); i<this->end(); i++) V[i] = this->elt(i);
415 return *this;
416}

◆ popBack()

template<class Type_ >
virtual void STK::Variable< Type_ >::popBack ( int  n = 1)
inlinevirtual

remove n elements to the end of the container

Parameters
nnumber of element to remove

Implements STK::IVariable.

Definition at line 196 of file STK_Variable.h.

196{ Base::popBack(n);}
Variable< Type_ > & popBack(int n=1)
Delete last elts of the container.

References STK::IArray1D< Variable< Type_ > >::popBack().

◆ push_back()

template<class Type_ >
void STK::Variable< Type_ >::push_back ( Type_ const v)
inline

Add an element to the container.

Parameters
vthe element to add

Definition at line 204 of file STK_Variable.h.

205 { Base::pushBack();
206 this->back() = v;
207 }
Variable< Type_ > & pushBack(int n=1)
Add n Elements to the end of the container.

References STK::ITContainer1D< Derived >::back(), and STK::IArray1D< Variable< Type_ > >::pushBack().

◆ pushBack()

template<class Type_ >
void STK::Variable< Type_ >::pushBack ( int  n = 1)
inlinevirtual

Add n elements to the container.

Parameters
nnumber of elements to add

Implements STK::IVariable.

Definition at line 200 of file STK_Variable.h.

200{ Base::pushBack(n);}

References STK::IArray1D< Variable< Type_ > >::pushBack().

◆ pushBackNAValues() [1/2]

void STK::Variable< String >::pushBackNAValues ( int  n)
inlinevirtual

push back n NA values.

Specialization for Type_ = String.

Parameters
nnumber of NA values to add

Implements STK::IVariable.

Definition at line 316 of file STK_Variable.h.

317{ int first = this->end(), end = first+n;
318 this->insertElt(this->end(), n);
319 for (int i=first; i<end; i++)
320 this->elt(i) = stringNa;
321}
void insertElt(int pos, int n=1)
Insert n elements at the position pos of the container.

References STK::stringNa.

◆ pushBackNAValues() [2/2]

template<class Type_ >
void STK::Variable< Type_ >::pushBackNAValues ( int  n = 1)
inlinevirtual

push back n NA values.

Parameters
nnumber of NA values to add

Implements STK::IVariable.

Definition at line 326 of file STK_Variable.h.

327{
328 int first = this->end(), end = first+n;
329 this->insertElt(this->end(), n);
330 for (int i=first; i<end; i++)
331 this->elt(i) = Arithmetic<Type_>::NA();
332}

References STK::Arithmetic< Type >::NA().

◆ resize1D()

template<class Type_ >
Variable< Type_ > & STK::Variable< Type_ >::resize1D ( Range const I)
inline

Resize the container.

Parameters
Ithe range to set to the container

Definition at line 191 of file STK_Variable.h.

192 { Base::resize(I, this->cols()); return *this;}

References STK::IArray1D< Variable< Type_ > >::cols(), and STK::ITContainer1D< Derived >::resize().

◆ shift()

template<class Type_ >
virtual void STK::Variable< Type_ >::shift ( int  beg)
inlinevirtual

New first index for the object.

Parameters
begthe index of the first column to set

Implements STK::IVariable.

Definition at line 269 of file STK_Variable.h.

269{ Base::shift(beg);}

References STK::ITContainer1D< Derived >::shift().

◆ shift1D()

template<class Type_ >
void STK::Variable< Type_ >::shift1D ( int  rbeg)
inline

New first index for the object.

Parameters
rbegthe index of the first row to set

Definition at line 187 of file STK_Variable.h.

187{ Base::shift(rbeg, this->beginCols());}

References STK::IArray1D< Variable< Type_ > >::beginCols(), and STK::ITContainer1D< Derived >::shift().

◆ size()

template<class Type_ >
virtual int STK::Variable< Type_ >::size ( ) const
inlinevirtual
Returns
the number of sample in the variable

Implements STK::IVariable.

Definition at line 258 of file STK_Variable.h.

References STK::IArray1D< Variable< Type_ > >::size().

Referenced by STK::Variable< Type_ >::maxLength().

Member Data Documentation

◆ coding_

template<class Type_ >
std::map<Type_, int> STK::Variable< Type_ >::coding_
protected

store the map String <-> int

Definition at line 299 of file STK_Variable.h.

Referenced by STK::Variable< Type_ >::encode().


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