The indexing interface to N-D arrays. More...
#include <ArrayIndexing.h>
Public Types | |
typedef types::value_type | value_type |
The element type of the array. | |
typedef types::parameter_type | parameter_type |
The parameter type. | |
typedef types::unqualified_value_type | unqualified_value_type |
The unqualified value type. | |
typedef types::pointer | pointer |
A pointer to an array element. | |
typedef types::const_pointer | const_pointer |
A pointer to a constant array element. | |
typedef types::reference | reference |
A reference to an array element. | |
typedef types::const_reference | const_reference |
A reference to a constant array element. | |
typedef types::size_type | size_type |
The size type is a signed integer. | |
typedef types::difference_type | difference_type |
Pointer difference type. | |
typedef FixedArray< N, int > | index_type |
A multi-index. Index in N dimensions. | |
typedef IndexRange< N, int > | range_type |
A range of multi-indices. | |
typedef ArrayIndexIterator< N > | index_iterator |
A multi-index iterator. | |
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. | |
index_iterator | indices_begin () const |
Return an index iterator to the beginning of the indices. | |
index_iterator | indices_end () const |
Return an index iterator to the end of the indices. | |
const_pointer | root () const |
Return the root for indexing, i.e., the location of (*this)(lbounds()). | |
Accessors: Indexing. | |
parameter_type | operator() (const index_type &mi) const |
Return the specified element. | |
parameter_type | operator() (const int i0, const int i1) const |
Return the specified the element. | |
parameter_type | operator() (const int i0, const int i1, const int i2) const |
Return the specified the element. | |
parameter_type | operator() (const ads::FixedArray< 1, int > &index, const ads::FixedArray< 1, int > &offset) const |
Return the element specified by the index and offset. | |
parameter_type | operator() (const ads::FixedArray< 2, int > &index, const ads::FixedArray< 2, int > &offset) const |
Return the element specified by the index and offset. | |
parameter_type | operator() (const ads::FixedArray< 3, int > &index, const ads::FixedArray< 3, int > &offset) const |
Return the element specified by the index and offset. | |
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. | |
Manipulators. | |
pointer | root () |
Return the root for indexing. | |
Manipulators: Array indexing. | |
reference | operator() (const index_type &mi) |
Return a reference to the element. | |
reference | operator() (const int i0, const int i1) |
Return a reference to the element. | |
reference | operator() (const int i0, const int i1, const int i2) |
Return a reference to the element. | |
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. | |
void | pretty_print (std::ostream &out) const |
Write to a file stream in a tabular format. | |
Equality. | |
template<typename T2 > | |
bool | operator== (const ArrayIndexing< N, T2 > &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 | |
Constructors etc. | |
ArrayIndexing () | |
Default constructor. Empty array. | |
ArrayIndexing (const ArrayIndexing &x) | |
Copy constructor. Shallow copy. | |
ArrayIndexing & | operator= (const ArrayIndexing &x) |
Assignment operator. Shallow assignment. | |
template<typename Type > | |
ArrayIndexing (const index_type &extents, Type *data) | |
Construct given the extents and a pointer to the data . | |
template<typename Type > | |
void | rebuild (const index_type &extents, Type *data) |
Rebuild given the extents and a pointer to the data . | |
template<typename Type > | |
ArrayIndexing (const range_type &ranges, Type *data) | |
Construct given the index ranges and a pointer to the data . | |
template<typename Type > | |
void | rebuild (const range_type &ranges, Type *data) |
Rebuild given the index ranges and a pointer to the data . | |
void | swap (ArrayIndexing &x) |
Swaps data with another ArrayIndexing. | |
~ArrayIndexing () | |
Destructor. Do nothing. Leave memory management to derived classes. |
The indexing interface to N-D arrays.
N | is the dimension. | |
T | is the value type. By default it is double. |
typedef types::parameter_type ArrayIndexing< N, T >::parameter_type |
The parameter type.
This is used for passing the value type as an argument.
Reimplemented in Array< N, T, A >, Array< 1, int >, Array< 1, iterator >, and Array< 1, container_type >.
typedef types::size_type ArrayIndexing< N, T >::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 from ArrayIndexingBase< N >.
Reimplemented in Array< N, T, A >, Array< 1, int >, Array< 1, iterator >, and Array< 1, container_type >.
typedef types::unqualified_value_type ArrayIndexing< N, T >::unqualified_value_type |
The unqualified value type.
The value type with top level const
and volatile
qualifiers removed.
Reimplemented in Array< N, T, A >, Array< 1, int >, Array< 1, iterator >, and Array< 1, container_type >.
int ArrayIndexing< N, T >::index | ( | const int | i0, | |
const int | i1, | |||
const int | i2 | |||
) | const [inline] |
Convert a multi-index to a container index.
Reimplemented from ArrayIndexingBase< N >.
int ArrayIndexing< N, T >::index | ( | const int | i0, | |
const int | i1 | |||
) | const [inline] |
Convert a multi-index to a container index.
Reimplemented from ArrayIndexingBase< N >.
void ArrayIndexing< N, T >::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 from ArrayIndexingBase< N >.
void ArrayIndexing< N, T >::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 from ArrayIndexingBase< N >.
void ArrayIndexing< N, T >::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 from ArrayIndexingBase< N >.
void ArrayIndexing< N, T >::index_to_indices | ( | const int | index, | |
int & | i, | |||
int & | j | |||
) | const [inline] |
Convert a container index to indices in a 2-D array.
Reimplemented from ArrayIndexingBase< N >.
Referenced by Array< 1, container_type >::getMemoryUsage(), and Array< 1, container_type >::iterator_to_indices().
reference ArrayIndexing< N, T >::operator() | ( | const int | i0, | |
const int | i1, | |||
const int | i2 | |||
) | [inline] |
Return a reference to the element.
reference ArrayIndexing< N, T >::operator() | ( | const int | i0, | |
const int | i1 | |||
) | [inline] |
Return a reference to the element.
parameter_type ArrayIndexing< N, T >::operator() | ( | const ads::FixedArray< 3, int > & | index, | |
const ads::FixedArray< 3, int > & | offset | |||
) | const [inline] |
Return the element specified by the index and offset.
This function avoids constructing an index.
parameter_type ArrayIndexing< N, T >::operator() | ( | const ads::FixedArray< 2, int > & | index, | |
const ads::FixedArray< 2, int > & | offset | |||
) | const [inline] |
Return the element specified by the index and offset.
This function avoids constructing an index.
parameter_type ArrayIndexing< N, T >::operator() | ( | const ads::FixedArray< 1, int > & | index, | |
const ads::FixedArray< 1, int > & | offset | |||
) | const [inline] |
Return the element specified by the index and offset.
This function avoids constructing an index.
parameter_type ArrayIndexing< N, T >::operator() | ( | const int | i0, | |
const int | i1, | |||
const int | i2 | |||
) | const [inline] |
Return the specified the element.
parameter_type ArrayIndexing< N, T >::operator() | ( | const int | i0, | |
const int | i1 | |||
) | const [inline] |
Return the specified the element.
void ArrayIndexing< N, T >::pretty_print | ( | std::ostream & | out | ) | const |
Write to a file stream in a tabular format.
In 1-D, write one element per line. In 2-D, write by rows. In 3-D, write by z-slices.