STK++ 0.9.13
STK::ITContainer1D< Derived > Class Template Reference

Interface base class for homogeneous 1D containers. More...

#include <STK_ITContainer1D.h>

Inheritance diagram for STK::ITContainer1D< Derived >:
Inheritance graph

Public Types

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

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 Member Functions

 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.
 

Private Attributes

RowRange range_
 range of the array.
 

Detailed Description

template<class Derived>
class STK::ITContainer1D< Derived >

Interface base class for homogeneous 1D containers.

The ITContainer1D class is the template base class for all homogeneous one-dimensional containers containing element of type Type where Type is not necessarily a scalar. It assumes that the derived class cannot be part of an expression and is not constant, so that it can be #- shifted, #- resized #- accessed in modification.

Implement the curious recursive template paradigm: the template parameter c Derived is the name of the class that implements ITContainer1D. For example template<class Type> class Derived: public ITContainer1D< Derived<Type> > {...}

The pseudo virtual function defined in this interface and to be implemented by derived classes have the following definitions

Type& elt1Impl(int const& pos);
Type const& elt1Impl(int const& pos) const;
void shiftImpl(int const& beg);
Derived& resizeImpl(Range const& I);
hidden::Traits< Derived >::Type Type
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

It is required that all these methods have to be implemented in Derived classes.

See also
List1D, Array1D

Definition at line 75 of file STK_ITContainer1D.h.

Member Typedef Documentation

◆ Col

template<class Derived >
typedef hidden::Traits<Derived>::Col STK::ITContainer1D< Derived >::Col

Definition at line 90 of file STK_ITContainer1D.h.

◆ ColRange

template<class Derived >
typedef hidden::Traits<Derived>::ColRange STK::ITContainer1D< Derived >::ColRange

Definition at line 87 of file STK_ITContainer1D.h.

◆ ConstIterator

template<class Derived >
typedef hidden::Traits<Derived>::ConstIterator STK::ITContainer1D< Derived >::ConstIterator

Definition at line 95 of file STK_ITContainer1D.h.

◆ ConstReverseIterator

template<class Derived >
typedef hidden::Traits<Derived>::ConstReverseIterator STK::ITContainer1D< Derived >::ConstReverseIterator

Definition at line 97 of file STK_ITContainer1D.h.

◆ Iterator

template<class Derived >
typedef hidden::Traits<Derived>::Iterator STK::ITContainer1D< Derived >::Iterator

Definition at line 94 of file STK_ITContainer1D.h.

◆ ReverseIterator

template<class Derived >
typedef hidden::Traits<Derived>::ReverseIterator STK::ITContainer1D< Derived >::ReverseIterator

Definition at line 96 of file STK_ITContainer1D.h.

◆ Row

template<class Derived >
typedef hidden::Traits<Derived>::Row STK::ITContainer1D< Derived >::Row

Definition at line 89 of file STK_ITContainer1D.h.

◆ RowRange

template<class Derived >
typedef hidden::Traits<Derived>::RowRange STK::ITContainer1D< Derived >::RowRange

Definition at line 86 of file STK_ITContainer1D.h.

◆ SubVector

template<class Derived >
typedef hidden::Traits<Derived>::SubVector STK::ITContainer1D< Derived >::SubVector

Definition at line 91 of file STK_ITContainer1D.h.

◆ Type

template<class Derived >
typedef hidden::Traits<Derived>::Type STK::ITContainer1D< Derived >::Type

Definition at line 83 of file STK_ITContainer1D.h.

◆ TypeConst

template<class Derived >
typedef hidden::Traits<Derived>::TypeConst STK::ITContainer1D< Derived >::TypeConst

Definition at line 84 of file STK_ITContainer1D.h.

Member Enumeration Documentation

◆ anonymous enum

template<class Derived >
anonymous enum
Enumerator
size_ 

Definition at line 78 of file STK_ITContainer1D.h.

79 {
80 size_ = hidden::Traits<Derived>::size_
81 };

Constructor & Destructor Documentation

◆ ITContainer1D() [1/2]

template<class Derived >
STK::ITContainer1D< Derived >::ITContainer1D ( )
inlineprotected

Default constructor.

Definition at line 101 of file STK_ITContainer1D.h.

101: range_() {}
RowRange range_
range of the array.

◆ ITContainer1D() [2/2]

template<class Derived >
STK::ITContainer1D< Derived >::ITContainer1D ( RowRange const I)
inlineprotected

constructor with a specified range.

Parameters
I: the range of the container

Definition at line 105 of file STK_ITContainer1D.h.

105: range_(I) {}

