layoutiterator.h

来自「自适应网格划分通用程序包」· C头文件 代码 · 共 112 行

H
112
字号
// This software is copyright (C) by the Lawrence Berkeley
// National Laboratory.  Permission is granted to reproduce
// this software for non-commercial purposes provided that
// this notice is left intact.
//
// It is acknowledged that the U.S. Government has rights to
// this software under Contract DE-AC03-765F00098 between
// the U.S.  Department of Energy and the University of
// California.
//
// This software is provided as a professional and academic
// contribution for joint exchange. Thus it is experimental,
// is provided ``as is'', with no warranties of any kind
// whatsoever, no support, no promise of updates, or printed
// documentation. By using this software, you acknowledge
// that the Lawrence Berkeley National Laboratory and
// Regents of the University of California shall have no
// liability with respect to the infringement of other
// copyrights by any part of this software.
//
#ifndef _LAYOUTITERATOR_H_
#define _LAYOUTITERATOR_H_

#ifndef WRAPPER

#include "DataIndex.H"
#include "BoxLayout.H"

#endif

class DataIterator ; //forward declaration


class LayoutIterator
{
public:
  LayoutIterator(){;}

  LayoutIterator(const BoxLayout& a_layout)
  {
        *this = a_layout.layoutIterator();
  }
  // default copy and null constructor should be fine
  // not useful to someone using the iterator.  Used by
  // other classes in Chombo.  Could make it private and
  // let BoxLayout have access....
  ~LayoutIterator() {;}

  const LayoutIndex& operator()() const;
  LayoutIndex i() const { return this ->operator()();}

  void operator++();
  void incr(){ ++(*this);}

  bool ok() const;

  void begin();

  void reset();


  void end();



protected:

  friend class BoxLayout;

  LayoutIterator(const BoxLayout& boxlayout, const int* layoutID);

  BoxLayout m_layout;

  unsigned int m_index;

  LayoutIndex m_current;

};


#ifndef WRAPPER

inline const LayoutIndex& LayoutIterator::operator()() const
{
  assert(ok());
  return m_current;
}

inline void LayoutIterator::operator++()
{
  ++m_index;
  if(ok())
    m_current.m_index = (*(m_layout.m_boxes))[m_index].index;
}

inline bool LayoutIterator::ok() const
{
  return m_index < m_layout.size();
}


inline void LayoutIterator::begin()
{
  m_index = 0;
  if(ok())
    m_current.m_index = (*(m_layout.m_boxes))[m_index].index;
}
#endif /*WRAPPER*/

#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?