Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef TSFSEQUENTIALITERATORIMPL_HPP
00030 #define TSFSEQUENTIALITERATORIMPL_HPP
00031
00032
00033 #include "TSFSequentialIteratorDecl.hpp"
00034 #include "TSFVectorSpaceDecl.hpp"
00035 #include "Thyra_SUNDIALS_Ops.hpp"
00036 #include "TSFIndexableVector.hpp"
00037
00038
00039 namespace TSFExtended
00040 {
00041
00042 template <class Scalar> inline
00043 bool SequentialIterator<Scalar>
00044 ::operator==(const SequentialIterator<Scalar>& other) const
00045 {
00046 if (this->atEnd_ == other.atEnd_) return true;
00047 if (this->blockIndex_ != other.blockIndex_
00048 || this->globalIndex_ != other.globalIndex_
00049 || this->indexInCurrentBlock_ != other.indexInCurrentBlock_
00050 || *(this->space_) != *(other.space_)) return false;
00051 return true;
00052 }
00053
00054
00055
00056 template <class Scalar> inline
00057 SequentialIterator<Scalar> SequentialIterator<Scalar>::operator++(int)
00058 {
00059 SequentialIterator<Scalar> old = *this;
00060 bool dataRemains = (this->space_)->advanceIndex(this->blockIndex_,
00061 this->indexInCurrentBlock_, this->globalIndex_);
00062 if (!dataRemains) this->atEnd_ = true;
00063 return old;
00064 }
00065
00066 template <class Scalar> inline
00067 const VectorSpace<Scalar>& SequentialIterator<Scalar>::space() const
00068 {
00069 return *(this->space_);
00070 }
00071
00072
00073 template <class Scalar> inline
00074 SequentialIterator<Scalar>::SequentialIterator(
00075 const VectorSpace<Scalar>& space,
00076 int blockIndex, int localIndex, int globalIndex
00077 )
00078 : space_(rcp(new VectorSpace<Scalar>(space))),
00079 blockIndex_(blockIndex),
00080 indexInCurrentBlock_(localIndex),
00081 globalIndex_(globalIndex),
00082 atEnd_(false)
00083 {}
00084
00085 template <class Scalar> inline
00086 SequentialIterator<Scalar>::SequentialIterator(
00087 const VectorSpace<Scalar>& space
00088 )
00089 : space_(rcp(new VectorSpace<Scalar>(space))),
00090 blockIndex_(-1),
00091 indexInCurrentBlock_(-1),
00092 globalIndex_(-1),
00093 atEnd_(true)
00094 {}
00095
00096
00097 template <class Scalar> inline
00098 std::ostream& SequentialIterator<Scalar>::print(std::ostream& os) const
00099 {
00100 if (atEnd_)
00101 {
00102 os << "[end]";
00103 }
00104 else
00105 {
00106 os << "[b=" << blockIndex_ << ", loc=" << indexInCurrentBlock_
00107 << ", glob=" << globalIndex_
00108 << "]";
00109 }
00110 return os;
00111 }
00112
00113
00114
00115 }
00116
00117
00118
00119
00120
00121 #endif