◆ ~ITContainer1D()

template<class Derived >
STK::ITContainer1D< Derived >::~ITContainer1D ( )
inlineprotected

destructor.

Definition at line 107 of file STK_ITContainer1D.h.

107{}

Member Function Documentation

◆ at() [1/2]

◆ at() [2/2]

template<class Derived >
TypeConst STK::ITContainer1D< Derived >::at ( int  i) const
inline
Returns
safely the constant jth element
Parameters
iindex of the element

Definition at line 203 of file STK_ITContainer1D.h.

204 {
205 if (begin() > i)
207 if (end() <= i)
209 return elt(i);
210 }

References STK::ITContainer1D< Derived >::at(), STK::ITContainer1D< Derived >::begin(), STK::ITContainer1D< Derived >::elt(), STK::ITContainer1D< Derived >::end(), and STKOUT_OF_RANGE_1ARG.

◆ back() [1/2]

template<class Derived >
Type & STK::ITContainer1D< Derived >::back ( )
inline
Returns
a reference on the last element

Definition at line 231 of file STK_ITContainer1D.h.

231{ return elt(lastIdx());}

References STK::ITContainer1D< Derived >::elt(), and STK::ITContainer1D< Derived >::lastIdx().

Referenced by STK::Variable< Type_ >::push_back(), and STK::DataFrame::pushBackVariable().

◆ back() [2/2]

template<class Derived >
TypeConst STK::ITContainer1D< Derived >::back ( ) const
inline
Returns
a constant reference on the last element

Definition at line 233 of file STK_ITContainer1D.h.

233{ return elt(lastIdx());}

References STK::ITContainer1D< Derived >::elt(), and STK::ITContainer1D< Derived >::lastIdx().

◆ begin()

◆ beginConstIterator()

template<class Derived >
ConstIterator STK::ITContainer1D< Derived >::beginConstIterator ( ) const
inline
Returns
an iterator on the beginning of the container

Definition at line 128 of file STK_ITContainer1D.h.

128{ return ConstIterator(this->asDerived(), begin());}
Derived & asDerived()
static cast : return a reference of this with a cast to the derived class.
hidden::Traits< Derived >::ConstIterator ConstIterator

References STK::IRecursiveTemplate< Derived >::asDerived(), and STK::ITContainer1D< Derived >::begin().

Referenced by STK::KernelHandler::addKernel(), STK::KernelHandler::getKernel(), STK::KernelHandler::isHandled(), and STK::ITContainer1D< Derived >::rendConstIterator().

◆ beginIterator()

template<class Derived >
Iterator STK::ITContainer1D< Derived >::beginIterator ( )
inline

◆ decFirst()

template<class Derived >
void STK::ITContainer1D< Derived >::decFirst ( int  n = 1)
inlineprotected

decrement the beginning of the container.

Parameters
ndecrement to apply to the beginning of the range

Definition at line 267 of file STK_ITContainer1D.h.

267{ range_.decFirst(n);}

References STK::ITContainer1D< Derived >::range_.

◆ decLast()

template<class Derived >
void STK::ITContainer1D< Derived >::decLast ( int  n = 1)
inlineprotected

decrement the end of the container.

Parameters
ndecrement to apply to the end of the range

Definition at line 275 of file STK_ITContainer1D.h.

275{ range_.decLast(n);}

References STK::ITContainer1D< Derived >::range_.

◆ elt() [1/2]

◆ elt() [2/2]

template<class Derived >
TypeConst STK::ITContainer1D< Derived >::elt ( int  i) const
inline
Returns
a constant reference on the ith element for vector_, point_ and diagonal_ containers
Parameters
iindex of the element to get

Definition at line 161 of file STK_ITContainer1D.h.

162 {
163#ifdef STK_BOUNDS_CHECK
164 if (begin() > i) { STKOUT_OF_RANGE_1ARG(ITContainer1D::elt, i, begin() > i);}
165 if (end() <= i) { STKOUT_OF_RANGE_1ARG(ITContainer1D::elt, i, end() <= i);}
166#endif
167 return this->asDerived().elt1Impl(i);
168 }

References STK::IRecursiveTemplate< Derived >::asDerived(), STK::ITContainer1D< Derived >::begin(), STK::ITContainer1D< Derived >::elt(), STK::ITContainer1D< Derived >::end(), and STKOUT_OF_RANGE_1ARG.

◆ empty()

template<class Derived >
bool STK::ITContainer1D< Derived >::empty ( ) const
inline

Is there some data ?

Returns
true if the container is empty, false otherwise

