Signal/Geometry Processing Library (SPL) 1.1.24 |

Classes | Typedefs | Functions
Two-Dimensional Arrays
Arrays and Sequences

Two-dimensional arrays. More...

## Classes
class | SPL::Array2< T >
| A two-dimensional array class with lazy copying and reference counting. More...

## Typedefs
typedef Array2< double > | SPL::RealArray2
| A two-dimensional array with real elements. More...
typedef Array2< int > | SPL::IntArray2
| A two-dimensional array with integer elements. More...

## Functions
template<class T >
std::ostream & | SPL::operator<< (std::ostream &out, const Array2< T > &a)
| Output an array to the specified stream. More...
template<class T >
std::istream & | SPL::operator>> (std::istream &in, Array2< T > &a)
| Input an array from the specified stream. More...
template<class T >
Array2< T > | SPL::transpose (const Array2< T > &a)
| Get the transpose of the array. More...
template<class T >
bool | SPL::operator== (const Array2< T > &a, const Array2< T > &b)
| Test two arrays for equality. More...
template<class T >
bool | SPL::operator!= (const Array2< T > &a, const Array2< T > &b)
| Test two arrays for inequality. More...
| SPL::Array2< T >::Array2 ()
| Create an empty array. More...
| SPL::Array2< T >::Array2 (int width, int height)
| Create an array of the specified width and height. More...
| SPL::Array2< T >::Array2 (const Array2 &a)
| The copy constructor. More...
| SPL::Array2< T >::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...
| SPL::Array2< T >::~Array2 ()
| The destructor. More...
Array2 & | SPL::Array2< T >::operator= (const Array2 &a)
| The assignment operator. More...
Array2 & | SPL::Array2< T >::operator+= (const Array2 &a)
| Add another array (elementwise) to this array. More...
Array2 & | SPL::Array2< T >::operator-= (const Array2 &a)
| Subtract another array (elementwise) from this array. More...
Array2 & | SPL::Array2< T >::operator*= (const Array2 &a)
| Multiply another array (elementwise) by this array. More...
Array2 & | SPL::Array2< T >::operator/= (const Array2 &a)
| Divide this array (elementwise) by another array. More...
Array2 & | SPL::Array2< T >::operator+= (const T &a)
| Add the specified value to each element in the array. More...
Array2 & | SPL::Array2< T >::operator-= (const T &a)
| Subtract the specified value from each element in the array. More...
Array2 & | SPL::Array2< T >::operator*= (const T &a)
| Multiply each element in the array by the specified value. More...
Array2 & | SPL::Array2< T >::operator/= (const T &a)
| Divide each element in the array by the specified value. More...
int | SPL::Array2< T >::getWidth () const
| Get the width of the array. More...
int | SPL::Array2< T >::getHeight () const
| Get the height of the array. More...
int | SPL::Array2< T >::getSize () const
| Get the number of elements in the array. More...
bool | SPL::Array2< T >::isShared () const
| Is the data for this array shared with another array? More...
bool | SPL::Array2< T >::isSharedWith (const Array2 &a) const
| Is the data for this array shared with the specified array? More...
T & | SPL::Array2< T >::operator() (int x, int y)
| Get a mutable reference to the (x,y)-th element in the array. More...
const T & | SPL::Array2< T >::operator() (int x, int y) const
| Get a const reference to the (x,y)-th element in the array. More...
T & | SPL::Array2< T >::operator() (int i)
| Get a mutable reference to the i-th element in the array. More...
const T & | SPL::Array2< T >::operator() (int i) const
| Get a const reference to the i-th element in the array. More...
ConstIterator | SPL::Array2< T >::begin () const
| Get a const iterator for the first element in the array. More...
Iterator | SPL::Array2< T >::begin ()
| Get a mutable iterator for the first element in the array. More...
ConstIterator | SPL::Array2< T >::end () const
| Get a const iterator for one past the last element in the array. More...
Iterator | SPL::Array2< T >::end ()
| Get a mutable iterator for one past the last element in the array. More...
ConstXIterator | SPL::Array2< T >::rowBegin (int y) const
| Get a const iterator for the first element in the specified row of the array. More...
XIterator | SPL::Array2< T >::rowBegin (int y)
| Get a mutable iterator for the first element in the specified row of the array. More...
ConstXIterator | SPL::Array2< T >::rowEnd (int y) const
| Get a const iterator for one past the end in the specified row of the array. More...
XIterator | SPL::Array2< T >::rowEnd (int y)
| Get a mutable iterator for one past the end in the specified row of the array. More...
ConstYIterator | SPL::Array2< T >::colBegin (int x) const
| Get a const iterator for the first element in the specified column of the array. More...
YIterator | SPL::Array2< T >::colBegin (int x)
| Get a mutable iterator for the first element in the specified column of the array. More...
ConstYIterator | SPL::Array2< T >::colEnd (int x) const
| Get a const iterator for one past the end in the specified column of the array. More...
YIterator | SPL::Array2< T >::colEnd (int x)
| Get a mutable iterator for one past the end in the specified column of the array. More...
void | SPL::Array2< T >::resize (int width, int height)
| Change the size of the array. More...
template<class InputIterator >
void | SPL::Array2< T >::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 | SPL::Array2< T >::max () const
| Get the maximum of the elements in the array. More...
T | SPL::Array2< T >::min () const
| Get the minimum of the elements in the array. More...
T | SPL::Array2< T >::sum () const
| Get the sum of the elements in the array. More...
std::ostream & | SPL::Array2< T >::output (std::ostream &out, int fieldWidth) const
| Output an array to a stream using the specified field width for each array element. More...
int | SPL::Array2< T >::load (const char *fileName)
| Load an array from the file with the specified name. More...
int | SPL::Array2< T >::save (const char *fileName) const
| Save an array to the file with the specified name. More...
void | SPL::Array2< T >::swap (Array2 &a)
| Swap the array data with the data of the specified array. More...
void | SPL::Array2< T >::fill (const T &value=T(0))
| Set all elements in the array to the specified value. More...
Array2 & | SPL::Array2< T >::flipud ()
| Flip the array upside down. More...
Array2 & | SPL::Array2< T >::fliplr ()
| Flip the array left to right. More...
void | SPL::Array2< T >::dump (std::ostream &out) const
| Output information about an array to a stream for debugging. More...
void | SPL::Array2< T >::unshare () const
| Force the underlying data to be copied if the data is shared. More...

