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

Interface class for SparseArray1D. More...

#include <STK_ISparseArray1D.h>

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

Public Types

enum  {
  structure_ = hidden::Traits<Derived>::structure_ , orient_ = hidden::Traits<Derived>::orient_ , sizeRows_ = hidden::Traits<Derived>::sizeRows_ , sizeCols_ = hidden::Traits<Derived>::sizeCols_ ,
  storage_ = hidden::Traits<Derived>::storage_
}
 
typedef ITContainer1D< Derived > Base
 
typedef hidden::Traits< Derived >::Type Type
 
typedef hidden::Traits< Derived >::Col Col
 
typedef hidden::Traits< Derived >::SubArray SubArray
 
typedef hidden::CheckShift< Derived, structure_CheckShift
 
typedef TRange< sizeRows_RowRange
 Type of the Range for the rows.
 
typedef TRange< sizeCols_ColRange
 Type of the Range for the columns.
 
- 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

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
 
void shiftImpl (int beg=baseIdx)
 New beginning index for the object.
 
Derived & 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 (Derived const &T)
 move T to this.
 
Derived & pushBack (int n=1)
 Add n Elements to the end of the container.
 
Derived & popBack (int n=1)
 Delete last elts of the container.
 
Derived & erase (int pos, int n=1)
 Delete n elements at the pos index to the container.
 
Derived & insertElt (int pos, int n=1)
 Insert n elements at the position pos of the container.
 
Derived & insert (int pos, Type const &v)
 STL compatibility: Insert element v at position pos of the Array.
 
Derived & insert (Range const &I, Type const &v)
 STL compatibility: Insert element v in the range I of the Array.
 
Derived & push_front (Type const &v)
 STL compatibility: push front an element.
 
Derived & 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 (ISparseArray1D &T)
 exchange this Container with T.
 
Derived & assign (ISparseArray1D const &src)
 overwrite this with src.
 
Derived & setValue (Type const &value)
 set a value to this container.
 
RowRange constrange () const
 
int begin () const
 
int end () const
 
int size () const
 
Typeelt (int i)
 
TypeConst elt (int i) const
 
void setRange (RowRange const &I=RowRange())
 Set range of the rows of the container.
 
- 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 Member Functions

 ISparseArray1D ()
 Default constructor.
 
 ISparseArray1D (Range const &I)
 constructor with a specified Range.
 
 ISparseArray1D (Range const &I, Type const &v)
 Misc constructor with first and last, initialization with a constant.
 
 ISparseArray1D (const ISparseArray1D &T, bool ref=false)
 Copy constructor.
 
template<class OtherDerived >
 ISparseArray1D (ExprBase< OtherDerived > const &T)
 Copy constructor.
 
 ISparseArray1D (ISparseArray1D const &T, Range const &I)
 constructor by reference, ref_=1.
 
template<class OtherDerived >
 ISparseArray1D (ISparseArray1D< OtherDerived > const &T, Range const &I)
 constructor by reference, ref_=1.
 
 ~ISparseArray1D ()
 destructor: allocated memory is liberated by MemAllocator base class.
 
- 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 Derived>
class STK::ISparseArray1D< Derived >

Interface class for SparseArray1D.

This class is the base class that is inherited by all objects (matrix, vector, point) which are not expressions and stored as SparseArrays. The common API for these objects is contained in this class.

Template Parameters
Derivedis the derived type, e.g., a matrix type.

Definition at line 56 of file STK_ISparseArray1D.h.

Member Typedef Documentation

◆ Base

template<class Derived >
typedef ITContainer1D<Derived> STK::ISparseArray1D< Derived >::Base

Definition at line 59 of file STK_ISparseArray1D.h.

◆ CheckShift

template<class Derived >
typedef hidden::CheckShift<Derived, structure_> STK::ISparseArray1D< Derived >::CheckShift

Definition at line 77 of file STK_ISparseArray1D.h.

◆ Col

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

Definition at line 63 of file STK_ISparseArray1D.h.

◆ ColRange

template<class Derived >
typedef TRange<sizeCols_> STK::ISparseArray1D< Derived >::ColRange

Type of the Range for the columns.

Definition at line 81 of file STK_ISparseArray1D.h.

◆ RowRange

template<class Derived >
typedef TRange<sizeRows_> STK::ISparseArray1D< Derived >::RowRange