Definition at line 145 of file STK_ITContainer1D.h.

145{ return range_.empty();}

References STK::ITContainer1D< Derived >::range_.

Referenced by STK::DataFrame::empty().

◆ end()

◆ endConstIterator()

template<class Derived >
ConstIterator STK::ITContainer1D< Derived >::endConstIterator ( ) const
inline

◆ endIterator()

template<class Derived >
Iterator STK::ITContainer1D< Derived >::endIterator ( )
inline
Returns
an iterator on the end of the container

Definition at line 125 of file STK_ITContainer1D.h.

125{ return Iterator(this->asDerived(), end());}

Referenced by STK::KernelHandler::addKernel(), STK::ITContainer1D< Derived >::rbeginIterator(), STK::KernelHandler::removeKernel(), and STK::KernelHandler::~KernelHandler().

◆ exchange()

template<class Derived >
void STK::ITContainer1D< Derived >::exchange ( ITContainer1D< Derived > &  T)
inlineprotected

exchange this container with T

Parameters
Tthe container to exchange with T

Definition at line 251 of file STK_ITContainer1D.h.

251{ std::swap(T.range_, range_ );}

References STK::ITContainer1D< Derived >::range_.

◆ front() [1/2]

template<class Derived >
Type & STK::ITContainer1D< Derived >::front ( )
inline
Returns
a reference on the first element.

Definition at line 227 of file STK_ITContainer1D.h.

227{ return elt(begin());}

References STK::ITContainer1D< Derived >::begin(), and STK::ITContainer1D< Derived >::elt().

◆ front() [2/2]

template<class Derived >
TypeConst STK::ITContainer1D< Derived >::front ( ) const
inline
Returns
a constant reference on the first element

Definition at line 229 of file STK_ITContainer1D.h.

229{ return elt(begin());}

References STK::ITContainer1D< Derived >::begin(), and STK::ITContainer1D< Derived >::elt().

◆ incFirst()

template<class Derived >
void STK::ITContainer1D< Derived >::incFirst ( int  n = 1)
inlineprotected

increment the beginning of the container (can be negative).

Parameters
nincrement to apply to the beginning of the range

Definition at line 263 of file STK_ITContainer1D.h.

263{ range_.incFirst(n);}

References STK::ITContainer1D< Derived >::range_.

◆ incLast()

template<class Derived >
void STK::ITContainer1D< Derived >::incLast ( int  n = 1)
inlineprotected

increment the end of the container (can be negative).

Parameters
nincrement to apply to the end of the range

Definition at line 271 of file STK_ITContainer1D.h.

271{ range_.incLast(n);}

References STK::ITContainer1D< Derived >::range_.

◆ incRange()

template<class Derived >
void STK::ITContainer1D< Derived >::incRange ( int  n = 1)
inlineprotected

increment the range of the container (can be negative).

Parameters
nincrement to apply to the range

Definition at line 259 of file STK_ITContainer1D.h.

259{ range_.inc(n);}

References STK::ITContainer1D< Derived >::range_.

◆ lastIdx()

template<class Derived >
int STK::ITContainer1D< Derived >::lastIdx ( ) const
inline
Returns
the index of the last element

Definition at line 120 of file STK_ITContainer1D.h.

120{ return range_.lastIdx();}

References STK::ITContainer1D< Derived >::range_.

Referenced by STK::ITContainer1D< Derived >::back(), STK::ITContainer1D< Derived >::back(), and STK::ISparseArray1D< Derived >::lastIdxRows().

◆ operator[]() [1/2]

template<class Derived >
Type & STK::ITContainer1D< Derived >::operator[] ( int  i)
inline
Returns
the element ith element
Parameters
iindex of the element to get

Definition at line 172 of file STK_ITContainer1D.h.

173 {
174#ifdef STK_BOUNDS_CHECK
175 if (begin() > i) { STKOUT_OF_RANGE_1ARG(ITContainer1D::operator[], i, begin() > i);}
176 if (end() <= i) { STKOUT_OF_RANGE_1ARG(ITContainer1D::operator[], i, end() <= i);}
177#endif
178 return elt(i);
179 }

References STK::ITContainer1D< Derived >::begin(), STK::ITContainer1D< Derived >::elt(), STK::ITContainer1D< Derived >::end(), and STKOUT_OF_RANGE_1ARG.

◆ operator[]() [2/2]

template<class Derived >
TypeConst STK::ITContainer1D< Derived >::operator[] ( int  i) const
inline
Returns
a constant reference on the ith element
Parameters
iindex of the element to get

Definition at line 183 of file STK_ITContainer1D.h.