## Detailed Description

Two-dimensional arrays.

## Typedef Documentation

typedef Array2<int> SPL::IntArray2

A two-dimensional array with integer elements.

typedef Array2<double> SPL::RealArray2

A two-dimensional array with real elements.

## Function Documentation

template<class T >

SPL_ARRAY2_INLINE SPL::Array2< T >::Array2 | ( |  | ) |

Create an empty array.

template<class T >

SPL_ARRAY2_INLINE SPL::Array2< T >::Array2 | ( | int | width,
|  | int | height
| ) |  |

Create an array of the specified width and height.

template<class T >

SPL_ARRAY2_INLINE SPL::Array2< T >::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.

template<class T >

SPL_ARRAY2_INLINE SPL::Array2< T >::Array2 | ( | const Array2< T > & | a | ) |

The copy constructor.

template<class T >

SPL_ARRAY2_INLINE Array2< T >::ConstIterator SPL::Array2< T >::begin | ( |  | ) | const

Get a const iterator for the first element in the array.

template<class T >

SPL_ARRAY2_INLINE Array2< T >::Iterator SPL::Array2< T >::begin | ( |  | ) |

Get a mutable iterator for the first element in the array.

template<class T >

SPL_ARRAY2_INLINE Array2< T >::ConstYIterator SPL::Array2< T >::colBegin | ( | int | x | ) | const

Get a const iterator for the first element in the specified column of the array.

template<class T >

SPL_ARRAY2_INLINE Array2< T >::YIterator SPL::Array2< T >::colBegin | ( | int | x | ) |

Get a mutable iterator for the first element in the specified column of the array.

template<class T >