Type of the Range for the rows.

Definition at line 79 of file STK_ISparseArray1D.h.

◆ SubArray

template<class Derived >
typedef hidden::Traits<Derived>::SubArray STK::ISparseArray1D< Derived >::SubArray

Definition at line 67 of file STK_ISparseArray1D.h.

◆ Type

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

Definition at line 61 of file STK_ISparseArray1D.h.

Member Enumeration Documentation

◆ anonymous enum

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

Definition at line 69 of file STK_ISparseArray1D.h.

70 {
71 structure_ = hidden::Traits<Derived>::structure_,
72 orient_ = hidden::Traits<Derived>::orient_,
73 sizeRows_ = hidden::Traits<Derived>::sizeRows_,
74 sizeCols_ = hidden::Traits<Derived>::sizeCols_,
75 storage_ = hidden::Traits<Derived>::storage_
76 };

Constructor & Destructor Documentation

◆ ISparseArray1D() [1/7]

template<class Derived >
STK::ISparseArray1D< Derived >::ISparseArray1D ( )
protected

Default constructor.

◆ ISparseArray1D() [2/7]

template<class Derived >
STK::ISparseArray1D< Derived >::ISparseArray1D ( Range const I)
protected

constructor with a specified Range.

Parameters
Irange of the container

◆ ISparseArray1D() [3/7]

template<class Derived >
STK::ISparseArray1D< Derived >::ISparseArray1D ( Range const I,
Type const v 
)
protected

Misc constructor with first and last, initialization with a constant.

Parameters
Irange of the container
vinitial value of the container

◆ ISparseArray1D() [4/7]

template<class Derived >
STK::ISparseArray1D< Derived >::ISparseArray1D ( const ISparseArray1D< Derived > &  T,
bool  ref = false 
)
protected

Copy constructor.

Parameters
Tthe container to copy
reftrue if T is wrapped

◆ ISparseArray1D() [5/7]

template<class Derived >
template<class OtherDerived >
STK::ISparseArray1D< Derived >::ISparseArray1D ( ExprBase< OtherDerived > const T)
protected

Copy constructor.

Parameters
Tthe container to copy

◆ ISparseArray1D() [6/7]

template<class Derived >
STK::ISparseArray1D< Derived >::ISparseArray1D ( ISparseArray1D< Derived > const T,
Range const I 
)
protected

constructor by reference, ref_=1.

Parameters
T,Ithe container and the range of data to wrap

◆ ISparseArray1D() [7/7]

template<class Derived >
template<class OtherDerived >
STK::ISparseArray1D< Derived >::ISparseArray1D ( ISparseArray1D< OtherDerived > const T,
Range const I 
)
protected

constructor by reference, ref_=1.

Parameters
T,Ithe container and the range of data to wrap

◆ ~ISparseArray1D()

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

destructor: allocated memory is liberated by MemAllocator base class.

Definition at line 124 of file STK_ISparseArray1D.h.

124{}

Member Function Documentation

◆ allocator()

template<class Derived >
Allocator const & STK::ISparseArray1D< Derived >::allocator ( ) const
inline
Returns
a constant reference on the allocator

Definition at line 139 of file STK_ISparseArray1D.h.

139{ return allocator_;}

◆ assign()

template<class Derived >
Derived & STK::ISparseArray1D< Derived >::assign ( ISparseArray1D< Derived > const src)

overwrite this with src.

Note
If the size match, this is not resized, and in this case, the method take care of the possibility of overlapping.
Parameters
srcthe container to assign

◆ begin()

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

Definition at line 113 of file STK_ITContainer1D.h.

113{ return range_.begin();}
RowRange range_
range of the array.
int begin() const
get the first index of the TRange.
Definition STK_Range.h:93

Referenced by STK::ISparseArray1D< Derived >::beginRows().

◆ beginCols()

template<class Derived >
int STK::ISparseArray1D< Derived >::beginCols ( ) const
inline
Returns
the index of the first column

Definition at line 153 of file STK_ISparseArray1D.h.

153{ return baseIdx;}
const int baseIdx
base index of the containers created in STK++.

References STK::baseIdx.

◆ beginRows()

template<class Derived >
int STK::ISparseArray1D< Derived >::beginRows ( ) const
inline
Returns
the index of the first element

