An N-D index range class. More...
#include <IndexRange.h>
Public Types | |
typedef T | index_type |
The index type. | |
typedef FixedArray< N, index_type > | multi_index_type |
The multi-index type. | |
Public Member Functions | |
Constructors etc. | |
IndexRange () | |
Default constructor. Empty range. | |
IndexRange (const index_type ubound) | |
Construct from an upper bound. Set the lower bound to zero. 1-D. | |
IndexRange (const multi_index_type &ubounds) | |
Construct from upper bounds. Set the lower bounds to zero. | |
IndexRange (const multi_index_type &lbounds, const multi_index_type &ubounds) | |
Construct from lower and upper bounds. | |
IndexRange (const index_type lb0, const index_type ub0) | |
Construct from lower and upper bounds. 1-D. | |
IndexRange (const index_type lb0, const index_type lb1, const index_type ub0, const index_type ub1) | |
Construct from lower and upper bounds. 2-D. | |
IndexRange (const index_type lb0, const index_type lb1, const index_type lb2, const index_type ub0, const index_type ub1, const index_type ub2) | |
Construct from lower and upper bounds. 3-D. | |
IndexRange (const IndexRange &x) | |
Copy constructor. | |
~IndexRange () | |
Trivial, non-virtual destructor. | |
Assignment operators. | |
IndexRange & | operator= (const IndexRange &other) |
Assignment operator. | |
Swapping. | |
void | swap (IndexRange &other) |
Accesors. | |
const multi_index_type & | lbounds () const |
Return a const reference to the lower bounds. | |
const multi_index_type & | ubounds () const |
Return a const reference to the upper bounds. | |
index_type | lbound (const index_type i) const |
Return the lower bound. | |
index_type | ubound (const index_type i) const |
Return the upper bound. | |
multi_index_type | extents () const |
Return the extents of the ranges. | |
index_type | content () const |
Return the product of the extents of the ranges. | |
bool | empty () const |
Return true iff the multi-range is empty. | |
bool | is_in (const multi_index_type &x) const |
Return true iff the point is in the multi-range. | |
bool | is_in (const index_type x) const |
Return true iff the coordinate are in the 1-D multi-range. | |
bool | is_in (const index_type x, const index_type y) const |
Return true iff the coordinates are in the multi-range. | |
bool | is_in (const index_type x, const index_type y, const index_type z) const |
Return true iff the coordinates are in the multi-range. | |
Accessors, specialized for 1-D. | |
index_type | lbound () const |
Return the lower bound. | |
index_type | ubound () const |
Return the upper bound. | |
index_type | extent () const |
Return the extent of the range. | |
Manipulators. | |
void | set_lbounds (const multi_index_type &lbounds) |
Set the lower bounds. | |
void | set_ubounds (const multi_index_type &ubounds) |
Set the upper bounds. | |
void | set_lbounds (const index_type lb0) |
Set the lower bounds. | |
void | set_ubounds (const index_type ub0) |
Set the upper bounds. | |
void | set_lbounds (const index_type lb0, const index_type lb1) |
Set the lower bounds. | |
void | set_ubounds (const index_type ub0, const index_type ub1) |
Set the upper bounds. | |
void | set_lbounds (const index_type lb0, const index_type lb1, const index_type lb2) |
Set the lower bounds. | |
void | set_ubounds (const index_type ub0, const index_type ub1, const index_type ub2) |
Set the upper bounds. | |
Manipulators, specialized for 1-D. | |
void | set_lbound (const index_type lbound) |
Set the lower bound. | |
void | set_ubound (const index_type ubound) |
Set the upper bound. | |
Equality. | |
bool | operator== (const IndexRange &x) const |
File I/O. | |
void | put (std::ostream &out) const |
Write the lower and upper bounds. | |
void | get (std::istream &in) |
Read an index range from a line of the input. | |
void | write (std::ostream &out) const |
Wrie the lower and upper bounds in binary format. | |
void | read (std::istream &in) |
Read the lower and upper bounds in binary format. | |
Static Public Member Functions | |
Static members. | |
static int | dimension () |
Return the dimension. | |
Related Functions | |
(Note that these are not member functions.) | |
template<int N, typename T > | |
bool | operator!= (const IndexRange< N, T > &a, const IndexRange< N, T > &b) |
Return true iff the ranges are not equal. | |
template<int N, typename T > | |
std::ostream & | operator<< (std::ostream &out, const IndexRange< N, T > &x) |
Write the multi-range. | |
template<int N, typename T > | |
std::istream & | operator>> (std::istream &in, IndexRange< N, T > &x) |
Read the multi-range. | |
template<int N, typename T > | |
void | compute_intersection (const IndexRange< N, T > &x, const IndexRange< N, T > &y, IndexRange< N, T > &result) |
Compute the intersection of the index ranges. |
An N-D index range class.
An N-D index range with index type T
. The range is closed at the lower end and open at the upper end.
This class is used for specifying the range of indices in the ads::Array class.
N | is the dimension. | |
T | is the index type. By default it is int . |
index_type IndexRange< N, T >::extent | ( | ) | const [inline] |
Return the extent of the range.
The extent is the difference between the upper and lower bounds.
multi_index_type IndexRange< N, T >::extents | ( | ) | const [inline] |
Return the extents of the ranges.
The extents are the differences between the upper and lower bounds.
Referenced by IndexRange< 1, int >::content(), and ArrayIndexingBase< N >::rebuild().
void IndexRange< N, T >::get | ( | std::istream & | in | ) | [inline] |
Read an index range from a line of the input.
The line may contain either the extents (upper bounds only) or both the lower and upper bounds.
Referenced by IndexRange< N, T >::operator>>().
bool IndexRange< N, T >::is_in | ( | const index_type | x, | |
const index_type | y, | |||
const index_type | z | |||
) | const [inline] |
Return true iff the coordinates are in the multi-range.
bool IndexRange< N, T >::is_in | ( | const index_type | x, | |
const index_type | y | |||
) | const [inline] |
Return true iff the coordinates are in the multi-range.
bool IndexRange< N, T >::is_in | ( | const index_type | x | ) | const [inline] |
Return true iff the coordinate are in the 1-D multi-range.
void IndexRange< N, T >::set_lbounds | ( | const index_type | lb0, | |
const index_type | lb1, | |||
const index_type | lb2 | |||
) | [inline] |
Set the lower bounds.
void IndexRange< N, T >::set_lbounds | ( | const index_type | lb0, | |
const index_type | lb1 | |||
) | [inline] |
Set the lower bounds.
void IndexRange< N, T >::set_lbounds | ( | const index_type | lb0 | ) | [inline] |
Set the lower bounds.
void IndexRange< N, T >::set_ubounds | ( | const index_type | ub0, | |
const index_type | ub1, | |||
const index_type | ub2 | |||
) | [inline] |
Set the upper bounds.
void IndexRange< N, T >::set_ubounds | ( | const index_type | ub0, | |
const index_type | ub1 | |||
) | [inline] |
Set the upper bounds.
void IndexRange< N, T >::set_ubounds | ( | const index_type | ub0 | ) | [inline] |
Set the upper bounds.
void compute_intersection | ( | const IndexRange< N, T > & | x, | |
const IndexRange< N, T > & | y, | |||
IndexRange< N, T > & | result | |||
) | [related] |
Compute the intersection of the index ranges.
References IndexRange< N, T >::lbound(), max(), min(), IndexRange< N, T >::set_lbounds(), IndexRange< N, T >::set_ubounds(), and IndexRange< N, T >::ubound().
bool operator!= | ( | const IndexRange< N, T > & | a, | |
const IndexRange< N, T > & | b | |||
) | [related] |
Return true iff the ranges are not equal.
std::ostream & operator<< | ( | std::ostream & | out, | |
const IndexRange< N, T > & | x | |||
) | [related] |
std::istream & operator>> | ( | std::istream & | in, | |
IndexRange< N, T > & | x | |||
) | [related] |