SPL_ARRAY2_INLINE Array2< T >::ConstYIterator SPL::Array2< T >::colEnd | ( | int | x | ) | const

Get a const iterator for one past the end in the specified column of the array.

template<class T >

SPL_ARRAY2_INLINE Array2< T >::YIterator SPL::Array2< T >::colEnd | ( | int | x | ) |

Get a mutable iterator for one past the end in the specified column of the array.

template<class T >

void SPL::Array2< T >::dump | ( | std::ostream & | out | ) | const

Output information about an array to a stream for debugging.

Ouput information about an array to the specified stream for debugging purposes.

template<class T >

SPL_ARRAY2_INLINE Array2< T >::ConstIterator SPL::Array2< T >::end | ( |  | ) | const

Get a const iterator for one past the last element in the array.

template<class T >

SPL_ARRAY2_INLINE Array2< T >::Iterator SPL::Array2< T >::end | ( |  | ) |

Get a mutable iterator for one past the last element in the array.

template<class T >

SPL_ARRAY2_INLINE void SPL::Array2< T >::fill | ( | const T & | value = `T(0)` | ) |

Set all elements in the array to the specified value.

template<class T >

Array2< T > & SPL::Array2< T >::fliplr | ( |  | ) |

Flip the array left to right.

template<class T >

Array2< T > & SPL::Array2< T >::flipud | ( |  | ) |

Flip the array upside down.

template<class T >

SPL_ARRAY2_INLINE int SPL::Array2< T >::getHeight | ( |  | ) | const

Get the height of the array.

template<class T >

SPL_ARRAY2_INLINE int SPL::Array2< T >::getSize | ( |  | ) | const

Get the number of elements in the array.

template<class T >

SPL_ARRAY2_INLINE int SPL::Array2< T >::getWidth | ( |  | ) | const

Get the width of the array.

template<class T >

SPL_ARRAY2_INLINE bool SPL::Array2< T >::isShared | ( |  | ) | const

Is the data for this array shared with another array?

Under most normal circumstances, one should never need to call this function. In some instances, however, it might be necessary to know whether data is shared in order to write more optimal code.

template<class T >

SPL_ARRAY2_INLINE bool SPL::Array2< T >::isSharedWith | ( | const Array2< T > & | a | ) | const

Is the data for this array shared with the specified array?

template<class T >

int SPL::Array2< T >::load | ( | const char * | fileName | ) |

Load an array from the file with the specified name.

template<class T >

SPL_ARRAY2_INLINE T SPL::Array2< T >::max | ( |  | ) | const

Get the maximum of the elements in the array.

The array must contain at least one element.

template<class T >

SPL_ARRAY2_INLINE T SPL::Array2< T >::min | ( |  | ) | const

Get the minimum of the elements in the array.

The array must contain at least one element.

template<class T >

bool SPL::operator!= | ( | const Array2< T > & | a,
|  | const Array2< T > & | b
| ) |  |

Test two arrays for inequality.

template<class T >

SPL_ARRAY2_INLINE T & SPL::Array2< T >::operator() | ( | int | x,
|  | int | y
| ) |  |

Get a mutable reference to the (x,y)-th element in the array.

template<class T >

SPL_ARRAY2_INLINE const T & SPL::Array2< T >::operator() | ( | int | x,
|  | int | y
| ) |  | const

Get a const reference to the (x,y)-th element in the array.

template<class T >

SPL_ARRAY2_INLINE T & SPL::Array2< T >::operator() | ( | int | i | ) |

Get a mutable reference to the i-th element in the array.

The array must have either a width or height of one.

template<class T >

SPL_ARRAY2_INLINE const T & SPL::Array2< T >::operator() | ( | int | i | ) | const

Get a const reference to the i-th element in the array.

The array must have either a width or height of one.

template<class T >

SPL_ARRAY2_INLINE Array2< T > & SPL::Array2< T >::operator*= | ( | const Array2< T > & | a | ) |

Multiply another array (elementwise) by this array.

template<class T >

SPL_ARRAY2_INLINE Array2< T > & SPL::Array2< T >::operator*= | ( | const T & | a | ) |

