IndexRange< N, T > Class Template Reference

An N-D index range class. More...

#include <IndexRange.h>

List of all members.

Public Types

typedef T index_type
 The index type.
typedef FixedArray< N, index_typemulti_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.

IndexRangeoperator= (const IndexRange &other)
 Assignment operator.
Swapping.

void swap (IndexRange &other)
Accesors.

const multi_index_typelbounds () const
 Return a const reference to the lower bounds.
const multi_index_typeubounds () const
 Return a const reference to the upper bounds.
index_type lbound (const index_type i) const
 Return the $ i^{th} $ lower bound.
index_type ubound (const index_type i) const
 Return the $ i^{th} $ 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.

Detailed Description

template<int N, typename T = int>
class IndexRange< N, T >

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.

\[ range = [lbounds[0] .. ubounds[0]) \times [lbounds[1] .. ubounds[1]) \times \cdots \times [lbounds[N-1] .. ubounds[N-1]) \]

This class is used for specifying the range of indices in the ads::Array class.

Parameters:
N is the dimension.
T is the index type. By default it is int.

Member Function Documentation

template<int N, typename T = 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.

template<int N, typename T = int>
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().

template<int N, typename T = int>
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>>().

template<int N, typename T = int>
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.

Precondition:
N == 3.
template<int N, typename T = int>
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.

Precondition:
N == 2.
template<int N, typename T = int>
bool IndexRange< N, T >::is_in ( const index_type  x  )  const [inline]

Return true iff the coordinate are in the 1-D multi-range.

Precondition:
N == 1.
template<int N, typename T = int>
void IndexRange< N, T >::set_lbounds ( const index_type  lb0,
const index_type  lb1,
const index_type  lb2 
) [inline]

Set the lower bounds.

Precondition:
N == 3.
template<int N, typename T = int>
void IndexRange< N, T >::set_lbounds ( const index_type  lb0,
const index_type  lb1 
) [inline]

Set the lower bounds.

Precondition:
N == 2.
template<int N, typename T = int>
void IndexRange< N, T >::set_lbounds ( const index_type  lb0  )  [inline]

Set the lower bounds.

Precondition:
N == 1.
template<int N, typename T = int>
void IndexRange< N, T >::set_ubounds ( const index_type  ub0,
const index_type  ub1,
const index_type  ub2 
) [inline]

Set the upper bounds.

Precondition:
N == 3.
template<int N, typename T = int>
void IndexRange< N, T >::set_ubounds ( const index_type  ub0,
const index_type  ub1 
) [inline]

Set the upper bounds.

Precondition:
N == 2.
template<int N, typename T = int>
void IndexRange< N, T >::set_ubounds ( const index_type  ub0  )  [inline]

Set the upper bounds.

Precondition:
N == 1.

Friends And Related Function Documentation

template<int N, typename T >
void compute_intersection ( const IndexRange< N, T > &  x,
const IndexRange< N, T > &  y,
IndexRange< N, T > &  result 
) [related]
template<int N, typename T >
bool operator!= ( const IndexRange< N, T > &  a,
const IndexRange< N, T > &  b 
) [related]

Return true iff the ranges are not equal.

template<int N, typename T >
std::ostream & operator<< ( std::ostream &  out,
const IndexRange< N, T > &  x 
) [related]

Write the multi-range.

This simply calls IndexRange::put().

References IndexRange< N, T >::put().

template<int N, typename T >
std::istream & operator>> ( std::istream &  in,
IndexRange< N, T > &  x 
) [related]

Read the multi-range.

This simply calls IndexRange::get().

References IndexRange< N, T >::get().


The documentation for this class was generated from the following file:
Generated on Thu Jun 30 02:14:51 2016 for Algorithms and Data Structures Package by  doxygen 1.6.3