#include <array.h>
Inheritance diagram for ABA_ARRAY< Type >:
Public Member Functions | |
ABA_ARRAY (ABA_GLOBAL *glob, int size) | |
ABA_ARRAY (ABA_GLOBAL *glob, int size, Type init) | |
ABA_ARRAY (ABA_GLOBAL *glob, const ABA_BUFFER< Type > &buf) | |
ABA_ARRAY (const ABA_ARRAY< Type > &rhs) | |
~ABA_ARRAY () | |
The destructor. | |
const ABA_ARRAY< Type > & | operator= (const ABA_ARRAY< Type > &rhs) |
const 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. | |
Type & | operator[] (int i) |
const Type & | operator[] (int i) const |
void | copy (const ABA_ARRAY< Type > &rhs) |
void | 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. | |
void | leftShift (ABA_BUFFER< int > &ind) |
Removes the components listed in ind by shifting the remaining components to the left. | |
void | 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. | |
void | set (int l, int r, Type val) |
void | set (Type val) |
This version of the function set() initializes all components of the array with the same value. | |
int | size () const |
void | 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. | |
void | 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. | |
Private Member Functions | |
void | rangeCheck (int i) const |
Stops the program with an error message if the index i is not within the bounds of the array. | |
Private Attributes | |
ABA_GLOBAL * | glob_ |
int | n_ |
Type * | a_ |
Friends | |
ostream & | operator<< (ostream &out, const ABA_ARRAY< Type > &array) |
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. |
Definition at line 53 of file array.h.
ABA_ARRAY< Type >::ABA_ARRAY | ( | ABA_GLOBAL * | glob, | |
int | size | |||
) |
A constructor without initialization.
glob | A pointer to the corresponding global object. | |
size | The length of the array. |
ABA_ARRAY< Type >::ABA_ARRAY | ( | ABA_GLOBAL * | glob, | |
int | size, | |||
Type | init | |||
) |
A constructor with initialization.
glob | A pointer to the corresponding global object. | |
size | The length of the array. | |
init | The initial value of all elements of the array. |
ABA_ARRAY< Type >::ABA_ARRAY | ( | ABA_GLOBAL * | glob, | |
const ABA_BUFFER< Type > & | buf | |||
) |
A constructor.
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. |
The copy constructor.
rhs | The array being copied. |
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.
rhs | The array being assigned. |
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.
rhs | The buffer being assigned. |
Type& ABA_ARRAY< Type >::operator[] | ( | int | i | ) |
The operator [].
i | The element being accessed. |
const Type& ABA_ARRAY< Type >::operator[] | ( | int | i | ) | const |
The operator [] is overloaded for constant use.
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.
rhs | The array being copied. |
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.
rhs | The array that is partially copied. | |
l | The first element being copied. | |
r | the last element being copied. |
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.
ind | The compenents being removed from the array. |
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.
remove | The marked components are removed from the array. |
void ABA_ARRAY< Type >::set | ( | int | l, | |
int | r, | |||
Type | val | |||
) |
Assigns the same value to a subset of the components of the array.
l | The first component the value is assigned. | |
r | The last component the value is assigned. | |
val | The new value of these components. |
void ABA_ARRAY< Type >::set | ( | Type | val | ) |
This version of the function set() initializes all components of the array with the same value.
val | The new value of all components. |
int ABA_ARRAY< Type >::size | ( | ) | const |
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.
newSize | The new length of the array. |
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.
newSize | The new length of the array. | |
init | The new value of all components of the array. |
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.
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.
out | The output stream. | |
array | The array being output. |
ABA_GLOBAL* ABA_ARRAY< Type >::glob_ [private] |