TSFSequentialIteratorImpl.hpp
Go to the documentation of this file.
00001 /* @HEADER@ */
00002 /* ***********************************************************************
00003 // 
00004 //           TSFExtended: Trilinos Solver Framework Extended
00005 //                 Copyright (2004) Sandia Corporation
00006 // 
00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00008 // license for use of this work by or on behalf of the U.S. Government.
00009 // 
00010 // This library is free software; you can redistribute it and/or modify
00011 // it under the terms of the GNU Lesser General Public License as
00012 // published by the Free Software Foundation; either version 2.1 of the
00013 // License, or (at your option) any later version.
00014 //  
00015 // This library is distributed in the hope that it will be useful, but
00016 // WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018 // Lesser General Public License for more details.
00019 //  
00020 // You should have received a copy of the GNU Lesser General Public
00021 // License along with this library; if not, write to the Free Software
00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00023 // USA
00024 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 
00025 // 
00026 // **********************************************************************/
00027  /* @HEADER@ */
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

Site Contact