Definition at line 144 of file STK_ISparseArray1D.h.

144{ return begin();}

References STK::ISparseArray1D< Derived >::begin().

◆ capacity()

template<class Derived >
int STK::ISparseArray1D< Derived >::capacity ( ) const
inline
Returns
the maximum possible number of elements without reallocation

Definition at line 165 of file STK_ISparseArray1D.h.

165{ return isRef() ? 0 : allocator_.size();}

References STK::ISparseArray1D< Derived >::isRef().

◆ clear()

template<class Derived >
void STK::ISparseArray1D< Derived >::clear ( )

Clear the object.

Memory is liberated and the range of the Container is set to 0:-1 or 1:0 (

See also
baseIdx).

◆ cols()

template<class Derived >
ColRange STK::ISparseArray1D< Derived >::cols ( ) const
inline
Returns
the Horizontal range (1 column)

Definition at line 151 of file STK_ISparseArray1D.h.

151{ return ColRange(1);}
TRange< sizeCols_ > ColRange
Type of the Range for the columns.

◆ elt() [1/2]

template<class Derived >
Type & STK::ITContainer1D< Derived >::elt ( int  i)
inline
Returns
the ith element for vector_, point_ and diagonal_ containers
Parameters
iindex of the element to get

Definition at line 150 of file STK_ITContainer1D.h.

151 {
152#ifdef STK_BOUNDS_CHECK
153 if (begin() > i) { STKOUT_OF_RANGE_1ARG(ITContainer1D::elt, i, begin() > i);}
154 if (end() <= i) { STKOUT_OF_RANGE_1ARG(ITContainer1D::elt, i, end() <= i);}
155#endif
156 return this->asDerived().elt1Impl(i);
157 }
#define STKOUT_OF_RANGE_1ARG(Where, Arg, Error)
Definition STK_Macros.h:93
Derived & asDerived()
static cast : return a reference of this with a cast to the derived class.

◆ 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 }

◆ elt1Impl() [1/2]

template<class Derived >
Type & STK::ISparseArray1D< Derived >::elt1Impl ( int  pos)
inline

access to an element

Parameters
posindex of the element
Returns
a reference on the element to modify

Definition at line 171 of file STK_ISparseArray1D.h.

171{ return allocator_.elt(pos);}

◆ elt1Impl() [2/2]

template<class Derived >
TypeConst STK::ISparseArray1D< Derived >::elt1Impl ( int  pos) const
inline

access to a constant element

Parameters
posindex of the const element
Returns
a constant reference on the element

Definition at line 176 of file STK_ISparseArray1D.h.

176{ return allocator_.elt(pos);}

◆ end()

template<class Derived >
int STK::ITContainer1D< Derived >::end ( ) const
inline
Returns
the ending index of the elements

Definition at line 115 of file STK_ITContainer1D.h.

115{ return range_.end();}
int end() const
get the ending index of the TRange.
Definition STK_Range.h:192

Referenced by STK::ISparseArray1D< Derived >::endRows().

◆ endCols()

template<class Derived >
int STK::ISparseArray1D< Derived >::endCols ( ) const
inline
Returns
the index of the ending column

Definition at line 155 of file STK_ISparseArray1D.h.

155{ return baseIdx+1;}

References STK::baseIdx.

◆ endRows()

template<class Derived >
int STK::ISparseArray1D< Derived >::endRows ( ) const
inline
Returns
the ending index of the elements

Definition at line 146 of file STK_ISparseArray1D.h.

146{ return end();}

References STK::ISparseArray1D< Derived >::end().

◆ erase()

template<class Derived >
Derived & STK::ISparseArray1D< Derived >::erase ( int  pos,
int  n = 1 
)

Delete n elements at the pos index to the container.

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

◆ exchange()

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

exchange this Container with T.

Parameters
Tthe Array to exchange with this

◆ insert() [1/2]

template<class Derived >
Derived & STK::ISparseArray1D< Derived >::insert ( int  pos,
Type const v 
)

STL compatibility: Insert element v at position pos of the Array.

Parameters
posposition to insert elements
vvalue to insert

◆ insert() [2/2]

template<class Derived >
Derived & STK::ISparseArray1D< Derived >::insert ( Range const I,
Type const v 
)

STL compatibility: Insert element v in the range I of the Array.

Parameters
Irange of the index where to insert elements
vvalue to insert

