6.54 ABA_ARRAY< Type > Class Template Reference

it is a template for arrays. It can be used like a “normal” C-style array

#include <array.h>

Inheritance diagram for ABA_ARRAY< Type >::


PIC


Public Member Functions

Private Member Functions

Private Attributes

Friends

6.54.1 Detailed Description

template<class Type> class ABA_ARRAY< Type >

it is a template for arrays. It can be used like a “normal” C-style array

Definition at line 53 of file array.h.

6.54.2 Constructor & Destructor Documentation

6.54.2.1 template<class Type> ABA_ARRAY< Type >::ABA_ARRAY (ABA_GLOBAL * glob, int size)

A constructor without initialization.

Parameters:

glob
A pointer to the corresponding global object.
size
The length of the array.

6.54.2.2 template<class Type> ABA_ARRAY< Type >::ABA_ARRAY (ABA_GLOBAL * glob, int size, Type init)

A constructor with initialization.

Parameters:

glob
A pointer to the corresponding global object.
size
The length of the array.
init
The initial value of all elements of the array.

6.54.2.3 template<class Type> ABA_ARRAY< Type >::ABA_ARRAY (ABA_GLOBAL * glob, const ABA_BUFFER< Type > & buf)

A constructor.

Parameters:

glob
A pointer to the corresponding global object.
buf
The array receives the length of this buffer and all buffered elements are copied to the array.

6.54.2.4 template<class Type> ABA_ARRAY< Type >::ABA_ARRAY (const ABA_ARRAY< Type > & rhs)

The copy constructor.

Parameters:

rhs
The array being copied.

6.54.2.5 template<class Type> ABA_ARRAY< Type >::~ABA_ARRAY ()

The destructor.

6.54.3 Member Function Documentation

6.54.3.1 template<class Type> const ABA_ARRAY<Type>& ABA_ARRAY< Type >::operator= (const ABA_ARRAY< Type > & rhs)

The assignment operator can only be used for arrays with equal length.

Returns:

A reference to the array on the left hand side.

Parameters:

rhs
The array being assigned.

6.54.3.2 template<class Type> const ABA_ARRAY<Type>& ABA_ARRAY< Type >::operator= (const ABA_BUFFER< Type > & rhs)

To assign an object of the class ABA_BUFFER to an object of the class ABA_ARRAY the size of the left hand side must be at least the size of rhs. Then all buffered elements of rhs are copied.

Returns:

A reference to the array on the left hand side.

Parameters:

rhs
The buffer being assigned.

6.54.3.3 ]

template<class Type> Type& ABA_ARRAY< Type >::operator[ ] (int i)

The operator [].

Returns:

The i-th element of the array.

Parameters:

i
The element being accessed.

6.54.3.4 ]

template<class Type> const Type& ABA_ARRAY< Type >::operator[ ] (int i) const

The operator [] is overloaded for constant use.

6.54.3.5 template<class Type> void ABA_ARRAY< Type >::copy (const ABA_ARRAY< Type > & rhs)

Copies all elements of rhs.

The difference to the operator = is that also copying between arrays of different size is allowed. If necessary the array on the left hand side is reallocated.

Parameters:

rhs
The array being copied.

6.54.3.6 template<class Type> void ABA_ARRAY< Type >::copy (const ABA_ARRAY< Type > & rhs, int l, int r)

This version of the function copy() copies the elements rhs[l], rhs[l+1]„ rhs[r] into the components 0„r-l of the array.

If the size of the array is smaller than r-l+1 storage is reallocated.

Parameters:

rhs
The array that is partially copied.
l
The first element being copied.
r
the last element being copied.

6.54.3.7 template<class Type> void ABA_ARRAY< Type >::leftShift (ABA_BUFFER< int > & ind)

Removes the components listed in ind by shifting the remaining components to the left.

Memory management of the removed components must be carefully implemented by the user of this function to avoid memory leaks.

Parameters:

ind
The compenents being removed from the array.

6.54.3.8 template<class Type> void ABA_ARRAY< Type >::leftShift (ABA_ARRAY< bool > & remove)

This version of the function leftShift() removes all components i with marked[i]==true from the array by shifting the other components to the left.

Parameters:

remove
The marked components are removed from the array.

6.54.3.9 template<class Type> void ABA_ARRAY< Type >::set (int l, int r, Type val)

Assigns the same value to a subset of the components of the array.

Parameters:

l
The first component the value is assigned.
r
The last component the value is assigned.
val
The new value of these components.

6.54.3.10 template<class Type> void ABA_ARRAY< Type >::set (Type val)

This version of the function set() initializes all components of the array with the same value.

Parameters:

val
The new value of all components.

6.54.3.11 template<class Type> int ABA_ARRAY< Type >::size () const

Returns:

The length of the array.

6.54.3.12 template<class Type> void ABA_ARRAY< Type >::realloc (int newSize)

The length of an array can be changed with the function realloc(). If the array is enlarged all elements of the old array are copied and the values of the additional new elements are undefined. If the array is shortened only the first newSize elements are copied.

Parameters:

newSize
The new length of the array.

6.54.3.13 template<class Type> void ABA_ARRAY< Type >::realloc (int newSize, Type init)

Is overloaded such that also an initialization with a new value of the elements of the array after reallocation is possible.

Parameters:

newSize
The new length of the array.
init
The new value of all components of the array.

6.54.3.14 template<class Type> void ABA_ARRAY< Type >::rangeCheck (int i) const [private]

Stops the program with an error message if the index i is not within the bounds of the array.

6.54.4 Friends And Related Function Documentation

6.54.4.1 template<class Type> ostream& operator<< (ostream & out, const ABA_ARRAY< Type > & array) [friend]

The output operator writes first the number of the element and a :’ followed by the value of the element line by line to the stream out.

Returns:

A reference to the output stream.

Parameters:

out
The output stream.
array
The array being output.

6.54.5 Member Data Documentation

6.54.5.1 template<class Type> ABA_GLOBAL*ABA_ARRAY< Type >::glob_ [private]

A pointer to the corresponding global object.

Definition at line 257 of file array.h.

6.54.5.2 template<class Type> int ABA_ARRAY< Type >::n_ [private]

The length of the array.

Definition at line 261 of file array.h.

6.54.5.3 template<class Type> Type*ABA_ARRAY< Type >::a_ [private]

The /-style array storing the elements of the ABA_ARRAY.

Definition at line 265 of file array.h.

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