ArrayIndexingBase< N > Class Template Reference

The indexing interface to N-D arrays that is independent of the value type. More...

#include <ArrayIndexingBase.h>

Inheritance diagram for ArrayIndexingBase< N >:
ArrayIndexing< N, T > Array< N, T, A >

List of all members.

Public Types

typedef int size_type
 The size type is a signed integer.
typedef FixedArray< N, int > index_type
 A multi-index. Index in N dimensions.
typedef IndexRange< N, int > range_type
 A range of multi-indices.

Public Member Functions

Accessors

const index_typeextents () const
 Return the extents of the array.
size_type extent (const int i) const
 Return the $ i^{th} $ extent of the array.
const range_typeranges () const
 Return the index ranges of the array.
const index_typelbounds () const
 Return the index lower bounds.
const index_typeubounds () const
 Return the index upper bounds.
int lbound (const int i) const
 Return the $ i^{th} $ lower bound.
int ubound (const int i) const
 Return the $ i^{th} $ upper bound.
const index_typestrides () const
 Return the strides between elements in each dimension.
Accessors: Convert between a container index and a multi-index.

int index (const index_type &mi) const
 Convert a multi-index to a container index.
int index (const int i0, const int i1) const
 Convert a multi-index to a container index.
int index (const int i0, const int i1, const int i2) const
 Convert a multi-index to a container index.
void index_to_indices (const int index, int &i, int &j) const
 Convert a container index to indices in a 2-D array.
void index_to_indices (int index, int &i, int &j, int &k) const
 Convert a container index to indices in a 3-D array.
void index_to_indices (const int index, ads::FixedArray< 2, int > &multi_index) const
 Convert a container index to indices in a 2-D array.
void index_to_indices (const int index, ads::FixedArray< 3, int > &multi_index) const
 Convert a container index to indices in a 3-D array.
File I/O.

void put (std::ostream &out) const
 Write the ranges to a file stream in ascii format.
void write (std::ostream &out) const
 Write to a file stream in binary format.
Equality.

bool operator== (const ArrayIndexingBase< N > &x) const
 Return true if the ranges are the same.

Static Public Member Functions

Static members.

static int rank ()
 Return the rank (number of dimensions) of the array.

Protected Member Functions

void compute_strides ()
 Compute the strides.
int root_offset (const index_type &mi) const
 Convert a multi-index to a root offset.
int root_offset (const int i0, const int i1) const
 Convert a multi-index to a root offset.
int root_offset (const int i0, const int i1, const int i2) const
 Convert a multi-index to a root offset.
Constructors etc.

 ArrayIndexingBase ()
 Default constructor. Empty array.
 ArrayIndexingBase (const ArrayIndexingBase &x)
 Copy constructor.
ArrayIndexingBaseoperator= (const ArrayIndexingBase &x)
 Assignment operator.
 ArrayIndexingBase (const index_type &extents)
 Construct given the extents.
void rebuild (const index_type &extents)
 Rebuild given the extents.
 ArrayIndexingBase (const range_type &ranges)
 Construct given the index ranges.
void rebuild (const range_type &ranges)
 Rebuild given the index ranges.
void swap (ArrayIndexingBase &x)
 Swaps data with another ArrayIndexingBase.
 ~ArrayIndexingBase ()
 Destructor.

Detailed Description

template<int N>
class ArrayIndexingBase< N >

The indexing interface to N-D arrays that is independent of the value type.

Parameters:
N is the dimension.

Member Typedef Documentation

template<int N>
typedef int ArrayIndexingBase< N >::size_type

The size type is a signed integer.

Having std::size_t (which is an unsigned integer) as the size type causes minor problems. Consult "Large Scale C++ Software Design" by John Lakos for a discussion of using unsigned integers in a class interface.

Reimplemented in Array< N, T, A >, ArrayIndexing< N, T >, Array< 1, int >, Array< 1, iterator >, Array< 1, container_type >, ArrayIndexing< N, container_type >, ArrayIndexing< N, int >, and ArrayIndexing< N, iterator >.


Member Function Documentation

template<int N>
int ArrayIndexingBase< N >::index ( const int  i0,
const int  i1,
const int  i2 
) const [inline]

Convert a multi-index to a container index.

Precondition:
This must be a 3-D array.

Reimplemented in ArrayIndexing< N, T >, ArrayIndexing< N, container_type >, ArrayIndexing< N, int >, and ArrayIndexing< N, iterator >.

References IndexRange< N, T >::is_in(), and IndexRange< N, T >::lbound().

template<int N>
int ArrayIndexingBase< N >::index ( const int  i0,
const int  i1 
) const [inline]

Convert a multi-index to a container index.

Precondition:
This must be a 2-D array.

Reimplemented in ArrayIndexing< N, T >, ArrayIndexing< N, container_type >, ArrayIndexing< N, int >, and ArrayIndexing< N, iterator >.

References IndexRange< N, T >::is_in(), and IndexRange< N, T >::lbound().

template<int N>
void ArrayIndexingBase< N >::index_to_indices ( const int  index,
ads::FixedArray< 3, int > &  multi_index 
) const [inline]

Convert a container index to indices in a 3-D array.

Precondition:
This must be a 3-D array.

Reimplemented in ArrayIndexing< N, T >, ArrayIndexing< N, container_type >, ArrayIndexing< N, int >, and ArrayIndexing< N, iterator >.

References ArrayIndexingBase< N >::index_to_indices().

template<int N>
void ArrayIndexingBase< N >::index_to_indices ( const int  index,
ads::FixedArray< 2, int > &  multi_index 
) const [inline]

Convert a container index to indices in a 2-D array.

Precondition:
This must be a 2-D array.

Reimplemented in ArrayIndexing< N, T >, ArrayIndexing< N, container_type >, ArrayIndexing< N, int >, and ArrayIndexing< N, iterator >.

References ArrayIndexingBase< N >::index_to_indices().

template<int N>
void ArrayIndexingBase< N >::index_to_indices ( int  index,
int &  i,
int &  j,
int &  k 
) const [inline]

Convert a container index to indices in a 3-D array.

Precondition:
This must be a 3-D array.

Reimplemented in ArrayIndexing< N, T >, ArrayIndexing< N, container_type >, ArrayIndexing< N, int >, and ArrayIndexing< N, iterator >.

References IndexRange< N, T >::is_in(), and IndexRange< N, T >::lbound().


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