SPUC  3.0
Public Member Functions | List of all members
SPUC::array< T > Class Template Reference

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...
 
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...
 
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...
 
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...
 

Detailed Description

template<class T>
class SPUC::array< T >

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

template class array<type>;

The following example shows how to define an array of vectors:

vec a = randn(10);
vec b = randn(20);
vec c = randn(30);
array<vec> my_array(3);
my_array(0) = a;
my_array(1) = b;
my_array(2) = c;

Constructor & Destructor Documentation

template<class T >
SPUC::array< T >::array ( )

Default constructor.

template<class T >
SPUC::array< T >::array ( int  n)

Create an array of size n.

template<class T >
SPUC::array< T >::array ( const array< T > &  a)

Create a copy of a.

template<class T >
SPUC::array< T >::~array ( )
virtual

Default destructor.

Member Function Documentation

template<class T>
int SPUC::array< T >::length ( ) const
inline

Returns the number of data elements in the array object.

template<class T>
T& SPUC::array< T >::operator() ( int  i)
inline

Get the i element.

template<class T>
T SPUC::array< T >::operator() ( int  i) const
inline

Get the i element.

template<class T >
array< T > SPUC::array< T >::operator() ( int  i1,
int  i2 
) const

Sub-array from element i1 to element i2.

template<class T >
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().

Here is the call graph for this function:

template<class T >
void SPUC::array< T >::operator= ( e)

Assignment operator.

template<class T >
void SPUC::array< T >::operator= ( const array< T > &  a)

Assignment operator.

template<class T>
void SPUC::array< T >::set_length ( int  n,
bool  copy = false 
)
inline

Resizing an array<T>.

References SPUC::array< T >::set_size().

Here is the call graph for this function:

template<class T >
void SPUC::array< T >::set_size ( int  n,
bool  copy = false 
)

Resizing an array<T>.

Referenced by SPUC::array< T >::set_length().

template<class T >
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.

template<class T >
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.

template<class T >
T SPUC::array< T >::shift_left ( e)

Shift in data at position Ndata()-1. return data at last position.

template<class T >
array< T > SPUC::array< T >::shift_left ( const array< T > &  a)

Shift in array at position Ndata()-1. return data at last position.

template<class T >
T SPUC::array< T >::shift_right ( e)

Shift in data at position 0. return data at last position.

template<class T >
array< T > SPUC::array< T >::shift_right ( const array< T > &  a)

Shift in array at position 0. return data at last position.

template<class T>
int SPUC::array< T >::size ( ) const
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()().

template<class T >
void SPUC::array< T >::swap ( int  i,
int  j 
)

Swap elements i and j.


The documentation for this class was generated from the following file: