Teuchos  Trilinos Tools Package Version of the Day

Subregion Index Range Class. More...
#include <Teuchos_Range1D.hpp>
Public Types  
enum  EInvalidRange 
More...  
typedef Teuchos_Ordinal  Index 
Deprecated.  
typedef Teuchos_Ordinal  Ordinal 
Deprecated.  
Public Member Functions  
Range1D ()  
Constructs a range representing the entire range.  
Range1D (EInvalidRange)  
Range1D (Ordinal lbound, Ordinal ubound)  
Constructs a range that represents the range [lbound, ubound] .  
bool  full_range () const 
Ordinal  lbound () const 
Return lower bound of the range.  
Ordinal  ubound () const 
Return upper bound of the range.  
Ordinal  size () const 
Return the size of the range (ubound()  lbound() + 1 )  
bool  in_range (Ordinal i) const 
Return true if the index is in range.  
Range1D &  operator+= (Ordinal incr) 
Increment the range by a constant.  
Range1D &  operator= (Ordinal incr) 
Deincrement the range by a constant.  
Static Public Attributes  
static const Range1D  Invalid 
Used for Range1D(INVALID)  
Related Functions  
(Note that these are not member functions.)  
bool  operator== (const Range1D &rng1, const Range1D &rng2) 
rng1 == rng2.  
Range1D  operator+ (const Range1D &rng_rhs, Range1D::Ordinal i) 
rng_lhs = rng_rhs + i.  
Range1D  operator+ (Range1D::Ordinal i, const Range1D &rng_rhs) 
rng_lhs = i + rng_rhs.  
Range1D  operator (const Range1D &rng_rhs, Range1D::Ordinal i) 
rng_lhs = rng_rhs  i.  
Range1D  full_range (const Range1D &rng, Range1D::Ordinal lbound, Range1D::Ordinal ubound) 
Return a bounded index range from a potentially unbounded index range. 
Subregion Index Range Class.
The class Range1D
abstracts a 1D, zerobased, range of indexes. It is used to index into vectors and matrices and return subregions of them respectively.
Constructing using Range1D()
yields a range that represents the entire dimension of an object [0, max_ubound1]
(an entire std::vector, all the rows in a matrix, or all the columns in a matrix etc.).
Constructing using Range1D(INVALID)
yields an invalid range [0,1]
with size() == 0
. In fact the condition size()==0
is the determining flag that a range is not valid. Once constructed with Range1D(INVALID)
, a Range1D
object can pass through many other operations that may change lbound()
and ubound()
but will never change size()==0
.
Constructing using Range1D(lbound,ubound)
yields a finitedimensional zerobased range. The validity of constructed range will only be checked if TEUCHOS_DEBUG
is defined.
There are many nonmember functions that can be used with Range1D
objects.
The default copy constructor and assignment operator functions are allowed since they have the correct semantics.
Definition at line 87 of file Teuchos_Range1D.hpp.
typedef Teuchos_Ordinal Teuchos::Range1D::Index 
Deprecated.
Definition at line 91 of file Teuchos_Range1D.hpp.
typedef Teuchos_Ordinal Teuchos::Range1D::Ordinal 
Deprecated.
Definition at line 94 of file Teuchos_Range1D.hpp.
Definition at line 97 of file Teuchos_Range1D.hpp.
Teuchos::Range1D::Range1D  (  )  [inline] 
Constructs a range representing the entire range.
Postconditions:
this>full_range()==true
this>size()
is a very large number this>lbound()==0
this>ubound()
is a very large number Definition at line 254 of file Teuchos_Range1D.hpp.
Teuchos::Range1D::Range1D  (  EInvalidRange  )  [inline] 
Constructs an invalid (zero) range.
Postconditions:
this>full_range() == false
this>size() == 0
this>lbound()==0
this>ubound()==1
Definition at line 259 of file Teuchos_Range1D.hpp.
Constructs a range that represents the range [lbound, ubound]
.
Preconditions:
lbound >= 0
(throw range_error
) lbound <= ubound
(throw range_error
) Postconditions:
this>full_range() == false
this>size() == ubound  lbound + 1
this>lbound() == lbound
this>ubound() == ubound
Definition at line 265 of file Teuchos_Range1D.hpp.
bool Teuchos::Range1D::full_range  (  )  const [inline] 
Returns true
if the range represents the entire region (constructed from Range1D()
)
Definition at line 272 of file Teuchos_Range1D.hpp.
Range1D::Ordinal Teuchos::Range1D::lbound  (  )  const [inline] 
Return lower bound of the range.
Definition at line 277 of file Teuchos_Range1D.hpp.
Range1D::Ordinal Teuchos::Range1D::ubound  (  )  const [inline] 
Return upper bound of the range.
Definition at line 282 of file Teuchos_Range1D.hpp.
Range1D::Ordinal Teuchos::Range1D::size  (  )  const [inline] 
Return the size of the range (ubound()  lbound() + 1
)
Definition at line 287 of file Teuchos_Range1D.hpp.
bool Teuchos::Range1D::in_range  (  Ordinal  i  )  const [inline] 
Return true if the index is in range.
Definition at line 292 of file Teuchos_Range1D.hpp.
Increment the range by a constant.
Definition at line 297 of file Teuchos_Range1D.hpp.
Deincrement the range by a constant.
Definition at line 305 of file Teuchos_Range1D.hpp.
rng1 == rng2.
rng1.lbound() == rng2.ubound() && rng1.ubound() == rng2.ubound()
. Definition at line 179 of file Teuchos_Range1D.hpp.
Range1D operator+  (  const Range1D &  rng_rhs, 
Range1D::Ordinal  i  
)  [related] 
rng_lhs = rng_rhs + i.
Increments the upper and lower bounds by a constant.
Postcondition:
rng_lhs.lbound() == rng_rhs.lbound() + i
rng_lhs.ubound() == rng_rhs.ubound() + i
Definition at line 195 of file Teuchos_Range1D.hpp.
Range1D operator+  (  Range1D::Ordinal  i, 
const Range1D &  rng_rhs  
)  [related] 
rng_lhs = i + rng_rhs.
Increments the upper and lower bounds by a constant.
Postcondition:
rng_lhs.lbound() == i + rng_rhs.lbound()
rng_lhs.ubound() == i + rng_rhs.ubound()
Definition at line 211 of file Teuchos_Range1D.hpp.
Range1D operator  (  const Range1D &  rng_rhs, 
Range1D::Ordinal  i  
)  [related] 
rng_lhs = rng_rhs  i.
Deincrements the upper and lower bounds by a constant.
Postcondition:
rng_lhs.lbound() == rng_rhs.lbound()  i
rng_lhs.ubound() == rng_rhs.ubound()  i
Definition at line 227 of file Teuchos_Range1D.hpp.
Range1D full_range  (  const Range1D &  rng, 
Range1D::Ordinal  lbound,  
Range1D::Ordinal  ubound  
)  [related] 
Return a bounded index range from a potentially unbounded index range.
Return a index range of lbound to ubound if rng.full_range() == true , otherwise just return a copy of rng.
Postconditions:
rng.full_range() == true
] return.lbound() == lbound
rng.full_range() == true
] return.ubound() == ubound
rng.full_range() == false
] return.lbound() == rng.lbound()
rng.full_range() == false
] return.ubound() == rng.ubound()
Definition at line 247 of file Teuchos_Range1D.hpp.
const Range1D Teuchos::Range1D::Invalid [static] 
Used for Range1D(INVALID)
Definition at line 100 of file Teuchos_Range1D.hpp.