45 #include "RTOpPack_Types.hpp"
79 typedef RTOpPack::Ordinal
Index;
244 : lbound_(1), ubound_(INT_MAX)
249 : lbound_(1), ubound_(0)
255 : lbound_(lbound), ubound_(ubound)
257 assert_valid_range(lbound,ubound);
262 return ubound_ == INT_MAX;
277 return 1 + ubound_ - lbound_;
282 return lbound_ <= i && i <= ubound_;
287 assert_valid_range( lbound_ + incr, ubound_ + incr );
295 assert_valid_range( lbound_ - incr, ubound_ - incr );
303 void Range1D::assert_valid_range(Index lbound, Index ubound)
const {
306 lbound < 1, std::range_error
307 ,
"Range1D::assert_valid_range(): Error, lbound ="<<lbound<<
" must be greater than 0." );
309 lbound > ubound, std::range_error
310 ,
"Range1D::assert_valid_range(): Error, lbound = "<<lbound<<
" > ubound = "<<ubound );
316 #endif // end RANGE1D_H
bool operator==(const Range1D &rng1, const Range1D &rng2)
rng1 == rng2.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Index size() const
Return the size of the range (ubound() - lbound() + 1)
Index ubound() const
Return upper bound of the range.
Range1D & operator+=(Index incr)
Increment the range by a constant.
Range1D operator-(const Range1D &rng_rhs, Range1D::Index i)
rng_lhs = rng_rhs - i.
. One-based subregion index range class.
Range1D()
Constructs a range representing the entire range.
Teuchos::Range1D convert(const Range1D &rng)
Convert from a 1-based RangePack::Range1D object to a 0-based Teuchos::Range1D object.
Range1D operator+(Range1D::Index i, const Range1D &rng_rhs)
rng_lhs = i + rng_rhs.
bool full_range() const
Returns true if the range represents the entire region (constructed from Range1D()) ...
Range1D full_range(const Range1D &rng, Range1D::Index lbound, Range1D::Index ubound)
Return a bounded index range from a potentially unbounded index range.
bool in_range(Index i) const
Return true if the index is in range.
static const Range1D Invalid
Range1D(INVALID)
Index lbound() const
Return lower bound of the range.
Range1D convert(const Teuchos::Range1D &rng)
Convert from a 0-based Teuchos::Range1D object to a 1-based RangePack::Range1D object.
Range1D operator+(const Range1D &rng_rhs, Range1D::Index i)
rng_lhs = rng_rhs + i.
Range1D & operator-=(Index incr)
Deincrement the range by a constant.