KrisLibrary
1.0.0
|
A three-dimensional m x n x parray. More...
#include <array3d.h>
Classes | |
class | iterator |
Public Member Functions | |
Array3D (int m, int n, int p) | |
Array3D (int m, int n, int p, const T &initVal) | |
Array3D (const Array3D< T > &rhs) | |
Array3D (Array3D< T > &&rhs) | |
T & | operator() (int i, int j, int k) |
const T & | operator() (int i, int j, int k) const |
T & | operator() (const IntTriple &t) |
const T & | operator() (const IntTriple &t) const |
Array3D< T > & | operator= (const Array3D< T > &rhs) |
Array3D< T > & | operator= (Array3D< T > &&rhs) |
bool | Read (File &f) |
bool | Write (File &f) const |
int | dim1 () const |
int | dim2 () const |
int | dim3 () const |
IntTriple | size () const |
bool | empty () const |
void | initialize (int m, int n, int p) |
void | initialize (int m, int n, int p, const T &initVal) |
void | resize (int m, int n, int p) |
void | resize (int m, int n, int p, const T &initVal) |
void | reserve (int cap) |
void | clear () |
bool | find (const T &item, int &i, int &j, int &k) const |
bool | find (const T &item, IntTriple &t) const |
bool | contains (const T &item) const |
void | set (const T &item) |
void | set (const Array3D< T > &) |
void | swap (Array3D< T > &) |
T * | getData () const |
iterator | begin () const |
iterator | end () const |
iterator | begin (const Range3Indices &range) const |
iterator | end (const Range3Indices &range) const |
Public Attributes | |
int | m |
int | n |
int | p |
Protected Attributes | |
T * | items |
int | capacity |
A three-dimensional m x n x parray.
Indices are in the range [0,m) x [0,n) x [0,p). Elements can be accessed with the (i,j,k) operator, or with the (IntTriple) operator. Element i,j,k is in memory at location i*n*p + j*p + k.
The array is sized with initialize(m,n,p) or resize(m,n,p). The difference is that initialize always deallocates previously allocated memory, and resize only deallocates it if the new size is greater than the established capacity (capacity >= m*n*p). Capacity can be set using the reserve() method, but only if the array is empty. The existing elements are not maintained in any particular order upon a resize.
If the optional initVal parameter is passed to initialize or resize, all elements are set to initVal after resizing.
The iterator class allows fast iteration of all or some elements. A range of the array can be accessed using the Range3Indices class.