00001 #ifdef CH_LANG_CC 00002 /* 00003 * _______ __ 00004 * / ___/ / ___ __ _ / / ___ 00005 * / /__/ _ \/ _ \/ V \/ _ \/ _ \ 00006 * \___/_//_/\___/_/_/_/_.__/\___/ 00007 * Please refer to Copyright.txt, in Chombo's root directory. 00008 */ 00009 #endif 00010 00011 #ifndef _NEIGHBORITERATOR_H_ 00012 #define _NEIGHBORITERATOR_H_ 00013 00014 #include "DataIndex.H" 00015 #include "ProblemDomain.H" 00016 #include "DisjointBoxLayout.H" 00017 #include "NamespaceHeader.H" 00018 00020 00023 class NeighborIterator 00024 { 00025 public: 00026 00027 NeighborIterator():m_dblPtr(NULL){;} 00028 00030 NeighborIterator(const DisjointBoxLayout& dbl); 00031 00033 00034 inline const LayoutIndex& operator()() const ; 00035 00036 Box box() const ; 00037 00039 inline void operator++(); 00040 00041 00043 inline bool ok() const; 00044 00046 void begin(const DataIndex& a_dataIndex); 00047 00049 00053 Box unshift(const Box& a_box) const ; 00054 00055 private: 00056 00057 const DisjointBoxLayout* m_dblPtr; 00058 std::vector<std::pair<int, unsigned int> >::const_iterator m_current, m_end; 00059 LayoutIndex m_lindex; 00060 }; 00061 00062 00063 inline bool NeighborIterator::ok() const 00064 { 00065 CH_assert(m_dblPtr!=NULL); 00066 return m_current != m_end; 00067 } 00068 00069 inline void NeighborIterator::operator++() 00070 { 00071 ++m_current; 00072 if(m_current != m_end) 00073 m_lindex.m_index = m_current->second; 00074 } 00075 00076 00077 inline const LayoutIndex& NeighborIterator::operator()() const 00078 { 00079 CH_assert(m_dblPtr!= NULL); 00080 CH_assert(this->ok()); 00081 return m_lindex; 00082 } 00083 00084 #include "NamespaceFooter.H" 00085 #endif