The indexing interface to N-D arrays that is independent of the value type. More...
#include <ArrayIndexingBase.h>
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_type & | extents () const |
Return the extents of the array. | |
size_type | extent (const int i) const |
Return the extent of the array. | |
const range_type & | ranges () const |
Return the index ranges of the array. | |
const index_type & | lbounds () const |
Return the index lower bounds. | |
const index_type & | ubounds () const |
Return the index upper bounds. | |
int | lbound (const int i) const |
Return the lower bound. | |
int | ubound (const int i) const |
Return the upper bound. | |
const index_type & | strides () 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. | |
ArrayIndexingBase & | operator= (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. |
The indexing interface to N-D arrays that is independent of the value type.
N | is the dimension. |
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 >.
int ArrayIndexingBase< N >::index | ( | const int | i0, | |
const int | i1, | |||
const int | i2 | |||
) | const [inline] |
Convert a multi-index to a container index.
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().
int ArrayIndexingBase< N >::index | ( | const int | i0, | |
const int | i1 | |||
) | const [inline] |
Convert a multi-index to a container index.
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().
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.
Reimplemented in ArrayIndexing< N, T >, ArrayIndexing< N, container_type >, ArrayIndexing< N, int >, and ArrayIndexing< N, iterator >.
References ArrayIndexingBase< N >::index_to_indices().
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.
Reimplemented in ArrayIndexing< N, T >, ArrayIndexing< N, container_type >, ArrayIndexing< N, int >, and ArrayIndexing< N, iterator >.
References ArrayIndexingBase< N >::index_to_indices().
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.
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().
void ArrayIndexingBase< N >::index_to_indices | ( | const int | index, | |
int & | i, | |||
int & | j | |||
) | const [inline] |
Convert a container index to indices in 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().
Referenced by ArrayIndexingBase< N >::index_to_indices(), ArrayIndexing< 1, T >::index_to_indices(), ArrayIndexing< N, iterator >::index_to_indices(), ArrayIndexIterator< N >::operator*(), ArrayIndexIterator< N >::operator->(), and ArrayIndexIterator< N >::operator[]().