Multiply each element in the array by the specified value.

template<class T >

SPL_ARRAY2_INLINE Array2< T > & SPL::Array2< T >::operator+= | ( | const Array2< T > & | a | ) |

Add another array (elementwise) to this array.

template<class T >

SPL_ARRAY2_INLINE Array2< T > & SPL::Array2< T >::operator+= | ( | const T & | a | ) |

Add the specified value to each element in the array.

template<class T >

SPL_ARRAY2_INLINE Array2< T > & SPL::Array2< T >::operator-= | ( | const Array2< T > & | a | ) |

Subtract another array (elementwise) from this array.

template<class T >

SPL_ARRAY2_INLINE Array2< T > & SPL::Array2< T >::operator-= | ( | const T & | a | ) |

Subtract the specified value from each element in the array.

template<class T >

SPL_ARRAY2_INLINE Array2< T > & SPL::Array2< T >::operator/= | ( | const Array2< T > & | a | ) |

Divide this array (elementwise) by another array.

template<class T >

SPL_ARRAY2_INLINE Array2< T > & SPL::Array2< T >::operator/= | ( | const T & | a | ) |

Divide each element in the array by the specified value.

template<class T >

std::ostream& SPL::operator<< | ( | std::ostream & | out,
|  | const Array2< T > & | a
| ) |  |

Output an array to the specified stream.

template<class T >

SPL_ARRAY2_INLINE Array2< T > & SPL::Array2< T >::operator= | ( | const Array2< T > & | a | ) |

The assignment operator.

template<class T >

bool SPL::operator== | ( | const Array2< T > & | a,
|  | const Array2< T > & | b
| ) |  |

Test two arrays for equality.

template<class T >

std::istream& SPL::operator>> | ( | std::istream & | in,
|  | Array2< T > & | a
| ) |  |

Input an array from the specified stream.

template<class T >

std::ostream & SPL::Array2< T >::output | ( | std::ostream & | out,
|  | int | fieldWidth
| ) |  | const

Output an array to a stream using the specified field width for each array element.

template<class T >

void SPL::Array2< T >::resize | ( | int | width,
|  | int | height
| ) |  |

Change the size of the array.

Effects: The array size is changed to the specified size. If the new size is the same as the old size, this function does nothing.

template<class T >
template<class InputIterator >

void SPL::Array2< T >::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.

template<class T >

SPL_ARRAY2_INLINE Array2< T >::ConstXIterator SPL::Array2< T >::rowBegin | ( | int | y | ) | const

Get a const iterator for the first element in the specified row of the array.

template<class T >

SPL_ARRAY2_INLINE Array2< T >::XIterator SPL::Array2< T >::rowBegin | ( | int | y | ) |

Get a mutable iterator for the first element in the specified row of the array.

template<class T >

SPL_ARRAY2_INLINE Array2< T >::ConstXIterator SPL::Array2< T >::rowEnd | ( | int | y | ) | const

Get a const iterator for one past the end in the specified row of the array.

template<class T >

SPL_ARRAY2_INLINE Array2< T >::XIterator SPL::Array2< T >::rowEnd | ( | int | y | ) |

Get a mutable iterator for one past the end in the specified row of the array.

template<class T >

int SPL::Array2< T >::save | ( | const char * | fileName | ) | const

Save an array to the file with the specified name.

template<class T >

SPL_ARRAY2_INLINE T SPL::Array2< T >::sum | ( |  | ) | const

Get the sum of the elements in the array.

template<class T >

void SPL::Array2< T >::swap | ( | Array2< T > & | a | ) |

Swap the array data with the data of the specified array.

template<class T >

Array2<T> SPL::transpose | ( | const Array2< T > & | a | ) |

Get the transpose of the array.

template<class T >

SPL_ARRAY2_INLINE void SPL::Array2< T >::unshare | ( |  | ) | const

Force the underlying data to be copied if the data is shared.

template<class T >

SPL_ARRAY2_INLINE SPL::Array2< T >::~Array2 | ( |  | ) |

The destructor.