interval.h

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

H
70
字号
// 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.
//

// Interval.H
// ============

//
// Little struct for passing component ranges in code.
//
// 

#ifndef INTERVAL_H
#define INTERVAL_H


struct Interval
{
  Interval():
        m_begin(0), m_end(-1) {}

  Interval(int a_firstComp, int a_lastComp):
    m_begin(a_firstComp), m_end(a_lastComp){}
  void define(int a_firstComp, int a_lastComp)
  {m_begin= a_firstComp; m_end=a_lastComp;}


  int begin() const;


  int end() const;


  int size() const {return m_end-m_begin+1;}

  bool contains(int a_val) const
  {
        return a_val>=m_begin && a_val <= m_end;
  }

private:
  int m_begin, m_end;

};

#ifndef WRAPPER
inline int Interval::begin() const {return m_begin;}
inline int Interval::end()   const {return m_end;}
#endif

#endif // INTERVAL_H

⌨️ 快捷键说明

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