SPUC
3.0
|
General array class. More...
#include <array.h>
Public Member Functions | |
array () | |
Default constructor. More... | |
array (int n) | |
Create an array of size n . More... | |
array (const array< T > &a) | |
Create a copy of a . More... | |
virtual | ~array () |
Default destructor. More... | |
T & | operator() (int i) |
Get the i element. More... | |
T | operator() (int i) const |
Get the i element. More... | |
array< T > | operator() (int i1, int i2) const |
Sub-array from element i1 to element i2 . More... | |
array< T > | operator() (const array< int > &indices) const |
Sub-array with the elements given by the integer array. More... | |
void | operator= (T e) |
Assignment operator. More... | |
void | operator= (const array< T > &a) |
Assignment operator. More... | |
int | size () const |
Append element e to the end of the array a . More... | |
int | length () const |
Returns the number of data elements in the array object. More... | |
void | set_size (int n, bool copy=false) |
Resizing an array<T>. More... | |
void | set_length (int n, bool copy=false) |
Resizing an array<T>. More... | |
T | shift_right (T e) |
Shift in data at position 0. return data at last position. More... | |
array< T > | shift_right (const array< T > &a) |
Shift in array at position 0. return data at last position. More... | |
T | shift_left (T e) |
Shift in data at position Ndata()-1. return data at last position. More... | |
array< T > | shift_left (const array< T > &a) |
Shift in array at position Ndata()-1. return data at last position. More... | |
void | swap (int i, int j) |
Swap elements i and j. More... | |
void | set_subarray (int i1, int i2, const array< T > &a) |
Set the subarray defined by indicies i1 to i2 to array<T> a. More... | |
void | set_subarray (int i1, int i2, const T t) |
Set the subarray defined by indicies i1 to i2 the element value t. More... | |
General array class.
This class is a general linear array class for arbitrary types. The operations and functions are the same as for the vector Vec class (except for the arithmetics).
For rarely used types you will need to instantiate the class by
The following example shows how to define an array of vectors:
SPUC::array< T >::array | ( | ) |
Default constructor.
SPUC::array< T >::array | ( | int | n | ) |
Create an array of size n
.
SPUC::array< T >::array | ( | const array< T > & | a | ) |
Create a copy of a
.
|
virtual |
Default destructor.
|
inline |
Returns the number of data elements in the array object.
|
inline |
Get the i
element.
|
inline |
Get the i
element.
array< T > SPUC::array< T >::operator() | ( | int | i1, |
int | i2 | ||
) | const |
Sub-array from element i1
to element i2
.
array< T > SPUC::array< T >::operator() | ( | const array< int > & | indices | ) | const |
Sub-array with the elements given by the integer array.
References SPUC::array< T >::size().
void SPUC::array< T >::operator= | ( | T | e | ) |
Assignment operator.
void SPUC::array< T >::operator= | ( | const array< T > & | a | ) |
Assignment operator.
|
inline |
Resizing an array<T>.
References SPUC::array< T >::set_size().
void SPUC::array< T >::set_size | ( | int | n, |
bool | copy = false |
||
) |
Resizing an array<T>.
Referenced by SPUC::array< T >::set_length().
void SPUC::array< T >::set_subarray | ( | int | i1, |
int | i2, | ||
const array< T > & | a | ||
) |
Set the subarray defined by indicies i1 to i2 to array<T> a.
void SPUC::array< T >::set_subarray | ( | int | i1, |
int | i2, | ||
const T | t | ||
) |
Set the subarray defined by indicies i1 to i2 the element value t.
T SPUC::array< T >::shift_left | ( | T | e | ) |
Shift in data at position Ndata()-1. return data at last position.
array< T > SPUC::array< T >::shift_left | ( | const array< T > & | a | ) |
Shift in array at position Ndata()-1. return data at last position.
T SPUC::array< T >::shift_right | ( | T | e | ) |
Shift in data at position 0. return data at last position.
array< T > SPUC::array< T >::shift_right | ( | const array< T > & | a | ) |
Shift in array at position 0. return data at last position.
|
inline |
Append element e
to the end of the array a
.
Concat element e
to the beginning of the array a
Concat arrays a1
and a2
Concat arrays a1
, a2
and a3
Returns the number of data elements in the array object
Referenced by SPUC::array< T >::operator()().
void SPUC::array< T >::swap | ( | int | i, |
int | j | ||
) |
Swap elements i and j.