47 #ifndef TEUCHOS_RANGE1D_HPP 48 #define TEUCHOS_RANGE1D_HPP 55 #include "Teuchos_Assert.hpp" 146 inline Ordinal
lbound()
const;
149 inline Ordinal
ubound()
const;
152 inline Ordinal
size()
const;
155 inline bool in_range(Ordinal i)
const;
169 inline void assert_valid_range(Ordinal
lbound, Ordinal
ubound)
const;
255 : lbound_(0), ubound_(INT_MAX-1)
260 : lbound_(0), ubound_(-1)
266 : lbound_(lbound_in), ubound_(ubound_in)
268 assert_valid_range(lbound_in,ubound_in);
273 return ubound_ == INT_MAX-1;
288 return ubound_ - lbound_ + 1;
293 return lbound_ <= i && i <= ubound_;
298 assert_valid_range( lbound_ + incr, ubound_ + incr );
307 assert_valid_range( lbound_ - incr, ubound_ - incr );
316 void Range1D::assert_valid_range(
Ordinal lbound_in,
Ordinal ubound_in)
const 318 (void)lbound_in; (void)ubound_in;
321 lbound_in < 0, std::range_error
322 ,
"Range1D::assert_valid_range(): Error, lbound =" 323 <<lbound_in<<
" must be greater than or equal to 0." 326 lbound_in > ubound_in, std::range_error
327 ,
"Range1D::assert_valid_range(): Error, lbound = " 328 <<lbound_in<<
" > ubound = "<<ubound_in
335 #endif // end TEUCHOS_RANGE1D_HPP bool in_range(Ordinal i) const
Return true if the index is in range.
Subregion Index Range Class.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Macro for throwing an exception with breakpointing to ease debugging.
Ordinal ubound() const
Return upper bound of the range.
Range1D()
Constructs a range representing the entire range.
Range1D operator-(const Range1D &rng_rhs, Range1D::Ordinal i)
rng_lhs = rng_rhs - i.
static const Range1D Invalid
Used for Range1D(INVALID)
Teuchos_Ordinal Ordinal
Deprecated.
Range1D & operator+=(Ordinal incr)
Increment the range by a constant.
Range1D full_range(const Range1D &rng, Range1D::Ordinal lbound, Range1D::Ordinal ubound)
Return a bounded index range from a potentially unbounded index range.
Ordinal lbound() const
Return lower bound of the range.
The Teuchos namespace contains all of the classes, structs and enums used by Teuchos, as well as a number of utility routines.
Range1D operator+(const Range1D &rng_rhs, Range1D::Ordinal i)
rng_lhs = rng_rhs + i.
bool operator==(const Range1D &rng1, const Range1D &rng2)
rng1 == rng2.
Ordinal size() const
Return the size of the range (ubound() - lbound() + 1)
Range1D & operator-=(Ordinal incr)
Deincrement the range by a constant.
Defines basic traits for the scalar field type.
Range1D operator+(Range1D::Ordinal i, const Range1D &rng_rhs)
rng_lhs = i + rng_rhs.
Teuchos_Ordinal Index
Deprecated.