184 {
185#ifdef STK_BOUNDS_CHECK
186 if (begin() > i) { STKOUT_OF_RANGE_1ARG(ITContainer1D::operator[], i, begin() > i);}
187 if (end() <= i) { STKOUT_OF_RANGE_1ARG(ITContainer1D::operator[], i, end() <= i);}
188#endif
189 return elt(i);
190 }

References STK::ITContainer1D< Derived >::begin(), STK::ITContainer1D< Derived >::elt(), STK::ITContainer1D< Derived >::end(), and STKOUT_OF_RANGE_1ARG.

◆ range()

template<class Derived >
RowRange const & STK::ITContainer1D< Derived >::range ( ) const
inline
Returns
the range of the container

Definition at line 111 of file STK_ITContainer1D.h.

111{ return range_;}

References STK::ITContainer1D< Derived >::range_.

Referenced by STK::List1D< Type_ >::operator=().

◆ rbeginConstIterator()

template<class Derived >
ConstReverseIterator STK::ITContainer1D< Derived >::rbeginConstIterator ( ) const
inline
Returns
a reversed iterator on the beginning of the reversed container

Definition at line 138 of file STK_ITContainer1D.h.

hidden::Traits< Derived >::ConstReverseIterator ConstReverseIterator
ConstIterator endConstIterator() const

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

◆ rbeginIterator()

template<class Derived >
ReverseIterator STK::ITContainer1D< Derived >::rbeginIterator ( )
inline
Returns
a reversed iterator on the beginning of the reversed container

Definition at line 133 of file STK_ITContainer1D.h.

133{ return ReverseIterator(endIterator());}
hidden::Traits< Derived >::ReverseIterator ReverseIterator

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

◆ rendConstIterator()

template<class Derived >
ConstReverseIterator STK::ITContainer1D< Derived >::rendConstIterator ( ) const
inline
Returns
a reversed iterator on the end of the reversed container

Definition at line 140 of file STK_ITContainer1D.h.

ConstIterator beginConstIterator() const

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

◆ rendIterator()

template<class Derived >
ReverseIterator STK::ITContainer1D< Derived >::rendIterator ( )
inline
Returns
a reversed iterator on the end of the reversed container

Definition at line 135 of file STK_ITContainer1D.h.

135{ return ReverseIterator(beginIterator());}

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

◆ resize()

◆ setRange()

template<class Derived >
void STK::ITContainer1D< Derived >::setRange ( RowRange const I = RowRange())
inlineprotected

Set range of the rows of the container.

Parameters
Ithe range to set (default empty)

Definition at line 255 of file STK_ITContainer1D.h.

255{ range_ = I;}

References STK::ITContainer1D< Derived >::range_.

Referenced by STK::DataFrame::clear().

◆ shift()

template<class Derived >
void STK::ITContainer1D< Derived >::shift ( int  beg)
inline
Parameters
begthe index of the first column to set

Definition at line 236 of file STK_ITContainer1D.h.

237 {
238 this->asDerived().shiftImpl(beg);
239 range_.shift(beg);
240 }

References STK::IRecursiveTemplate< Derived >::asDerived(), and STK::ITContainer1D< Derived >::range_.

Referenced by STK::Variable< Type_ >::shift(), STK::DataFrame::shift(), and STK::Variable< Type_ >::shift1D().

◆ size()

template<class Derived >
int STK::ITContainer1D< Derived >::size ( ) const
inline
Returns
the size of the container

Definition at line 117 of file STK_ITContainer1D.h.

117{ return range_.size();}

References STK::ITContainer1D< Derived >::range_.

◆ sub()

template<class Derived >
SubVector STK::ITContainer1D< Derived >::sub ( Range const I) const
inline

Access to many elements.

Parameters
Ithe range of the elements
Returns
a reference container with the elements of this in the range I

Definition at line 215 of file STK_ITContainer1D.h.

216 {
217#ifdef STK_BOUNDS_CHECK
218 if ((I.begin()<begin()))
220 if ((I.end()>end()))
222#endif
223 return SubVector(this->asDerived(), I, true);
224 }
hidden::Traits< Derived >::SubVector SubVector
SubVector sub(Range const &I) const
Access to many elements.

References STK::IRecursiveTemplate< Derived >::asDerived(), STK::ITContainer1D< Derived >::begin(), STK::ITContainer1D< Derived >::end(), STKOUT_OF_RANGE_1ARG, and STK::ITContainer1D< Derived >::sub().

Referenced by STK::ITContainer1D< Derived >::sub().

Member Data Documentation

◆ range_


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