A one-dimensional array class with lazy copying and reference counting. More...
#include <Array1.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 the array elements. More... | |
typedef std::vector< T >::const_iterator | ConstIterator |
A constant iterator for the array elements. More... | |
Public Member Functions | |
Array1 () | |
Create an empty array. More... | |
Array1 (int size) | |
Create an array of the specified size. More... | |
Array1 (int size, const T &value) | |
Create an array of the given size with all elements initialized to the specified value. More... | |
template<class InputIterator > | |
Array1 (int size, InputIterator data) | |
Create an array of the specified size with the elements initialized to the data obtained from the given input iterator. More... | |
Array1 (const Array1 &a) | |
Create a copy of an array. More... | |
template<class OtherType > | |
Array1 (const Array1< OtherType > &a) | |
Create a copy of an array with elements of arbitrary type. More... | |
~Array1 () | |
Destroy an array. More... | |
Array1 & | operator= (const Array1 &a) |
Assign one array to another. More... | |
template<class OtherType > | |
Array1< T > & | operator= (const Array1< OtherType > &a) |
Assign an array with elements of arbitrary type to another array. More... | |
Array1 & | operator+= (const Array1 &a) |
Add another array (elementwise) to this array. More... | |
Array1 & | operator-= (const Array1 &a) |
Subtract another array (elementwise) from this array. More... | |
Array1 & | operator*= (const Array1 &a) |
Multiply another array (elementwise) by this array. More... | |
Array1 & | operator/= (const Array1 &a) |
Divide this array (elementwise) by another array. More... | |
Array1 & | operator+= (const T &value) |
Add the specified value to each element in the array. More... | |
Array1 & | operator-= (const T &value) |
Subtract the specified value from each element in the array. More... | |
Array1 & | operator*= (const T &value) |
Multiply each element in the array by the specified value. More... | |
Array1 & | operator/= (const T &value) |
Divide each element in the array by the specified value. 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 Array1 &a) const |
Is the data for this array shared with the specified array? More... | |
T & | operator() (int i) |
Get a mutable reference to the specified element in the array. More... | |
const T & | operator() (int i) const |
Get a const reference to the specified element in the array. More... | |
ConstIterator | begin () const |
Get a const iterator referring to the first element in the array. More... | |
Iterator | begin () |
Get a mutable iterator referring to the first element in the array. More... | |
ConstIterator | end () const |
Get a const iterator referring to one past the last element in the array. More... | |
Iterator | end () |
Get a mutable iterator referring to one past the last element in the array. More... | |
void | resize (int size) |
Change the size of the array. More... | |
template<class InputIterator > | |
void | resize (int size, 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 with a particular field width to be used for each 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... | |
void | swap (Array1 &a) |
Swap the contents of the array with the contents of another array. More... | |
void | dump (std::ostream &out) const |
Output information about an array to a stream for debugging. More... | |
A one-dimensional array class with lazy copying and reference counting.
typedef std::vector<T>::const_iterator SPL::Array1< T >::ConstIterator |
A constant iterator for the array elements.
typedef T SPL::Array1< T >::ElemType |
The type of the elements in the array.
typedef std::vector<T>::iterator SPL::Array1< T >::Iterator |
A mutable iterator for the array elements.
SPL::Array1< T >::Array1 | ( | int | size, |
InputIterator | data | ||
) |
Create an array of the specified size with the elements initialized to the data obtained from the given input iterator.
SPL::Array1< T >::Array1 | ( | const Array1< OtherType > & | a | ) |
Create a copy of an array with elements of arbitrary type.
Note: The type OtherType must be assignable to the type T.