◆ insertElt()

template<class Derived >
Derived & STK::ISparseArray1D< Derived >::insertElt ( int  pos,
int  n = 1 
)

Insert n elements at the position pos of the container.

Parameters
pos,nindex where to insert the n elements (default is 1)

◆ isRef()

template<class Derived >
bool STK::ISparseArray1D< Derived >::isRef ( ) const
inline
Returns
true if *this is reference container, false otherwise

Definition at line 128 of file STK_ISparseArray1D.h.

128{ return allocator_.isRef();}

Referenced by STK::ISparseArray1D< Derived >::capacity().

◆ lastIdxCols()

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

Definition at line 162 of file STK_ISparseArray1D.h.

162{ return baseIdx;}

References STK::baseIdx.

◆ lastIdxRows()

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

Definition at line 160 of file STK_ISparseArray1D.h.

160{ return this->lastIdx();}

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

◆ move()

template<class Derived >
void STK::ISparseArray1D< Derived >::move ( Derived const T)

move T to this.

Note
: T is not modified but just set as a reference of the data it was owner.
Parameters
Tthe container to move to this.

◆ popBack()

template<class Derived >
Derived & STK::ISparseArray1D< Derived >::popBack ( int  n = 1)

Delete last elts of the container.

Parameters
nnumber of elts to delete

◆ push_back()

template<class Derived >
Derived & STK::ISparseArray1D< Derived >::push_back ( Type const v)

STL compatibility: append an element v.

Parameters
vvalue to append

◆ push_front()

template<class Derived >
Derived & STK::ISparseArray1D< Derived >::push_front ( Type const v)

STL compatibility: push front an element.

Parameters
vvalue to append

◆ pushBack()

template<class Derived >
Derived & STK::ISparseArray1D< Derived >::pushBack ( int  n = 1)

Add n Elements to the end of the container.

Parameters
nnumber of elements to add

◆ 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_;}

Referenced by STK::ISparseArray1D< Derived >::rows().

◆ reserve()

template<class Derived >
void STK::ISparseArray1D< Derived >::reserve ( int  size)

reserve internal memory for at least size elements.

Parameters
sizenumber of elements to reserve

◆ resizeImpl()

template<class Derived >
Derived & STK::ISparseArray1D< Derived >::resizeImpl ( Range const I)

Resize the container.

  • call shift
  • call pushBack if there will be more elements
  • call popBack if three will be less elements
    Parameters
    Ithe range to set to the Array1D

◆ rows()

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

Definition at line 142 of file STK_ISparseArray1D.h.

142{ return range();}
RowRange const & range() const

References STK::ISparseArray1D< Derived >::range().

◆ setRange()

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

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;}

◆ setRef()

template<class Derived >
void STK::ISparseArray1D< Derived >::setRef ( bool  ref) const
inline

Modify the state of the container: this become a reference (if ref is true) or the owner of the data (if ref is false).

Note
To use with care in order to avoid memory leak
Parameters
ref: has top be false if this own its own data

Definition at line 134 of file STK_ISparseArray1D.h.

134{ allocator_.setRef(ref);}

◆ setValue()

template<class Derived >
Derived & STK::ISparseArray1D< Derived >::setValue ( Type const value)

set a value to this container.

Parameters
valuethe value to set

◆ shiftImpl()

template<class Derived >
void STK::ISparseArray1D< Derived >::shiftImpl ( int  beg = baseIdx)

New beginning index for the object.

Parameters
begthe index of the first column to set

◆ 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();}
int size() const
get the size of the TRange (the number of elements).
Definition STK_Range.h:196

Referenced by STK::ISparseArray1D< Derived >::sizeRows().

◆ sizeCols()

template<class Derived >
int STK::ISparseArray1D< Derived >::sizeCols ( ) const
inline
Returns
the number of columns

Definition at line 157 of file STK_ISparseArray1D.h.

157{ return 1;};

◆ sizeRows()

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

Definition at line 148 of file STK_ISparseArray1D.h.

148{ return size();}

References STK::ISparseArray1D< Derived >::size().

◆ swap()

template<class Derived >
void STK::ISparseArray1D< Derived >::swap ( int  pos1,
int  pos2 
)

Swapping the pos1 elt and the pos2 elt.

Parameters
pos1,pos2positions of the elements to swap

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