A two-dimensional array class with lazy copying and reference counting. More...
#include <Array2.hpp>
Public Types | |
typedef T | ElemType |
The type of the elements in the array. More... | |
typedef std::vector< T >::iterator | Iterator |
A mutable iterator for all elements in the array. More... | |
typedef std::vector< T >::const_iterator | ConstIterator |
A constant iterator for all elements in the array. More... | |
typedef Iterator | XIterator |
A mutable iterator for elements of a row in the array. More... | |
typedef std::vector< T >::const_iterator | ConstXIterator |
A constant iterator for elements of a row in the array. More... | |
typedef YIter< T > | YIterator |
A mutable iterator for elements of a column in the array. More... | |
typedef YIter< const T > | ConstYIterator |
A constant iterator for elements of a column in the array. More... | |
Public Member Functions | |
Array2 () | |
Create an empty array. More... | |
Array2 (int width, int height) | |
Create an array of the specified width and height. More... | |
Array2 (int width, int height, const T &value) | |
Create an array of the specified width and height with the elements of the array initialized to the specified value. More... | |
template<class InputIter > | |
Array2 (int width, int height, InputIter data) | |
Create an array of the specified width and height with the elements of the array initialized to the specified data. More... | |
~Array2 () | |
The destructor. More... | |
Array2 (const Array2 &a) | |
The copy constructor. More... | |
template<class OtherType > | |
Array2 (const Array2< OtherType > &a) | |
Create an array from an array having elements of a different type. More... | |
Array2 & | operator= (const Array2 &a) |
The assignment operator. More... | |
template<class OtherType > | |
Array2 & | operator= (const Array2< OtherType > &a) |
Assign another array with elements of a different type to this array. More... | |
Array2 & | operator+= (const Array2 &a) |
Add another array (elementwise) to this array. More... | |
Array2 & | operator-= (const Array2 &a) |
Subtract another array (elementwise) from this array. More... | |
Array2 & | operator*= (const Array2 &a) |
Multiply another array (elementwise) by this array. More... | |
Array2 & | operator/= (const Array2 &a) |
Divide this array (elementwise) by another array. More... | |
Array2 & | operator+= (const T &a) |
Add the specified value to each element in the array. More... | |
Array2 & | operator-= (const T &a) |
Subtract the specified value from each element in the array. More... | |
Array2 & | operator*= (const T &a) |
Multiply each element in the array by the specified value. More... | |
Array2 & | operator/= (const T &a) |
Divide each element in the array by the specified value. More... | |
int | getWidth () const |
Get the width of the array. More... | |
int | getHeight () const |
Get the height of the array. More... | |
int | getSize () const |
Get the number of elements in the array. More... | |
bool | isShared () const |
Is the data for this array shared with another array? More... | |
bool | isSharedWith (const Array2 &a) const |
Is the data for this array shared with the specified array? More... | |
T & | operator() (int x, int y) |
Get a mutable reference to the (x,y)-th element in the array. More... | |
const T & | operator() (int x, int y) const |
Get a const reference to the (x,y)-th element in the array. More... | |
T & | operator() (int i) |
Get a mutable reference to the i-th element in the array. More... | |
const T & | operator() (int i) const |
Get a const reference to the i-th element in the array. More... | |
ConstIterator | begin () const |
Get a const iterator for the first element in the array. More... | |
Iterator | begin () |
Get a mutable iterator for the first element in the array. More... | |
ConstIterator | end () const |
Get a const iterator for one past the last element in the array. More... | |
Iterator | end () |
Get a mutable iterator for one past the last element in the array. More... | |
ConstXIterator | rowBegin (int y) const |
Get a const iterator for the first element in the specified row of the array. More... | |
XIterator | rowBegin (int y) |
Get a mutable iterator for the first element in the specified row of the array. More... | |
ConstXIterator | rowEnd (int y) const |
Get a const iterator for one past the end in the specified row of the array. More... | |
XIterator | rowEnd (int y) |
Get a mutable iterator for one past the end in the specified row of the array. More... | |
ConstYIterator | colBegin (int x) const |
Get a const iterator for the first element in the specified column of the array. More... | |
YIterator | colBegin (int x) |
Get a mutable iterator for the first element in the specified column of the array. More... | |
ConstYIterator | colEnd (int x) const |
Get a const iterator for one past the end in the specified column of the array. More... | |
YIterator | colEnd (int x) |
Get a mutable iterator for one past the end in the specified column of the array. More... | |
void | resize (int width, int height) |
Change the size of the array. More... | |
template<class InputIterator > | |
void | resize (int width, int height, InputIterator data) |
Change the size of the array, initializing the resized array with the data obtained from the specified input iterator. More... | |
T | max () const |
Get the maximum of the elements in the array. More... | |
T | min () const |
Get the minimum of the elements in the array. More... | |
T | sum () const |
Get the sum of the elements in the array. More... | |
std::ostream & | output (std::ostream &out, int fieldWidth) const |
Output an array to a stream using the specified field width for each array element. More... | |
int | load (const char *fileName) |
Load an array from the file with the specified name. More... | |
int | save (const char *fileName) const |
Save an array to the file with the specified name. More... | |
void | fill (const T &value=T(0)) |
Set all elements in the array to the specified value. More... | |
Array2 & | flipud () |
Flip the array upside down. More... | |
Array2 & | fliplr () |
Flip the array left to right. More... | |
void | swap (Array2 &a) |
Swap the array data with the data of the specified array. More... | |
void | dump (std::ostream &out) const |
Output information about an array to a stream for debugging. More... | |
void | unshare () const |
Force the underlying data to be copied if the data is shared. More... | |
A two-dimensional array class with lazy copying and reference counting.
typedef std::vector<T>::const_iterator SPL::Array2< T >::ConstIterator |
A constant iterator for all elements in the array.
typedef std::vector<T>::const_iterator SPL::Array2< T >::ConstXIterator |
A constant iterator for elements of a row in the array.
typedef YIter<const T> SPL::Array2< T >::ConstYIterator |
A constant iterator for elements of a column in the array.
typedef T SPL::Array2< T >::ElemType |
The type of the elements in the array.
typedef std::vector<T>::iterator SPL::Array2< T >::Iterator |
A mutable iterator for all elements in the array.
typedef Iterator SPL::Array2< T >::XIterator |
A mutable iterator for elements of a row in the array.
typedef YIter<T> SPL::Array2< T >::YIterator |
A mutable iterator for elements of a column in the array.
SPL::Array2< T >::Array2 | ( | int | width, |
int | height, | ||
InputIter | data | ||
) |
Create an array of the specified width and height with the elements of the array initialized to the specified data.
SPL::Array2< T >::Array2 | ( | const Array2< OtherType > & | a | ) |
Create an array from an array having elements of a different type.
Array2& SPL::Array2< T >::operator= | ( | const Array2< OtherType > & | a | ) |
Assign another array with elements of a different type to this array.